-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve mission dialog layout * wip * Update storybook * Rework mission system * Fix asteroid mining order * Add mission generator * Simplify Observer type * Add trade tutorial * Remove unused files * Drop .m. part of conversation filename * Fix mission chains * Fix copy * Add pirate removing tutorial * Use fromPolar util * Degrade Russo to commander * Fix case when player ends conversation * Add rescue missions * Fix negative trade offer * Add tutorial end * Update base save * Update readme
- Loading branch information
1 parent
de1f8e5
commit afab3ac
Showing
91 changed files
with
95,504 additions
and
99,047 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
to: core/world/data/missions/<%= name.split(".").join("/") %>.yml | ||
--- | ||
|
||
Start: npc.greeting | ||
|
||
Actors: | ||
npc: | ||
name: NPC | ||
lines: | ||
greeting: | ||
text: Line | ||
next: | ||
- player.greeting | ||
|
||
player: | ||
lines: | ||
greeting: | ||
text: Response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
to: core/systems/mission/<%= name.split(".").join("/") %>.ts | ||
--- | ||
|
||
import Mustache from "mustache"; | ||
import type { Mission, MissionCommon } from "@core/components/missions"; | ||
import { first } from "@fxts/core"; | ||
import type { Sim } from "@core/sim"; | ||
import type { MissionHandler } from "../../types"; | ||
import conversation from "../../../../world/data/missions/<%= name.split(".").join("/") %>.yml"; | ||
|
||
Mustache.escape = (text) => text; | ||
|
||
interface <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_"), false) %>Mission extends Mission { | ||
type: "<%= name %>"; | ||
} | ||
|
||
export const <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_"), true) %>Mission = ( | ||
minerId: number, | ||
common: MissionCommon | ||
): <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission => ({ | ||
...common, | ||
minerId, | ||
type: "<%= name %>", | ||
}); | ||
|
||
export const is<%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission = ( | ||
mission: Mission | ||
): mission is <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission => | ||
mission.type === "<%= name %>"; | ||
|
||
export const <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_"), true) %>MissionHandler: MissionHandler = { | ||
generate: (_sim) => ({ | ||
conversation, | ||
rewards: [], | ||
type: "<%= name %>", | ||
}), | ||
accept: (sim, offer) => { | ||
const player = first(sim.queries.player.getIt())!; | ||
|
||
return <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_"), true) %>Mission(miner.id, { | ||
accepted: sim.getTime(), | ||
}); | ||
}, | ||
isFailed: (mission, sim) => { | ||
if (!is<%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission(mission)) | ||
throw new Error("Mission is not a <%= name %> mission"); | ||
}, | ||
isCompleted: (mission: Mission, sim) => { | ||
if (!is<%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission(mission)) | ||
throw new Error("Mission is not a <%= name %> mission"); | ||
}, | ||
update: (mission: Mission, _sim: Sim) => { | ||
if (!is<%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission(mission)) | ||
throw new Error("Mission is not a <%= name %> mission"); | ||
}, | ||
formatProgress: (mission: <%= h.inflection.camelize(name.replace(/\./g, "_").replace(/-/g, "_")) %>Mission) => "", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* eslint-disable no-invalid-this */ | ||
|
||
import { load } from "js-yaml"; | ||
import type webpack from "webpack"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import AJV from "ajv"; | ||
import schema from "../core/world/data/missions/schema.json"; | ||
|
||
const validator = new AJV(); | ||
|
||
// eslint-disable-next-line func-names | ||
const loader: webpack.LoaderDefinition = function (this, content) { | ||
const parsed = load(content, { | ||
json: true, | ||
}); | ||
if (!validator.validate(schema, parsed)) { | ||
throw new Error(validator.errorsText()); | ||
} | ||
|
||
const filename = `${this.resourcePath.split(".yml")[0]}.d.ts`; | ||
|
||
let fileContent = ""; | ||
try { | ||
fileContent = fs.readFileSync(filename).toString(); | ||
} catch (err) { | ||
if (err.code !== "ENOENT") { | ||
throw err; | ||
} | ||
} | ||
|
||
const generatedContent = `/* @generated */ | ||
/* prettier-ignore */ | ||
/* eslint-disable */ | ||
declare module "*/${path.relative( | ||
path.join(process.cwd(), "core/world/data"), | ||
this.resourcePath | ||
)}" { | ||
import type { MissionConversation } from "@core/systems/mission/types"; | ||
const content: MissionConversation; | ||
export default content; | ||
} | ||
`; | ||
|
||
if (fileContent !== generatedContent) { | ||
fs.writeFileSync(filename, generatedContent); | ||
} | ||
|
||
return `export default ${JSON.stringify(parsed)}`; | ||
}; | ||
|
||
export default loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { Observable } from "./utils/observer"; | ||
|
||
export const storageHook = new Observable<[string]>("storage"); | ||
export const storageHook = new Observable<string>("storage"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.