rpg-engine 0.3.0 → 0.4.1

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.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/index.d.ts +1 -1
  3. package/dist/campaign/index.js +1 -1
  4. package/dist/campaign/settings.d.ts +10 -1
  5. package/dist/campaign/settings.js +9 -2
  6. package/dist/command-line.js +6 -1
  7. package/dist/commands/change.d.ts +7 -0
  8. package/dist/commands/change.js +34 -8
  9. package/dist/commands/config.d.ts +1 -1
  10. package/dist/commands/config.js +41 -7
  11. package/dist/commands/game-master-rolls.d.ts +17 -0
  12. package/dist/commands/game-master-rolls.js +36 -0
  13. package/dist/commands/game-mode.js +2 -1
  14. package/dist/commands/game-system-code.js +8 -1
  15. package/dist/commands/game-tables.d.ts +7 -0
  16. package/dist/commands/game-tables.js +40 -0
  17. package/dist/commands/game-upkeep.js +1 -1
  18. package/dist/commands/package.js +5 -3
  19. package/dist/commands/roll.d.ts +4 -0
  20. package/dist/commands/roll.js +73 -18
  21. package/dist/dashboard/i18n/ar.json +6 -0
  22. package/dist/dashboard/i18n/cs.json +6 -0
  23. package/dist/dashboard/i18n/da.json +6 -0
  24. package/dist/dashboard/i18n/de.json +6 -0
  25. package/dist/dashboard/i18n/el.json +6 -0
  26. package/dist/dashboard/i18n/es.json +6 -0
  27. package/dist/dashboard/i18n/fi.json +6 -0
  28. package/dist/dashboard/i18n/fr.json +6 -0
  29. package/dist/dashboard/i18n/he.json +6 -0
  30. package/dist/dashboard/i18n/hi.json +6 -0
  31. package/dist/dashboard/i18n/hu.json +6 -0
  32. package/dist/dashboard/i18n/is.json +6 -0
  33. package/dist/dashboard/i18n/it.json +6 -0
  34. package/dist/dashboard/i18n/ja.json +6 -0
  35. package/dist/dashboard/i18n/ko.json +6 -0
  36. package/dist/dashboard/i18n/nb.json +6 -0
  37. package/dist/dashboard/i18n/nl.json +6 -0
  38. package/dist/dashboard/i18n/pl.json +6 -0
  39. package/dist/dashboard/i18n/pt.json +6 -0
  40. package/dist/dashboard/i18n/ro.json +6 -0
  41. package/dist/dashboard/i18n/ru.json +6 -0
  42. package/dist/dashboard/i18n/sv.json +6 -0
  43. package/dist/dashboard/i18n/tr.json +6 -0
  44. package/dist/dashboard/i18n/uk.json +6 -0
  45. package/dist/dashboard/i18n/zh.json +6 -0
  46. package/dist/dashboard/labels.js +3 -0
  47. package/dist/dashboard/markdown.js +15 -4
  48. package/dist/dashboard/scene.js +21 -10
  49. package/dist/dashboard/settings.js +3 -3
  50. package/dist/dashboard/style.css +3 -1
  51. package/dist/dice/index.d.ts +2 -0
  52. package/dist/dice/index.js +3 -1
  53. package/dist/dice/oracle.d.ts +19 -0
  54. package/dist/dice/oracle.js +22 -0
  55. package/dist/dice/tables.d.ts +29 -0
  56. package/dist/dice/tables.js +123 -0
  57. package/dist/pages/index.d.ts +1 -1
  58. package/dist/pages/index.js +1 -1
  59. package/dist/pages/markdown.d.ts +8 -0
  60. package/dist/pages/markdown.js +27 -0
  61. package/dist/systems/system-code.d.ts +1 -1
  62. package/instructions/combat.md +1 -1
  63. package/instructions/core.md +1 -1
  64. package/instructions/play.md +1 -1
  65. package/package.json +2 -2
  66. package/systems/5e/instructions/play.md +1 -0
package/README.md CHANGED
@@ -42,7 +42,7 @@ Today RPG Engine plays **fifth edition**, from the free System Reference Documen
42
42
 
43
43
  ## What you need
44
44
 
45
- **Node.js 22** or newer, a web browser, and an AI agent to be the master: an AI app that can work with the files on your computer, such as Claude Code or Codex. A plain chat such as claude.ai or ChatGPT, or a phone app, is not enough: the master needs to reach the campaign's files on your computer.
45
+ **Node.js 22.4** or newer, a web browser, and an AI agent to be the master: an AI app that can work with the files on your computer, such as Claude Code or Codex. A plain chat such as claude.ai or ChatGPT, or a phone app, is not enough: the master needs to reach the campaign's files on your computer.
46
46
 
