rpg-engine 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/campaign/settings.d.ts +1 -0
- package/dist/campaign/settings.js +6 -5
- package/dist/command-line.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.d.ts +37 -2
- package/dist/commands/ask.js +106 -35
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +69 -21
- package/dist/commands/effect.js +42 -23
- package/dist/commands/find.js +1 -1
- package/dist/commands/game-adventures.js +2 -2
- package/dist/commands/game-catalog.d.ts +13 -0
- package/dist/commands/game-catalog.js +26 -2
- package/dist/commands/game-checks.js +23 -21
- package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
- package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
- package/dist/commands/game-effects.d.ts +12 -4
- package/dist/commands/game-effects.js +21 -13
- package/dist/commands/game-examples.d.ts +22 -0
- package/dist/commands/game-examples.js +72 -0
- package/dist/commands/game-extension-list.d.ts +31 -3
- package/dist/commands/game-extension-list.js +94 -6
- package/dist/commands/game-images.d.ts +1 -1
- package/dist/commands/game-images.js +3 -2
- package/dist/commands/game-library.d.ts +3 -0
- package/dist/commands/game-library.js +2 -2
- package/dist/commands/game-mode.js +1 -1
- package/dist/commands/game-package-code.d.ts +87 -0
- package/dist/commands/game-package-code.js +648 -0
- package/dist/commands/game-package-hooks.d.ts +37 -0
- package/dist/commands/game-package-hooks.js +116 -0
- package/dist/commands/game-recipes.js +2 -2
- package/dist/commands/game-reminders.d.ts +5 -2
- package/dist/commands/game-reminders.js +7 -4
- package/dist/commands/game-rules.d.ts +4 -1
- package/dist/commands/game-rules.js +7 -1
- package/dist/commands/game-upkeep.js +3 -3
- package/dist/commands/game-view-place.d.ts +8 -20
- package/dist/commands/game-view-place.js +16 -35
- package/dist/commands/game-widgets.d.ts +42 -8
- package/dist/commands/game-widgets.js +182 -31
- package/dist/commands/game-world.d.ts +32 -3
- package/dist/commands/game-world.js +113 -24
- package/dist/commands/image.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package.d.ts +15 -1
- package/dist/commands/package.js +96 -24
- package/dist/commands/progression.d.ts +2 -0
- package/dist/commands/progression.js +7 -2
- package/dist/commands/roll.d.ts +2 -0
- package/dist/commands/roll.js +50 -24
- package/dist/commands/rules.js +6 -4
- package/dist/commands/scene.d.ts +2 -2
- package/dist/commands/scene.js +13 -10
- package/dist/commands/sheet.js +10 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +14 -4
- package/dist/commands/trade.js +6 -4
- package/dist/commands/translate.js +2 -2
- package/dist/commands/travel.js +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/view.d.ts +12 -4
- package/dist/commands/view.js +11 -8
- package/dist/commands/worked-out.js +11 -5
- package/dist/commands/write.d.ts +8 -1
- package/dist/commands/write.js +84 -25
- package/dist/core/command-reference.js +3 -2
- package/dist/core/consents.d.ts +18 -0
- package/dist/core/consents.js +93 -0
- package/dist/core/context.d.ts +68 -27
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/core/files.d.ts +2 -0
- package/dist/core/files.js +10 -1
- package/dist/core/package-api.d.ts +388 -0
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +4 -0
- package/dist/core/text.d.ts +5 -0
- package/dist/core/text.js +12 -0
- package/dist/dashboard/acts.js +31 -24
- package/dist/dashboard/address.js +4 -1
- package/dist/dashboard/api.js +65 -3
- package/dist/dashboard/app.js +222 -98
- package/dist/dashboard/ask-card.js +169 -0
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +6 -4
- package/dist/dashboard/extension-widgets.js +136 -16
- package/dist/dashboard/faces.js +6 -4
- package/dist/dashboard/help.js +10 -3
- package/dist/dashboard/i18n/ar.json +34 -29
- package/dist/dashboard/i18n/cs.json +34 -29
- package/dist/dashboard/i18n/da.json +34 -29
- package/dist/dashboard/i18n/de.json +34 -29
- package/dist/dashboard/i18n/el.json +34 -29
- package/dist/dashboard/i18n/es.json +34 -29
- package/dist/dashboard/i18n/fi.json +34 -29
- package/dist/dashboard/i18n/fr.json +34 -29
- package/dist/dashboard/i18n/he.json +34 -29
- package/dist/dashboard/i18n/hi.json +34 -29
- package/dist/dashboard/i18n/hu.json +34 -29
- package/dist/dashboard/i18n/is.json +34 -29
- package/dist/dashboard/i18n/it.json +34 -29
- package/dist/dashboard/i18n/ja.json +34 -29
- package/dist/dashboard/i18n/ko.json +34 -29
- package/dist/dashboard/i18n/nb.json +34 -29
- package/dist/dashboard/i18n/nl.json +34 -29
- package/dist/dashboard/i18n/pl.json +34 -29
- package/dist/dashboard/i18n/pt.json +34 -29
- package/dist/dashboard/i18n/ro.json +34 -29
- package/dist/dashboard/i18n/ru.json +34 -29
- package/dist/dashboard/i18n/sv.json +34 -29
- package/dist/dashboard/i18n/tr.json +34 -29
- package/dist/dashboard/i18n/uk.json +34 -29
- package/dist/dashboard/i18n/zh.json +34 -29
- package/dist/dashboard/icons.js +4 -1
- package/dist/dashboard/kit.js +35 -0
- package/dist/dashboard/labels.js +1 -0
- package/dist/dashboard/pack-card.js +97 -0
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +180 -24
- package/dist/dashboard/page-code.js +248 -0
- package/dist/dashboard/party.js +13 -14
- package/dist/dashboard/people.js +4 -0
- package/dist/dashboard/person-panel.js +110 -0
- package/dist/dashboard/place-map-view.js +11 -6
- package/dist/dashboard/rolls.js +2 -2
- package/dist/dashboard/scene.js +12 -9
- package/dist/dashboard/settings.js +55 -9
- package/dist/dashboard/sheet.js +21 -13
- package/dist/dashboard/status.js +69 -15
- package/dist/dashboard/style.css +859 -574
- package/dist/dashboard/top.js +75 -25
- package/dist/dashboard/turns.js +34 -13
- package/dist/dashboard/widgets.js +9 -2
- package/dist/dashboard-server.js +246 -11
- package/dist/dice/roll-dice.js +1 -1
- package/dist/effects/effect.d.ts +7 -4
- package/dist/effects/effect.js +12 -9
- package/dist/extensions/engine.d.ts +4 -0
- package/dist/extensions/engine.js +74 -0
- package/dist/extensions/extension.d.ts +28 -33
- package/dist/extensions/extension.js +37 -46
- package/dist/extensions/index.d.ts +4 -3
- package/dist/extensions/index.js +5 -2
- package/dist/extensions/packages.d.ts +14 -0
- package/dist/extensions/packages.js +148 -12
- package/dist/extensions/words.d.ts +2 -1
- package/dist/extensions/words.js +5 -4
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +52 -15
- package/dist/page-words.d.ts +4 -0
- package/dist/page-words.js +4 -4
- package/dist/page.d.ts +218 -0
- package/dist/page.js +2 -0
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/load.d.ts +7 -1
- package/dist/pages/load.js +10 -5
- package/dist/pages/page-file.js +1 -1
- package/dist/pages/stack-writes.js +5 -4
- package/dist/pages/standard-fields.d.ts +2 -0
- package/dist/pages/standard-fields.js +8 -1
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +61 -30
- package/dist/systems/game-system.js +159 -50
- package/dist/systems/index.d.ts +3 -3
- package/dist/systems/index.js +3 -3
- package/dist/systems/system-code.d.ts +29 -88
- package/dist/systems/system-code.js +68 -23
- package/dist/systems/words.d.ts +2 -0
- package/dist/systems/words.js +11 -0
- package/dist/testing.d.ts +76 -0
- package/dist/testing.js +197 -0
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/setup.md +1 -1
- package/package.json +15 -2
- package/systems/5e/LICENSE.md +13 -3
- package/systems/5e/dist/dying.js +83 -16
- package/systems/5e/dist/index.js +2 -2
- package/systems/5e/dist/page-style.js +634 -0
- package/systems/5e/dist/page.js +166 -0
- package/systems/5e/dist/shown.js +23 -0
- package/systems/5e/instructions/combat.md +1 -0
- package/systems/5e/package.json +4 -2
- package/systems/5e/system.yaml +35 -7
- package/systems/5e/versions/srd-5.1/system.yaml +2 -0
- package/systems/5e/words/ar.yaml +30 -0
- package/systems/5e/words/cs.yaml +30 -0
- package/systems/5e/words/da.yaml +30 -0
- package/systems/5e/words/de.yaml +30 -0
- package/systems/5e/words/el.yaml +30 -0
- package/systems/5e/words/es.yaml +30 -0
- package/systems/5e/words/fi.yaml +30 -0
- package/systems/5e/words/fr.yaml +30 -0
- package/systems/5e/words/he.yaml +30 -0
- package/systems/5e/words/hi.yaml +30 -0
- package/systems/5e/words/hu.yaml +30 -0
- package/systems/5e/words/is.yaml +30 -0
- package/systems/5e/words/it.yaml +30 -0
- package/systems/5e/words/ja.yaml +30 -0
- package/systems/5e/words/ko.yaml +30 -0
- package/systems/5e/words/nb.yaml +30 -0
- package/systems/5e/words/nl.yaml +30 -0
- package/systems/5e/words/pl.yaml +30 -0
- package/systems/5e/words/pt.yaml +30 -0
- package/systems/5e/words/ro.yaml +30 -0
- package/systems/5e/words/ru.yaml +30 -0
- package/systems/5e/words/sv.yaml +30 -0
- package/systems/5e/words/tr.yaml +30 -0
- package/systems/5e/words/uk.yaml +30 -0
- package/systems/5e/words/zh.yaml +30 -0
- package/dist/commands/game-extensions.d.ts +0 -34
- package/dist/commands/game-extensions.js +0 -182
- package/dist/commands/game-system-code.d.ts +0 -25
- package/dist/commands/game-system-code.js +0 -172
- package/dist/dashboard/death-save.js +0 -67
- package/dist/dashboard/dying.js +0 -46
- package/dist/dashboard/save-outcome.js +0 -42
- package/dist/dashboard/spend.js +0 -115
- package/dist/extensions/api.d.ts +0 -155
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
|
@@ -5,12 +5,12 @@ import { rollDice } from "../dice/index.js";
|
|
|
5
5
|
import { findPage, isPartyMember, withPage, writePage } from "../pages/index.js";
|
|
6
6
|
import { effectGiving, effectiveFields, effectsOf, withValue } from "./effect-layer.js";
|
|
7
7
|
import { saveEffects } from "./game-effects.js";
|
|
8
|
-
import { allSaid,
|
|
8
|
+
import { allSaid, packagesCounterChanged } from "./game-package-hooks.js";
|
|
9
9
|
import { thresholdNotes } from "./game-thresholds.js";
|
|
10
10
|
import { newDatedLogEntry } from "./game-time.js";
|
|
11
11
|
import { formulaValue } from "./worked-out.js";
|
|
12
12
|
/**
|
|
13
|
-
* Spends dice of a counter named after its die, as
|
|
13
|
+
* Spends dice of a counter named after its die, as stamina-d6, in a recipe that lets one (D-449): each die rolled with what the recipe adds, at least 0, the
|
|
14
14
|
* total given to its counter up to the maximum, the dice taken from theirs, each on the effect that gives it, if one does (EFF-7); the line that says it, with the
|
|
15
15
|
* rules a party member's counters touch (DAT-3). `how` gives the why, the check that names the roll in the log, as the player's own rolls are named (ASK-14),
|
|
16
16
|
* and the faces of physical dice, one for each die (ASK-8). Refused when the recipe spends no such counter, there are not as many, or the faces are not one a die.
|
|
@@ -67,11 +67,11 @@ export function spendDice(root, context, world, spending, name, field, amount, h
|
|
|
67
67
|
const notes = isPartyMember(page)
|
|
68
68
|
? [[field, dice.value, dice.value - count], [rule.gives, target.value, after]].flatMap(([changed, before, now]) => thresholdNotes(root, system, String(changed), { before, after: now, amount: {} }))
|
|
69
69
|
: [];
|
|
70
|
-
// What the counter regained sets off in the
|
|
71
|
-
const
|
|
70
|
+
// What the counter regained sets off in the packages' code, as a game's down point (D-448).
|
|
71
|
+
const hooked = allSaid(packagesCounterChanged(root, context, { page: page.name, field: rule.gives, before: target.value, after, lost: 0, ...(target.max === undefined ? {} : { max: target.max }) }));
|
|
72
72
|
const within = (changed) => (layers.get(changed) === undefined ? "" : ` in ${layers.get(changed)}`);
|
|
73
73
|
const line = `${page.name} spends ${count} ${field}: ${result}; ${rule.gives} ${target.value}${max(target)} → ${after}${max(target)}${within(rule.gives)}; ${field} ${dice.value}${max(dice)} → ${dice.value - count}${max(dice)}${within(field)}.`;
|
|
74
|
-
return { text: [line, ...notes, ...
|
|
74
|
+
return { text: [line, ...notes, ...hooked].join("\n"), notes: [...notes, ...hooked], faces: roll.faces, adds, total: healed, id: entry.id };
|
|
75
75
|
}
|
|
76
76
|
/** The counters of dice a recipe lets this page spend, as the page reads them, with a maximum above 0: those at 0 too, as a page shows them spent. */
|
|
77
77
|
export function restDice(world, recipe, page) {
|
|
@@ -85,7 +85,7 @@ export function restDice(world, recipe, page) {
|
|
|
85
85
|
: [{ field, sides, value: counter.value, max: counter.max, adds: formulaValue(world, fields, rule.adds) ?? 0, gives: rule.gives }];
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
/** The counters of dice worth spending, as
|
|
88
|
+
/** The counters of dice worth spending, as stamina-d6 2/3: some left, and the counter they give to below its maximum, where they would give something. */
|
|
89
89
|
export function spendableDice(world, recipe, page) {
|
|
90
90
|
const fields = effectiveFields(world, page);
|
|
91
91
|
return restDice(world, recipe, page).filter((dice) => {
|
|
@@ -114,7 +114,7 @@ function writeCounters(root, context, world, page, values) {
|
|
|
114
114
|
}
|
|
115
115
|
return layers;
|
|
116
116
|
}
|
|
117
|
-
/** What a recipe's spend says of a counter: by its name, or by a name ending in *, such as
|
|
117
|
+
/** What a recipe's spend says of a counter: by its name, or by a name ending in *, such as stamina-*. */
|
|
118
118
|
function spendRule(recipe, field) {
|
|
119
119
|
return Object.entries(recipe.spend).find(([pattern]) => pattern.endsWith("*") ? comparableText(field).startsWith(comparableText(pattern.slice(0, -1))) : comparableText(pattern) === comparableText(field))?.[1];
|
|
120
120
|
}
|
|
@@ -42,7 +42,7 @@ export interface SeenEffect {
|
|
|
42
42
|
text: string;
|
|
43
43
|
/** One of the system's conditions (D-186, D-419). */
|
|
44
44
|
condition?: true;
|
|
45
|
-
/**
|
|
45
|
+
/** Its drawing, when the system, an extension or the campaign gives one by its name (D-419, D-516): the d of an SVG path on a grid of 24. */
|
|
46
46
|
icon?: string;
|
|
47
47
|
/** For something that burns, as a torch, what it spends and how many of it are still carried (UPK-3). */
|
|
48
48
|
burns?: {
|
|
@@ -51,9 +51,17 @@ export interface SeenEffect {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
/** An effect as the dashboard shows it on someone of the party: its name, its end, the line status gives, and whether it is a condition (D-276, D-314, D-419). */
|
|
54
|
-
export declare function effectParts(world: World, system: GameSystem | undefined, effect: Effect): SeenEffect;
|
|
55
|
-
/**
|
|
56
|
-
|
|
54
|
+
export declare function effectParts(world: World, system: GameSystem | undefined, effect: Effect, words?: Record<string, string>): SeenEffect;
|
|
55
|
+
/**
|
|
56
|
+
* Whether an effect's name is one of the system's conditions, whatever its case (D-419), and the drawing given to its name, a condition's or any effect's, by
|
|
57
|
+
* the system with its extensions' and the campaign's over it (D-516); a name in the campaign's language too, by the system's `words` in it (D-403).
|
|
58
|
+
*/
|
|
59
|
+
export declare function conditionMark(system: GameSystem | undefined, name: string, words?: Record<string, string>): Pick<SeenEffect, "condition" | "icon">;
|
|
60
|
+
/**
|
|
61
|
+
* The name of a list of the system's that an effect's name is, whatever its case: as written first, else as the system's words say it in the campaign's
|
|
62
|
+
* language, Prono for Prone (D-403).
|
|
63
|
+
*/
|
|
64
|
+
export declare function systemNamed(names: string[], name: string, words: Record<string, string> | undefined): string | undefined;
|
|
57
65
|
/** "Benedizione (Ennio, Bruno)": what someone keeps alive, on whom (D-138). */
|
|
58
66
|
export declare function keptEffects(world: World, scene: Scene | undefined, name: string): string[];
|
|
59
67
|
/** What someone keeps alive, each effect with the pages and copies that have it (D-138). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { appendLogEntry } from "../core/log.js";
|
|
2
|
-
import { comparableText } from "../core/text.js";
|
|
2
|
+
import { comparableText, sameName, sameWord } from "../core/text.js";
|
|
3
3
|
import { formatCounter, readCounter } from "../counters/index.js";
|
|
4
4
|
import { endsAtTurn, formatEffect, formatEnd, keeperOf, readEffects } from "../effects/index.js";
|
|
5
5
|
import { concernsPlayer, isDeclaredUncounted, isEmptyField, systemFirstFix, writePage } from "../pages/index.js";
|
|
@@ -108,17 +108,25 @@ export function effectShown(world, effect) {
|
|
|
108
108
|
return `${effect.name}${values.length === 0 ? "" : ` (${values.join(", ")})`}${end}`;
|
|
109
109
|
}
|
|
110
110
|
/** An effect as the dashboard shows it on someone of the party: its name, its end, the line status gives, and whether it is a condition (D-276, D-314, D-419). */
|
|
111
|
-
export function effectParts(world, system, effect) {
|
|
112
|
-
return { name: effect.name, ...(effect.end === undefined ? {} : { end: effect.end }), text: effectShown(world, effect), ...conditionMark(system, effect.name) };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
111
|
+
export function effectParts(world, system, effect, words) {
|
|
112
|
+
return { name: effect.name, ...(effect.end === undefined ? {} : { end: effect.end }), text: effectShown(world, effect), ...conditionMark(system, effect.name, words) };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Whether an effect's name is one of the system's conditions, whatever its case (D-419), and the drawing given to its name, a condition's or any effect's, by
|
|
116
|
+
* the system with its extensions' and the campaign's over it (D-516); a name in the campaign's language too, by the system's `words` in it (D-403).
|
|
117
|
+
*/
|
|
118
|
+
export function conditionMark(system, name, words) {
|
|
119
|
+
const condition = systemNamed(system?.conditions ?? [], name, words) !== undefined;
|
|
120
|
+
const icons = system?.conditionIcons ?? {};
|
|
121
|
+
const drawn = systemNamed(Object.keys(icons), name, words);
|
|
122
|
+
return { ...(condition ? { condition: true } : {}), ...(drawn === undefined ? {} : { icon: icons[drawn] }) };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The name of a list of the system's that an effect's name is, whatever its case: as written first, else as the system's words say it in the campaign's
|
|
126
|
+
* language, Prono for Prone (D-403).
|
|
127
|
+
*/
|
|
128
|
+
export function systemNamed(names, name, words) {
|
|
129
|
+
return sameName(names, name) ?? names.find((own) => sameWord(own, name, words));
|
|
122
130
|
}
|
|
123
131
|
/** "Benedizione (Ennio, Bruno)": what someone keeps alive, on whom (D-138). */
|
|
124
132
|
export function keptEffects(world, scene, name) {
|
|
@@ -149,7 +157,7 @@ export function effectProblems(world, scene, now, occasions, sceneProblem) {
|
|
|
149
157
|
const path = copy ? "state.yaml" : page.path;
|
|
150
158
|
const read = readEffects(effectsField(page));
|
|
151
159
|
if ("problem" in read) {
|
|
152
|
-
const fix = `write each line of effects in quotes, such as - "
|
|
160
|
+
const fix = `write each line of effects in quotes, such as - "Protezione (armor: 2) until day 2, 14:20", and each effect once; or remove them all with write ${page.name}, unset effects, and add again with effect add those that still hold`;
|
|
153
161
|
return [{ path, message: `${page.name}: ${read.problem}`, fix }];
|
|
154
162
|
}
|
|
155
163
|
return read.effects.flatMap((effect) => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Context } from "../core/context.ts";
|
|
2
|
+
import { type Examples } from "../core/examples.ts";
|
|
3
|
+
import type { Coin } from "../money/index.ts";
|
|
4
|
+
import type { GameSystem, SystemWords } from "../systems/index.ts";
|
|
5
|
+
/** The examples for a campaign: its system's names, in its language where the system has words for them; neutral without a campaign or a system. */
|
|
6
|
+
export declare function campaignExamples(root: string | undefined, context: Context): Examples;
|
|
7
|
+
/** The examples a game system gives, with the labels of its words and the campaign's coins. */
|
|
8
|
+
export declare function systemExamples(system: GameSystem, words: SystemWords | undefined, coins: Coin[]): Examples;
|
|
9
|
+
/** A coin and a smaller one of a campaign for an example, as gp and sp, never a rare one; neutral names without them. */
|
|
10
|
+
export declare function coinExamples(coins: Coin[] | undefined): {
|
|
11
|
+
coin: string;
|
|
12
|
+
smallCoin: string;
|
|
13
|
+
};
|
|
14
|
+
/** A rest of a game system for an example, one that spends no dice first; a neutral name without one (D-514). */
|
|
15
|
+
export declare function restExample(system: GameSystem | undefined): string;
|
|
16
|
+
/** A rest whose dice are spent and a counter of its pool, as a game system has them, for an example; neutral without one (D-514). */
|
|
17
|
+
export declare function poolExample(system: GameSystem | undefined): {
|
|
18
|
+
recipe: string;
|
|
19
|
+
field: string;
|
|
20
|
+
};
|
|
21
|
+
/** The fields an effect adds to in a game system, those it declares bonuses. */
|
|
22
|
+
export declare function bonusFields(system: GameSystem): string[];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The examples of the commands' descriptions in the names of the campaign's game system (D-518): its counter, its dice, its coins, its turn, its rests and
|
|
2
|
+
// what an effect adds to; neutral where it names none.
|
|
3
|
+
import { readTextSetting } from "../campaign/index.js";
|
|
4
|
+
import { neutralExamples } from "../core/examples.js";
|
|
5
|
+
import { comparableText } from "../core/text.js";
|
|
6
|
+
import { campaignCoins } from "./game-money.js";
|
|
7
|
+
import { campaignSystem, systemWordsOf } from "./game-world.js";
|
|
8
|
+
/** The examples for a campaign: its system's names, in its language where the system has words for them; neutral without a campaign or a system. */
|
|
9
|
+
export function campaignExamples(root, context) {
|
|
10
|
+
const system = root === undefined ? undefined : campaignSystem(root, context);
|
|
11
|
+
if (root === undefined || system === undefined) {
|
|
12
|
+
return neutralExamples;
|
|
13
|
+
}
|
|
14
|
+
const language = readTextSetting(root, "language");
|
|
15
|
+
const words = language === undefined ? undefined : systemWordsOf(root, system, language, context);
|
|
16
|
+
return systemExamples(system, words, campaignCoins(root, context).coins ?? []);
|
|
17
|
+
}
|
|
18
|
+
/** The examples a game system gives, with the labels of its words and the campaign's coins. */
|
|
19
|
+
export function systemExamples(system, words, coins) {
|
|
20
|
+
const [check, otherCheck] = rolledFields(system);
|
|
21
|
+
const checkText = (field) => `${checkLabel(field, words)} ${system.sheetDice[field]}+${field}`;
|
|
22
|
+
const uses = Object.keys(system.turnUses).slice(0, 3);
|
|
23
|
+
return {
|
|
24
|
+
counter: system.damage?.counter ?? system.combat?.track ?? neutralExamples.counter,
|
|
25
|
+
roll: check === undefined ? neutralExamples.roll : `${system.sheetDice[check]}+${check}`,
|
|
26
|
+
check: check === undefined ? neutralExamples.check : checkText(check),
|
|
27
|
+
otherCheck: otherCheck === undefined ? neutralExamples.otherCheck : checkText(otherCheck),
|
|
28
|
+
...coinExamples(coins),
|
|
29
|
+
uses: uses.length === 0 ? neutralExamples.uses : uses.join(", "),
|
|
30
|
+
rest: restExample(system),
|
|
31
|
+
pool: poolExample(system).field,
|
|
32
|
+
bonus: bonusExample(system),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** A coin and a smaller one of a campaign for an example, as gp and sp, never a rare one; neutral names without them. */
|
|
36
|
+
export function coinExamples(coins) {
|
|
37
|
+
const [coin, smallCoin] = (coins ?? []).filter((one) => !one.rare).sort((one, other) => other.value - one.value);
|
|
38
|
+
return { coin: coin?.name ?? neutralExamples.coin, smallCoin: smallCoin?.name ?? neutralExamples.smallCoin };
|
|
39
|
+
}
|
|
40
|
+
/** A rest of a game system for an example, one that spends no dice first; a neutral name without one (D-514). */
|
|
41
|
+
export function restExample(system) {
|
|
42
|
+
const recipes = system?.recipes ?? [];
|
|
43
|
+
return (recipes.find((recipe) => Object.keys(recipe.spend).length === 0) ?? recipes[0])?.name ?? neutralExamples.rest;
|
|
44
|
+
}
|
|
45
|
+
/** A rest whose dice are spent and a counter of its pool, as a game system has them, for an example; neutral without one (D-514). */
|
|
46
|
+
export function poolExample(system) {
|
|
47
|
+
const recipe = system?.recipes.find((candidate) => Object.keys(candidate.spend).length > 0);
|
|
48
|
+
const pool = recipe === undefined ? undefined : Object.keys(recipe.spend)[0];
|
|
49
|
+
const field = pool?.endsWith("*") === true ? Object.keys(system?.fields ?? {}).find((name) => name.startsWith(pool.slice(0, -1))) : pool;
|
|
50
|
+
return recipe === undefined || field === undefined ? { recipe: "breather", field: neutralExamples.pool } : { recipe: recipe.name, field };
|
|
51
|
+
}
|
|
52
|
+
/** The fields an effect adds to in a game system, those it declares bonuses. */
|
|
53
|
+
export function bonusFields(system) {
|
|
54
|
+
return Object.entries(system.fields).filter(([, kind]) => kind === "bonus").map(([name]) => name);
|
|
55
|
+
}
|
|
56
|
+
/** Two numbers of the sheet rolled with dice, those shown beside no score first, as the saves of the 5e before its ability modifiers. */
|
|
57
|
+
function rolledFields(system) {
|
|
58
|
+
const beside = new Set(system.sheet.flatMap((group) => group.entries.map((entry) => entry.beside)));
|
|
59
|
+
const rolled = Object.keys(system.sheetDice);
|
|
60
|
+
return [...rolled.filter((field) => !beside.has(field)), ...rolled.filter((field) => beside.has(field))].slice(0, 2);
|
|
61
|
+
}
|
|
62
|
+
/** A check's name as the player reads it: the field's whole name or label in the campaign's language, else the field. */
|
|
63
|
+
function checkLabel(field, words) {
|
|
64
|
+
return words?.names?.[field] ?? words?.fields[field] ?? field;
|
|
65
|
+
}
|
|
66
|
+
/** A bonus of the system for an example: one that adds to a number of the sheet by its name, as bonus-ac to ac or guard-bonus to guard; else its first. */
|
|
67
|
+
function bonusExample(system) {
|
|
68
|
+
const onSheet = system.sheet.flatMap((group) => group.entries.flatMap((entry) => [entry.field, entry.beside ?? ""]));
|
|
69
|
+
const bonuses = bonusFields(system);
|
|
70
|
+
const adding = bonuses.find((name) => onSheet.some((field) => field !== "" && [`bonus-${field}`, `${field}-bonus`].some((form) => comparableText(form) === comparableText(name))));
|
|
71
|
+
return adding ?? bonuses[0] ?? neutralExamples.bonus;
|
|
72
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Context } from "../core/context.ts";
|
|
2
2
|
import type { InstructionPart } from "../core/instruction-parts.ts";
|
|
3
3
|
import type { Problem } from "../core/problem.ts";
|
|
4
|
-
import { type Extension } from "../extensions/index.ts";
|
|
4
|
+
import { type CodePackage, type Extension, type ExtensionWords } from "../extensions/index.ts";
|
|
5
|
+
import type { FigureSize } from "../page.ts";
|
|
6
|
+
import { type GameSystem } from "../systems/index.ts";
|
|
5
7
|
/** The extensions the campaign uses, and what keeps one from being used, with how to fix it. */
|
|
6
8
|
export interface CampaignExtensions {
|
|
7
9
|
extensions: Extension[];
|
|
@@ -16,8 +18,34 @@ export declare function campaignExtensions(root: string, context: Context): Camp
|
|
|
16
18
|
export declare function extensionSources(root: string, context: Context): (path: string) => boolean;
|
|
17
19
|
/** The packages campaign.yaml lists as extensions, with the version each was added with: none when it lists none or the list does not read. */
|
|
18
20
|
export declare function listedExtensions(root: string): Record<string, string>;
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Whether a package's code may run, on the server and in the dashboard's page alike (D-441, D-478, D-510): ours, verified; a system the engine ships; one the
|
|
23
|
+
* player installed from a folder or a file of their own; or another's that the player said yes to, at this version and with these files.
|
|
24
|
+
*/
|
|
25
|
+
export declare function runsCode(code: CodePackage): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* A package's words in a language, or its base language, by the English its code writes (D-502): an extension's words/, a game system's words section of its
|
|
28
|
+
* own; undefined when it has none in it. It throws when they do not read.
|
|
29
|
+
*/
|
|
30
|
+
export declare function packageWords(code: CodePackage, language: string): ExtensionWords | undefined;
|
|
31
|
+
/** The code of a package of the campaign for the dashboard's page (D-510, D-511): whose it is, its module's file and address, and its figures. */
|
|
32
|
+
export interface PageModule {
|
|
33
|
+
package: string;
|
|
34
|
+
kind: "system" | "extension";
|
|
35
|
+
version: string;
|
|
36
|
+
file: string;
|
|
37
|
+
address: string;
|
|
38
|
+
figures: Record<string, FigureSize>;
|
|
39
|
+
/** Its words in the campaign's language, by their English, for its page code's own words; none when it is written in that language. */
|
|
40
|
+
words?: Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The page modules of the campaign's packages whose code runs (D-510, D-511): its game system's, then its extensions', in the order campaign.yaml lists them.
|
|
44
|
+
* A system the engine ships, or one of ours, runs; another's as an extension's does, after the player's yes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function campaignPageModules(root: string, context: Context, system: GameSystem | undefined): PageModule[];
|
|
47
|
+
/** The address the dashboard serves a package's page module at: by the package's name and version, its folder's files beside it. */
|
|
48
|
+
export declare function pageAddress(name: string, version: string, file: string): string;
|
|
21
49
|
/**
|
|
22
50
|
* The parts of the instructions of the system and of the extensions above it, each part layered as D-121 says, under a title of the extension's own (D-441): an
|
|
23
51
|
* extension adds to a part, or takes its place when it is verified.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// The extensions a campaign uses (D-27, D-28, D-427): those campaign.yaml lists, as installed, and their parts of the instructions over the system's (D-121).
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
2
|
+
import { basename, join, resolve } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { campaignFileName, readOneSetting, readTextSetting } from "../campaign/index.js";
|
|
5
|
+
import { packageCodeMayRun } from "../core/consents.js";
|
|
6
|
+
import { updateEngine } from "../core/package-declarations.js";
|
|
5
7
|
import { files, isInside } from "../core/store.js";
|
|
6
8
|
import { comparableText } from "../core/text.js";
|
|
7
|
-
import { findExtension, isVerified } from "../extensions/index.js";
|
|
9
|
+
import { extensionWords, findExtension, hasConsent, isVerified } from "../extensions/index.js";
|
|
10
|
+
import { isCoreField } from "../pages/index.js";
|
|
11
|
+
import { layeredSystemWords, systemApiProblem, systemContentFolders, systemPageModule, systemWords } from "../systems/index.js";
|
|
8
12
|
/**
|
|
9
13
|
* The extensions campaign.yaml lists (D-27), each as installed on this computer, in the order written: the nearest layer last. One not installed, that does not
|
|
10
14
|
* read, that needs another game system or has the name of another is left out, with its problem: the campaign plays without it.
|
|
@@ -28,9 +32,72 @@ export function listedExtensions(root) {
|
|
|
28
32
|
return {};
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Whether a package's code may run, on the server and in the dashboard's page alike (D-441, D-478, D-510): ours, verified; a system the engine ships; one the
|
|
37
|
+
* player installed from a folder or a file of their own; or another's that the player said yes to, at this version and with these files.
|
|
38
|
+
*/
|
|
39
|
+
export function runsCode(code) {
|
|
40
|
+
return code.kind === "system" ? packageCodeMayRun(code.folder) : isVerified(code.package, code.linked) || code.linked || hasConsent(code.folder, code.package, code.version);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A package's words in a language, or its base language, by the English its code writes (D-502): an extension's words/, a game system's words section of its
|
|
44
|
+
* own; undefined when it has none in it. It throws when they do not read.
|
|
45
|
+
*/
|
|
46
|
+
export function packageWords(code, language) {
|
|
47
|
+
if (code.kind === "extension") {
|
|
48
|
+
return extensionWords(code.folder, language);
|
|
49
|
+
}
|
|
50
|
+
const words = systemWords(code.folder, language);
|
|
51
|
+
return words === undefined ? undefined : { words: words.words };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The page modules of the campaign's packages whose code runs (D-510, D-511): its game system's, then its extensions', in the order campaign.yaml lists them.
|
|
55
|
+
* A system the engine ships, or one of ours, runs; another's as an extension's does, after the player's yes.
|
|
56
|
+
*/
|
|
57
|
+
export function campaignPageModules(root, context, system) {
|
|
58
|
+
const own = system === undefined ? undefined : systemPageModule(system.folder);
|
|
59
|
+
const language = readTextSetting(root, "language");
|
|
60
|
+
// A system made for an API this engine does not read brings no code, in the page either.
|
|
61
|
+
const systems = own === undefined || system === undefined || !packageCodeMayRun(system.folder) || systemApiProblem(system.folder) !== undefined
|
|
62
|
+
? []
|
|
63
|
+
: [{
|
|
64
|
+
package: own.package,
|
|
65
|
+
kind: "system",
|
|
66
|
+
version: own.version,
|
|
67
|
+
file: own.file,
|
|
68
|
+
address: pageAddress(own.package, own.version, own.file),
|
|
69
|
+
figures: system.figures,
|
|
70
|
+
...wordsIn(language, system.language, () => layeredSystemWords(systemContentFolders(system), language ?? "")?.words),
|
|
71
|
+
}];
|
|
72
|
+
const extensions = campaignExtensions(root, context).extensions.flatMap((extension) => extension.page === undefined || !runsCode(extension)
|
|
73
|
+
? []
|
|
74
|
+
: [{
|
|
75
|
+
package: extension.package,
|
|
76
|
+
kind: "extension",
|
|
77
|
+
version: extension.version,
|
|
78
|
+
file: extension.page,
|
|
79
|
+
address: pageAddress(extension.package, extension.version, extension.page),
|
|
80
|
+
figures: extension.figures,
|
|
81
|
+
...wordsIn(language, extension.language, () => extensionWords(extension.folder, language ?? "")?.words),
|
|
82
|
+
}]);
|
|
83
|
+
return [...systems, ...extensions];
|
|
84
|
+
}
|
|
85
|
+
/** A package's words in the campaign's language, when it is written in another; none when they are not there or do not read, which validate says. */
|
|
86
|
+
function wordsIn(language, own, read) {
|
|
87
|
+
if (language === undefined || language.split("-")[0] === own.split("-")[0]) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const words = read();
|
|
92
|
+
return words === undefined || Object.keys(words).length === 0 ? {} : { words };
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** The address the dashboard serves a package's page module at: by the package's name and version, its folder's files beside it. */
|
|
99
|
+
export function pageAddress(name, version, file) {
|
|
100
|
+
return `/pkg/${encodeURIComponent(name)}/${encodeURIComponent(version)}/${encodeURIComponent(basename(file))}`;
|
|
34
101
|
}
|
|
35
102
|
/**
|
|
36
103
|
* The parts of the instructions of the system and of the extensions above it, each part layered as D-121 says, under a title of the extension's own (D-441): an
|
|
@@ -54,6 +121,10 @@ export function extensionsLine(root, context) {
|
|
|
54
121
|
const { extensions } = campaignExtensions(root, context);
|
|
55
122
|
return extensions.length === 0 ? "" : `Extensions: ${extensions.map((extension) => `${extension.name} (${extension.about})`).join("; ")}.`;
|
|
56
123
|
}
|
|
124
|
+
/** The fields of the core an extension declares among its fields or counters, which no extension may declare (D-505). */
|
|
125
|
+
function coreFieldsOf(extension) {
|
|
126
|
+
return [...Object.keys(extension.adds.fields ?? {}), ...Object.keys(extension.adds.counters ?? {})].filter(isCoreField);
|
|
127
|
+
}
|
|
57
128
|
function readCampaignExtensions(root, context) {
|
|
58
129
|
const extensions = [];
|
|
59
130
|
const problems = [];
|
|
@@ -64,7 +135,9 @@ function readCampaignExtensions(root, context) {
|
|
|
64
135
|
extension = findExtension(context.extensionFolders ?? [], name);
|
|
65
136
|
}
|
|
66
137
|
catch (error) {
|
|
67
|
-
|
|
138
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
139
|
+
// One made for a newer API waits for the engine, never for itself.
|
|
140
|
+
problems.push({ path: campaignFileName, message, ...(message.includes(updateEngine) ? {} : { fix: `install it again with package install ${name}` }) });
|
|
68
141
|
continue;
|
|
69
142
|
}
|
|
70
143
|
if (extension === undefined) {
|
|
@@ -77,6 +150,21 @@ function readCampaignExtensions(root, context) {
|
|
|
77
150
|
fix: `take it away with package remove ${extension.name}`,
|
|
78
151
|
});
|
|
79
152
|
}
|
|
153
|
+
else if (comparableText(extension.name) === comparableText(system ?? "")) {
|
|
154
|
+
// Its state, widgets and pictures go by its name, which the system's would share (D-514).
|
|
155
|
+
problems.push({
|
|
156
|
+
path: campaignFileName,
|
|
157
|
+
message: `The extension ${name} has the name of the game system the campaign plays, ${system ?? ""}: it is left out.`,
|
|
158
|
+
fix: `take it away with package remove ${extension.package}`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else if (coreFieldsOf(extension).length > 0) {
|
|
162
|
+
problems.push({
|
|
163
|
+
path: campaignFileName,
|
|
164
|
+
message: `The extension ${name} declares ${coreFieldsOf(extension).join(", ")}, which the engine's own pages hold: it is left out.`,
|
|
165
|
+
fix: `install another version of it with package install ${extension.name}, or take it away with package remove ${extension.name}`,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
80
168
|
else if (extensions.some((other) => other.name === extension.name)) {
|
|
81
169
|
problems.push({
|
|
82
170
|
path: campaignFileName,
|
|
@@ -13,7 +13,7 @@ export declare function questPictureNote(root: string, context: Context, world:
|
|
|
13
13
|
* one line, with the advice to write a creature of the campaign for one of the game system, which is read-only; undefined when all have one, or otherwise.
|
|
14
14
|
*/
|
|
15
15
|
export declare function metPictureNote(root: string, context: Context, entering: Page[]): string | undefined;
|
|
16
|
-
/** The folders whose images folder holds the pictures pages link: the campaign's first, then its game system's (D-267). */
|
|
16
|
+
/** The folders whose images folder holds the pictures pages link: the campaign's first, then its game system's (D-267), its version's before its own (VER-3). */
|
|
17
17
|
export declare function imageFolders(root: string, context: Context): string[];
|
|
18
18
|
/** The picture an image field links, as a file; undefined when the field is not a link or no images folder has the file. */
|
|
19
19
|
export declare function imageFile(root: string, context: Context, value: unknown): string | undefined;
|
|
@@ -3,6 +3,7 @@ import { readSettings } from "../campaign/index.js";
|
|
|
3
3
|
import { files } from "../core/store.js";
|
|
4
4
|
import { findImage, imageFileName } from "../images/index.js";
|
|
5
5
|
import { baseChain, isPartyMember, ownField } from "../pages/index.js";
|
|
6
|
+
import { systemContentFolders } from "../systems/index.js";
|
|
6
7
|
import { campaignSystem } from "./game-world.js";
|
|
7
8
|
/**
|
|
8
9
|
* What the master hears of the places' pictures (D-308, PIC-4): where pictures can be made and the player has not chosen, to ask them once; with new elements, that
|
|
@@ -45,10 +46,10 @@ export function metPictureNote(root, context, entering) {
|
|
|
45
46
|
: [`${system.join(", ")} ${system.length === 1 ? "is" : "are"} of the game system: for a picture, write a creature of the campaign from it, as write "<name>", type creature, set creature=[[${system[0]}]], and bring that in.`];
|
|
46
47
|
return make.length + write.length === 0 ? undefined : [...make, ...write].join(" ");
|
|
47
48
|
}
|
|
48
|
-
/** The folders whose images folder holds the pictures pages link: the campaign's first, then its game system's (D-267). */
|
|
49
|
+
/** The folders whose images folder holds the pictures pages link: the campaign's first, then its game system's (D-267), its version's before its own (VER-3). */
|
|
49
50
|
export function imageFolders(root, context) {
|
|
50
51
|
const system = campaignSystem(root, context);
|
|
51
|
-
return system === undefined ? [root] : [root, system.
|
|
52
|
+
return system === undefined ? [root] : [root, ...[...systemContentFolders(system)].reverse()];
|
|
52
53
|
}
|
|
53
54
|
/** The picture an image field links, as a file; undefined when the field is not a link or no images folder has the file. */
|
|
54
55
|
export function imageFile(root, context, value) {
|
|
@@ -94,6 +94,9 @@ export declare function libraryLines(answer: LibraryAnswer | undefined, text: st
|
|
|
94
94
|
/** The game system as its words are searched by: where its words are, its language, and the words a foe's hits are heard in, which name no rule. */
|
|
95
95
|
export interface SearchedSystem {
|
|
96
96
|
folder: string;
|
|
97
|
+
version?: {
|
|
98
|
+
folder: string;
|
|
99
|
+
};
|
|
97
100
|
language: string;
|
|
98
101
|
combat?: {
|
|
99
102
|
inWords: string[];
|
|
@@ -6,7 +6,7 @@ import { comparableText } from "../core/text.js";
|
|
|
6
6
|
import { documentAt, documentKinds } from "../documents/index.js";
|
|
7
7
|
import { dropUnlisted, foldersIn, isWithin, libraryFolders, libraryReader, libraryState, mostBooks, samePath, saveLibraryFolders } from "../library/index.js";
|
|
8
8
|
import { bookHeadings, findPages, hasAllWords, pageExcerpt, pageTitle } from "../rules/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { layeredSystemWords, systemContentFolders } from "../systems/index.js";
|
|
10
10
|
import { languageName } from "./game-world.js";
|
|
11
11
|
import { YesRefused } from "./package.js";
|
|
12
12
|
/** What a library takes: the documents the engine reads, outside every campaign (LIB-2). */
|
|
@@ -316,7 +316,7 @@ export function systemWordsNamed(system, language, text, intoSystem) {
|
|
|
316
316
|
return [];
|
|
317
317
|
}
|
|
318
318
|
try {
|
|
319
|
-
const words =
|
|
319
|
+
const words = layeredSystemWords(systemContentFolders(system), language);
|
|
320
320
|
const heard = (system.combat?.inWords ?? []).map(comparableText);
|
|
321
321
|
// Not the names, which are of fields by their ids, as cha or str-save.
|
|
322
322
|
const pairs = Object.entries({ ...words?.groups, ...words?.words }).filter(([own]) => !heard.includes(comparableText(own)));
|
|
@@ -88,7 +88,7 @@ export function checklistLine(mode, root, context, world) {
|
|
|
88
88
|
const name = unnamed ? ` The campaign is still named after its folder, ${settings.name}: propose a name that fits the premise, and set it with config name once the player likes it.` : "";
|
|
89
89
|
// With the dashboard open, the setup's closed choices are made there, one at a time (D-370).
|
|
90
90
|
const page = mode === "setup" && context.dashboard !== undefined
|
|
91
|
-
? " The player can make the setup's choices on the dashboard, one at a time: offer it, and meanwhile ask in the chat only the premise, the language and when the story starts. "
|
|
91
|
+
? " The player can make the setup's choices on the dashboard, one at a time: offer it, and meanwhile ask in the chat only the game system, the premise, the language and when the story starts. "
|
|
92
92
|
+ "Ask the rest only when they leave it to you, or once they say they are ready."
|
|
93
93
|
: "";
|
|
94
94
|
return `${missing.charAt(0).toUpperCase()}${missing.slice(1)}. When ${blocked === undefined ? "" : "none is left and "}the player confirms: ${modeCall(next)}.${name}${page}`;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type CardAsked, type Context } from "../core/context.ts";
|
|
2
|
+
import type { Asking, Game, GameView, PackageCode } from "../core/package-api.ts";
|
|
3
|
+
import type { Problem } from "../core/problem.ts";
|
|
4
|
+
import { type Command } from "../core/registry.ts";
|
|
5
|
+
import { type CodePackage, type Extension } from "../extensions/index.ts";
|
|
6
|
+
import { type GameDate } from "../time/index.ts";
|
|
7
|
+
import { type Told } from "./ask.ts";
|
|
8
|
+
/** The folder of the campaign where a package keeps its own files, its state among them (D-433, D-436): an extension's, or its game system's. */
|
|
9
|
+
export declare const extensionsFolderName = "extensions";
|
|
10
|
+
/** The packages that bring code to the campaign (D-514): its game system first, then its extensions in the order campaign.yaml lists them. */
|
|
11
|
+
export declare function campaignPackages(root: string, context: Context): CodePackage[];
|
|
12
|
+
/** The campaign's game system as a package of the campaign (D-514): its package.json's name and version, or, for one that is data alone, its name and the engine's version. */
|
|
13
|
+
export declare function campaignSystemPackage(root: string, context: Context): CodePackage | undefined;
|
|
14
|
+
/** A package as messages name it: the game system 5e, the extension weather. */
|
|
15
|
+
export declare function packageLabel(code: CodePackage): string;
|
|
16
|
+
/**
|
|
17
|
+
* The commands of the campaign's packages whose code may run (D-63, D-428, D-441), as commands of rpg-engine: each runs with the game of D-436 and gives the
|
|
18
|
+
* master its text; by name, the package and version that give it, so that a server knows when another takes its place.
|
|
19
|
+
*/
|
|
20
|
+
export declare function packageCommands(root: string, context: Context, taken: string[]): Promise<{
|
|
21
|
+
commands: Command[];
|
|
22
|
+
sources: Record<string, string>;
|
|
23
|
+
problems: Problem[];
|
|
24
|
+
}>;
|
|
25
|
+
/** The names of a package's commands, its code loaded and checked as the campaign would use it; it throws what keeps it from being used. */
|
|
26
|
+
export declare function packageCommandNames(code: CodePackage, context: Context, taken: string[]): Promise<string[]>;
|
|
27
|
+
/** Tells the loader npm has just installed: code installed again at the same version is read anew. */
|
|
28
|
+
export declare function packagesInstalled(): void;
|
|
29
|
+
/** What keeps the code of the campaign's packages from being used, for validate and status: it loads them. */
|
|
30
|
+
export declare function packageCodeProblems(root: string, context: Context, taken: string[]): Promise<Problem[]>;
|
|
31
|
+
/**
|
|
32
|
+
* What the campaign's packages say after time passed from one date to another, or as the game starts, when both are the same (D-436). The time has passed
|
|
33
|
+
* whatever they do: one that fails says so in its line, never in place of the output.
|
|
34
|
+
*/
|
|
35
|
+
export declare function timePassedLines(root: string, context: Context, from: GameDate, to: GameDate): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* The code of a package, when it may run (D-441, D-514): an extension's module's default export, given the kit, loaded as it is first needed; a game system's
|
|
38
|
+
* as the engine loaded it when it started. It throws why a system's code is not there.
|
|
39
|
+
*/
|
|
40
|
+
export declare function packageCode(code: CodePackage, context: Context): Promise<PackageCode | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* A package's code as loaded already, for the hooks the commands call at once (D-448, D-514): its code, or why it is not there; undefined where it brings none
|
|
43
|
+
* or does not run. An extension's is there once its import has ended, as an entry starts or as its commands were read; one whose commands are refused is not.
|
|
44
|
+
*/
|
|
45
|
+
export declare function loadedCode(code: CodePackage, context: Context): PackageCode | string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Loads the code of the campaign's packages, as an entry that calls their hooks starts (D-514), and again after package installs one: their hooks are called at
|
|
48
|
+
* once, never waiting for an import. What keeps one from being used is kept for its hooks, and left to validate.
|
|
49
|
+
*/
|
|
50
|
+
export declare function loadCampaignCode(context: Context): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* The code of the campaign's game system when this process has not loaded it, as one installed in the chat that plays it (D-513 (1)): new to the process, it
|
|
53
|
+
* is imported now, with the commands of the campaign's packages; a system loaded already, refused or broken, stays as it was.
|
|
54
|
+
*/
|
|
55
|
+
export declare function loadNewSystemCode(context: Context): Promise<void>;
|
|
56
|
+
/** A package's lines for the master, cut at the most it may say in one call, with a line that says so. */
|
|
57
|
+
export declare function cappedLines(code: CodePackage, lines: string[]): string[];
|
|
58
|
+
/** A package that is an extension. */
|
|
59
|
+
export declare function isExtension(code: CodePackage): code is Extension;
|
|
60
|
+
/**
|
|
61
|
+
* The game as a package's code reaches it (D-436, D-505, D-514): what a widget reads, the dice, asking the player, its own state, the fields it may write and
|
|
62
|
+
* the log; nothing else is written. A command's or time's game writes nothing once the call is stopped (ASK-9); a hook's finishes what the engine began.
|
|
63
|
+
*/
|
|
64
|
+
export declare function gameOf(root: string, context: Context, code: CodePackage, options?: {
|
|
65
|
+
asked?: {
|
|
66
|
+
card?: CardAsked;
|
|
67
|
+
};
|
|
68
|
+
hook?: boolean;
|
|
69
|
+
}): Game;
|
|
70
|
+
/**
|
|
71
|
+
* The game as a widget of a package reads it (D-502, D-505): the time, where the party is and who is in it, a page, the scene, the campaign's settings and the
|
|
72
|
+
* package's state.
|
|
73
|
+
*/
|
|
74
|
+
export declare function gameViewOf(root: string, context: Context, code: CodePackage): GameView;
|
|
75
|
+
/**
|
|
76
|
+
* How a package's code words a roll it asks (D-507): its buttons and its rule translated, what its faces mean and how they turned out, and the card of its
|
|
77
|
+
* widget, read for its key and whose roll it is, refused when the package has no widget by that name.
|
|
78
|
+
*/
|
|
79
|
+
export declare function toldOf(root: string, context: Context, code: CodePackage, wanted: Asking, who?: string): Told;
|
|
80
|
+
/** The first line of what went wrong, without its last stop, for a line among others. */
|
|
81
|
+
export declare function firstLine(error: unknown): string;
|
|
82
|
+
/**
|
|
83
|
+
* A system's code as the engine loaded it, or why it is not there: not loaded, loaded at another version than the one installed now, refused or broken; undefined
|
|
84
|
+
* when it brings none.
|
|
85
|
+
*/
|
|
86
|
+
/** Whether a package's code is refused, as another's without the player's yes, one made for another API or with commands refused: said once, not at each call. */
|
|
87
|
+
export declare function codeRefused(code: CodePackage, context: Context): boolean;
|