rpg-engine 0.13.0 → 0.14.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/dist/campaign/choices.d.ts +30 -0
- package/dist/campaign/choices.js +84 -0
- package/dist/campaign/index.d.ts +4 -1
- package/dist/campaign/index.js +4 -1
- package/dist/campaign/last-choices.d.ts +6 -0
- package/dist/campaign/last-choices.js +34 -0
- package/dist/campaign/levels.d.ts +50 -0
- package/dist/campaign/levels.js +189 -0
- package/dist/campaign/settings.d.ts +35 -13
- package/dist/campaign/settings.js +20 -51
- package/dist/commands/ask.d.ts +8 -0
- package/dist/commands/ask.js +2 -1
- package/dist/commands/change/change.js +6 -4
- package/dist/commands/choices.d.ts +64 -0
- package/dist/commands/choices.js +216 -0
- package/dist/commands/config.d.ts +8 -1
- package/dist/commands/config.js +165 -21
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +8 -4
- package/dist/commands/rename.js +8 -3
- package/dist/commands/save.d.ts +1 -1
- package/dist/commands/shared/experience.d.ts +9 -2
- package/dist/commands/shared/experience.js +42 -7
- package/dist/commands/shared/knowledge.d.ts +2 -0
- package/dist/commands/shared/knowledge.js +5 -0
- package/dist/commands/shared/mode.js +10 -3
- package/dist/commands/shared/offers.d.ts +3 -1
- package/dist/commands/shared/offers.js +6 -1
- package/dist/commands/shared/rules.js +5 -1
- package/dist/commands/shared/time.d.ts +6 -0
- package/dist/commands/shared/time.js +35 -3
- package/dist/commands/shared/upkeep.js +3 -3
- package/dist/commands/shared/world.js +7 -4
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +15 -7
- package/dist/commands/view/view.js +10 -7
- package/dist/commands/write/write.js +5 -2
- package/dist/dashboard/address.js +8 -1
- package/dist/dashboard/api.js +20 -0
- package/dist/dashboard/app.js +18 -6
- package/dist/dashboard/choices.js +338 -0
- package/dist/dashboard/guide/ar.md +7 -7
- package/dist/dashboard/guide/cs.md +7 -7
- package/dist/dashboard/guide/da.md +8 -8
- package/dist/dashboard/guide/de.md +7 -7
- package/dist/dashboard/guide/el.md +9 -9
- package/dist/dashboard/guide/en.md +6 -6
- package/dist/dashboard/guide/es.md +7 -7
- package/dist/dashboard/guide/fi.md +7 -7
- package/dist/dashboard/guide/fr.md +7 -7
- package/dist/dashboard/guide/he.md +7 -7
- package/dist/dashboard/guide/hi.md +7 -7
- package/dist/dashboard/guide/hu.md +7 -7
- package/dist/dashboard/guide/is.md +8 -8
- package/dist/dashboard/guide/it.md +7 -7
- package/dist/dashboard/guide/ja.md +7 -7
- package/dist/dashboard/guide/ko.md +8 -8
- package/dist/dashboard/guide/nb.md +8 -8
- package/dist/dashboard/guide/nl.md +7 -7
- package/dist/dashboard/guide/pl.md +7 -7
- package/dist/dashboard/guide/pt.md +7 -7
- package/dist/dashboard/guide/ro.md +7 -7
- package/dist/dashboard/guide/ru.md +7 -7
- package/dist/dashboard/guide/sv.md +7 -7
- package/dist/dashboard/guide/tr.md +7 -7
- package/dist/dashboard/guide/uk.md +7 -7
- package/dist/dashboard/guide/zh.md +7 -7
- package/dist/dashboard/i18n/ar.json +79 -0
- package/dist/dashboard/i18n/cs.json +79 -0
- package/dist/dashboard/i18n/da.json +79 -0
- package/dist/dashboard/i18n/de.json +79 -0
- package/dist/dashboard/i18n/el.json +79 -0
- package/dist/dashboard/i18n/es.json +79 -0
- package/dist/dashboard/i18n/fi.json +79 -0
- package/dist/dashboard/i18n/fr.json +79 -0
- package/dist/dashboard/i18n/he.json +79 -0
- package/dist/dashboard/i18n/hi.json +79 -0
- package/dist/dashboard/i18n/hu.json +79 -0
- package/dist/dashboard/i18n/is.json +79 -0
- package/dist/dashboard/i18n/it.json +79 -0
- package/dist/dashboard/i18n/ja.json +79 -0
- package/dist/dashboard/i18n/ko.json +79 -0
- package/dist/dashboard/i18n/nb.json +79 -0
- package/dist/dashboard/i18n/nl.json +79 -0
- package/dist/dashboard/i18n/pl.json +79 -0
- package/dist/dashboard/i18n/pt.json +79 -0
- package/dist/dashboard/i18n/ro.json +79 -0
- package/dist/dashboard/i18n/ru.json +79 -0
- package/dist/dashboard/i18n/sv.json +79 -0
- package/dist/dashboard/i18n/tr.json +79 -0
- package/dist/dashboard/i18n/uk.json +79 -0
- package/dist/dashboard/i18n/zh.json +79 -0
- package/dist/dashboard/icons.js +4 -0
- package/dist/dashboard/labels.js +32 -0
- package/dist/dashboard/party.js +13 -5
- package/dist/dashboard/settings.js +89 -40
- package/dist/dashboard/setup.js +1 -1
- package/dist/dashboard/sheet.js +3 -2
- package/dist/dashboard/style.css +729 -1
- package/dist/dashboard/top.js +8 -4
- package/dist/server/dashboard/choices.d.ts +38 -0
- package/dist/server/dashboard/choices.js +174 -0
- package/dist/server/dashboard/index.js +17 -1
- package/dist/time/game-date.d.ts +9 -0
- package/dist/time/game-date.js +9 -0
- package/dist/time/index.d.ts +1 -1
- package/dist/time/index.js +1 -1
- package/instructions/dashboard-guide.md +1 -1
- package/package.json +1 -1
package/dist/commands/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { parse, stringify } from "yaml";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, clearSetting, companionWays, diceWays, difficulties, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, masterRollWays, mentorWays, pictureWays, preparations, proseWays, readCampaignData, readSettings, readTextSetting, refreshHostFiles, requireCampaign, rigors, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unitSystems, voiceWays, writeEffortFiles, } from "../campaign/index.js";
|
|
4
|
+
import { changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, clearSetting, companionWays, customLevel, customLevels, customSettings, diceWays, difficulties, efforts, entrySettingNames, itemMeaning, lastChoices, lethalities, leveled, listSettingNames, mapSettingNames, masterRollWays, mentorWays, pictureWays, preparations, proseWays, readCampaignData, readOneSetting, readSettings, readTextSetting, refreshHostFiles, rememberChoice, requireCampaign, rigors, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, startingLevels, storyWays, styleTextLengths, unitSystems, voiceWays, writeEffortFiles, } from "../campaign/index.js";
|
|
5
5
|
import { engineSystemsFolder } from "../core/context.js";
|
|
6
6
|
import { appendLogEntry } from "../core/log.js";
|
|
7
7
|
import { defineCommand } from "../core/registry.js";
|
|
@@ -14,7 +14,7 @@ import { hostInstructions } from "../instructions/index.js";
|
|
|
14
14
|
import { coinList, readAmount, readCoins } from "../money/index.js";
|
|
15
15
|
import { declaredKind } from "../pages/index.js";
|
|
16
16
|
import { campaignDataNames, findCampaignSystem, findSystem, readableSystems, rulesetSetting, systemFileName, systemPackage } from "../systems/index.js";
|
|
17
|
-
import { readCalendar, readCalendarStart } from "../time/index.js";
|
|
17
|
+
import { formatDuration, readBetweenSessions, readCalendar, readCalendarStart } from "../time/index.js";
|
|
18
18
|
import { checkLibraryRemovals, libraryAdditions, libraryRemovals, libraryShown, startLibraryReading } from "./shared/library.js";
|
|
19
19
|
import { campaignMode, campaignNote } from "./shared/mode.js";
|
|
20
20
|
import { campaignCoins, coinsShown } from "./shared/money.js";
|
|
@@ -42,6 +42,8 @@ export const config = defineCommand({
|
|
|
42
42
|
+ "table: what you promised the player about how you play, in the words you said. "
|
|
43
43
|
+ 'coins, when the system gives none: each coin with its value in the smallest coin, other names after a slash, "rare" for one never given as change. '
|
|
44
44
|
+ "widgets: where the dashboard shows an extension's widget, such as value 'weather.today: side'; remove gives it back its place. "
|
|
45
|
+
+ "difficulty and rigor custom: each item at its own level, which custom-difficulty and custom-rigor take by item, such as value 'food: rules, load: smooth'; "
|
|
46
|
+
+ "custom starts from the level played until then, and remove gives an item the default. "
|
|
45
47
|
+ "fields, tables, computed, counters and recipes add to the game system what it lacks, or change it as a house rule: entries by name, written as in system.yaml, "
|
|
46
48
|
+ "each replacing the system's one of that name (a recipe adds to the system's); remove takes their names. status-line adds fields to the player character's line. "
|
|
47
49
|
+ "A formula with commas goes in quotes; a use's max reads what gives it, so that only who has it has it. "
|
|
@@ -89,7 +91,9 @@ export function setupQuestions(root, context, writtenWorld) {
|
|
|
89
91
|
const difficulty = settings.difficulty;
|
|
90
92
|
// The value a system's setting suggests (DAT-17).
|
|
91
93
|
const systemSuggests = Object.fromEntries(held.flatMap((setting) => setting.values.filter((value) => value.suggested === true).map((value) => [setting.name, value.value])));
|
|
92
|
-
|
|
94
|
+
// The player's last choices first: how they like to play, from their last campaign on this computer (T-134).
|
|
95
|
+
const last = lastChoices(context.home);
|
|
96
|
+
const suggested = { ...suggestedValues, ...(difficulty === undefined ? {} : { lethality: suggestedLethality[difficulty] ?? "dice" }), ...systemSuggests, ...last };
|
|
93
97
|
// The system's settings others depend on right after the mentor, before what they change (DAT-16, DAT-17).
|
|
94
98
|
const leading = held.filter(isLeading).map((setting) => setting.name);
|
|
95
99
|
const order = setupOrder.filter((name) => name !== "preparation" || !writtenWorld);
|
|
@@ -98,7 +102,9 @@ export function setupQuestions(root, context, writtenWorld) {
|
|
|
98
102
|
const suggestion = suggested[question.name];
|
|
99
103
|
// A suggestion the game does not offer is none (DAT-16).
|
|
100
104
|
const offered = suggestion !== undefined && (question.choices === undefined || question.choices.some((choice) => choice.value === suggestion));
|
|
101
|
-
|
|
105
|
+
const asked = { ...question, ...(question.choices === undefined ? {} : { choices: question.choices.filter((choice) => choice.value !== customLevel) }) };
|
|
106
|
+
const lastOne = offered && last[question.name] === suggestion ? { last: suggestion } : {};
|
|
107
|
+
return { ...(question.name === "mentor" ? mentorQuestion(asked) : unsetUnanswered(asked, settings)), ...(offered ? { suggested: suggestion } : {}), ...lastOne };
|
|
102
108
|
});
|
|
103
109
|
}
|
|
104
110
|
/** A setting only the setup lets the dashboard change (D-370): how companions come, the preparation, the name; undefined for any other. */
|
|
@@ -129,17 +135,22 @@ export function playerSettings(root, context) {
|
|
|
129
135
|
return { name: setting.name, about: setting.about ?? "a setting of the game system", ...(value === undefined ? {} : { value }), choices };
|
|
130
136
|
});
|
|
131
137
|
return [
|
|
132
|
-
...playerSettingNames.
|
|
138
|
+
...playerSettingNames.flatMap((name) => {
|
|
133
139
|
const words = playerWords[name];
|
|
134
|
-
const
|
|
140
|
+
const custom = customOf(name);
|
|
141
|
+
if (custom !== undefined) {
|
|
142
|
+
return customItems(root, context, custom, words);
|
|
143
|
+
}
|
|
144
|
+
const written = settings[name] ?? words.unset;
|
|
145
|
+
const value = name === "between-sessions" && typeof written === "string" ? shownBetweenSessions(written) : written;
|
|
135
146
|
const choices = words.values?.map((one) => ({ value: one, ...(words.means?.[one] === undefined ? {} : { means: words.means[one] }) }));
|
|
136
|
-
return {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
return [{
|
|
148
|
+
name,
|
|
149
|
+
about: words.about,
|
|
150
|
+
...(Array.isArray(value) ? { items: value.map(String) } : value === undefined || value === null ? {} : { value: String(value) }),
|
|
151
|
+
...(choices === undefined ? {} : { choices }),
|
|
152
|
+
...(words.most === undefined ? {} : { most: words.most }),
|
|
153
|
+
}];
|
|
143
154
|
}).flatMap((setting) => offeredSetting(root, context, setting)),
|
|
144
155
|
...own,
|
|
145
156
|
];
|
|
@@ -153,6 +164,9 @@ export function playerSettingNamed(root, context, name) {
|
|
|
153
164
|
* player's first change since their last call, a value with what it means to the master; nothing for one that came back as it was.
|
|
154
165
|
*/
|
|
155
166
|
export function playerChangeNews(root, context, before, after) {
|
|
167
|
+
if (before.entries !== undefined || after.entries !== undefined) {
|
|
168
|
+
return customNews(root, context, before, after);
|
|
169
|
+
}
|
|
156
170
|
if (before.items !== undefined || after.items !== undefined) {
|
|
157
171
|
const added = (after.items ?? []).filter((item) => !(before.items ?? []).includes(item));
|
|
158
172
|
const removed = (before.items ?? []).filter((item) => !(after.items ?? []).includes(item));
|
|
@@ -174,7 +188,9 @@ export function playerChangeNews(root, context, before, after) {
|
|
|
174
188
|
const cleared = wordsOf(after.name)?.cleared;
|
|
175
189
|
return cleared === undefined ? [] : [`The player took ${after.name} away on the dashboard: ${cleared}. Play by it from now on.`, ...(style === "" ? [] : [style])];
|
|
176
190
|
}
|
|
177
|
-
const meaning = settingMeaning(after.name, after.value, countedByGame(campaignSystem(root, context))
|
|
191
|
+
const meaning = settingMeaning(after.name, after.value, countedByGame(campaignSystem(root, context)), customWritten(root, after.name))
|
|
192
|
+
?? (after.name === "between-sessions" ? betweenSessionsMeaning(after.value) : undefined)
|
|
193
|
+
?? systemSetting(root, context, after.name)?.values.find((one) => one.value === after.value)?.means;
|
|
178
194
|
const value = after.most === undefined ? after.value : `"${after.value}"`;
|
|
179
195
|
const author = after.name === "prose" && readSettings(root).author !== undefined ? " An author is written: theirs takes its place until the player takes it away." : "";
|
|
180
196
|
// The mentor's new part comes with it, once in the chat (D-347); in play, a value of the system's with its own part (DAT-18).
|
|
@@ -248,8 +264,23 @@ function configure(input, context) {
|
|
|
248
264
|
const shown = input.setting === undefined ? settingNames : [checkSettingName(input.setting)];
|
|
249
265
|
const mapped = input.setting !== undefined && mapSettingNames.includes(checkSettingName(input.setting));
|
|
250
266
|
let replaced = [];
|
|
251
|
-
//
|
|
252
|
-
|
|
267
|
+
// A custom difficulty or rigor starts from the preset played until then, each item not yet written at its level (T-132).
|
|
268
|
+
const leveledName = input.setting === "difficulty" || input.setting === "rigor" ? input.setting : undefined;
|
|
269
|
+
const startsCustom = leveledName !== undefined && input.value?.trim().toLowerCase() === customLevel;
|
|
270
|
+
const preset = leveledName === undefined ? undefined : readSettings(root)[leveledName];
|
|
271
|
+
const custom = customOf(input.setting ?? "");
|
|
272
|
+
// The items of a custom difficulty or rigor, each at a level it takes (T-132).
|
|
273
|
+
if (custom !== undefined && (input.value !== undefined || input.remove !== undefined)) {
|
|
274
|
+
const name = customSettings[custom];
|
|
275
|
+
if (changeMapSetting(root, name, { set: input.value === undefined ? undefined : customEntries(custom, input.value), remove: input.remove })) {
|
|
276
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: name, value: input.value, remove: input.remove }));
|
|
277
|
+
}
|
|
278
|
+
// Kept for when it is chosen, but played only then.
|
|
279
|
+
if (playedEngineSetting(root, context, custom) !== customLevel) {
|
|
280
|
+
replaced = [...replaced, `${name} plays only while ${custom} is custom.`];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else if (input.setting?.trim() === "widgets" && (input.value !== undefined || input.remove !== undefined)) {
|
|
253
284
|
const set = input.value === undefined ? undefined : entriesOf("widgets", input.value);
|
|
254
285
|
checkWidgetSpots(root, context, set ?? {});
|
|
255
286
|
if (changeMapSetting(root, "widgets", { set, remove: input.remove })) {
|
|
@@ -281,6 +312,18 @@ function configure(input, context) {
|
|
|
281
312
|
}
|
|
282
313
|
else if (input.setting !== undefined && input.value !== undefined && changeSetting(root, input.setting, settingValue(root, input.setting, input.value, context))) {
|
|
283
314
|
appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: input.setting, value: input.value }));
|
|
315
|
+
// What the next campaign's setup suggests; a custom difficulty or rigor is this campaign's own (T-134).
|
|
316
|
+
const chosen = readSettings(root)[input.setting];
|
|
317
|
+
if (chosen !== customLevel) {
|
|
318
|
+
rememberChoice(context.home, input.setting, chosen);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (startsCustom && leveledName !== undefined && readSettings(root)[leveledName] === customLevel) {
|
|
322
|
+
const written = readSettings(root)[customSettings[leveledName]] ?? {};
|
|
323
|
+
const unwritten = Object.entries(startingLevels(leveledName, preset)).filter(([item]) => !Object.hasOwn(written, item));
|
|
324
|
+
if (unwritten.length > 0) {
|
|
325
|
+
changeMapSetting(root, customSettings[leveledName], { set: Object.fromEntries(unwritten) });
|
|
326
|
+
}
|
|
284
327
|
}
|
|
285
328
|
// The effort written where each app reads it in the campaign's folder (D-462).
|
|
286
329
|
if (input.setting?.trim() === "effort" && input.value !== undefined) {
|
|
@@ -305,7 +348,7 @@ function configure(input, context) {
|
|
|
305
348
|
const settings = readSettings(root);
|
|
306
349
|
// Listed all together, what the campaign adds to its system only when it adds something.
|
|
307
350
|
const added = (name) => campaignDataNames.includes(name);
|
|
308
|
-
const listed = input.setting === undefined ? shown.filter((name) => !(added(name) || name === "calendar" || name === "widgets") || settings[name] !== undefined) : shown;
|
|
351
|
+
const listed = input.setting === undefined ? shown.filter((name) => !(added(name) || name === "calendar" || name === "widgets" || customOf(name) !== undefined) || settings[name] !== undefined) : shown;
|
|
309
352
|
const system = input.setting === undefined ? heldSystemSettings(root, context) : [];
|
|
310
353
|
// The master's own change of the mentor brings its part, once in the chat; the player's comes with the news of the dashboard (D-347).
|
|
311
354
|
const changed = input.value !== undefined && context.actor !== "player" ? input.setting?.trim() : undefined;
|
|
@@ -329,12 +372,17 @@ function configure(input, context) {
|
|
|
329
372
|
// The settings of free words the player may leave unset again, with the value none, and all those of how the master writes (D-395).
|
|
330
373
|
const freeSettingNames = ["author", "style", "calendar"];
|
|
331
374
|
const styleSettingNames = ["prose", "story", "author", "style"];
|
|
375
|
+
// The game time between sessions the dashboard offers (D-133): stopped, a day of the game for each real week, or as real time.
|
|
376
|
+
const betweenSessionsWays = ["stops", "1d per 7d", "1d per 1d"];
|
|
332
377
|
/** The settings the player changes on the dashboard (D-341): how the game plays for them; the master's own, as house rules, coins and precedents, stay in the chat. */
|
|
333
378
|
export const playerSettingNames = [
|
|
334
379
|
"difficulty",
|
|
380
|
+
"custom-difficulty",
|
|
335
381
|
"lethality",
|
|
336
382
|
"saves",
|
|
337
383
|
"rigor",
|
|
384
|
+
"custom-rigor",
|
|
385
|
+
"between-sessions",
|
|
338
386
|
"mentor",
|
|
339
387
|
"learned",
|
|
340
388
|
"prose",
|
|
@@ -355,15 +403,17 @@ export const playerSettingNames = [
|
|
|
355
403
|
const playerWords = {
|
|
356
404
|
difficulty: {
|
|
357
405
|
about: "how hard the world plays",
|
|
358
|
-
values: difficulties,
|
|
406
|
+
values: [...difficulties, customLevel],
|
|
359
407
|
means: {
|
|
360
408
|
story: "fights low, foes naive, clues obvious, resources plentiful",
|
|
361
409
|
easy: "fights low to moderate, simple foes, resources generous",
|
|
362
410
|
normal: "fights moderate to high, sensible foes, resources standard",
|
|
363
411
|
hard: "fights high, smart and tenacious foes, resources scarce",
|
|
364
412
|
brutal: "fights far beyond, optimized and fanatical foes, resources very scarce",
|
|
413
|
+
custom: "each part at its own level, chosen below",
|
|
365
414
|
},
|
|
366
415
|
},
|
|
416
|
+
"custom-difficulty": { about: "how hard each part of the world plays", values: difficulties },
|
|
367
417
|
lethality: { about: "what a fall means", values: lethalities, means: { narrative: "your character never dies", epic: "your character dies only when it matters", dice: "the dice decide" } },
|
|
368
418
|
saves: {
|
|
369
419
|
about: "when the game may go back",
|
|
@@ -372,12 +422,25 @@ const playerWords = {
|
|
|
372
422
|
},
|
|
373
423
|
rigor: {
|
|
374
424
|
about: "how closely food, light, fatigue and the like follow the rules",
|
|
375
|
-
values: rigors,
|
|
425
|
+
values: [...rigors, customLevel],
|
|
376
426
|
means: {
|
|
377
427
|
smooth: "only when the story turns on them",
|
|
378
428
|
rules: "as written: food and water each day, light as it burns, fatigue and encumbrance",
|
|
379
429
|
simulation: "as written, and beyond: wear, spoilage, weather",
|
|
430
|
+
custom: "each part at its own level, chosen below",
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
"custom-rigor": { about: "how closely each part follows the rules", values: rigors },
|
|
434
|
+
// The few rates the dashboard offers (D-133); one written in the chat or by hand shows as it is, beside them.
|
|
435
|
+
"between-sessions": {
|
|
436
|
+
about: "whether the story's time runs while you are away, from one session to the next",
|
|
437
|
+
values: betweenSessionsWays,
|
|
438
|
+
means: {
|
|
439
|
+
stops: "the world waits for you: the story picks up at the moment you left it",
|
|
440
|
+
"1d per 7d": "a day of the story for each week you are away: when you come back, at your first move the master lets it pass and tells what the world did meanwhile",
|
|
441
|
+
"1d per 1d": "a day of the story for each day you are away: when you come back, at your first move the master lets it pass and tells what the world did meanwhile",
|
|
380
442
|
},
|
|
443
|
+
unset: "stops",
|
|
381
444
|
},
|
|
382
445
|
mentor: {
|
|
383
446
|
about: "how much the master teaches the game, out of the story",
|
|
@@ -590,7 +653,7 @@ function systemShownValue(root, context, setting) {
|
|
|
590
653
|
}
|
|
591
654
|
/** A setting as config shows it: a list or entries by name, none when missing; the coins and the system as they read (MON-7, D-173); difficulty and rigor with what they mean (D-263). */
|
|
592
655
|
function shownValue(root, context, settings, name) {
|
|
593
|
-
const meaning = settingMeaning(name, settings[name], countedByGame(campaignSystem(root, context)));
|
|
656
|
+
const meaning = settingMeaning(name, settings[name], countedByGame(campaignSystem(root, context)), customWritten(root, name));
|
|
594
657
|
if (meaning !== undefined) {
|
|
595
658
|
return `${String(settings[name])}: ${meaning}`;
|
|
596
659
|
}
|
|
@@ -606,7 +669,7 @@ function shownValue(root, context, settings, name) {
|
|
|
606
669
|
return settings[name] ?? {};
|
|
607
670
|
}
|
|
608
671
|
// How the master writes, unset: the core's own ways, never missing (D-395).
|
|
609
|
-
// And the master's effort, unset: each app's own, the player's to choose (D-462); who voices the characters, unset: auto (D-490); the master's rolls, behind the screen (D-287).
|
|
672
|
+
// And the master's effort, unset: each app's own, the player's to choose (D-462); who voices the characters, unset: auto (D-490); the master's rolls, behind the screen (D-287); the game time between sessions, stopped (D-133).
|
|
610
673
|
const own = {
|
|
611
674
|
prose: "plain (as your instructions write)",
|
|
612
675
|
story: "situations (as your instructions write)",
|
|
@@ -615,6 +678,7 @@ function shownValue(root, context, settings, name) {
|
|
|
615
678
|
effort: "(the app's own: the player's to choose)",
|
|
616
679
|
voices: "auto (a subagent at key moments, as you choose, where the app has them)",
|
|
617
680
|
"master-rolls": "behind the screen (unset: roll hides your rolls for foes and NPCs)",
|
|
681
|
+
"between-sessions": "stops (unset: no game time passes between sessions)",
|
|
618
682
|
};
|
|
619
683
|
if (settings[name] === undefined && Object.hasOwn(own, name)) {
|
|
620
684
|
return own[name];
|
|
@@ -635,6 +699,13 @@ function settingValue(root, setting, value, context) {
|
|
|
635
699
|
if (setting === "calendar-start") {
|
|
636
700
|
return calendarStartValue(root, context, value);
|
|
637
701
|
}
|
|
702
|
+
// The game time between sessions (D-133): it stops, or runs at a rate of game time to real time.
|
|
703
|
+
if (setting === "between-sessions") {
|
|
704
|
+
if (readBetweenSessions(value) === undefined) {
|
|
705
|
+
throw new Error(`"${value}" is no between-sessions: give stops, or the game time that passes for a real time, such as 1d per 7d. Nothing changed.`);
|
|
706
|
+
}
|
|
707
|
+
return value.trim().replace(/\s+/g, " ");
|
|
708
|
+
}
|
|
638
709
|
return setting === "coins" ? newCoins(root, value, context) : setting === "system" ? installedSystemName(value, context, "config") : value;
|
|
639
710
|
}
|
|
640
711
|
/**
|
|
@@ -767,6 +838,79 @@ function checkAdditions(root, context, setting, change) {
|
|
|
767
838
|
throw new Error(`With this, the system ${system} would not read: ${problem} Nothing changed.`);
|
|
768
839
|
}
|
|
769
840
|
}
|
|
841
|
+
/** The game time between sessions as the dashboard shows it (D-133): by the words of a way it offers that plays the same, as STOPS or 2d per 14d; any other as written. */
|
|
842
|
+
function shownBetweenSessions(written) {
|
|
843
|
+
const read = readBetweenSessions(written);
|
|
844
|
+
const same = (way) => {
|
|
845
|
+
const offered = readBetweenSessions(way);
|
|
846
|
+
return read === "stops" || offered === "stops" ? read === offered : read !== undefined && offered !== undefined && read.game * offered.real === offered.game * read.real;
|
|
847
|
+
};
|
|
848
|
+
return betweenSessionsWays.find(same) ?? written;
|
|
849
|
+
}
|
|
850
|
+
/** What the game time between sessions means to the master (D-133): stopped, or a rate with what status asks of them after a pause; undefined for what does not read. */
|
|
851
|
+
function betweenSessionsMeaning(value) {
|
|
852
|
+
const read = readBetweenSessions(value);
|
|
853
|
+
if (read === "stops") {
|
|
854
|
+
return "no game time passes between sessions: the next one opens at the moment this one ends";
|
|
855
|
+
}
|
|
856
|
+
return read === undefined
|
|
857
|
+
? undefined
|
|
858
|
+
: `the game time runs ${formatDuration(read.game)} for each ${formatDuration(read.real)} of real time between sessions: after a pause, status says how much to let pass with advance `
|
|
859
|
+
+ "before you open the new session, and the opening tells what the world did meanwhile";
|
|
860
|
+
}
|
|
861
|
+
/** The difficulty or rigor whose items a setting holds: difficulty for custom-difficulty; undefined for any other (T-132). */
|
|
862
|
+
function customOf(name) {
|
|
863
|
+
return name.trim() === customSettings.difficulty ? "difficulty" : name.trim() === customSettings.rigor ? "rigor" : undefined;
|
|
864
|
+
}
|
|
865
|
+
/** The items of a custom difficulty or rigor as campaign.yaml writes them, for its meaning; undefined for another setting. */
|
|
866
|
+
function customWritten(root, name) {
|
|
867
|
+
return name === "difficulty" || name === "rigor" ? readOneSetting(root, customSettings[name]) : undefined;
|
|
868
|
+
}
|
|
869
|
+
/** The items of a custom difficulty or rigor as config takes them, food: rules, each checked and named as the engine names it (T-132). */
|
|
870
|
+
function customEntries(setting, text) {
|
|
871
|
+
const { items, levels } = leveled[setting];
|
|
872
|
+
// food: rules, load: smooth as the master says it, and as YAML writes it, {food: rules, load: smooth}.
|
|
873
|
+
const written = text.trim().startsWith("{") ? text : `{${text}}`;
|
|
874
|
+
const entries = Object.entries(entriesOf(customSettings[setting], written)).map(([item, level]) => {
|
|
875
|
+
const known = items.find((one) => comparableText(one) === comparableText(item));
|
|
876
|
+
const at = levels.find((one) => typeof level === "string" && comparableText(one) === comparableText(level));
|
|
877
|
+
if (known === undefined) {
|
|
878
|
+
throw new Error(`${item} is no item of the custom ${setting}: they are ${items.join(", ")}. Nothing changed.`);
|
|
879
|
+
}
|
|
880
|
+
if (at === undefined) {
|
|
881
|
+
throw new Error(level === null
|
|
882
|
+
? `${known} needs its level, ${levels.join(", ")}: write it as ${known}: ${levels[1]}. Nothing changed.`
|
|
883
|
+
: `${known} takes ${levels.join(", ")}, not ${String(level)}. Nothing changed.`);
|
|
884
|
+
}
|
|
885
|
+
return [known, at];
|
|
886
|
+
});
|
|
887
|
+
return Object.fromEntries(entries);
|
|
888
|
+
}
|
|
889
|
+
/** The items of a custom difficulty or rigor as the dashboard shows them, each with its level, only while the campaign plays it custom (T-132). */
|
|
890
|
+
function customItems(root, context, setting, words) {
|
|
891
|
+
if (playedEngineSetting(root, context, setting) !== customLevel) {
|
|
892
|
+
return [];
|
|
893
|
+
}
|
|
894
|
+
const levels = customLevels(setting, readOneSetting(root, customSettings[setting]));
|
|
895
|
+
return [{
|
|
896
|
+
name: customSettings[setting],
|
|
897
|
+
about: words.about,
|
|
898
|
+
entries: Object.entries(levels).map(([name, value]) => ({ name, value })),
|
|
899
|
+
choices: (words.values ?? []).map((value) => ({ value })),
|
|
900
|
+
}];
|
|
901
|
+
}
|
|
902
|
+
/** What the master hears of the items of a custom difficulty or rigor the player changed on the dashboard: those changed, then the whole as it plays now. */
|
|
903
|
+
function customNews(root, context, before, after) {
|
|
904
|
+
const setting = customOf(after.name);
|
|
905
|
+
const changed = (after.entries ?? []).filter((entry) => before.entries?.find((one) => one.name === entry.name)?.value !== entry.value);
|
|
906
|
+
if (setting === undefined || changed.length === 0) {
|
|
907
|
+
return [];
|
|
908
|
+
}
|
|
909
|
+
// Each item changed with what it means now: the whole custom one is in status, and comes with the news when the player chose it.
|
|
910
|
+
const counted = countedByGame(campaignSystem(root, context));
|
|
911
|
+
const set = changed.map((entry) => `${entry.name} to ${entry.value} (${itemMeaning(setting, entry.name, entry.value, counted) ?? entry.value})`).join("; ");
|
|
912
|
+
return [`The player set in the custom ${setting} on the dashboard ${set}. Play by it from now on.`];
|
|
913
|
+
}
|
|
770
914
|
/** What a setting of the player's is to them and to the master, by its name; undefined for one of the game system. */
|
|
771
915
|
function wordsOf(name) {
|
|
772
916
|
return Object.hasOwn(playerWords, name) ? playerWords[name] : undefined;
|
package/dist/commands/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { advance } from "./advance.js";
|
|
2
2
|
import { ask } from "./ask.js";
|
|
3
3
|
import { change } from "./change/change.js";
|
|
4
|
+
import { choices } from "./choices.js";
|
|
4
5
|
import { config } from "./config.js";
|
|
5
6
|
import { effect } from "./effect.js";
|
|
6
7
|
import { find } from "./find.js";
|
|
@@ -50,6 +51,7 @@ export const commands = [
|
|
|
50
51
|
rules,
|
|
51
52
|
roll,
|
|
52
53
|
ask,
|
|
54
|
+
choices,
|
|
53
55
|
change,
|
|
54
56
|
effect,
|
|
55
57
|
mood,
|
package/dist/commands/init.d.ts
CHANGED
package/dist/commands/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename, resolve } from "node:path";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { createCampaign, difficulties, lethalities } from "../campaign/index.js";
|
|
3
|
+
import { createCampaign, difficulties, lethalities, rememberChoice } from "../campaign/index.js";
|
|
4
4
|
import { appendLogEntry, newLogEntry } from "../core/log.js";
|
|
5
5
|
import { defineCommand } from "../core/registry.js";
|
|
6
6
|
import { hostInstructions } from "../instructions/index.js";
|
|
@@ -11,7 +11,7 @@ export const init = defineCommand({
|
|
|
11
11
|
name: "init",
|
|
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
|
-
+ "Use it once, when the player starts a new campaign
|
|
14
|
+
+ "Use it once, when the player starts a new campaign, with master true when you, the AI, create it: the answer then says what is still to agree with the player, to set with config. "
|
|
15
15
|
+ 'Example: name "The Salt Isles", language en.',
|
|
16
16
|
group: "campaign",
|
|
17
17
|
positionals: ["folder"],
|
|
@@ -22,6 +22,7 @@ export const init = defineCommand({
|
|
|
22
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
|
+
master: z.boolean().optional().describe("true when you, the AI, create the campaign: the answer adds what is still to agree with the player"),
|
|
25
26
|
}),
|
|
26
27
|
run(input, context) {
|
|
27
28
|
const folder = resolve(context.folder, input.folder ?? ".");
|
|
@@ -31,9 +32,12 @@ export const init = defineCommand({
|
|
|
31
32
|
const root = createCampaign(folder, settings, context.platform, hostInstructions());
|
|
32
33
|
createWorld(root);
|
|
33
34
|
appendLogEntry(root, newLogEntry(context, "campaign-created", "public", settings));
|
|
34
|
-
|
|
35
|
+
// What the next campaign's setup suggests (T-134).
|
|
36
|
+
rememberChoice(context.home, "difficulty", settings.difficulty);
|
|
37
|
+
rememberChoice(context.home, "lethality", settings.lethality);
|
|
38
|
+
return { root, name: settings.name, note: input.master === true ? campaignNote(root, context) : "" };
|
|
35
39
|
},
|
|
36
|
-
// The player reads it
|
|
40
|
+
// The player reads it, who made the campaign in a terminal: what to do next. What the master still agrees with them only when the master made it (T-185).
|
|
37
41
|
format(result) {
|
|
38
42
|
return [
|
|
39
43
|
`Created the campaign "${result.name}" in ${result.root}.`,
|
package/dist/commands/rename.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { parseDocument } from "yaml";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { requireCampaign } from "../campaign/index.js";
|
|
4
|
+
import { readChoices, requireCampaign, writeChoices } from "../campaign/index.js";
|
|
5
5
|
import { appendLogEntry } from "../core/log.js";
|
|
6
6
|
import { defineCommand } from "../core/registry.js";
|
|
7
7
|
import { files } from "../core/store.js";
|
|
@@ -76,8 +76,8 @@ function pageAtPath(world, given) {
|
|
|
76
76
|
return page;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* The present follows the new name: its links, and the open scene's names, as its order, its turn and who is hostile (D-415,
|
|
80
|
-
* nothing, when the links renamed would leave state.yaml unreadable.
|
|
79
|
+
* The present follows the new name: its links, whose the choices waiting are, and the open scene's names, as its order, its turn and who is hostile (D-415,
|
|
80
|
+
* D-416). Refused, changing nothing, when the links renamed would leave state.yaml unreadable.
|
|
81
81
|
*/
|
|
82
82
|
function renameInState(root, from, to) {
|
|
83
83
|
const path = join(root, "state.yaml");
|
|
@@ -89,6 +89,11 @@ function renameInState(root, from, to) {
|
|
|
89
89
|
if (count > 0) {
|
|
90
90
|
files().write(path, renamed);
|
|
91
91
|
}
|
|
92
|
+
// Whose the choices on the dashboard are (D-556).
|
|
93
|
+
const sets = readChoices(root);
|
|
94
|
+
if (sets.some((set) => comparableText(set.who) === comparableText(from))) {
|
|
95
|
+
writeChoices(root, sets.map((set) => (comparableText(set.who) === comparableText(from) ? { ...set, who: to } : set)));
|
|
96
|
+
}
|
|
92
97
|
const { scene } = readOpenScene(root);
|
|
93
98
|
if (scene === undefined) {
|
|
94
99
|
return;
|
package/dist/commands/save.d.ts
CHANGED
|
@@ -28,8 +28,8 @@ export type SaveResult = {
|
|
|
28
28
|
};
|
|
29
29
|
export declare const save: import("../core/registry.ts").Command<z.ZodObject<{
|
|
30
30
|
action: z.ZodDefault<z.ZodEnum<{
|
|
31
|
-
list: "list";
|
|
32
31
|
load: "load";
|
|
32
|
+
list: "list";
|
|
33
33
|
make: "make";
|
|
34
34
|
reset: "reset";
|
|
35
35
|
"new chat": "new chat";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Context } from "../../core/context.ts";
|
|
1
2
|
import type { Problem } from "../../core/problem.ts";
|
|
2
3
|
import { type World } from "../../pages/index.ts";
|
|
3
4
|
/**
|
|
@@ -42,12 +43,18 @@ export declare function experienceText(experience: Experience): string | undefin
|
|
|
42
43
|
* "Ennio has the xp for level 3: level up with the player, …": said while the points reach a level the classes have not (PRO-6); a companion's choices are the
|
|
43
44
|
* master's (D-205, D-209). Undefined when they reach none.
|
|
44
45
|
*/
|
|
45
|
-
export declare function levelDueNote(name: string, experience: Experience | undefined, companion: boolean): string | undefined;
|
|
46
|
+
export declare function levelDueNote(name: string, experience: Experience | undefined, companion: boolean, way?: LevelWay): string | undefined;
|
|
47
|
+
/** How a player character levels up now (D-556): with choices on the dashboard, waiting for a set of choices already prepared, or in the chat (undefined). */
|
|
48
|
+
export type LevelWay = "choices" | "waiting" | undefined;
|
|
49
|
+
/** How `name` levels up now: waiting while a set of choices of theirs waits on the dashboard, with choices where the player has one, else in the chat. */
|
|
50
|
+
export declare function levelWay(root: string, context: Context, name: string): LevelWay;
|
|
46
51
|
/**
|
|
47
52
|
* The note of a change that brings the points to a new level, with what `levelUp` gives of the part on what a level gives, empty once told (PRO-6, D-97): none when
|
|
48
53
|
* that level was already due, and then the part is not asked for.
|
|
49
54
|
*/
|
|
50
|
-
export declare function newLevelNotes(name: string, before: Experience | undefined, after: Experience | undefined, companion: boolean, levelUp: () => string): string[];
|
|
55
|
+
export declare function newLevelNotes(name: string, before: Experience | undefined, after: Experience | undefined, companion: boolean, levelUp: () => string, way?: LevelWay): string[];
|
|
56
|
+
/** Once a character's level rises, the master wrote it: its choices on the dashboard, confirmed or left, leave state.yaml (D-556). */
|
|
57
|
+
export declare function settleChoices(root: string, name: string, before: Experience | undefined, after: Experience | undefined): void;
|
|
51
58
|
/** "Ennio is level 5: a character of that level has at least 6500 xp": said when a write leaves the points below what the level needs (PRO-6). */
|
|
52
59
|
export declare function leastNotes(name: string, before: Experience | undefined, after: Experience | undefined): string[];
|
|
53
60
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The experience points of a character (D-205, D-233, PRO-6): how many it lacks for the next level, the least its level needs, and the level they reach that its
|
|
2
2
|
// classes have not.
|
|
3
|
+
import { readChoices, writeChoices } from "../../campaign/index.js";
|
|
3
4
|
import { listItems, numberOf } from "../../core/formula.js";
|
|
4
5
|
import { comparableText, valueNamed } from "../../core/text.js";
|
|
5
6
|
import { readCounter } from "../../counters/index.js";
|
|
@@ -57,27 +58,61 @@ export function experienceText(experience) {
|
|
|
57
58
|
* "Ennio has the xp for level 3: level up with the player, …": said while the points reach a level the classes have not (PRO-6); a companion's choices are the
|
|
58
59
|
* master's (D-205, D-209). Undefined when they reach none.
|
|
59
60
|
*/
|
|
60
|
-
export function levelDueNote(name, experience, companion) {
|
|
61
|
-
if (experience?.due === undefined) {
|
|
61
|
+
export function levelDueNote(name, experience, companion, way) {
|
|
62
|
+
if (experience?.due === undefined || way === "waiting") {
|
|
62
63
|
return undefined;
|
|
63
64
|
}
|
|
65
|
+
// One level at a time, the next: its choices come before those of the level after (D-556).
|
|
66
|
+
const next = experience.level + 1;
|
|
67
|
+
const beyond = experience.due > next ? `, then up to level ${experience.due}, one level at a time` : "";
|
|
64
68
|
const rules = experience.rules === undefined ? "" : `: read rules "${experience.rules}"`;
|
|
69
|
+
if (way === "choices" && !companion) {
|
|
70
|
+
const prepare = "prepare with choices, in one call, all that level asks the player to choose, before you write to the player: they choose on the dashboard when they like, "
|
|
71
|
+
+ "so never wait for a rest or a quiet moment; then go on with the story";
|
|
72
|
+
return `${name} has the ${experience.field} for level ${next}${beyond}${rules === "" ? `: ${prepare}` : `${rules}, then ${prepare}`}.`;
|
|
73
|
+
}
|
|
65
74
|
const how = companion
|
|
66
75
|
? "level up the companion: what the new level asks is yours to choose, as the story has shaped the companion, or the player's if they made it"
|
|
67
76
|
: "level up with the player, out of the story, now or at the next rest as they prefer; they choose what the new level asks";
|
|
68
|
-
return `${name} has the ${experience.field} for level ${
|
|
77
|
+
return `${name} has the ${experience.field} for level ${next}${beyond}: ${how}${rules}.`;
|
|
78
|
+
}
|
|
79
|
+
/** How `name` levels up now: waiting while a set of choices of theirs waits on the dashboard, with choices where the player has one, else in the chat. */
|
|
80
|
+
export function levelWay(root, context, name) {
|
|
81
|
+
if (readChoices(root).some((set) => comparableText(set.who) === comparableText(name))) {
|
|
82
|
+
return "waiting";
|
|
83
|
+
}
|
|
84
|
+
return context.dashboard === undefined ? undefined : "choices";
|
|
69
85
|
}
|
|
70
86
|
/**
|
|
71
87
|
* The note of a change that brings the points to a new level, with what `levelUp` gives of the part on what a level gives, empty once told (PRO-6, D-97): none when
|
|
72
88
|
* that level was already due, and then the part is not asked for.
|
|
73
89
|
*/
|
|
74
|
-
export function newLevelNotes(name, before, after, companion, levelUp) {
|
|
75
|
-
const note = levelDueNote(name, after, companion);
|
|
76
|
-
|
|
90
|
+
export function newLevelNotes(name, before, after, companion, levelUp, way) {
|
|
91
|
+
const note = levelDueNote(name, after, companion, way);
|
|
92
|
+
// Said when the points reach a level not due before, or when a level written leaves one more due (D-556).
|
|
93
|
+
const risen = before !== undefined && after !== undefined && after.level > before.level;
|
|
94
|
+
if (note === undefined || (before?.due !== undefined && before.due >= (after?.due ?? 0) && !risen)) {
|
|
77
95
|
return [];
|
|
78
96
|
}
|
|
79
97
|
const part = levelUp();
|
|
80
|
-
|
|
98
|
+
// With choices to prepare, the note comes last, after the part it reads: what the master does next (D-556).
|
|
99
|
+
return [
|
|
100
|
+
part === "" ? note : way === "choices" && !companion
|
|
101
|
+
? `${part}
|
|
102
|
+
${note}`
|
|
103
|
+
: `${note} ${part}`,
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
/** Once a character's level rises, the master wrote it: its choices on the dashboard, confirmed or left, leave state.yaml (D-556). */
|
|
107
|
+
export function settleChoices(root, name, before, after) {
|
|
108
|
+
if (before === undefined || after === undefined || after.level <= before.level) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const sets = readChoices(root);
|
|
112
|
+
const kept = sets.filter((set) => comparableText(set.who) !== comparableText(name));
|
|
113
|
+
if (kept.length < sets.length) {
|
|
114
|
+
writeChoices(root, kept);
|
|
115
|
+
}
|
|
81
116
|
}
|
|
82
117
|
/** "Ennio is level 5: a character of that level has at least 6500 xp": said when a write leaves the points below what the level needs (PRO-6). */
|
|
83
118
|
export function leastNotes(name, before, after) {
|
|
@@ -18,6 +18,8 @@ export declare function playerCharacter(world: World): Page | undefined;
|
|
|
18
18
|
* foreground as whose it is. Undefined before there is one.
|
|
19
19
|
*/
|
|
20
20
|
export declare function playerKnowledge(root: string, world: World, wanted?: string): Knowledge | undefined;
|
|
21
|
+
/** The knowledge with these pages known too, by each player character. */
|
|
22
|
+
export declare function withPagesKnown(knowledge: Knowledge, pages: Page[]): Knowledge;
|
|
21
23
|
/** Who of the player characters knows a page, when more than one is played and only some of them do (VIEW-12); undefined otherwise. */
|
|
22
24
|
export declare function pageKnownBy(knowledge: Knowledge, page: Page): string[] | undefined;
|
|
23
25
|
/** Who of the player characters discovered a secret, by the page that writes it and its name, when more than one is played and only some of them did (VIEW-12). */
|
|
@@ -29,6 +29,11 @@ export function playerKnowledge(root, world, wanted) {
|
|
|
29
29
|
const each = players.map((player) => knowledgeOf(root, world, player, read, living && player.fields.status === "dead"));
|
|
30
30
|
return { pc, pages: new Set(each.flatMap((one) => [...one.pages])), secrets: new Set(each.flatMap((one) => [...one.secrets])), each };
|
|
31
31
|
}
|
|
32
|
+
/** The knowledge with these pages known too, by each player character. */
|
|
33
|
+
export function withPagesKnown(knowledge, pages) {
|
|
34
|
+
const add = (one) => ({ ...one, pages: new Set([...one.pages, ...pages]) });
|
|
35
|
+
return pages.length === 0 ? knowledge : { ...add(knowledge), ...(knowledge.each === undefined ? {} : { each: knowledge.each.map(add) }) };
|
|
36
|
+
}
|
|
32
37
|
/** Who of the player characters knows a page, when more than one is played and only some of them do (VIEW-12); undefined otherwise. */
|
|
33
38
|
export function pageKnownBy(knowledge, page) {
|
|
34
39
|
return knownApart(knowledge, (one) => knowsPage(one, page));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// The mode of the campaign, the main state of the game (D-77): setup, session zero or play, each opened by the checklist of the one before (D-221, D-241; MOD-1–MOD-7).
|
|
2
2
|
import { basename } from "node:path";
|
|
3
|
-
import { companionWays, diceWays, difficulties, lethalities, masterRollWays, missingSettings, preparations, readSettings, readStateValues, rigors, saveModes, unansweredSettings, unitSystems, } from "../../campaign/index.js";
|
|
3
|
+
import { companionWays, diceWays, difficulties, lastChoices, lethalities, masterRollWays, missingSettings, preparations, readSettings, readStateValues, rigors, saveModes, unansweredSettings, unitSystems, } from "../../campaign/index.js";
|
|
4
4
|
import { readLog } from "../../core/log.js";
|
|
5
5
|
import { comparableText } from "../../core/text.js";
|
|
6
6
|
import { isInParty, playerCharacters } from "../../pages/index.js";
|
|
7
7
|
import { missingSettingsNote } from "./notes.js";
|
|
8
|
-
import { missingWithSystems, offeredLabel } from "./offers.js";
|
|
8
|
+
import { missingWithSystems, offeredLabel, offeredValues } from "./offers.js";
|
|
9
9
|
import { partText } from "./parts.js";
|
|
10
10
|
import { missingSheetFields } from "./sheet.js";
|
|
11
11
|
import { campaignSystem, campaignWorld } from "./world.js";
|
|
@@ -128,7 +128,14 @@ function writtenMode(root) {
|
|
|
128
128
|
function setupMissing(root, context, world, brief) {
|
|
129
129
|
const unanswered = unansweredSettings(readSettings(root), world.pages.length > 0);
|
|
130
130
|
const label = (name) => (brief ? valueLabels[name] : undefined) ?? settingLabels[name];
|
|
131
|
-
|
|
131
|
+
// The player's choice in their last campaign, which the setup offers first (T-134), when the game offers it.
|
|
132
|
+
const last = lastChoices(context.home);
|
|
133
|
+
const withLast = (name, text) => {
|
|
134
|
+
const value = last[name];
|
|
135
|
+
const offered = offeredValues(root, context, name);
|
|
136
|
+
return value === undefined || (offered !== undefined && !offered.includes(value)) ? text : `${text}, in their last campaign ${value}: offer it first`;
|
|
137
|
+
};
|
|
138
|
+
return missingWithSystems(root, unanswered, context).map((name) => withLast(name, offeredLabel(root, context, name) ?? label(name) ?? name));
|
|
132
139
|
}
|
|
133
140
|
/** What session zero still has to make (MOD-4): a living player character, the companions the setup said are made in it, and the sheets they keep, whole. */
|
|
134
141
|
function sessionZeroMissing(root, context, world) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SettingName } from "../../campaign/index.ts";
|
|
1
|
+
import { type rigorItems, type SettingName } from "../../campaign/index.ts";
|
|
2
2
|
import type { Context } from "../../core/context.ts";
|
|
3
3
|
import { type SystemSetting } from "../../systems/index.ts";
|
|
4
4
|
/** The settings of the system that hold in the campaign, in the system's order (DAT-17): those no value asks, and those a value it plays asks. */
|
|
@@ -7,6 +7,8 @@ export declare function heldSystemSettings(root: string, context: Context): Syst
|
|
|
7
7
|
export declare function offeredValues(root: string, context: Context, name: string): string[] | undefined;
|
|
8
8
|
/** An engine's setting as the campaign plays it (DAT-16): the one value the game offers, else the written one when the game offers it; undefined while it is to be asked. */
|
|
9
9
|
export declare function playedEngineSetting(root: string, context: Context, name: string): unknown;
|
|
10
|
+
/** The level the campaign plays an item of the rigor at (DAT-16, T-132): the rigor played, or the item's own when it is custom; undefined while it is to be asked. */
|
|
11
|
+
export declare function playedRigor(root: string, context: Context, item: (typeof rigorItems)[number]): string | undefined;
|
|
10
12
|
/** Whether the game plays an engine's setting with one value alone (DAT-16): no choice, never asked nor shown to the player. */
|
|
11
13
|
export declare function isFixedSetting(root: string, context: Context, name: string): boolean;
|
|
12
14
|
/**
|