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
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { join, resolve } from "node:path";
|
|
2
2
|
import { campaignFileName, readCampaignData, readOneSetting, readTextSetting } from "../campaign/index.js";
|
|
3
|
+
import { ourSystems } from "../core/package-declarations.js";
|
|
3
4
|
import { files, isInside } from "../core/store.js";
|
|
4
5
|
import { comparableText } from "../core/text.js";
|
|
6
|
+
import { extensionWords } from "../extensions/index.js";
|
|
5
7
|
import { languagePackFor, packSystemFolder } from "../languages/index.js";
|
|
6
8
|
import { homeSystemWords } from "../page-words.js";
|
|
7
|
-
import { loadWorld, searchSystemPages, worldFolderName } from "../pages/index.js";
|
|
8
|
-
import { findCampaignSystem, findSystem, installedSystems, systemWords, withSettings } from "../systems/index.js";
|
|
9
|
+
import { loadWorld, playerCharacters, searchSystemPages, worldFolderName } from "../pages/index.js";
|
|
10
|
+
import { findCampaignSystem, findSystem, installedSystems, layeredSystemWords, rulesetSetting, systemContentFolders, systemWords, withSettings, } from "../systems/index.js";
|
|
9
11
|
import { campaignExtensions, extensionSources, layeredParts } from "./game-extension-list.js";
|
|
10
12
|
/** The world of the campaign in `root`, with the pages of its game system when campaign.yaml names one that is installed (SYS-1, SYS-3). */
|
|
11
13
|
export function campaignWorld(root, context) {
|
|
@@ -18,18 +20,43 @@ export function campaignWorld(root, context) {
|
|
|
18
20
|
return loadWorld(root, {
|
|
19
21
|
system,
|
|
20
22
|
language: readTextSetting(root, "language"),
|
|
23
|
+
words: campaignSystemWords(root, context),
|
|
21
24
|
missingSystem: system === undefined ? named : undefined,
|
|
22
25
|
noSystem: named === undefined,
|
|
23
26
|
rigor: readTextSetting(root, "rigor"),
|
|
24
27
|
});
|
|
25
28
|
});
|
|
26
29
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The game system's words in the campaign's language (D-403): its own, else those translated on the fly on this computer (D-406); with the names of the
|
|
32
|
+
* fields the campaign's extensions add, from their words, layered as their additions are (CAM-2, D-505).
|
|
33
|
+
*/
|
|
34
|
+
export function systemWordsOf(root, system, language, context) {
|
|
29
35
|
// A language package's words come first, then the system's own, then those translated on the fly (D-485 (3)).
|
|
30
36
|
const pack = languagePackFor(context.extensionFolders ?? [], language);
|
|
31
37
|
const packed = pack === undefined ? undefined : packSystemFolder(pack, system.name);
|
|
32
|
-
|
|
38
|
+
const own = (packed === undefined ? undefined : systemWords(packed, language)) ?? layeredSystemWords(systemContentFolders(system), language) ?? homeSystemWords(context.home, system, language);
|
|
39
|
+
const added = campaignExtensions(root, context).extensions.reduce((fields, extension) => ({ ...fields, ...extensionFieldWords(extension, language) }), {});
|
|
40
|
+
return Object.keys(added).length === 0 ? own : { ...(own ?? { groups: {}, words: {} }), fields: { ...own?.fields, ...added } };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The game system's words in the campaign's language, by their English (D-403), by which a name written in it is the system's, Prono its Prone; none without a
|
|
44
|
+
* language, or when they do not read. Kept until campaign.yaml, an extension or a translation of this computer changes.
|
|
45
|
+
*/
|
|
46
|
+
export function campaignSystemWords(root, context) {
|
|
47
|
+
const sources = extensionSources(root, context);
|
|
48
|
+
const translated = context.home === undefined ? undefined : resolve(join(context.home, "systems"));
|
|
49
|
+
const dependsOn = (path) => sources(path) || (translated !== undefined && (isInside(translated, path) || isInside(path, translated)));
|
|
50
|
+
return files().remember(`system words ${resolve(root)}`, dependsOn, () => {
|
|
51
|
+
const system = campaignSystem(root, context);
|
|
52
|
+
const language = readTextSetting(root, "language");
|
|
53
|
+
try {
|
|
54
|
+
return system === undefined || language === undefined ? undefined : systemWordsOf(root, system, language, context)?.words;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
33
60
|
}
|
|
34
61
|
/**
|
|
35
62
|
* The installed game system that campaign.yaml names, with what the campaign adds to it (CAM-1, CAM-2): alone when the additions do not read (CAM-3). Undefined
|
|
@@ -39,23 +66,58 @@ export function campaignSystem(root, context) {
|
|
|
39
66
|
return systemOf(root, context).system;
|
|
40
67
|
}
|
|
41
68
|
/**
|
|
42
|
-
* The game system campaign.yaml names, with its
|
|
43
|
-
* a call asks for it many times.
|
|
69
|
+
* The game system campaign.yaml names, with what its extensions and then the campaign add to it (CAM-2), and the layers left out with why (CAM-3), as its
|
|
70
|
+
* settings have it (DAT-10), read once until campaign.yaml changes: a call asks for it many times.
|
|
44
71
|
*/
|
|
45
72
|
function systemOf(root, context) {
|
|
46
|
-
// campaign.yaml, and the extensions' packages, whose parts it gives.
|
|
73
|
+
// campaign.yaml, and the extensions' packages, whose parts and additions it gives.
|
|
47
74
|
return files().remember(`system ${resolve(root)}`, extensionSources(root, context), () => {
|
|
48
75
|
const name = readTextSetting(root, "system");
|
|
49
|
-
const found = name === undefined ? {} : findCampaignSystem(context.systemFolders, name, readCampaignData(root));
|
|
76
|
+
const found = name === undefined ? { refused: [] } : findCampaignSystem(context.systemFolders, name, systemLayers(root, context, readCampaignData(root)), readTextSetting(root, rulesetSetting));
|
|
50
77
|
// And the parts of the instructions of its extensions over its own (D-121).
|
|
51
78
|
const played = found.system === undefined ? undefined : withSettings(found.system, (setting) => readTextSetting(root, setting));
|
|
52
79
|
return played === undefined ? found : { ...found, system: { ...played, parts: layeredParts(played.parts, campaignExtensions(root, context).extensions) } };
|
|
53
80
|
});
|
|
54
81
|
}
|
|
82
|
+
/** What the campaign's extensions add to its game system, in the order campaign.yaml lists them, then the campaign's own additions, which win (CAM-2). */
|
|
83
|
+
export function systemLayers(root, context, campaign) {
|
|
84
|
+
const extensions = campaignExtensions(root, context).extensions.map((extension) => ({ from: extensionLayer(extension.name), data: extension.adds }));
|
|
85
|
+
return [...extensions, { from: campaignFileName, data: campaign }];
|
|
86
|
+
}
|
|
87
|
+
/** The layers over the campaign's system that it plays with, in order, and by name those left out because the system would not read with them (CAM-3). */
|
|
88
|
+
export function playedLayers(root, context) {
|
|
89
|
+
const refused = systemOf(root, context).refused.map((layer) => layer.from);
|
|
90
|
+
return { kept: systemLayers(root, context, readCampaignData(root)).filter((layer) => !refused.includes(layer.from)), refused };
|
|
91
|
+
}
|
|
92
|
+
/** The name of an extension's layer of additions, as messages give it. */
|
|
93
|
+
export function extensionLayer(name) {
|
|
94
|
+
return `the extension ${name}`;
|
|
95
|
+
}
|
|
96
|
+
/** The names an extension's words give the fields it adds; none when its words do not read, which validate names. */
|
|
97
|
+
function extensionFieldWords(extension, language) {
|
|
98
|
+
try {
|
|
99
|
+
return extensionWords(extension.folder, language)?.fields ?? {};
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
55
105
|
/** A setting the campaign's game system adds to the setup (DAT-10), by its name in any case; undefined when the system has none by that name. */
|
|
56
106
|
export function systemSetting(root, context, name) {
|
|
57
107
|
return campaignSystem(root, context)?.settings.find((setting) => comparableText(setting.name) === comparableText(name.trim()));
|
|
58
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The value a setting of the system has in the campaign (DAT-10): the one campaign.yaml gives, when the system has it; for the version of the rules, once the game
|
|
111
|
+
* has begun, the one it plays unwritten, the first (VER-2). Undefined while it is still to be chosen.
|
|
112
|
+
*/
|
|
113
|
+
export function playedSettingValue(root, context, setting) {
|
|
114
|
+
const written = systemSettingValue(root, setting);
|
|
115
|
+
return written !== undefined || setting.name !== rulesetSetting || playersOfTheGame(root, context).length === 0 ? written : campaignSystem(root, context)?.version?.name;
|
|
116
|
+
}
|
|
117
|
+
/** The names of the player characters the game has begun with (D-519): from the first, the campaign keeps its system and the version of its rules (SYS-9, VER-4). */
|
|
118
|
+
export function playersOfTheGame(root, context) {
|
|
119
|
+
return playerCharacters(campaignWorld(root, context)).map((page) => page.name);
|
|
120
|
+
}
|
|
59
121
|
/** The value campaign.yaml gives a setting of the system, when it is one the system has (DAT-10). */
|
|
60
122
|
export function systemSettingValue(root, setting) {
|
|
61
123
|
const written = readTextSetting(root, setting.name);
|
|
@@ -107,30 +169,46 @@ export function systemOccasions(root, context) {
|
|
|
107
169
|
export function systemProblems(root, context) {
|
|
108
170
|
const name = readTextSetting(root, "system");
|
|
109
171
|
const found = name === undefined ? undefined : systemOf(root, context);
|
|
110
|
-
// What the campaign adds that does not read: the campaign plays
|
|
111
|
-
if (found
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
172
|
+
// What an extension or the campaign adds that does not read: the campaign plays without it (CAM-3).
|
|
173
|
+
if (found !== undefined && found.refused.length > 0) {
|
|
174
|
+
return found.refused.map(({ from, problem }) => ({
|
|
175
|
+
path: campaignFileName,
|
|
176
|
+
message: `What ${from} adds to the system ${name ?? ""} does not read, so the campaign plays without it: ${problem}`,
|
|
177
|
+
fix: from === campaignFileName
|
|
178
|
+
? "fix it first, with the config command or by hand: until then validate does not check what the system works out on the pages"
|
|
179
|
+
: `install another version of it with package install ${from.replace(/^the extension /, "")}, or take it away with package remove`,
|
|
180
|
+
}));
|
|
117
181
|
}
|
|
118
182
|
if (name === undefined || found?.system !== undefined) {
|
|
119
183
|
return [];
|
|
120
184
|
}
|
|
121
|
-
const [first] = installedSystems(context.systemFolders);
|
|
122
185
|
return [{
|
|
123
186
|
path: "campaign.yaml",
|
|
124
187
|
message: `The system ${name} is not installed: no creatures, items or rules come from a system. ${installedText(context)}`,
|
|
125
|
-
fix:
|
|
188
|
+
fix: missingSystemFix(name, context),
|
|
126
189
|
}];
|
|
127
190
|
}
|
|
191
|
+
/** How a campaign gets the system it names that is not installed: one of ours with package install (D-513), else another of those installed, asked of the player. */
|
|
192
|
+
function missingSystemFix(name, context) {
|
|
193
|
+
const ours = ourSystems.find((one) => comparableText(one.name) === comparableText(name.trim()));
|
|
194
|
+
if (ours !== undefined) {
|
|
195
|
+
return `install it, one of RPG Engine's own, with package install ${ours.name}; until then, play on without its pages`;
|
|
196
|
+
}
|
|
197
|
+
const [first] = installedSystems(context.systemFolders);
|
|
198
|
+
return first === undefined ? "install the game system" : `ask the player which game you play, then config, setting system, value ${first.name}`;
|
|
199
|
+
}
|
|
128
200
|
/** The name of an installed game system, as it is installed; refused, with those that are, when none has it (D-167). */
|
|
129
201
|
export function installedSystemName(name, context, how) {
|
|
130
202
|
const system = findSystem(context.systemFolders, name);
|
|
131
203
|
if (system === undefined) {
|
|
132
204
|
const [first] = installedSystems(context.systemFolders);
|
|
133
|
-
const
|
|
205
|
+
const ours = ourSystems.find((one) => comparableText(one.name) === comparableText(name.trim()));
|
|
206
|
+
// One of ours is installed first, once the player wants it (D-513 (1)).
|
|
207
|
+
const example = ours !== undefined
|
|
208
|
+
? ` It is one of RPG Engine's own: install it with package install ${ours.name} once the player wants it, then give it again.`
|
|
209
|
+
: first === undefined
|
|
210
|
+
? ""
|
|
211
|
+
: ` Give one of them, such as ${how === "init" ? "system" : "setting system, value"} ${first.name}.`;
|
|
134
212
|
throw new Error(`"${name}" is not an installed system. ${installedText(context)}${example} Nothing changed.`);
|
|
135
213
|
}
|
|
136
214
|
return system.name;
|
|
@@ -194,7 +272,7 @@ export function missingWithSystems(root, missing, context) {
|
|
|
194
272
|
const names = installedSystems(context.systemFolders).map((system) => system.name);
|
|
195
273
|
const system = names.length > 0 ? `system (installed: ${names.join(", ")})` : "system";
|
|
196
274
|
// What the system adds to the setup, with its values: config says what each means (DAT-10).
|
|
197
|
-
const added = (campaignSystem(root, context)?.settings ?? []).filter((setting) =>
|
|
275
|
+
const added = (campaignSystem(root, context)?.settings ?? []).filter((setting) => playedSettingValue(root, context, setting) === undefined).map((setting) => `${setting.name} (${valuesText(setting)})`);
|
|
198
276
|
// The system first (D-167): the other settings may depend on the game.
|
|
199
277
|
return [...(missing.includes("system") ? [system, ...missing.filter((name) => name !== "system")] : missing), ...added];
|
|
200
278
|
}
|
|
@@ -204,12 +282,23 @@ export function missingWithSystems(root, missing, context) {
|
|
|
204
282
|
*/
|
|
205
283
|
export function systemInStatus(root, context) {
|
|
206
284
|
const name = readTextSetting(root, "system");
|
|
207
|
-
const system = name === undefined ? undefined : findSystem(context.systemFolders, name);
|
|
285
|
+
const system = name === undefined ? undefined : findSystem(context.systemFolders, name, readTextSetting(root, rulesetSetting));
|
|
286
|
+
// With the version of its rules the campaign plays (VER-1).
|
|
208
287
|
if (name === undefined || system !== undefined) {
|
|
209
|
-
return system === undefined ? undefined : `${system.name}, ${system.title}`;
|
|
288
|
+
return system === undefined ? undefined : `${system.name}, ${system.title}${playedRules(root, context, system)}`;
|
|
210
289
|
}
|
|
211
|
-
|
|
212
|
-
|
|
290
|
+
return `${name} (not installed: ${missingSystemFix(name, context)})`;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* ", the second rules": the version of its rules a system is played with, when it has more than one to choose from (VER-1), or that it is still to ask, so
|
|
294
|
+
* that the first, read meanwhile, is never taken as chosen; empty otherwise.
|
|
295
|
+
*/
|
|
296
|
+
export function playedRules(root, context, system) {
|
|
297
|
+
const setting = system.settings.find((one) => one.name === rulesetSetting);
|
|
298
|
+
if (system.version === undefined || setting === undefined) {
|
|
299
|
+
return "";
|
|
300
|
+
}
|
|
301
|
+
return playedSettingValue(root, context, setting) === undefined ? ", the version of its rules still to ask" : `, ${system.version.title ?? system.version.name}`;
|
|
213
302
|
}
|
|
214
303
|
/** A language as messages name it, such as English for en. */
|
|
215
304
|
export function languageName(code) {
|
package/dist/commands/image.js
CHANGED
|
@@ -16,7 +16,7 @@ import { sheetHeadline } from "./sheet.js";
|
|
|
16
16
|
export const image = defineCommand({
|
|
17
17
|
name: "image",
|
|
18
18
|
description: "Give a page its picture: a portrait for a character, an image for a creature, an item or a place, as the dashboard will show it in a round token. "
|
|
19
|
-
+ "It copies the file into the campaign and links it in the page's image field; a page without one shows the picture of the page it derives from, such as a
|
|
19
|
+
+ "It copies the file into the campaign and links it in the page's image field; a page without one shows the picture of the page it derives from, such as a wolf's icon. "
|
|
20
20
|
+ "Use it when the player gives you a picture, or after you made or downloaded one with your own tools. "
|
|
21
21
|
+ "For a place, a quest, a character or a creature of the campaign, describe instead of file has the picture made on this computer, as the campaign's pictures setting allows: "
|
|
22
22
|
+ "for the player character or a companion only when the player asks; for a creature once for each kind, whose copies show it. "
|
package/dist/commands/init.js
CHANGED
|
@@ -12,14 +12,14 @@ export const init = defineCommand({
|
|
|
12
12
|
description: "Create a new campaign. "
|
|
13
13
|
+ "It writes the settings, the log, the world's folders, and the .mcp.json, AGENTS.md and CLAUDE.md through which an AI host finds these tools. "
|
|
14
14
|
+ "Use it once, when the player starts a new campaign; then ask the player for the missing settings and set them with config. "
|
|
15
|
-
+ 'Example: name "The Salt Isles", language en
|
|
15
|
+
+ 'Example: name "The Salt Isles", language en.',
|
|
16
16
|
group: "campaign",
|
|
17
17
|
positionals: ["folder"],
|
|
18
18
|
input: z.object({
|
|
19
19
|
folder: z.string().optional().describe("folder of the new campaign; the current folder if left out"),
|
|
20
20
|
name: z.string().optional().describe("name of the campaign; the folder's name if left out"),
|
|
21
21
|
language: z.string().optional().describe("language of the game, as a code such as it or en"),
|
|
22
|
-
system: z.string().optional().describe("game system: one of those installed
|
|
22
|
+
system: z.string().optional().describe("game system: one of those installed"),
|
|
23
23
|
difficulty: z.enum(difficulties).optional().describe(`how hard the world plays: ${difficulties.join(", ")}`),
|
|
24
24
|
lethality: z.enum(lethalities).optional().describe(`what a fall means: ${lethalities.join(", ")}`),
|
|
25
25
|
}),
|
package/dist/commands/mode.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { type Mode } from "./game-mode.ts";
|
|
|
3
3
|
import { type ResetPoint } from "./game-saves.ts";
|
|
4
4
|
export declare const mode: import("../core/registry.ts").Command<z.ZodObject<{
|
|
5
5
|
to: z.ZodEnum<{
|
|
6
|
-
setup: "setup";
|
|
7
6
|
"session zero": "session zero";
|
|
7
|
+
setup: "setup";
|
|
8
8
|
play: "play";
|
|
9
9
|
}>;
|
|
10
10
|
}, z.core.$strip>, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type Context } from "../core/context.ts";
|
|
2
3
|
import { type Extension } from "../extensions/index.ts";
|
|
3
4
|
import { type AdventureExported, type AdventureInstalled } from "./game-adventures.ts";
|
|
4
5
|
type PackageResult = {
|
|
@@ -51,7 +52,7 @@ type PackageResult = {
|
|
|
51
52
|
} | ({
|
|
52
53
|
kind: "exported";
|
|
53
54
|
} & AdventureExported);
|
|
54
|
-
/** A package on this computer, as list gives it to the master and to the dashboard; broken when it does not read (D-442). */
|
|
55
|
+
/** A package on this computer, as list gives it to the master and to the dashboard; broken when it does not read (D-442); with where its problems are reported. */
|
|
55
56
|
type Installed = {
|
|
56
57
|
name: string;
|
|
57
58
|
package: string;
|
|
@@ -60,10 +61,12 @@ type Installed = {
|
|
|
60
61
|
about: string;
|
|
61
62
|
verified: boolean;
|
|
62
63
|
used: boolean;
|
|
64
|
+
issues?: string;
|
|
63
65
|
} | {
|
|
64
66
|
name: string;
|
|
65
67
|
package: string;
|
|
66
68
|
broken: string;
|
|
69
|
+
issues?: string;
|
|
67
70
|
};
|
|
68
71
|
/** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
|
|
69
72
|
export declare class YesRefused extends Error {
|
|
@@ -80,6 +83,8 @@ export interface InstalledSystem {
|
|
|
80
83
|
used: boolean;
|
|
81
84
|
/** Whether it brings code, which runs from the next start of the game's server. */
|
|
82
85
|
code: boolean;
|
|
86
|
+
/** Where its problems are reported, as its package.json says: the engine's own for those shipped with it. */
|
|
87
|
+
issues?: string;
|
|
83
88
|
}
|
|
84
89
|
/** A language package on this computer (D-485 (3)), for every campaign: one for each language. */
|
|
85
90
|
export interface InstalledLanguage {
|
|
@@ -88,6 +93,8 @@ export interface InstalledLanguage {
|
|
|
88
93
|
package: string;
|
|
89
94
|
version: string;
|
|
90
95
|
verified: boolean;
|
|
96
|
+
/** Where its problems are reported, as its package.json says. */
|
|
97
|
+
issues?: string;
|
|
91
98
|
}
|
|
92
99
|
/** A package on npm for this rpg-engine, with the version installed here, if any, and whether it is newer (D-442). */
|
|
93
100
|
interface Available {
|
|
@@ -99,6 +106,11 @@ interface Available {
|
|
|
99
106
|
verified: boolean;
|
|
100
107
|
installed?: string;
|
|
101
108
|
update: boolean;
|
|
109
|
+
/** Its latest version, which needs a newer rpg-engine (D-515 (2)). */
|
|
110
|
+
newer?: {
|
|
111
|
+
version: string;
|
|
112
|
+
engine?: string;
|
|
113
|
+
};
|
|
102
114
|
}
|
|
103
115
|
export declare const packageCommand: import("../core/registry.ts").Command<z.ZodObject<{
|
|
104
116
|
action: z.ZodEnum<{
|
|
@@ -113,6 +125,8 @@ export declare const packageCommand: import("../core/registry.ts").Command<z.Zod
|
|
|
113
125
|
author: z.ZodOptional<z.ZodString>;
|
|
114
126
|
license: z.ZodOptional<z.ZodString>;
|
|
115
127
|
}, z.core.$strip>, PackageResult>;
|
|
128
|
+
/** Whether a package is on this computer, by its name as package takes it: an extension, a game system or a language npm installed (D-510). */
|
|
129
|
+
export declare function isInstalledPackage(context: Context, name: string): boolean;
|
|
116
130
|
/** What the master hears of an adventure installed (D-483 (5)): what it is in a few lines, then what to read and where it starts, never its text. */
|
|
117
131
|
export declare function adventureText(result: AdventureInstalled): string;
|
|
118
132
|
export {};
|