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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** How many options of an item the player picks: from `least` to `most`. */
|
|
2
|
+
export interface PickRange {
|
|
3
|
+
least: number;
|
|
4
|
+
most: number;
|
|
5
|
+
}
|
|
6
|
+
/** One choice of a set: its question, its options as the master wrote them, how many to pick, the player's answer so far, and the roll an option made. */
|
|
7
|
+
export interface ChoiceItem {
|
|
8
|
+
question: string;
|
|
9
|
+
options: string[];
|
|
10
|
+
pick: PickRange;
|
|
11
|
+
answer?: string[];
|
|
12
|
+
rolled?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A set of choices for one character, such as a new level: its title, when it was made, its items, and the day the player confirmed it. */
|
|
15
|
+
export interface ChoiceSet {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
who: string;
|
|
19
|
+
made: string;
|
|
20
|
+
items: ChoiceItem[];
|
|
21
|
+
confirmed?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The choices waiting in state.yaml, in the order they were made; none when there are none, or when they do not read. */
|
|
24
|
+
export declare function readChoices(root: string): ChoiceSet[];
|
|
25
|
+
/** Writes the choices waiting, in place of those in state.yaml; none takes the key away. */
|
|
26
|
+
export declare function writeChoices(root: string, sets: ChoiceSet[]): void;
|
|
27
|
+
/** "2" as 2 to 2, "0-2" as 0 to 2; undefined for anything else. One alone, as a choice is, when nothing is given. */
|
|
28
|
+
export declare function readPick(value: number | string | undefined): PickRange | undefined;
|
|
29
|
+
/** How a pick is written: 2, or 0-2. */
|
|
30
|
+
export declare function pickText(pick: PickRange): string;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// The choices waiting for the player (D-556): what the master prepares for the player to choose on the dashboard when they like, as a new level, kept in
|
|
2
|
+
// state.yaml with the present of the game, so that a save brings them back; the player's answers stay there until the master hears them.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { changeStateAt, readStateValues } from "./state.js";
|
|
5
|
+
const pickPattern = /^\s*(\d+)\s*(?:-\s*(\d+)\s*)?$/;
|
|
6
|
+
const itemSchema = z.object({
|
|
7
|
+
question: z.string(),
|
|
8
|
+
options: z.array(z.string()),
|
|
9
|
+
pick: z.union([z.number().int(), z.string()]).optional(),
|
|
10
|
+
answer: z.array(z.string()).optional(),
|
|
11
|
+
rolled: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
const setSchema = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
title: z.string(),
|
|
16
|
+
who: z.string(),
|
|
17
|
+
made: z.string(),
|
|
18
|
+
items: z.array(itemSchema),
|
|
19
|
+
confirmed: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
/** The choices waiting in state.yaml, in the order they were made; none when there are none, or when they do not read. */
|
|
22
|
+
export function readChoices(root) {
|
|
23
|
+
let values;
|
|
24
|
+
// A state.yaml that does not read is validate's to say: what reads it goes on without choices.
|
|
25
|
+
try {
|
|
26
|
+
values = readStateValues(root);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const parsed = z.array(z.unknown()).safeParse(values.choices ?? []);
|
|
32
|
+
return parsed.success ? parsed.data.flatMap((value) => readSet(value) ?? []) : [];
|
|
33
|
+
}
|
|
34
|
+
/** Writes the choices waiting, in place of those in state.yaml; none takes the key away. */
|
|
35
|
+
export function writeChoices(root, sets) {
|
|
36
|
+
changeStateAt(root, [[["choices"], sets.length === 0 ? undefined : sets.map(writtenSet)]]);
|
|
37
|
+
}
|
|
38
|
+
/** "2" as 2 to 2, "0-2" as 0 to 2; undefined for anything else. One alone, as a choice is, when nothing is given. */
|
|
39
|
+
export function readPick(value) {
|
|
40
|
+
if (value === undefined) {
|
|
41
|
+
return { least: 1, most: 1 };
|
|
42
|
+
}
|
|
43
|
+
const found = pickPattern.exec(String(value));
|
|
44
|
+
if (found === null) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const least = Number(found[1]);
|
|
48
|
+
const most = found[2] === undefined ? least : Number(found[2]);
|
|
49
|
+
return least <= most ? { least, most } : undefined;
|
|
50
|
+
}
|
|
51
|
+
/** How a pick is written: 2, or 0-2. */
|
|
52
|
+
export function pickText(pick) {
|
|
53
|
+
return pick.least === pick.most ? String(pick.least) : `${pick.least}-${pick.most}`;
|
|
54
|
+
}
|
|
55
|
+
function readSet(value) {
|
|
56
|
+
const parsed = setSchema.safeParse(value);
|
|
57
|
+
if (!parsed.success) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const items = parsed.data.items.flatMap((item) => {
|
|
61
|
+
const pick = readPick(item.pick);
|
|
62
|
+
return pick === undefined
|
|
63
|
+
? []
|
|
64
|
+
: [{ question: item.question, options: item.options, pick, ...(item.answer === undefined ? {} : { answer: item.answer }), ...(item.rolled === undefined ? {} : { rolled: item.rolled }) }];
|
|
65
|
+
});
|
|
66
|
+
return { ...parsed.data, items };
|
|
67
|
+
}
|
|
68
|
+
// As state.yaml keeps it: a pick of one left out, a pick of a range as text.
|
|
69
|
+
function writtenSet(set) {
|
|
70
|
+
return {
|
|
71
|
+
id: set.id,
|
|
72
|
+
title: set.title,
|
|
73
|
+
who: set.who,
|
|
74
|
+
made: set.made,
|
|
75
|
+
items: set.items.map((item) => ({
|
|
76
|
+
question: item.question,
|
|
77
|
+
options: item.options,
|
|
78
|
+
...(item.pick.least === 1 && item.pick.most === 1 ? {} : { pick: item.pick.least === item.pick.most ? item.pick.least : pickText(item.pick) }),
|
|
79
|
+
...(item.answer === undefined ? {} : { answer: item.answer }),
|
|
80
|
+
...(item.rolled === undefined ? {} : { rolled: item.rolled }),
|
|
81
|
+
})),
|
|
82
|
+
...(set.confirmed === undefined ? {} : { confirmed: set.confirmed }),
|
|
83
|
+
};
|
|
84
|
+
}
|
package/dist/campaign/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { type ChoiceItem, type ChoiceSet, type PickRange, pickText, readChoices, readPick, writeChoices } from "./choices.ts";
|
|
1
2
|
export { createCampaign } from "./create-campaign.ts";
|
|
2
3
|
export { campaignFileName, findCampaign, houseRulesFolderName, requireCampaign } from "./find-campaign.ts";
|
|
3
4
|
export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.ts";
|
|
4
|
-
export {
|
|
5
|
+
export { lastChoices, rememberChoice, rememberedSettings } from "./last-choices.ts";
|
|
6
|
+
export { type CountedByGame, customLevel, customLevels, customSettings, difficulties, difficultyItems, itemMeaning, leveled, type LeveledSetting, rigorItems, rigors, startingLevels } from "./levels.ts";
|
|
7
|
+
export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, checkSettings, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
|
|
5
8
|
export { type CampaignState, changeState, changeStateAt, readState, readStateValues } from "./state.ts";
|
package/dist/campaign/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// The campaign: a folder with campaign.yaml, its settings, the present, the sessions and the files an AI host reads.
|
|
2
|
+
export { pickText, readChoices, readPick, writeChoices } from "./choices.js";
|
|
2
3
|
export { createCampaign } from "./create-campaign.js";
|
|
3
4
|
export { campaignFileName, findCampaign, houseRulesFolderName, requireCampaign } from "./find-campaign.js";
|
|
4
5
|
export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.js";
|
|
5
|
-
export {
|
|
6
|
+
export { lastChoices, rememberChoice, rememberedSettings } from "./last-choices.js";
|
|
7
|
+
export { customLevel, customLevels, customSettings, difficulties, difficultyItems, itemMeaning, leveled, rigorItems, rigors, startingLevels } from "./levels.js";
|
|
8
|
+
export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, checkSettings, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
|
|
6
9
|
export { changeState, changeStateAt, readState, readStateValues } from "./state.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The settings whose last choice a new campaign's setup suggests: how the player likes to play, never what belongs to one game, as how well they know it. */
|
|
2
|
+
export declare const rememberedSettings: readonly string[];
|
|
3
|
+
/** The last choice of each remembered setting, from the player's folder on this computer; none when there is no folder or the file does not read. */
|
|
4
|
+
export declare function lastChoices(home: string | undefined): Record<string, string>;
|
|
5
|
+
/** Remembers a choice of a remembered setting in the player's folder; a choice of another setting, or a folder that cannot be written, changes nothing. */
|
|
6
|
+
export declare function rememberChoice(home: string | undefined, name: string, value: unknown): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// The player's last choices of the setup's settings on this computer (D-37, T-134): what the setup of a new campaign suggests, never chooses.
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
/** The settings whose last choice a new campaign's setup suggests: how the player likes to play, never what belongs to one game, as how well they know it. */
|
|
5
|
+
export const rememberedSettings = ["difficulty", "lethality", "saves", "rigor", "dice", "master-rolls", "units", "companions", "preparation"];
|
|
6
|
+
const fileName = "last-choices.json";
|
|
7
|
+
/** The last choice of each remembered setting, from the player's folder on this computer; none when there is no folder or the file does not read. */
|
|
8
|
+
export function lastChoices(home) {
|
|
9
|
+
if (home === undefined) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const read = JSON.parse(readFileSync(join(home, fileName), "utf8"));
|
|
14
|
+
const entries = read !== null && typeof read === "object" && !Array.isArray(read) ? Object.entries(read) : [];
|
|
15
|
+
return Object.fromEntries(entries.filter((entry) => rememberedSettings.includes(entry[0]) && typeof entry[1] === "string"));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Remembers a choice of a remembered setting in the player's folder; a choice of another setting, or a folder that cannot be written, changes nothing. */
|
|
22
|
+
export function rememberChoice(home, name, value) {
|
|
23
|
+
if (home === undefined || !rememberedSettings.includes(name) || typeof value !== "string") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const file = join(home, fileName);
|
|
27
|
+
try {
|
|
28
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
29
|
+
writeFileSync(file, `${JSON.stringify({ ...lastChoices(home), [name]: value }, null, 2)}\n`);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// A suggestion lost is no reason to stop the change the player asked for.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** How hard the world plays (D-13, D-141): its presets. */
|
|
2
|
+
export declare const difficulties: readonly ["story", "easy", "normal", "hard", "brutal"];
|
|
3
|
+
/** How closely the rules are followed, apart from difficulty (D-42): the master glosses over them, as they are written, or beyond them. */
|
|
4
|
+
export declare const rigors: readonly ["smooth", "rules", "simulation"];
|
|
5
|
+
/** The value of difficulty and rigor whose items each have a level of their own, written in custom-difficulty and custom-rigor (D-13, D-42). */
|
|
6
|
+
export declare const customLevel = "custom";
|
|
7
|
+
/** The items of a custom difficulty, as the GDD's table has them. */
|
|
8
|
+
export declare const difficultyItems: readonly ["fights", "foes", "clues", "resources", "encounters", "clocks", "take-backs"];
|
|
9
|
+
/** The items of a custom rigor: those the engine counts (food, light, load) and those the master counts. */
|
|
10
|
+
export declare const rigorItems: readonly ["food", "light", "load", "fatigue", "travel", "supplies"];
|
|
11
|
+
/** The setting that holds the items' levels of a custom difficulty or rigor, by the setting's name. */
|
|
12
|
+
export declare const customSettings: {
|
|
13
|
+
readonly difficulty: "custom-difficulty";
|
|
14
|
+
readonly rigor: "custom-rigor";
|
|
15
|
+
};
|
|
16
|
+
export type LeveledSetting = keyof typeof customSettings;
|
|
17
|
+
/** What the game system counts itself (UPK-1, UPK-3): the day's food, and what burns as it is lit, by its first name; what a rigor's meaning adds of them. */
|
|
18
|
+
export interface CountedByGame {
|
|
19
|
+
upkeep: boolean;
|
|
20
|
+
/** Whether advance pays a day of the lifestyle chosen in a settlement (UPK-4). */
|
|
21
|
+
lifestyle?: boolean;
|
|
22
|
+
burning?: string;
|
|
23
|
+
}
|
|
24
|
+
/** The items of a difficulty or rigor, the levels each takes, and the level of an item the custom one does not write: the setting's default. */
|
|
25
|
+
export declare const leveled: {
|
|
26
|
+
readonly difficulty: {
|
|
27
|
+
readonly items: readonly ["fights", "foes", "clues", "resources", "encounters", "clocks", "take-backs"];
|
|
28
|
+
readonly levels: readonly ["story", "easy", "normal", "hard", "brutal"];
|
|
29
|
+
readonly unset: "normal";
|
|
30
|
+
};
|
|
31
|
+
readonly rigor: {
|
|
32
|
+
readonly items: readonly ["food", "light", "load", "fatigue", "travel", "supplies"];
|
|
33
|
+
readonly levels: readonly ["smooth", "rules", "simulation"];
|
|
34
|
+
readonly unset: "smooth";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** The level of each item of a custom difficulty or rigor, as the setting that holds them writes it; an item written wrongly, or not at all, takes the default. */
|
|
38
|
+
export declare function customLevels(setting: LeveledSetting, written: unknown): Record<string, string>;
|
|
39
|
+
/** The level a custom difficulty or rigor starts from: each item at the preset played until then, or at the default. */
|
|
40
|
+
export declare function startingLevels(setting: LeveledSetting, preset: unknown): Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* What a difficulty or rigor means to the master (D-263), the rigor with what the game counts itself; the custom one, item by item, with the levels written.
|
|
43
|
+
* Undefined for a value it does not take.
|
|
44
|
+
*/
|
|
45
|
+
export declare function levelMeaning(setting: LeveledSetting, value: string, counted: CountedByGame | undefined, custom: unknown): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* What one item of a custom difficulty or rigor means at a level, as the master hears it when the player changes it: food and water as written, with what the game
|
|
48
|
+
* counts itself of it.
|
|
49
|
+
*/
|
|
50
|
+
export declare function itemMeaning(setting: LeveledSetting, item: string, level: string, counted: CountedByGame | undefined): string | undefined;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// The difficulty and the rigor (D-13, D-42): their presets, and the custom one, each item at a level of its own (T-132), with what they mean to the master.
|
|
2
|
+
/** How hard the world plays (D-13, D-141): its presets. */
|
|
3
|
+
export const difficulties = ["story", "easy", "normal", "hard", "brutal"];
|
|
4
|
+
/** How closely the rules are followed, apart from difficulty (D-42): the master glosses over them, as they are written, or beyond them. */
|
|
5
|
+
export const rigors = ["smooth", "rules", "simulation"];
|
|
6
|
+
/** The value of difficulty and rigor whose items each have a level of their own, written in custom-difficulty and custom-rigor (D-13, D-42). */
|
|
7
|
+
export const customLevel = "custom";
|
|
8
|
+
/** The items of a custom difficulty, as the GDD's table has them. */
|
|
9
|
+
export const difficultyItems = ["fights", "foes", "clues", "resources", "encounters", "clocks", "take-backs"];
|
|
10
|
+
/** The items of a custom rigor: those the engine counts (food, light, load) and those the master counts. */
|
|
11
|
+
export const rigorItems = ["food", "light", "load", "fatigue", "travel", "supplies"];
|
|
12
|
+
/** The setting that holds the items' levels of a custom difficulty or rigor, by the setting's name. */
|
|
13
|
+
export const customSettings = { difficulty: "custom-difficulty", rigor: "custom-rigor" };
|
|
14
|
+
/** The items of a difficulty or rigor, the levels each takes, and the level of an item the custom one does not write: the setting's default. */
|
|
15
|
+
export const leveled = {
|
|
16
|
+
difficulty: { items: difficultyItems, levels: difficulties, unset: "normal" },
|
|
17
|
+
rigor: { items: rigorItems, levels: rigors, unset: "smooth" },
|
|
18
|
+
};
|
|
19
|
+
/** The level of each item of a custom difficulty or rigor, as the setting that holds them writes it; an item written wrongly, or not at all, takes the default. */
|
|
20
|
+
export function customLevels(setting, written) {
|
|
21
|
+
const { items, levels, unset } = leveled[setting];
|
|
22
|
+
const entries = written !== null && typeof written === "object" && !Array.isArray(written) ? written : {};
|
|
23
|
+
return Object.fromEntries(items.map((item) => {
|
|
24
|
+
const level = entries[item];
|
|
25
|
+
return [item, typeof level === "string" && levels.includes(level) ? level : unset];
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/** The level a custom difficulty or rigor starts from: each item at the preset played until then, or at the default. */
|
|
29
|
+
export function startingLevels(setting, preset) {
|
|
30
|
+
const { items, levels, unset } = leveled[setting];
|
|
31
|
+
const level = typeof preset === "string" && levels.includes(preset) ? preset : unset;
|
|
32
|
+
return Object.fromEntries(items.map((item) => [item, level]));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What a difficulty or rigor means to the master (D-263), the rigor with what the game counts itself; the custom one, item by item, with the levels written.
|
|
36
|
+
* Undefined for a value it does not take.
|
|
37
|
+
*/
|
|
38
|
+
export function levelMeaning(setting, value, counted, custom) {
|
|
39
|
+
if (setting === "difficulty") {
|
|
40
|
+
return value === customLevel ? customDifficultyMeaning(customLevels("difficulty", custom)) : presetDifficultyMeaning(value);
|
|
41
|
+
}
|
|
42
|
+
return value === customLevel ? customRigorMeaning(customLevels("rigor", custom), counted) : rigorMeaning(value, counted);
|
|
43
|
+
}
|
|
44
|
+
/** What each item of the difficulty means at each level, from the GDD's table; fights in the words of a budget of low, moderate and high (D-266). */
|
|
45
|
+
const difficultyItemMeanings = {
|
|
46
|
+
fights: {
|
|
47
|
+
story: "fights low, yet each asks one choice that counts; the plain approach wins at a small cost, the risk falling on goals and allies",
|
|
48
|
+
easy: "fights low to moderate; the plain approach wins at a cost",
|
|
49
|
+
normal: "fights moderate to high; two to four between full rests; the plain approach wins at a real cost, a good choice cheaply",
|
|
50
|
+
hard: "fights high and beyond; the plain approach may lose, a good choice wins at a cost",
|
|
51
|
+
brutal: "fights far beyond high; the plain approach loses, only good choices win",
|
|
52
|
+
},
|
|
53
|
+
foes: {
|
|
54
|
+
story: "foes naive, ignoring the place, quick to flee",
|
|
55
|
+
easy: "foes with simple tactics, using the plainest feature of the place",
|
|
56
|
+
normal: "foes with sensible tactics, using the place, normal morale",
|
|
57
|
+
hard: "foes smart (focus, control), taking the place first, tenacious",
|
|
58
|
+
brutal: "foes optimized (prepared ground, retreats, ambushes, finishing the fallen), fanatical",
|
|
59
|
+
},
|
|
60
|
+
clues: {
|
|
61
|
+
story: "clues obvious, four or more",
|
|
62
|
+
easy: "clues plain",
|
|
63
|
+
normal: "clues three for each conclusion",
|
|
64
|
+
hard: "clues subtle",
|
|
65
|
+
brutal: "clues subtle",
|
|
66
|
+
},
|
|
67
|
+
resources: {
|
|
68
|
+
story: "resources plentiful",
|
|
69
|
+
easy: "resources generous",
|
|
70
|
+
normal: "resources standard (treasure, supplies, prices)",
|
|
71
|
+
hard: "resources scarce",
|
|
72
|
+
brutal: "resources very scarce; rests at their harshest",
|
|
73
|
+
},
|
|
74
|
+
encounters: {
|
|
75
|
+
story: "random encounters rare",
|
|
76
|
+
easy: "random encounters rare",
|
|
77
|
+
normal: "random encounters normal",
|
|
78
|
+
hard: "random encounters frequent",
|
|
79
|
+
brutal: "random encounters frequent",
|
|
80
|
+
},
|
|
81
|
+
clocks: {
|
|
82
|
+
story: "threat clocks slow: a step only for what the characters do",
|
|
83
|
+
easy: "threat clocks slow: a step only for what the characters do",
|
|
84
|
+
normal: "threat clocks at their pace: a step at their event, or each day their holder acts undisturbed",
|
|
85
|
+
hard: "threat clocks fast: in doubt, a step",
|
|
86
|
+
brutal: "threat clocks fast: in doubt, a step",
|
|
87
|
+
},
|
|
88
|
+
"take-backs": {
|
|
89
|
+
story: "you may soften your own rolls; take-backs granted whenever asked",
|
|
90
|
+
easy: "small take-backs granted gladly",
|
|
91
|
+
normal: "a take-back now and then, when little hangs on it",
|
|
92
|
+
hard: "take-backs rare",
|
|
93
|
+
brutal: "no take-backs",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
/** What each rigor means in play (D-42, D-263): what the master counts. */
|
|
97
|
+
const rigorMeanings = {
|
|
98
|
+
smooth: "you gloss over food and water, light, encumbrance, fatigue and the like: count them only when the story turns on them",
|
|
99
|
+
rules: "as written: charge with change what is used up; encumbrance, fatigue and the like as the rules say; warn before something runs out, and once it has, the rule applies",
|
|
100
|
+
simulation: "as rules, and beyond what is written: wear, spoilage, weather and the like",
|
|
101
|
+
};
|
|
102
|
+
/** The items of the rigor as the master reads them. */
|
|
103
|
+
const rigorItemNames = {
|
|
104
|
+
food: "food and water",
|
|
105
|
+
light: "light",
|
|
106
|
+
load: "load",
|
|
107
|
+
fatigue: "fatigue",
|
|
108
|
+
travel: "travel",
|
|
109
|
+
supplies: "ammunition and components",
|
|
110
|
+
};
|
|
111
|
+
/** What each level of a custom rigor means for the items at it. */
|
|
112
|
+
const rigorLevelMeanings = {
|
|
113
|
+
smooth: "glossed over: count them only when the story turns on them",
|
|
114
|
+
rules: "as written: charge with change what is used up, warn before something runs out, and once it has, the rule applies",
|
|
115
|
+
simulation: "as written, and beyond: wear, spoilage, weather and the like",
|
|
116
|
+
};
|
|
117
|
+
function presetDifficultyMeaning(value) {
|
|
118
|
+
const level = difficulties.find((one) => one === value);
|
|
119
|
+
return level === undefined ? undefined : difficultyItems.map((item) => difficultyItemMeanings[item][level]).join("; ");
|
|
120
|
+
}
|
|
121
|
+
function customDifficultyMeaning(levels) {
|
|
122
|
+
const items = difficultyItems.map((item) => difficultyItemMeanings[item][levels[item]]);
|
|
123
|
+
return `item by item: ${items.join("; ")}`;
|
|
124
|
+
}
|
|
125
|
+
/** A rigor's meaning with what the game counts itself said (review of 17 October): a game that counts no food is never promised it. */
|
|
126
|
+
function rigorMeaning(rigor, counted) {
|
|
127
|
+
const meaning = rigorMeanings[rigor];
|
|
128
|
+
const burns = counted?.burning === undefined ? "" : `an effect named after what burns, such as ${counted.burning}, spends it as it is lit`;
|
|
129
|
+
if (meaning === undefined || rigor === "simulation" || counted === undefined) {
|
|
130
|
+
return meaning;
|
|
131
|
+
}
|
|
132
|
+
if (rigor === "smooth") {
|
|
133
|
+
return burns === "" ? meaning : `${meaning}; a light you put on as an effect, as a ${counted.burning}, still spends one`;
|
|
134
|
+
}
|
|
135
|
+
const food = counted.upkeep ? `${foodCounted(counted)}; ${yoursToCharge(counted)} are yours to charge` : "";
|
|
136
|
+
const counts = [food, burns].filter((part) => part !== "").join("; ");
|
|
137
|
+
return counts === "" ? meaning : meaning.replace("charge with change what is used up; ", `charge with change what is used up; ${counts}; `);
|
|
138
|
+
}
|
|
139
|
+
/** A custom rigor's meaning: the items grouped by level, each level with what it asks and what the game counts itself of its items. */
|
|
140
|
+
function customRigorMeaning(levels, counted) {
|
|
141
|
+
const groups = rigors.flatMap((level) => {
|
|
142
|
+
const items = rigorItems.filter((item) => levels[item] === level);
|
|
143
|
+
if (items.length === 0) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
const names = items.map((item) => rigorItemNames[item]);
|
|
147
|
+
const counts = items.flatMap((item) => gameCounts(item, level, counted));
|
|
148
|
+
return [`${listText(names)} ${rigorLevelMeanings[level]}${counts.map((count) => `, and ${count}`).join("")}`];
|
|
149
|
+
});
|
|
150
|
+
return `item by item: ${groups.join("; ")}. Where your instructions name a rigor, read it as the level of the item they speak of`;
|
|
151
|
+
}
|
|
152
|
+
/** What the game counts itself of an item at a level, said so that the master leaves it to the game. */
|
|
153
|
+
function gameCounts(item, level, counted) {
|
|
154
|
+
if (item === "food" && level !== "smooth" && counted?.upkeep === true) {
|
|
155
|
+
return [`${foodCounted(counted)}, ${yoursToCharge(counted)} yours to charge`];
|
|
156
|
+
}
|
|
157
|
+
if (item === "light" && counted?.burning !== undefined) {
|
|
158
|
+
return [level === "smooth" ? `a light you put on as an effect, as a ${counted.burning}, still spends one` : `an effect named after what burns, such as ${counted.burning}, spends it as it is lit`];
|
|
159
|
+
}
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* What one item of a custom difficulty or rigor means at a level, as the master hears it when the player changes it: food and water as written, with what the game
|
|
164
|
+
* counts itself of it.
|
|
165
|
+
*/
|
|
166
|
+
export function itemMeaning(setting, item, level, counted) {
|
|
167
|
+
if (setting === "difficulty") {
|
|
168
|
+
const meanings = difficultyItemMeanings[item];
|
|
169
|
+
return meanings?.[level];
|
|
170
|
+
}
|
|
171
|
+
const known = rigorItems.find((one) => one === item);
|
|
172
|
+
const meaning = rigorLevelMeanings[level];
|
|
173
|
+
if (known === undefined || meaning === undefined) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
return [`${rigorItemNames[known]} ${meaning}`, ...gameCounts(known, level, counted)].join(", and ");
|
|
177
|
+
}
|
|
178
|
+
/** What advance spends itself of the day's upkeep (UPK-1, UPK-4): the food outside a settlement, and the lifestyle inside one where the game has it. */
|
|
179
|
+
function foodCounted(counted) {
|
|
180
|
+
return counted.lifestyle === true ? "advance spends the day's food outside a settlement and the day's lifestyle inside one" : "advance spends the day's food outside a settlement";
|
|
181
|
+
}
|
|
182
|
+
/** What of the day's upkeep is the master's to charge: what advance does not spend itself. */
|
|
183
|
+
function yoursToCharge(counted) {
|
|
184
|
+
return counted.lifestyle === true ? "water and wages" : "water, lifestyle and wages";
|
|
185
|
+
}
|
|
186
|
+
/** "a, b and c". */
|
|
187
|
+
function listText(items) {
|
|
188
|
+
return items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1) ?? ""}`;
|
|
189
|
+
}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { unitSystems } from "../core/length.ts";
|
|
3
3
|
import type { Problem } from "../core/problem.ts";
|
|
4
|
-
|
|
5
|
-
export declare const difficulties: readonly ["story", "easy", "normal", "hard", "brutal"];
|
|
4
|
+
import { type CountedByGame } from "./levels.ts";
|
|
6
5
|
/** What a fall means (D-13, D-141): the character never dies, dies only when it matters, or as the dice say. */
|
|
7
6
|
export declare const lethalities: readonly ["narrative", "epic", "dice"];
|
|
8
7
|
/** When the game may go back (D-55): never, to the last end of a scene once the player character dies, or to any save, which the player may also ask for. */
|
|
9
8
|
export declare const saveModes: readonly ["permadeath", "checkpoint", "free"];
|
|
10
|
-
/** How closely the rules are followed, apart from difficulty (D-42): the master glosses over them, as they are written, or beyond them. */
|
|
11
|
-
export declare const rigors: readonly ["smooth", "rules", "simulation"];
|
|
12
|
-
/** What the game system counts itself (UPK-1, UPK-3): the day's food, and what burns as it is lit, by its first name; what a rigor's meaning adds of them. */
|
|
13
|
-
export interface CountedByGame {
|
|
14
|
-
upkeep: boolean;
|
|
15
|
-
burning?: string;
|
|
16
|
-
}
|
|
17
9
|
/**
|
|
18
|
-
* What the chosen difficulty, rigor or mentor means, as status and config give it, the rigor with what the game counts itself
|
|
19
|
-
* or a value it does not take.
|
|
10
|
+
* What the chosen difficulty, rigor or mentor means, as status and config give it, the rigor with what the game counts itself, a custom one with the levels of
|
|
11
|
+
* its items as custom-difficulty or custom-rigor writes them (T-132); undefined for another setting or a value it does not take.
|
|
20
12
|
*/
|
|
21
|
-
export declare function settingMeaning(name: string, value: unknown, counted?: CountedByGame): string | undefined;
|
|
13
|
+
export declare function settingMeaning(name: string, value: unknown, counted?: CountedByGame, custom?: unknown): string | undefined;
|
|
22
14
|
/** What a setting of the engine that takes one of some values is, and those values, as config gives it for that setting alone; undefined for any other. */
|
|
23
15
|
export declare function settingDescription(name: string): string | undefined;
|
|
24
16
|
export type CampaignSettings = z.infer<typeof settingsSchema>;
|
|
@@ -135,6 +127,7 @@ export declare const settingsSchema: z.ZodObject<{
|
|
|
135
127
|
author: z.ZodOptional<z.ZodPreprocess<z.ZodString, unknown>>;
|
|
136
128
|
style: z.ZodOptional<z.ZodPreprocess<z.ZodString, unknown>>;
|
|
137
129
|
difficulty: z.ZodOptional<z.ZodEnum<{
|
|
130
|
+
custom: "custom";
|
|
138
131
|
story: "story";
|
|
139
132
|
easy: "easy";
|
|
140
133
|
normal: "normal";
|
|
@@ -152,10 +145,38 @@ export declare const settingsSchema: z.ZodObject<{
|
|
|
152
145
|
free: "free";
|
|
153
146
|
}>>;
|
|
154
147
|
rigor: z.ZodOptional<z.ZodEnum<{
|
|
148
|
+
custom: "custom";
|
|
155
149
|
rules: "rules";
|
|
156
150
|
smooth: "smooth";
|
|
157
151
|
simulation: "simulation";
|
|
158
152
|
}>>;
|
|
153
|
+
"custom-difficulty": z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
154
|
+
fights: "fights";
|
|
155
|
+
foes: "foes";
|
|
156
|
+
clues: "clues";
|
|
157
|
+
resources: "resources";
|
|
158
|
+
encounters: "encounters";
|
|
159
|
+
clocks: "clocks";
|
|
160
|
+
"take-backs": "take-backs";
|
|
161
|
+
}> & z.core.$partial, z.ZodEnum<{
|
|
162
|
+
story: "story";
|
|
163
|
+
easy: "easy";
|
|
164
|
+
normal: "normal";
|
|
165
|
+
hard: "hard";
|
|
166
|
+
brutal: "brutal";
|
|
167
|
+
}>>>;
|
|
168
|
+
"custom-rigor": z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
169
|
+
light: "light";
|
|
170
|
+
food: "food";
|
|
171
|
+
load: "load";
|
|
172
|
+
fatigue: "fatigue";
|
|
173
|
+
travel: "travel";
|
|
174
|
+
supplies: "supplies";
|
|
175
|
+
}> & z.core.$partial, z.ZodEnum<{
|
|
176
|
+
rules: "rules";
|
|
177
|
+
smooth: "smooth";
|
|
178
|
+
simulation: "simulation";
|
|
179
|
+
}>>>;
|
|
159
180
|
dice: z.ZodOptional<z.ZodEnum<{
|
|
160
181
|
digital: "digital";
|
|
161
182
|
physical: "physical";
|
|
@@ -181,6 +202,7 @@ export declare const settingsSchema: z.ZodObject<{
|
|
|
181
202
|
"met in play": "met in play";
|
|
182
203
|
}>>;
|
|
183
204
|
"calendar-start": z.ZodOptional<z.ZodString>;
|
|
205
|
+
"between-sessions": z.ZodOptional<z.ZodString>;
|
|
184
206
|
pictures: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
|
|
185
207
|
none: "none";
|
|
186
208
|
"on request": "on request";
|
|
@@ -216,7 +238,7 @@ export declare const settingNames: SettingName[];
|
|
|
216
238
|
export declare const listSettingNames: SettingName[];
|
|
217
239
|
/** The settings that hold entries by name, what the campaign adds to its game system (CAM-1): given or removed one entry at a time. */
|
|
218
240
|
export declare const mapSettingNames: SettingName[];
|
|
219
|
-
/** The settings that hold entries by name: what the campaign adds to its game system,
|
|
241
|
+
/** The settings that hold entries by name: what the campaign adds to its game system, where the dashboard shows the extensions' widgets (D-502), and the items of a custom difficulty or rigor (T-132). */
|
|
220
242
|
export declare const entrySettingNames: SettingName[];
|
|
221
243
|
/**
|
|
222
244
|
* What only the setup asks (D-241, MOD-3, D-347, D-287): how much the master teaches the game, whether the master's rolls are shown, how the companions come,
|