47
47
  RPG Engine is tied to no AI company: any agent that supports MCP tools can be the master, local ones included. We play and test it with **Claude Code**; **Codex** is connected and checked, but no whole campaign has been played with it yet; [the guide](https://github.com/stefanocaronia/rpg-engine/blob/main/src/dashboard/guide/en.md#24-connect-your-ai) says how to connect any other agent. Give the master the largest model you have: a small one is easier to talk into revealing secrets or bending the rules.
48
48
 
@@ -1,5 +1,5 @@
1
1
  export { createCampaign } from "./create-campaign.ts";
2
2
  export { campaignFileName, findCampaign, houseRulesFolderName, requireCampaign } from "./find-campaign.ts";
3
3
  export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.ts";
4
- export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, checkSettings, clearSetting, companionWays, type CountedByGame, diceWays, difficulties, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, mentorWays, missingSettings, pictureWays, preparations, proseWays, readCampaignData, readCoinsSetting, readListSetting, readOneSetting, readSettings, readTextSetting, rigors, saveModes, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
4
+ export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, checkSettings, clearSetting, companionWays, type CountedByGame, diceWays, difficulties, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureWays, preparations, proseWays, readCampaignData, readCoinsSetting, readListSetting, readOneSetting, readSettings, readTextSetting, rigors, saveModes, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
5
5
  export { type CampaignState, changeState, changeStateAt, readState, readStateValues } from "./state.ts";
@@ -2,5 +2,5 @@
2
2
  export { createCampaign } from "./create-campaign.js";
3
3
  export { campaignFileName, findCampaign, houseRulesFolderName, requireCampaign } from "./find-campaign.js";
4
4
  export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.js";
5
- export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, checkSettings, clearSetting, companionWays, diceWays, difficulties, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, mentorWays, missingSettings, pictureWays, preparations, proseWays, readCampaignData, readCoinsSetting, readListSetting, readOneSetting, readSettings, readTextSetting, rigors, saveModes, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
5
+ export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, checkSettings, clearSetting, companionWays, diceWays, difficulties, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureWays, preparations, proseWays, readCampaignData, readCoinsSetting, readListSetting, readOneSetting, readSettings, readTextSetting, rigors, saveModes, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
6
6
  export { changeState, changeStateAt, readState, readStateValues } from "./state.js";
@@ -29,6 +29,8 @@ export declare const mentorMeanings: Record<(typeof mentorWays)[number], string>
29
29
  export declare function settingMeaning(name: string, value: unknown, counted?: CountedByGame): string | undefined;
30
30
  /** Who rolls the player character's dice (D-241): rpg, or the player with their own, telling the values; the master's are always rolled by rpg. */
31
31
  export declare const diceWays: readonly ["digital", "physical"];
32
+ /** Whether the master's rolls for anyone outside the party are hidden (D-287): behind the screen, unset too, or in view; the party's are always shown. */
33
+ export declare const masterRollWays: readonly ["behind the screen", "in view"];
32
34
  /**
33
35
  * Who voices the characters (D-490), where the AI app has subagents: a character as a subagent of its own at key moments, the master chooses (auto); the master
34
36
  * always; always for the companions and the main characters; always for everyone.
@@ -107,6 +109,10 @@ export declare const settingsSchema: z.ZodObject<{
107
109
  digital: "digital";
108
110
  physical: "physical";
109
111
  }>>;
112
+ "master-rolls": z.ZodOptional<z.ZodEnum<{
113
+ "behind the screen": "behind the screen";
114
+ "in view": "in view";
115
+ }>>;
110
116
  units: z.ZodOptional<z.ZodEnum<{
111
117
  metric: "metric";
112
118
  imperial: "imperial";
@@ -162,7 +168,10 @@ export declare const listSettingNames: SettingName[];
162
168
  export declare const mapSettingNames: SettingName[];
163
169
  /** The settings that hold entries by name: what the campaign adds to its game system, and where the dashboard shows the extensions' widgets (D-502). */
164
170
  export declare const entrySettingNames: SettingName[];
165
- /** What only the setup asks (D-241, MOD-3, D-347): how much the master teaches the game, how the companions come, when the story starts, and the lines and veils, which "none" answers too. */
171
+ /**
172
+ * 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,
173
+ * when the story starts, and the lines and veils, which "none" answers too.
174
+ */
166
175
  export declare const setupSettingNames: SettingName[];
167
176
  /** What the setup asks only of a campaign without a written world (D-79, D-80, MOD-3). */
168
177
  export declare const premiseSettingNames: SettingName[];
@@ -68,6 +68,8 @@ export function settingMeaning(name, value, counted) {
68
68
  }
69
69
  /** Who rolls the player character's dice (D-241): rpg, or the player with their own, telling the values; the master's are always rolled by rpg. */
70
70
  export const diceWays = ["digital", "physical"];
71
+ /** Whether the master's rolls for anyone outside the party are hidden (D-287): behind the screen, unset too, or in view; the party's are always shown. */
72
+ export const masterRollWays = ["behind the screen", "in view"];
71
73
  /**
72
74
  * Who voices the characters (D-490), where the AI app has subagents: a character as a subagent of its own at key moments, the master chooses (auto); the master
73
75
  * always; always for the companions and the main characters; always for everyone.
@@ -128,6 +130,8 @@ export const settingsSchema = z.object({
128
130
  saves: z.enum(saveModes).optional().describe("when the game may go back: permadeath (never, but to the start, the campaign starting over), checkpoint (to the last end of a scene, once the player character dies) or free (to any save, and saves when the player asks)"),
129
131
  rigor: z.enum(rigors).optional().describe("how closely travel, fatigue, food and the like follow the rules: smooth (the master glosses over them), rules (as written) or simulation (beyond them)"),
130
132
  dice: z.enum(diceWays).optional().describe("the player character's dice: digital (rpg rolls them) or physical (the player rolls their own and tells the values)"),
133
+ "master-rolls": z.enum(masterRollWays).optional().describe("the master's rolls for foes and anyone else outside the party: behind the screen (roll hides them, the master telling only the outcome) or in view (roll shows them); "
134
+ + "the party's rolls are always shown; unset, behind the screen"),
131
135
  units: z.enum(unitSystems).optional().describe("the units of measure of the story: metric or imperial"),
132
136
  voices: z.enum(voiceWays).optional().describe("who voices the characters, where the AI app has subagents, from the master to the characters: master (the master, always), auto (at key moments, as the master chooses, "
133
137
  + "a character answers as a subagent of its own, knowing only what it knows), important (always a subagent for the companions and the characters with kind main), "
@@ -171,8 +175,11 @@ export const listSettingNames = ["lines", "veils", "table", "precedents", "learn
171
175
  export const mapSettingNames = ["fields", "tables", "computed", "counters", "recipes", "travel", "values"];
172
176
  /** The settings that hold entries by name: what the campaign adds to its game system, and where the dashboard shows the extensions' widgets (D-502). */
173
177
  export const entrySettingNames = [...mapSettingNames, "widgets"];
174
- /** What only the setup asks (D-241, MOD-3, D-347): how much the master teaches the game, how the companions come, when the story starts, and the lines and veils, which "none" answers too. */
175
- export const setupSettingNames = ["mentor", "companions", "calendar-start", "lines", "veils"];
178
+ /**
179
+ * 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,
180
+ * when the story starts, and the lines and veils, which "none" answers too.
181
+ */
182
+ export const setupSettingNames = ["mentor", "master-rolls", "companions", "calendar-start", "lines", "veils"];
176
183
  /** What the setup asks only of a campaign without a written world (D-79, D-80, MOD-3). */
177
184
  export const premiseSettingNames = ["premise", "preparation"];
178
185
  // Settings that only some games have, or that only the setup asks: never asked for in play when missing.
@@ -73,11 +73,16 @@ function readArguments(command, args) {
73
73
  const positionals = command.positionals ?? [];
74
74
  const options = { json: { type: "boolean" } };
75
75
  for (const [name, field] of inputFields(command)) {
76
+ // --no-x turns x off: a field named no-x would be lost, as an extension's might be (review of 25 October).
77
+ if (name.startsWith("no-")) {
78
+ throw new Error(`${command.name} has a field named ${name}, and none may start with no-, which the command line reads as turning ${name.slice(3)} off: rename it.`);
79
+ }
76
80
  if (!positionals.includes(name)) {
77
81
  options[name] = { type: isBoolean(field) ? "boolean" : "string", multiple: isList(field) };
78
82
  }
79
83
  }
80
- const parsed = parseArgs({ args, options, allowPositionals: true, strict: true, tokens: true });
84
+ // A flag is turned off as --no-hidden, where a setting would turn it on, as the MCP server takes hidden: false.
85
+ const parsed = parseArgs({ args, options, allowPositionals: true, allowNegative: true, strict: true, tokens: true });
81
86
  // The last positional, when it is a list, takes the arguments left before the first option, as in rpg move Ettore Lena --to Ossario.
82
87
  const last = positionals.at(-1);
83
88
  const takesRest = last !== undefined && isList(command.input.shape[last]);
@@ -38,6 +38,7 @@ export declare const change: import("../core/registry.ts").Command<z.ZodObject<{
38
38
  /** What the change may break that someone keeps alive, and what shields the counter it lowered (EFF-14, DAT-14). */
39
39
  reminders: string[];
40
40
  } | {
41
+ hiddenRoll?: HiddenDice | undefined;
41
42
  rolled: string;
42
43
  problems: string[];
43
44
  page: string;
@@ -57,6 +58,12 @@ export declare const change: import("../core/registry.ts").Command<z.ZodObject<{
57
58
  /** What the change may break that someone keeps alive, and what shields the counter it lowered (EFF-14, DAT-14). */
58
59
  reminders: string[];
59
60
  }>;
61
+ /** The dice in by, hidden: the roll's id, the fingerprint the player may ask for, and whether master-rolls hid them. */
62
+ interface HiddenDice {
63
+ id: string;
64
+ fingerprint: string;
65
+ screened: boolean;
66
+ }
60
67
  /** What a step did to a counter or to money. */
61
68
  interface StepOutcome {
62
69
  page: string;
@@ -13,6 +13,7 @@ import { checkEffectsReadable, saveEffects } from "./game-effects.js";
13
13
  import { fireEvents, nowDueNote } from "./game-events.js";
14
14
  import { experienceOf, newLevelNotes } from "./game-experience.js";
15
15
  import { spendableDice, spendDice } from "./game-hit-dice.js";
16
+ import { screenNote, screenUp, sealHiddenRoll } from "./game-master-rolls.js";
16
17
  import { campaignCoins } from "./game-money.js";
17
18
  import { logRecipeApplied, tooSoonNote } from "./game-recipe-pace.js";
18
19
  import { effectsAtRecipe, notBroughtBack, partyPages, recipeChoices, recipeNamed, recipeTargets } from "./game-recipes.js";
@@ -43,7 +44,7 @@ export const change = defineCommand({
43
44
  input: z.object({
44
45
  page: z.string().optional().describe("page that holds the counter or the money; with a recipe, left out for the player character and the companions with them"),
45
46
  field: z.string().optional().describe("the counter or the money, such as hp, or the kind of a stack, such as Torch; none with a recipe"),
46
- by: z.union([wholeNumber, z.string()]).optional().describe("how much to add, or to take away when negative, or coins; stops at a limit (damage, healing); on the command line write --by=-7. Dice are rolled here, as the player sees: by -(2d6+3) takes away 2d6+3, by -2d6 a die alone, as the game's rules have them rolled"),
47
+ by: z.union([wholeNumber, z.string()]).optional().describe("how much to add, or to take away when negative, or coins; stops at a limit (damage, healing); on the command line write --by=-7. Dice are rolled here: by -(2d6+3) takes away 2d6+3, by -2d6 a die alone, as the game's rules have them rolled; taking away from the party, the master's roll, hidden or shown as master-rolls says"),
47
48
  spend: z.union([wholeNumber, z.string()]).optional().describe("how much is paid or used up, or coins; refused when there is not enough"),
48
49
  to: z.union([z.number().int(), z.string()]).optional().describe("the new value, even outside the limits: a number, max, current/max such as 15/15 (the maximum changes too), or coins; on the command line write --to=-3"),
49
50
  why: z.string().optional().describe("what the change is for"),
@@ -63,16 +64,15 @@ export const change = defineCommand({
63
64
  if (input.page === undefined || input.field === undefined) {
64
65
  throw new Error('Give the page and the field, such as page Bruna, field hp, by -7; or a recipe of the game system, such as recipe "long rest".');
65
66
  }
66
- // Dice in by are rolled first and logged once the change is made, as a roll the player sees (D-459): one call for a roll and its damage.
67
+ // Dice in by are rolled first and logged once the change is made (D-459): one call for a roll and its damage.
67
68
  const roll = diceBy(input.by, context);
69
+ const hiding = roll === undefined ? undefined : diceHiding(root, world, input.page, roll.taking);
68
70
  const { hitCounter, ...result } = changeField(root, context, world, { ...input, page: input.page, field: input.field, ...(roll === undefined ? {} : { by: roll.by }) });
69
- if (roll !== undefined) {
70
- appendLogEntry(root, newDatedLogEntry(root, context, "roll", "public", { ...roll.data, why: input.why ?? `${input.field} of ${input.page}` }));
71
- }
71
+ const hiddenRoll = roll === undefined ? undefined : logDiceBy(root, context, { ...roll.data, why: input.why ?? `${input.field} of ${input.page}` }, hiding);
72
72
  // The game system's code follows the change, after the roll that made it (D-448): as the 5e's dying point.
73
73
  const lines = hitCounter === undefined ? [] : allSaid(systemCounterChanged(root, context, hitCounter));
74
74
  const told = lines.length === 0 ? result : { ...result, reminders: [...result.reminders, ...lines] };
75
- return roll === undefined ? told : { ...told, rolled: roll.data.result };
75
+ return roll === undefined ? told : { ...told, rolled: roll.data.result, ...(hiddenRoll === undefined ? {} : { hiddenRoll }) };
76
76
  },
77
77
  format(result) {
78
78
  if ("recipe" in result) {
@@ -83,7 +83,7 @@ export const change = defineCommand({
83
83
  const summary = result.changed ? `${result.page}: ${result.field} ${result.before} → ${after}${note}.` : `Nothing changed: ${result.field} on ${result.page} is ${after}${note}.`;
84
84
  // A rule's text, of several lines, comes after the lines of the change.
85
85
  const notes = stepNotes(result);
86
- const lines = [...("rolled" in result && result.rolled !== undefined ? [`Rolled ${result.rolled}.`] : []), summary, ...notes.filter((line) => !line.includes("\n"))];
86
+ const lines = [...("rolled" in result && result.rolled !== undefined ? [rolledText(result.rolled, result.hiddenRoll)] : []), summary, ...notes.filter((line) => !line.includes("\n"))];
87
87
  return [lines.join("\n"), ...notes.filter((line) => line.includes("\n")), skippedPagesNote(result.problems)].filter((block) => block !== "").join("\n\n");
88
88
  },
89
89
  });
@@ -151,7 +151,33 @@ function diceBy(by, context) {
151
151
  }
152
152
  const rolled = rollDice(notation, { random: context.random });
153
153
  const total = Math.max(0, rolled.total);
154
- return { by: text.startsWith("-") ? -total : total, data: { notation, total: rolled.total, result: rolled.text, physical: false, dice: rolled.dice } };
154
+ return { by: text.startsWith("-") ? -total : total, taking: text.startsWith("-"), data: { notation, total: rolled.total, result: rolled.text, physical: false, dice: rolled.dice } };
155
+ }
156
+ /**
157
+ * Why the dice in by are hidden, or undefined when shown (D-287): with their change, on a page that does not concern the player, whatever master-rolls says;
158
+ * behind the screen, taking away from the player character or a companion, as a foe's or a trap's do. Healing them, or dice on a copy in the scene, are shown.
159
+ */
160
+ function diceHiding(root, world, name, taking) {
161
+ const holder = holderNamed(root, world, name);
162
+ if (holder.kind === "copy") {
163
+ return undefined;
164
+ }
165
+ if (holder.visibility === "hidden") {
166
+ return "secret";
167
+ }
168
+ return taking && screenUp(root) && isPartyMember(holder.page) ? "screen" : undefined;
169
+ }
170
+ /** Logs the roll of the dice in by, sealed when hidden as roll seals one; what the master is told of it when hidden. */
171
+ function logDiceBy(root, context, data, hiding) {
172
+ const entry = newDatedLogEntry(root, context, "roll", hiding === undefined ? "public" : "hidden", data);
173
+ const fingerprint = hiding === undefined ? undefined : sealHiddenRoll(entry, data.result, context);
174
+ appendLogEntry(root, entry);
175
+ return fingerprint === undefined ? undefined : { id: entry.id, fingerprint, screened: hiding === "screen" };
176
+ }
177
+ /** "Rolled 2d6+3 = 11 [5, 3] + 3.", or the hidden roll as roll tells it, only for the master. */
178
+ function rolledText(rolled, hidden) {
179
+ const screen = hidden?.screened === true ? `. ${screenNote}` : "";
180
+ return hidden === undefined ? `Rolled ${rolled}.` : `Hidden roll ${hidden.id}, only for the master: ${rolled}${screen}\nIts fingerprint, only if the player asks for it: ${hidden.fingerprint}`;
155
181
  }
156
182
  /** Whether a text reads as dice, such as 2d6+3: coins and names of fields do not. */
157
183
  function isDiceNotation(text) {
@@ -14,7 +14,7 @@ interface ConfigResult {
14
14
  part?: string;
15
15
  }
16
16
  /** 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. */
17
- export declare const playerSettingNames: readonly ["difficulty", "lethality", "saves", "rigor", "mentor", "learned", "prose", "story", "author", "style", "dice", "units", "voices", "pictures", "effort", "lines", "veils", "language"];
17
+ export declare const playerSettingNames: readonly ["difficulty", "lethality", "saves", "rigor", "mentor", "learned", "prose", "story", "author", "style", "dice", "master-rolls", "units", "voices", "pictures", "effort", "lines", "veils", "language"];
18
18
  /** A setting of the player's as the dashboard shows it (D-341): what it is, its value or a list's items, and its values with what each means to the player. */
19
19
  export interface PlayerSetting {
20
20
  name: string;
@@ -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, mentorWays, pictureWays, preparations, proseWays, readCampaignData, readSettings, readTextSetting, refreshHostFiles, requireCampaign, rigors, saveModes, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unitSystems, voiceWays, writeEffortFiles, } from "../campaign/index.js";
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, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unitSystems, voiceWays, writeEffortFiles, } from "../campaign/index.js";
5
5
  import { appendLogEntry } from "../core/log.js";
6
6
  import { defineCommand } from "../core/registry.js";
7
7
  import { comparableText } from "../core/text.js";
@@ -33,6 +33,7 @@ export const config = defineCommand({
33
33
  + "saves, when the game may go back: permadeath (never, only to the start, the campaign starting over), checkpoint (to the last end of a scene, once the player character dies), free (to any save, and saves when the player asks). "
34
34
  + "rigor, how closely travel, fatigue, food and the like follow the rules: smooth (you gloss over them), rules (as written), simulation (beyond them). "
35
35
  + "dice, who rolls the player character's dice: digital (rpg) or physical (the player, who tells you the values). units: metric or imperial. "
36
+ + "master-rolls, your rolls for foes and NPCs: behind the screen (roll hides them, unset too: tell only the outcome) or in view; the party's are always shown. "
36
37
  + "voices, who voices the characters where your app has subagents: master (you, always), auto (a subagent at key moments, as you choose), "
37
38
  + "important (always a subagent for the companions and the characters with kind main), always (always a subagent); unset, auto. "
38
39
  + "companions: none, made with the player or made by the master in session zero, or met in play. "
@@ -202,7 +203,27 @@ function configure(input, context) {
202
203
  const freeSettingNames = ["author", "style", "calendar"];
203
204
  const styleSettingNames = ["prose", "story", "author", "style"];
204
205
  /** 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. */
205
- export const playerSettingNames = ["difficulty", "lethality", "saves", "rigor", "mentor", "learned", "prose", "story", "author", "style", "dice", "units", "voices", "pictures", "effort", "lines", "veils", "language"];
206
+ export const playerSettingNames = [
207
+ "difficulty",
208
+ "lethality",
209
+ "saves",
210
+ "rigor",
211
+ "mentor",
212
+ "learned",
213
+ "prose",
214
+ "story",
215
+ "author",
216
+ "style",
217
+ "dice",
218
+ "master-rolls",
219
+ "units",
220
+ "voices",
221
+ "pictures",
222
+ "effort",
223
+ "lines",
224
+ "veils",
225
+ "language",
226
+ ];
206
227
  // What each of the player's settings is, and what its values mean to the player, in their words rather than the master's.
207
228
  const playerWords = {
208
229
  difficulty: {
@@ -278,6 +299,12 @@ const playerWords = {
278
299
  cleared: "their own words on how you write no longer hold",
279
300
  },
280
301
  dice: { about: "who rolls your character's dice", values: diceWays, means: { digital: "the engine rolls them", physical: "you roll your own and tell the values" } },
302
+ "master-rolls": {
303
+ about: "the master's rolls for foes and the characters you meet; yours and your companions' are always in view",
304
+ values: masterRollWays,
305
+ means: { "behind the screen": "hidden: the master tells you only what comes of them", "in view": "shown among the rolls, beside yours" },
306
+ unset: "behind the screen",
307
+ },
281
308
  units: { about: "the units of the story", values: unitSystems, means: { metric: "metres and kilometres", imperial: "feet and miles" } },
282
309
  voices: {
283
310
  about: "who speaks for the characters you meet",
@@ -326,11 +353,11 @@ const setupWords = {
326
353
  };
327
354
  // The setup's questions, in the order the player meets them on the dashboard: how well they know the game, how it plays, how it is rolled, who comes along,
328
355
  // then the limits.
329
- const setupOrder = ["mentor", "difficulty", "lethality", "saves", "rigor", "dice", "units", "companions", "preparation"];
356
+ const setupOrder = ["mentor", "difficulty", "lethality", "saves", "rigor", "dice", "master-rolls", "units", "companions", "preparation"];
330
357
  // The mentor as the setup asks it (D-347): how well the player knows the game, each answer a way of the mentor, from the newest player's.
331
358
  const mentorAnswers = { tutorial: "never played it", hints: "a little", off: "I know it" };
332
359
  // The values the game suggests in the setup, as the design has them by default (D-370): never chosen for the player.
333
- const suggestedValues = { saves: "checkpoint", rigor: "smooth", preparation: "on the fly" };
360
+ const suggestedValues = { saves: "checkpoint", rigor: "smooth", "master-rolls": "behind the screen", preparation: "on the fly" };
334
361
  // The lethality the difficulty suggests (D-141).
335
362
  const suggestedLethality = { story: "narrative", easy: "epic" };
336
363
  /**
@@ -344,13 +371,19 @@ export function setupQuestions(root, context, writtenWorld) {
344
371
  return setting === undefined ? [] : [setting];
345
372
  };
346
373
  const system = (campaignSystem(root, context)?.settings ?? []).map((setting) => setting.name);
347
- const difficulty = readSettings(root).difficulty;
374
+ const settings = readSettings(root);
375
+ const difficulty = settings.difficulty;
348
376
  const suggested = { ...suggestedValues, ...(difficulty === undefined ? {} : { lethality: suggestedLethality[difficulty] ?? "dice" }) };
349
377
  return [...setupOrder.filter((name) => name !== "preparation" || !writtenWorld), ...system, "lines", "veils"].flatMap(named).map((question) => ({
350
- ...(question.name === "mentor" ? mentorQuestion(question) : question),
378
+ ...(question.name === "mentor" ? mentorQuestion(question) : unsetUnanswered(question, settings)),
351
379
  ...(suggested[question.name] === undefined ? {} : { suggested: suggested[question.name] }),
352
380
  }));
353
381
  }
382
+ /** A question whose value is only the one shown while it is unset, as master-rolls behind the screen (D-287): still unanswered in the setup. */
383
+ function unsetUnanswered(question, settings) {
384
+ const { value, ...unanswered } = question;
385
+ return value !== undefined && wordsOf(question.name)?.unset === value && settings[question.name] === undefined ? unanswered : question;
386
+ }
354
387
  /** The mentor as the setup asks it (D-347): how well the player knows the game, never played it first. */
355
388
  function mentorQuestion(question) {
356
389
  const order = Object.keys(mentorAnswers);
@@ -507,7 +540,7 @@ function shownValue(root, context, settings, name) {
507
540
  return settings[name] ?? {};
508
541
  }
509
542
  // How the master writes, unset: the core's own ways, never missing (D-395).
510
- // 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).
543
+ // 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).
511
544
  const own = {
512
545
  prose: "plain (as your instructions write)",
513
546
  story: "situations (as your instructions write)",
@@ -515,6 +548,7 @@ function shownValue(root, context, settings, name) {
515
548
  style: "(none)",
516
549
  effort: "(the app's own: the player's to choose)",
517
550
  voices: "auto (a subagent at key moments, as you choose, where the app has them)",
551
+ "master-rolls": "behind the screen (unset: roll hides your rolls for foes and NPCs)",
518
552
  };
519
553
  if (settings[name] === undefined && Object.hasOwn(own, name)) {
520
554
  return own[name];
@@ -0,0 +1,17 @@
1
+ import type { Context } from "../core/context.ts";
2
+ import type { LogEntry } from "../core/log.ts";
3
+ /** What the master is told of a roll the setting hid. */
4
+ export declare const screenNote = "Behind the screen, as master-rolls says: tell only the outcome, in the story.";
5
+ /**
6
+ * Whether the master-rolls setting hides a roll of who: one for anyone the party does not hold, by name or alias, as a foe's copy in the scene or a name of
7
+ * no page; never a roll of no one, as an oracle's.
8
+ */
9
+ export declare function behindTheScreen(root: string, context: Context, who: string | undefined): boolean;
10
+ /** Whether who is the player character or a companion, by name or alias, dead ones too. */
11
+ export declare function ofTheParty(root: string, context: Context, who: string): boolean;
12
+ /** Whether the campaign keeps the master's own rolls, as a table's or the oracle's, behind the screen: unless master-rolls says in view. */
13
+ export declare function screenUp(root: string): boolean;
14
+ /** Whether who names no page and no copy in the open scene: a stranger named in words, or a party member named wrongly. */
15
+ export declare function namesNoOne(root: string, context: Context, who: string): boolean;
16
+ /** Seals a hidden roll's line with its proof, kept for a reveal, and gives the fingerprint the player may ask for. */
17
+ export declare function sealHiddenRoll(entry: LogEntry, text: string, context: Context): string;
@@ -0,0 +1,36 @@
1
+ // The master's rolls for anyone outside the party (D-287): hidden behind the screen, as the master-rolls setting has them when unset too, or in view.
2
+ import { readTextSetting } from "../campaign/index.js";
3
+ import { sameName } from "../core/text.js";
4
+ import { createProof, fingerprint } from "../dice/index.js";
5
+ import { isPartyMember, pagesWithNameOrAlias } from "../pages/index.js";
6
+ import { readOpenScene } from "./game-scene.js";
7
+ import { campaignWorld } from "./game-world.js";
8
+ /** What the master is told of a roll the setting hid. */
9
+ export const screenNote = "Behind the screen, as master-rolls says: tell only the outcome, in the story.";
10
+ /**
11
+ * Whether the master-rolls setting hides a roll of who: one for anyone the party does not hold, by name or alias, as a foe's copy in the scene or a name of
12
+ * no page; never a roll of no one, as an oracle's.
13
+ */
14
+ export function behindTheScreen(root, context, who) {
15
+ return who !== undefined && screenUp(root) && !ofTheParty(root, context, who);
16
+ }
17
+ /** Whether who is the player character or a companion, by name or alias, dead ones too. */
18
+ export function ofTheParty(root, context, who) {
19
+ return pagesWithNameOrAlias(campaignWorld(root, context), who).some(isPartyMember);
20
+ }
21
+ /** Whether the campaign keeps the master's own rolls, as a table's or the oracle's, behind the screen: unless master-rolls says in view. */
22
+ export function screenUp(root) {
23
+ return readTextSetting(root, "master-rolls") !== "in view";
24
+ }
25
+ /** Whether who names no page and no copy in the open scene: a stranger named in words, or a party member named wrongly. */
26
+ export function namesNoOne(root, context, who) {
27
+ const copies = Object.keys(readOpenScene(root).scene?.copies ?? {});
28
+ return pagesWithNameOrAlias(campaignWorld(root, context), who).length === 0 && sameName(copies, who) === undefined;
29
+ }
30
+ /** Seals a hidden roll's line with its proof, kept for a reveal, and gives the fingerprint the player may ask for. */
31
+ export function sealHiddenRoll(entry, text, context) {
32
+ const proof = createProof(entry.id, text, context.newSalt());
33
+ const shown = fingerprint(proof);
34
+ Object.assign(entry.data, { proof, fingerprint: shown });
35
+ return shown;
36
+ }
@@ -1,6 +1,6 @@
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, missingSettings, preparations, readSettings, readStateValues, rigors, saveModes, unansweredSettings, unitSystems } from "../campaign/index.js";
3
+ import { companionWays, diceWays, difficulties, 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";
@@ -21,6 +21,7 @@ const settingLabels = {
21
21
  saves: `saves (${saveModes.join(", ")})`,
22
22
  rigor: `rigor (${rigors.join(", ")})`,
23
23
  dice: `dice (${diceWays.join(", ")})`,
24
+ "master-rolls": `master-rolls (your rolls for foes and NPCs: ${masterRollWays.join(", ")}; suggest behind the screen)`,
24
25
  units: `units (${unitSystems.join(", ")})`,
25
26
  companions: `companions (${companionWays.join(", ")})`,
26
27
  "calendar-start": "calendar-start (when the story starts: day 1 to count only the days, or a day of the world, such as 14 April 1491)",
@@ -9,6 +9,7 @@ import { withEffect } from "../effects/index.js";
9
9
  import { concernsPlayer, isPartyMember, isPlayerCharacter, pagesWithName, writePage } from "../pages/index.js";
10
10
  import { effectiveFields, effectsOf } from "./effect-layer.js";
11
11
  import { saveEffects } from "./game-effects.js";
12
+ import { behindTheScreen, sealHiddenRoll } from "./game-master-rolls.js";
12
13
  import { keepingConditionNote } from "./game-reminders.js";
13
14
  import { readOpenScene } from "./game-scene.js";
14
15
  import { newDatedLogEntry } from "./game-time.js";
@@ -95,7 +96,13 @@ function game(root, context) {
95
96
  endEffect: (name, effect, why) => endEffect(root, context, name, effect, why),
96
97
  roll: (notation, by) => {
97
98
  const rolled = rollDice(notation, { random: context.random });
98
- appendLogEntry(root, newDatedLogEntry(root, context, "roll", "public", { notation: rolled.notation, total: rolled.total, result: rolled.text, why: by.why, who: by.who, physical: false, dice: rolled.dice }));
99
+ // For anyone outside the party, hidden as the master-rolls setting says (D-287).
100
+ const hidden = behindTheScreen(root, context, by.who);
101
+ const entry = newDatedLogEntry(root, context, "roll", hidden ? "hidden" : "public", { notation: rolled.notation, total: rolled.total, result: rolled.text, why: by.why, who: by.who, physical: false, dice: rolled.dice });
102
+ if (hidden) {
103
+ sealHiddenRoll(entry, rolled.text, context);
104
+ }
105
+ appendLogEntry(root, entry);
99
106
  return { total: rolled.total, dice: rolled.dice, text: rolled.text };
100
107
  },
101
108
  };
@@ -0,0 +1,7 @@
1
+ import type { Context } from "../core/context.ts";
2
+ import { type FaceSource, type TableRoll } from "../dice/index.ts";
3
+ /** A roll on the table of a page's section, given as Page#Section; refused, saying what to fix, before anything is rolled. */
4
+ export declare function rollPageTable(root: string, context: Context, reference: string, source: FaceSource): TableRoll & {
5
+ table: string;
6
+ secret: boolean;
7
+ };
@@ -0,0 +1,40 @@
1
+ import { comparableText } from "../core/text.js";
2
+ import { DiceError, readRandomTable, rollOnTable } from "../dice/index.js";
3
+ import { baseChain, findPage, firstTable, pageNamed, parsePageReference, readSection, secretNames, sectionTitles } from "../pages/index.js";
4
+ import { campaignWorld, missingSystemHint } from "./game-world.js";
5
+ /** A roll on the table of a page's section, given as Page#Section; refused, saying what to fix, before anything is rolled. */
6
+ export function rollPageTable(root, context, reference, source) {
7
+ const { name, section } = parsePageReference(reference);
8
+ if (name.trim() === "") {
9
+ throw new Error(`Give the page before #, such as Colli di Vallerana#${section ?? "Incontri"}. Nothing rolled.`);
10
+ }
11
+ if (section === undefined || section === "") {
12
+ throw new Error(`Give the section that holds the table after #, such as ${name || "Colli di Vallerana"}#Incontri. Nothing rolled.`);
13
+ }
14
+ const world = campaignWorld(root, context);
15
+ const page = findPage(world, name) ?? pageNamed(world, name);
16
+ if (page === undefined) {
17
+ throw new Error(`There is no page named ${name}: give the page and the section of its table, such as Colli di Vallerana#Incontri; look for the page with the find command.${missingSystemHint(world)} Nothing rolled.`);
18
+ }
19
+ // The page's own section, or its nearest base's (INH-13).
20
+ const text = [page, ...baseChain(world, page)].map((holder) => readSection(holder.body, section)).find((found) => found !== undefined);
21
+ if (text === undefined) {
22
+ const titles = sectionTitles(page.body);
23
+ throw new Error(`${page.name} has no section "${section}". ${titles.length === 0 ? "It has no sections." : `Its sections are: ${titles.join(", ")}.`} Nothing rolled.`);
24
+ }
25
+ const table = firstTable(text);
26
+ if (table === undefined) {
27
+ throw new Error(`${page.name}#${section} holds no table: write one under its heading, the die in the first header cell and each row's numbers in the first column, such as | d8 | Encounter |, |---|---|, | 1–2 | Wolves |. Nothing rolled.`);
28
+ }
29
+ try {
30
+ // A table in a secret, or a secret named after #, is the master's alone.
31
+ const secret = table.secret || secretNames(page.body).some((one) => comparableText(one) === comparableText(section));
32
+ return { ...rollOnTable(readRandomTable(table.rows), source), table: `${page.name}#${section}`, secret };
33
+ }
34
+ catch (error) {
35
+ if (error instanceof DiceError) {
36
+ throw new Error(`The table of ${page.name}#${section}: ${error.message} Nothing rolled.`);
37
+ }
38
+ throw error;
39
+ }
40
+ }
@@ -94,7 +94,7 @@ function lifestylePaid(root, context, world, member, lifestyle) {
94
94
  // A lifestyle of the campaign's has no price the system knows: the master charges it.
95
95
  return typeof chosen === "string" && chosen.trim() !== ""
96
96
  ? `${member.name}'s ${lifestyle.field} ${chosen} has no price here: charge the day with change ${member.name} money, or set one of ${names.join(", ")}. Read ${lifestyle.rules}.`
97
- : `${member.name} has no ${lifestyle.field} to pay a day in a settlement: ${who}set ${lifestyle.field}=${example}, one of ${names.join(", ")}. Read ${lifestyle.rules}.`;
97
+ : `${member.name} has no ${lifestyle.field} to pay a day in a settlement: ${who}set ${lifestyle.field}=${example}, one of ${names.join(", ")}; or, for a night paid on its own or board earned by work, charge it with change ${member.name} money, if not yet charged. Read ${lifestyle.rules}.`;
98
98
  }
99
99
  const price = coins === undefined ? undefined : readAmount(lifestyle.costs[named], coins);
100
100
  if (coins === undefined || price === undefined || totalOf(price, coins) === 0) {
@@ -187,11 +187,13 @@ async function installed(root, context, name) {
187
187
  throw new Error("Packages are installed only by the game's server or the command line, which reach npm.");
188
188
  }
189
189
  // A name alone is one of ours: weather is @rpgengine/weather, never a stranger's of that name, which is given as npm:weather.
190
- const spec = name.startsWith("npm:") ? name.slice(4) : isLocalSpec(name) || name.startsWith("@") ? name : `${verifiedScope}${name}`;
191
- const described = await packages.describe(spec);
190
+ const asked = name.startsWith("npm:") ? name.slice(4) : isLocalSpec(name) || name.startsWith("@") ? name : `${verifiedScope}${name}`;
191
+ const described = await packages.describe(asked);
192
192
  if ("failed" in described) {
193
- throw new Error(`${described.failed}. Nothing changed${spec === name ? "" : `: ${name} alone means ${spec}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`);
193
+ throw new Error(`${described.failed}. Nothing changed${asked === name ? "" : `: ${name} alone means ${asked}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`);
194
194
  }
195
+ // npm is given the version described, which the player's yes was for: by its name alone, npm would keep the exact version it saved before.
196
+ const spec = isLocalSpec(asked) ? asked : `${described.name}@${described.version}`;
195
197
  if (described.kind === "system") {
196
198
  return await systemInstalled(root, context, spec, name, described);
197
199
  }
@@ -15,6 +15,8 @@ export declare const roll: import("../core/registry.ts").Command<z.ZodObject<{
15
15
  use: z.ZodOptional<z.ZodString>;
16
16
  from: z.ZodOptional<z.ZodString>;
17
17
  double: z.ZodOptional<z.ZodBoolean>;
18
+ table: z.ZodOptional<z.ZodString>;
19
+ oracle: z.ZodOptional<z.ZodString>;
18
20
  }, z.core.$strip>, {
19
21
  kind: "roll";
20
22
  id: string;
@@ -25,6 +27,8 @@ export declare const roll: import("../core/registry.ts").Command<z.ZodObject<{
25
27
  check?: string;
26
28
  physical: boolean;
27
29
  hidden: boolean;
30
+ screened?: true;
31
+ stranger?: true;
28
32
  fingerprint?: string;
29
33
  note?: string;
30
34
  kept?: string;