rpg-engine 0.12.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.
Files changed (146) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/choices.d.ts +30 -0
  3. package/dist/campaign/choices.js +84 -0
  4. package/dist/campaign/index.d.ts +4 -1
  5. package/dist/campaign/index.js +4 -1
  6. package/dist/campaign/last-choices.d.ts +6 -0
  7. package/dist/campaign/last-choices.js +34 -0
  8. package/dist/campaign/levels.d.ts +50 -0
  9. package/dist/campaign/levels.js +189 -0
  10. package/dist/campaign/settings.d.ts +35 -13
  11. package/dist/campaign/settings.js +20 -51
  12. package/dist/commands/ask.d.ts +8 -0
  13. package/dist/commands/ask.js +2 -1
  14. package/dist/commands/change/change.js +6 -4
  15. package/dist/commands/choices.d.ts +64 -0
  16. package/dist/commands/choices.js +216 -0
  17. package/dist/commands/config.d.ts +8 -1
  18. package/dist/commands/config.js +165 -21
  19. package/dist/commands/effect.d.ts +1 -1
  20. package/dist/commands/index.js +2 -0
  21. package/dist/commands/init.d.ts +1 -0
  22. package/dist/commands/init.js +8 -4
  23. package/dist/commands/rename.js +8 -3
  24. package/dist/commands/save.d.ts +1 -1
  25. package/dist/commands/shared/experience.d.ts +9 -2
  26. package/dist/commands/shared/experience.js +42 -7
  27. package/dist/commands/shared/inputs.d.ts +2 -2
  28. package/dist/commands/shared/inputs.js +15 -2
  29. package/dist/commands/shared/knowledge.d.ts +2 -0
  30. package/dist/commands/shared/knowledge.js +5 -0
  31. package/dist/commands/shared/mode.js +10 -3
  32. package/dist/commands/shared/offers.d.ts +3 -1
  33. package/dist/commands/shared/offers.js +6 -1
  34. package/dist/commands/shared/page-words.d.ts +4 -0
  35. package/dist/commands/shared/page-words.js +7 -7
  36. package/dist/commands/shared/rules.js +5 -1
  37. package/dist/commands/shared/system-texts.d.ts +11 -0
  38. package/dist/commands/shared/system-texts.js +203 -0
  39. package/dist/commands/shared/time.d.ts +6 -0
  40. package/dist/commands/shared/time.js +35 -3
  41. package/dist/commands/shared/upkeep.js +3 -3
  42. package/dist/commands/shared/world.d.ts +2 -0
  43. package/dist/commands/shared/world.js +20 -7
  44. package/dist/commands/status.d.ts +2 -0
  45. package/dist/commands/status.js +15 -7
  46. package/dist/commands/view/view.d.ts +4 -0
  47. package/dist/commands/view/view.js +24 -10
  48. package/dist/commands/write/write.d.ts +3 -3
  49. package/dist/commands/write/write.js +5 -2
  50. package/dist/core/context.d.ts +16 -0
  51. package/dist/core/files.js +2 -3
  52. package/dist/core/language.d.ts +2 -0
  53. package/dist/core/language.js +8 -0
  54. package/dist/core/text.d.ts +2 -0
  55. package/dist/core/text.js +5 -0
  56. package/dist/dashboard/address.js +8 -1
  57. package/dist/dashboard/api.js +20 -0
  58. package/dist/dashboard/app.js +20 -7
  59. package/dist/dashboard/choices.js +338 -0
  60. package/dist/dashboard/guide/ar.md +8 -8
  61. package/dist/dashboard/guide/cs.md +8 -8
  62. package/dist/dashboard/guide/da.md +9 -9
  63. package/dist/dashboard/guide/de.md +8 -8
  64. package/dist/dashboard/guide/el.md +10 -10
  65. package/dist/dashboard/guide/en.md +7 -7
  66. package/dist/dashboard/guide/es.md +8 -8
  67. package/dist/dashboard/guide/fi.md +8 -8
  68. package/dist/dashboard/guide/fr.md +8 -8
  69. package/dist/dashboard/guide/he.md +8 -8
  70. package/dist/dashboard/guide/hi.md +8 -8
  71. package/dist/dashboard/guide/hu.md +8 -8
  72. package/dist/dashboard/guide/is.md +9 -9
  73. package/dist/dashboard/guide/it.md +8 -8
  74. package/dist/dashboard/guide/ja.md +8 -8
  75. package/dist/dashboard/guide/ko.md +9 -9
  76. package/dist/dashboard/guide/nb.md +9 -9
  77. package/dist/dashboard/guide/nl.md +8 -8
  78. package/dist/dashboard/guide/pl.md +8 -8
  79. package/dist/dashboard/guide/pt.md +8 -8
  80. package/dist/dashboard/guide/ro.md +8 -8
  81. package/dist/dashboard/guide/ru.md +8 -8
  82. package/dist/dashboard/guide/sv.md +8 -8
  83. package/dist/dashboard/guide/tr.md +8 -8
  84. package/dist/dashboard/guide/uk.md +8 -8
  85. package/dist/dashboard/guide/zh.md +8 -8
  86. package/dist/dashboard/i18n/ar.json +81 -1
  87. package/dist/dashboard/i18n/cs.json +81 -1
  88. package/dist/dashboard/i18n/da.json +81 -1
  89. package/dist/dashboard/i18n/de.json +81 -1
  90. package/dist/dashboard/i18n/el.json +81 -1
  91. package/dist/dashboard/i18n/es.json +81 -1
  92. package/dist/dashboard/i18n/fi.json +81 -1
  93. package/dist/dashboard/i18n/fr.json +81 -1
  94. package/dist/dashboard/i18n/he.json +81 -1
  95. package/dist/dashboard/i18n/hi.json +81 -1
  96. package/dist/dashboard/i18n/hu.json +81 -1
  97. package/dist/dashboard/i18n/is.json +81 -1
  98. package/dist/dashboard/i18n/it.json +81 -1
  99. package/dist/dashboard/i18n/ja.json +81 -1
  100. package/dist/dashboard/i18n/ko.json +81 -1
  101. package/dist/dashboard/i18n/nb.json +81 -1
  102. package/dist/dashboard/i18n/nl.json +81 -1
  103. package/dist/dashboard/i18n/pl.json +81 -1
  104. package/dist/dashboard/i18n/pt.json +81 -1
  105. package/dist/dashboard/i18n/ro.json +81 -1
  106. package/dist/dashboard/i18n/ru.json +81 -1
  107. package/dist/dashboard/i18n/sv.json +81 -1
  108. package/dist/dashboard/i18n/tr.json +81 -1
  109. package/dist/dashboard/i18n/uk.json +81 -1
  110. package/dist/dashboard/i18n/zh.json +81 -1
  111. package/dist/dashboard/icons.js +4 -0
  112. package/dist/dashboard/labels.js +32 -0
  113. package/dist/dashboard/notices.js +9 -2
  114. package/dist/dashboard/party.js +13 -5
  115. package/dist/dashboard/saves.js +1 -1
  116. package/dist/dashboard/settings.js +89 -40
  117. package/dist/dashboard/setup.js +1 -1
  118. package/dist/dashboard/sheet.js +3 -2
  119. package/dist/dashboard/style.css +729 -1
  120. package/dist/dashboard/text.js +7 -2
  121. package/dist/dashboard/top.js +8 -4
  122. package/dist/documents/png.d.ts +2 -3
  123. package/dist/documents/png.js +6 -6
  124. package/dist/documents/read.js +2 -1
  125. package/dist/extensions/words.js +2 -1
  126. package/dist/languages/language-pack.js +2 -2
  127. package/dist/pages/index.d.ts +1 -1
  128. package/dist/pages/index.js +1 -1
  129. package/dist/pages/world.d.ts +5 -0
  130. package/dist/pages/world.js +22 -11
  131. package/dist/server/dashboard/choices.d.ts +38 -0
  132. package/dist/server/dashboard/choices.js +174 -0
  133. package/dist/server/dashboard/files.js +3 -2
  134. package/dist/server/dashboard/index.d.ts +3 -1
  135. package/dist/server/dashboard/index.js +20 -2
  136. package/dist/server/mcp.js +3 -1
  137. package/dist/systems/game-system.js +2 -1
  138. package/dist/systems/words.js +2 -1
  139. package/dist/testing/index.js +1 -1
  140. package/dist/time/game-date.d.ts +9 -0
  141. package/dist/time/game-date.js +9 -0
  142. package/dist/time/index.d.ts +1 -1
  143. package/dist/time/index.js +1 -1
  144. package/instructions/dashboard-guide.md +1 -1
  145. package/instructions/play.md +1 -1
  146. package/package.json +4 -4
@@ -28,6 +28,8 @@ export const shippedLanguages = [
28
28
  ];
29
29
  // Codes the page reads as another it ships: Norwegian as Bokmål.
30
30
  const aliases = { no: "nb" };
31
+ // Chinese in traditional characters, whose base zh is the simplified.
32
+ const traditionalChinese = /^zh-(hant|tw|hk|mo)(-|$)/;
31
33
  // The languages written from right to left, shipped or translated on the fly: the page mirrors for them.
32
34
  const rightToLeft = ["ar", "he", "fa", "ur", "ps", "sd", "ug", "yi", "dv", "ckb"];
33
35
  let phrases = {};
@@ -42,10 +44,13 @@ let flying;
42
44
  const lacked = new Set();
43
45
  const asked = new Set();
44
46
  let asking;
45
- /** The language the page writes in for a campaign's code: its own when shipped, else its base language's (pt-BR, pt), else English. */
47
+ /**
48
+ * The language the page writes in for a campaign's code: its own when shipped, else its base language's when written in the same script (pt-BR, pt; never
49
+ * zh-HK, zh, which is simplified), else English.
50
+ */
46
51
  export function pageLanguageOf(code) {
47
52
  const asked = (code ?? "en").toLowerCase();
48
- const base = asked.split("-")[0];
53
+ const base = traditionalChinese.test(asked) ? "" : asked.split("-")[0];
49
54
  return [asked, base, aliases[base] ?? ""].find((one) => shippedLanguages.includes(one)) ?? "en";
50
55
  }
51
56
  /** The browser's language, where the package ships it: the page's until the setup sets the campaign's (playtest 01); none for English or another. */
@@ -30,14 +30,14 @@ export function Top(top) {
30
30
  setPoke({ id: String(Date.now()), mood: pokedMoods[Date.now() % pokedMoods.length] ?? "happy" });
31
31
  };
32
32
  const title = top.campaign ?? top.product;
33
- return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: room, class: "top-room", children: [_jsx("span", { class: "top-mark far", "aria-hidden": "true" }), _jsx("span", { class: "top-mark near", "aria-hidden": "true" })] }), _jsxs("header", { ref: header, class: compact ? "top compact" : "top", children: [_jsx(MasterHome, { top: top, poke: poke, onHome: home }), _jsxs("div", { class: "titles", children: [_jsx("h1", { dir: "auto", children: _jsx("a", { class: "title-home", dir: "auto", href: sectionAddress("party"), onClick: home, children: title }) }), top.campaign !== undefined && (_jsxs("p", { class: "product", children: [top.product, top.system && _jsx("span", { class: "system-chip", children: top.system })] })), top.campaign !== undefined && top.now !== undefined && _jsx("p", { class: "product-time", children: gameDateLabel(top.now) })] }), _jsx(StatusChips, { now: top.now, calendar: top.calendar, live: top.live }), _jsx(Navigation, { current: top.section, fight: top.fight, yourTurn: top.yourTurn, turnName: top.turnName, ownPages: top.ownPages ?? [], ownShown: top.ownShown }), top.path !== undefined && top.path.length > 0 && _jsx(PlacePath, { path: top.path })] }), _jsx(ThemeCorner, {})] }));
33
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: room, class: "top-room", children: [_jsx("span", { class: "top-mark far", "aria-hidden": "true" }), _jsx("span", { class: "top-mark near", "aria-hidden": "true" })] }), _jsxs("header", { ref: header, class: compact ? "top compact" : "top", children: [_jsx(MasterHome, { top: top, poke: poke, onHome: home }), _jsxs("div", { class: "titles", children: [_jsx("h1", { dir: "auto", children: _jsx("a", { class: "title-home", dir: "auto", href: sectionAddress("party"), onClick: home, children: title }) }), top.campaign !== undefined && (_jsxs("p", { class: "product", children: [top.product, top.system && _jsx("span", { class: "system-chip", children: top.system })] })), top.campaign !== undefined && top.now !== undefined && _jsx("p", { class: "product-time", children: gameDateLabel(top.now) })] }), _jsx(StatusChips, { now: top.now, calendar: top.calendar, live: top.live }), _jsx(Navigation, { current: top.section, fight: top.fight, yourTurn: top.yourTurn, turnName: top.turnName, ownPages: top.ownPages ?? [], ownShown: top.ownShown, choices: top.choices }), top.path !== undefined && top.path.length > 0 && _jsx(PlacePath, { path: top.path })] }), _jsx(ThemeCorner, {})] }));
34
34
  }
35
35
  /**
36
36
  * The sections, each a link to its address (D-276, D-309), the one shown marked, then the packages' pages that are tabs (D-512); then the saves, Help, the
37
37
  * settings, the packages and About as icons at the row's end (D-333, D-409), the packages a menu of the packages' other pages when they have some: what does
38
38
  * not fit goes into the menu, those icons first, then the tabs from the last.
39
39
  */
40
- function Navigation({ current, fight, yourTurn, turnName, ownPages, ownShown }) {
40
+ function Navigation({ current, fight, yourTurn, turnName, ownPages, ownShown, choices }) {
41
41
  // While the scene goes by turns the Scene's name is in gold; on the player's turn, from another section, it pulses (D-315, D-349, D-351, D-444).
42
42
  const turns = fight === true && current !== "scene";
43
43
  const turn = yourTurn === true && current !== "scene";
@@ -51,8 +51,12 @@ function Navigation({ current, fight, yourTurn, turnName, ownPages, ownShown })
51
51
  const gone = awayTabs.includes(tab);
52
52
  const kinds = [tab.key === "scene" && turns ? (turn ? "your-turn" : "in-turns") : "", tab.own ? "own-tab" : "", gone ? "away" : ""];
53
53
  // The scene's whole name for a screen reader in a turn: Scene, your turn.
54
- const named = tab.key === "scene" && turn ? `${tab.label}, ${turnName === undefined ? t("your turn") : t("It's {name}'s turn", { name: turnName })}` : undefined;
55
- return (_jsxs("a", { href: tab.href, class: kinds.filter((kind) => kind !== "").join(" ") || undefined, "aria-label": named, "aria-current": tab.current ? "page" : undefined, "aria-hidden": gone ? true : undefined, tabIndex: gone ? -1 : undefined, children: [_jsx("span", { class: "section-mark", children: tab.icon }), _jsx("span", { class: "section-name", dir: "auto", children: tab.label })] }, tab.key));
54
+ const named = tab.key === "scene" && turn
55
+ ? `${tab.label}, ${turnName === undefined ? t("your turn") : t("It's {name}'s turn", { name: turnName })}`
56
+ : tab.key === "party" && choices === true
57
+ ? t("Party, choices waiting")
58
+ : undefined;
59
+ return (_jsxs("a", { href: tab.href, class: kinds.filter((kind) => kind !== "").join(" ") || undefined, "aria-label": named, "aria-current": tab.current ? "page" : undefined, "aria-hidden": gone ? true : undefined, tabIndex: gone ? -1 : undefined, children: [_jsxs("span", { class: "section-mark", children: [tab.icon, tab.key === "party" && choices === true && _jsx("span", { class: "choices-dot", "aria-hidden": "true" })] }), _jsx("span", { class: "section-name", dir: "auto", children: tab.label })] }, tab.key));
56
60
  }), menuPages.map((page, index) => {
57
61
  const gone = !fitting.pages;
58
62
  const kinds = ["page-link tip-below", index === 0 ? "pages-start" : "", gone ? "away" : ""].filter((kind) => kind !== "").join(" ");
@@ -1,9 +1,8 @@
1
- /** Raw pixels: one, three or four bytes for each, row after row. */
1
+ /** Raw pixels: four bytes for each, red, green, blue and alpha, row after row. */
2
2
  export interface Pixels {
3
- data: Uint8Array | Uint8ClampedArray;
3
+ data: Uint8Array;
4
4
  width: number;
5
5
  height: number;
6
- channels: 1 | 3 | 4;
7
6
  }
8
7
  /** The pixels as a PNG, made smaller when their longer side passes `longest`. */
9
8
  export declare function pngOf(pixels: Pixels, longest: number): Uint8Array;
@@ -1,9 +1,9 @@
1
- // Pixels as a PNG file, for the pictures a PDF holds as raw pixels (D-489 (8)): RGB or RGBA, at most a size on its longer side.
1
+ // Pixels as a PNG file, for the pictures a PDF holds as raw pixels (D-489 (8)): RGBA, at most a size on its longer side.
2
2
  import { zlibSync } from "fflate";
3
+ const channels = 4;
3
4
  /** The pixels as a PNG, made smaller when their longer side passes `longest`. */
4
5
  export function pngOf(pixels, longest) {
5
- const { data, width, height, channels } = smaller(pixels, longest);
6
- const kind = channels === 4 ? 6 : channels === 3 ? 2 : 0;
6
+ const { data, width, height } = smaller(pixels, longest);
7
7
  const row = width * channels;
8
8
  const raw = new Uint8Array((row + 1) * height);
9
9
  for (let y = 0; y < height; y++) {
@@ -13,7 +13,8 @@ export function pngOf(pixels, longest) {
13
13
  const view = new DataView(header.buffer);
14
14
  view.setUint32(0, width);
15
15
  view.setUint32(4, height);
16
- header.set([8, kind, 0, 0, 0], 8);
16
+ // Eight bits a channel, colour type 6: RGBA.
17
+ header.set([8, 6, 0, 0, 0], 8);
17
18
  return joined([new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", header), chunk("IDAT", zlibSync(raw, { level: 6 })), chunk("IEND", new Uint8Array(0))]);
18
19
  }
19
20
  // The pixels shrunk by a whole step, each new one the mean of the square it covers, until the longer side fits.
@@ -24,7 +25,6 @@ function smaller(pixels, longest) {
24
25
  }
25
26
  const width = Math.floor(pixels.width / step);
26
27
  const height = Math.floor(pixels.height / step);
27
- const { channels } = pixels;
28
28
  const data = new Uint8Array(width * height * channels);
29
29
  for (let y = 0; y < height; y++) {
30
30
  for (let x = 0; x < width; x++) {
@@ -39,7 +39,7 @@ function smaller(pixels, longest) {
39
39
  }
40
40
  }
41
41
  }
42
- return { data, width, height, channels };
42
+ return { data, width, height };
43
43
  }
44
44
  function chunk(type, body) {
45
45
  const out = new Uint8Array(body.length + 12);
@@ -94,7 +94,8 @@ async function readFolder(folder, options) {
94
94
  */
95
95
  async function readPdf(path, options) {
96
96
  const { extractText, getDocumentProxy } = await import("unpdf");
97
- const pdf = await getDocumentProxy(new Uint8Array(readFileSync(path))).catch((error) => {
97
+ // pdf.js says its warnings on the standard output, which is the MCP server's channel: errors only.
98
+ const pdf = await getDocumentProxy(new Uint8Array(readFileSync(path)), { verbosity: 0 }).catch((error) => {
98
99
  throw error?.name === "PasswordException" ? new Error(`${basename(path)} asks for a password to open: the engine never opens a locked document.`) : error;
99
100
  });
100
101
  const { text } = await extractText(pdf, { mergePages: false });
@@ -2,6 +2,7 @@
2
2
  // the names of the fields it adds to the game system, and any word or phrase its widgets write, by the English as its code writes it. The core hands them on: a word the list lacks stays as written.
3
3
  import { join } from "node:path";
4
4
  import { z } from "zod";
5
+ import { codeAndBase } from "../core/language.js";
5
6
  import { files } from "../core/store.js";
6
7
  import { readYamlValues } from "../core/yaml-file.js";
7
8
  const wordsSchema = z.object({
@@ -12,7 +13,7 @@ const wordsSchema = z.object({
12
13
  }, { error: "write its title, its about, the names of its fields and its words, each from the text the code writes to the language's own, such as {words: {Weather: Meteo}}" }).strict();
13
14
  /** The words of the extension in this folder for a language, or for its base language (pt for pt-BR); undefined when it has none in it. It throws when they do not read. */
14
15
  export function extensionWords(folder, language) {
15
- const file = [language, language.split("-")[0]].map((code) => join(folder, "words", `${code.toLowerCase()}.yaml`)).find((path) => files().exists(path));
16
+ const file = codeAndBase(language).map((code) => join(folder, "words", `${code}.yaml`)).find((path) => files().exists(path));
16
17
  if (file === undefined) {
17
18
  return undefined;
18
19
  }
@@ -1,6 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { z } from "zod";
3
3
  import { packageFoldersIn } from "../core/files.js";
4
+ import { codeAndBase } from "../core/language.js";
4
5
  import { files } from "../core/store.js";
5
6
  import { readYamlValues } from "../core/yaml-file.js";
6
7
  /** The file that makes a package a language's (D-485 (3)): its code and its name. */
@@ -33,8 +34,7 @@ export function installedLanguages(folders) {
33
34
  /** The package for a language: its own code, else its base language's (pt for pt-BR); undefined when none is installed. */
34
35
  export function languagePackFor(folders, code) {
35
36
  const packs = installedLanguages(folders);
36
- const wanted = code.toLowerCase();
37
- return packs.find((pack) => pack.code.toLowerCase() === wanted) ?? packs.find((pack) => pack.code.toLowerCase() === wanted.split("-")[0]);
37
+ return codeAndBase(code).map((wanted) => packs.find((pack) => pack.code.toLowerCase() === wanted)).find((pack) => pack !== undefined);
38
38
  }
39
39
  /** A language package from its folder; it throws, saying what is wrong, when it does not read. */
40
40
  export function readLanguagePack(folder) {
@@ -14,5 +14,5 @@ export { countedText, entryOfKind, type EntryReading, readEntry, withStackCount
14
14
  export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, type HeldStack, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, type Stack, stackName, stacksOf } from "./stacks/kinds.ts";
15
15
  export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.ts";
16
16
  export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.ts";
17
- export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, type Page, pageFileNamed, type PageMatch, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, type SystemInfo, systemPageNamed, type SystemPages, textsIn, validHoldersOf, withPage, type World, } from "./world.ts";
17
+ export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, type Page, pageFileNamed, type PageMatch, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, type SystemInfo, systemPageNamed, type SystemPages, textsIn, validHoldersOf, versionTranslations, withPage, type World, } from "./world.ts";
18
18
  export { checkFieldChange, type PageChange, writePage } from "./write-page.ts";
@@ -15,5 +15,5 @@ export { countedText, entryOfKind, readEntry, withStackCount } from "./stacks/en
15
15
  export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, stackName, stacksOf } from "./stacks/kinds.js";
16
16
  export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.js";
17
17
  export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.js";
18
- export { backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, pageFileNamed, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, systemPageNamed, textsIn, validHoldersOf, withPage, } from "./world.js";
18
+ export { backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, pageFileNamed, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, systemPageNamed, textsIn, validHoldersOf, versionTranslations, withPage, } from "./world.js";
19
19
  export { checkFieldChange, writePage } from "./write-page.js";
@@ -105,6 +105,7 @@ export declare function loadWorld(root: string, options?: {
105
105
  system?: SystemInfo & {
106
106
  folder: string;
107
107
  version?: {
108
+ name: string;
108
109
  folder: string;
109
110
  };
110
111
  };
@@ -113,6 +114,8 @@ export declare function loadWorld(root: string, options?: {
113
114
  missingSystem?: string;
114
115
  noSystem?: boolean;
115
116
  rigor?: string;
117
+ /** The folder of the system's pages translated on this computer into the campaign's language (D-539), where the system has no translation of its own. */
118
+ ownTranslations?: string;
116
119
  }): World;
117
120
  /**
118
121
  * The page with this name, ignoring case and Unicode normalization: the campaign's, else the game system's (SYS-3). Two pages of the campaign with that name stop the command:
@@ -210,3 +213,5 @@ export declare function pageFileNamed(root: string, name: string): {
210
213
  } | undefined;
211
214
  /** The pages of the system's bonus lists a page names (FOR-5, D-449): an attuned ring, a feat; of a list given only while in another, only those in it too, as a ring worn (BND-4). */
212
215
  export declare function bonusPages(world: World, fields: Record<string, unknown>): Page[];
216
+ /** Where a version's pages translated on this computer are, under the folder of the language's (D-539). */
217
+ export declare function versionTranslations(version: string): string;
@@ -3,7 +3,7 @@ import { isReservedName } from "../core/archive-paths.js";
3
3
  import { translationFolder } from "../core/files.js";
4
4
  import { frozen } from "../core/frozen.js";
5
5
  import { files } from "../core/store.js";
6
- import { comparableText, valueNamed } from "../core/text.js";
6
+ import { comparableText, textPrint, valueNamed } from "../core/text.js";
7
7
  import { linkedPages, links } from "./markdown.js";
8
8
  import { readFields, splitPageFile } from "./page-file.js";
9
9
  import { pageTypes, typeOfFolder, worldFolderName } from "./page-types.js";
@@ -27,12 +27,15 @@ export function createWorld(root) {
27
27
  */
28
28
  export function loadWorld(root, options = {}) {
29
29
  const campaign = readPages(root);
30
- const { system, language, words, missingSystem, noSystem, rigor } = options;
30
+ const { system, language, words, missingSystem, noSystem, rigor, ownTranslations } = options;
31
31
  if (system === undefined) {
32
32
  return frozen({ root, ...campaign, language, missingSystem, noSystem, ...(rigor === undefined ? {} : { rigor }) });
33
33
  }
34
- const read = (folder) => translatedPages(packagePages(folder, system.name), folder, system.name, language);
35
- const systemPages = system.version === undefined ? read(system.folder) : versionPages(read(system.folder), read(system.version.folder));
34
+ const read = (folder, own) => translatedPages(packagePages(folder, system.name), folder, system.name, language, own);
35
+ // A version's pages translated on this computer have a folder of their own, as their text is the version's (D-539).
36
+ const systemPages = system.version === undefined
37
+ ? read(system.folder, ownTranslations)
38
+ : versionPages(read(system.folder, ownTranslations), read(system.version.folder, ownTranslations === undefined ? undefined : join(ownTranslations, versionTranslations(system.version.name))));
36
39
  const { name, title, fields, formulas, progression, itemFormulas, alwaysIn, uses, statusLine, load, lengthUnit, bonusLists, bonusWhile } = system;
37
40
  const problems = [...campaign.problems, ...systemPages.problems];
38
41
  return frozen({
@@ -364,27 +367,35 @@ function packagePages(folder, system) {
364
367
  const packages = new Map();
365
368
  /**
366
369
  * A system's pages with their text and their name in the campaign's language beside their own, where the system has a translation of them in it, by the same
367
- * path under translations/<language> (D-542); their fields and text stay, which the engine reads. Read once in a process, as the pages are.
370
+ * path under translations/<language> (D-542); their fields and text stay, which the engine reads. Read once in a process, as the pages are. Where the system
371
+ * has none, those translated on this computer (D-539), each while the text it was made from is the page's: read through the store, as they grow.
368
372
  */
369
- function translatedPages(read, folder, system, language) {
373
+ function translatedPages(read, folder, system, language, own) {
370
374
  const translations = translationFolder(folder, language);
371
375
  if (translations === undefined) {
372
- return read;
376
+ return own === undefined ? read : withTranslations(read, readPages(own, system), true);
373
377
  }
374
378
  const key = `${translations}|${system}`;
375
- const known = translated.get(key) ?? withTranslations(read, readPages(translations, system));
379
+ const known = translated.get(key) ?? withTranslations(read, readPages(translations, system), false);
376
380
  translated.set(key, known);
377
381
  return known;
378
382
  }
379
383
  const translated = new Map();
380
- function withTranslations(read, translations) {
384
+ function withTranslations(read, translations, printed) {
381
385
  const byPath = new Map(translations.pages.map((page) => [page.path, page]));
382
386
  const pages = read.pages.map((page) => {
383
- const other = byPath.get(page.path);
387
+ const found = byPath.get(page.path);
388
+ // A translation made on this computer from a text the system has since changed is no longer the page's.
389
+ const other = printed && found?.fields.source !== textPrint(page.body) ? undefined : found;
384
390
  const title = typeof other?.fields.name === "string" && other.fields.name.trim() !== "" ? other.fields.name.trim() : undefined;
385
391
  return other === undefined ? page : frozen({ ...page, translated: other.body, ...(title === undefined ? {} : { title }) });
386
392
  });
387
- return { pages, problems: [...read.problems, ...translations.problems] };
393
+ // A file of this computer's that does not read is no problem of the campaign's: the page is translated again, over it.
394
+ return { pages, problems: printed ? read.problems : [...read.problems, ...translations.problems] };
395
+ }
396
+ /** Where a version's pages translated on this computer are, under the folder of the language's (D-539). */
397
+ export function versionTranslations(version) {
398
+ return join("versions", version);
388
399
  }
389
400
  /** A system's pages with those of the version of its rules over them (VER-3): a page of the version takes the place of a common one with its name. */
390
401
  function versionPages(common, version) {
@@ -0,0 +1,38 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { Served } from "./index.ts";
3
+ /** An option as the page shows it: the master's words, its label without dice, its dice when it is a roll, the page it names with that page's first sentence. */
4
+ export interface ShownOption {
5
+ text: string;
6
+ label: string;
7
+ notation?: string;
8
+ page?: {
9
+ name: string;
10
+ opening: string;
11
+ };
12
+ }
13
+ /** A set of choices as the page shows it. */
14
+ export interface ShownChoices {
15
+ id: string;
16
+ title: string;
17
+ who: string;
18
+ made: string;
19
+ confirmed?: string;
20
+ items: {
21
+ question: string;
22
+ least: number;
23
+ most: number;
24
+ options: ShownOption[];
25
+ answer: string[];
26
+ rolled?: string;
27
+ }[];
28
+ }
29
+ /** GET: the choices waiting, as the page shows them, and whether the player rolls their own dice. POST: an answer, a roll, or the confirm. */
30
+ export declare function choicesRequest(request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
31
+ /**
32
+ * What the master hears at the head of their next call of the choices the player confirmed (D-556): the answers to write, with the part of the game system on
33
+ * what a level gives, once in a chat, as the call's told keeps it; a call that never answers keeps nothing it told, so the next one tells them again.
34
+ */
35
+ export declare function choicesNews(served: Served, told?: Set<string>): {
36
+ lines: string[];
37
+ restore(): void;
38
+ };
@@ -0,0 +1,174 @@
1
+ import { z } from "zod";
2
+ import { findCampaign, readChoices, readSettings, writeChoices } from "../../campaign/index.js";
3
+ import { confirmedNotes, offeredPages, optionParts } from "../../commands/choices.js";
4
+ import { knownIntroduction, playerKnowledge, withPagesKnown } from "../../commands/shared/knowledge.js";
5
+ import { newDatedLogEntry } from "../../commands/shared/time.js";
6
+ import { campaignSystem, campaignWorld } from "../../commands/shared/world.js";
7
+ import { appendLogEntry } from "../../core/log.js";
8
+ import { withFiles } from "../../core/store.js";
9
+ import { firstSentence } from "../../core/text.js";
10
+ import { rollDice } from "../../dice/index.js";
11
+ import { findPage, introductionText, withoutComments } from "../../pages/index.js";
12
+ import { actText } from "../player-acts.js";
13
+ import { mostSaid, readBody, sendJson } from "./files.js";
14
+ import { deliverActs } from "./news.js";
15
+ const answerBody = z.union([
16
+ z.object({ id: z.string().min(1).max(64), item: z.number().int().min(0), answer: z.array(z.string().max(mostSaid)).max(200) }).strict(),
17
+ z.object({ id: z.string().min(1).max(64), item: z.number().int().min(0), roll: z.string().max(mostSaid), faces: z.array(z.number().int()).max(100).optional() }).strict(),
18
+ z.object({ id: z.string().min(1).max(64), confirm: z.literal(true), said: z.string().max(mostSaid) }).strict(),
19
+ ]);
20
+ /** GET: the choices waiting, as the page shows them, and whether the player rolls their own dice. POST: an answer, a roll, or the confirm. */
21
+ export async function choicesRequest(request, response, served) {
22
+ const root = withFiles(served.session, () => findCampaign(served.context.folder));
23
+ if (root === undefined) {
24
+ sendJson(response, 404, { error: "No campaign here." });
25
+ return;
26
+ }
27
+ if (request.method === "GET") {
28
+ sendJson(response, 200, withFiles(served.session, () => shownChoices(root, served)));
29
+ return;
30
+ }
31
+ const parsed = answerBody.safeParse(await readBody(request));
32
+ if (!parsed.success) {
33
+ sendJson(response, 400, { error: "Send { id, item, answer } with the options picked, { id, item, roll } with the option that rolls, or { id, confirm: true, said }." });
34
+ return;
35
+ }
36
+ try {
37
+ const body = parsed.data;
38
+ withFiles(served.session, () => {
39
+ if ("confirm" in body) {
40
+ confirm(root, served, body.id, body.said);
41
+ }
42
+ else if ("roll" in body) {
43
+ roll(root, served, body.id, body.item, body.roll, body.faces);
44
+ }
45
+ else {
46
+ answer(root, body.id, body.item, body.answer);
47
+ }
48
+ });
49
+ served.notify();
50
+ sendJson(response, 200, withFiles(served.session, () => shownChoices(root, served)));
51
+ }
52
+ catch (error) {
53
+ sendJson(response, 409, { error: error instanceof Error ? error.message : String(error) });
54
+ }
55
+ }
56
+ /**
57
+ * What the master hears at the head of their next call of the choices the player confirmed (D-556): the answers to write, with the part of the game system on
58
+ * what a level gives, once in a chat, as the call's told keeps it; a call that never answers keeps nothing it told, so the next one tells them again.
59
+ */
60
+ export function choicesNews(served, told) {
61
+ const root = withFiles(served.session, () => findCampaign(served.context.folder));
62
+ const context = told === undefined ? served.context : { ...served.context, told };
63
+ const lines = root === undefined ? [] : withFiles(served.session, () => confirmedNotes(root, context, campaignWorld(root, served.context), campaignSystem(root, served.context)));
64
+ return { lines, restore: () => undefined };
65
+ }
66
+ function shownChoices(root, served) {
67
+ const world = campaignWorld(root, served.context);
68
+ // The options' pages as the player reads them to choose (VIEW-2, VIEW-3).
69
+ const known = playerKnowledge(root, world);
70
+ const knowledge = known === undefined ? undefined : withPagesKnown(known, offeredPages(root, world));
71
+ const sets = readChoices(root).map((set) => ({
72
+ id: set.id,
73
+ title: set.title,
74
+ who: set.who,
75
+ made: set.made,
76
+ ...(set.confirmed === undefined ? {} : { confirmed: set.confirmed }),
77
+ items: set.items.map((item) => ({
78
+ question: item.question,
79
+ least: item.pick.least,
80
+ most: item.pick.most,
81
+ options: item.options.map((option) => shownOption(world, knowledge, option)),
82
+ answer: item.answer ?? [],
83
+ ...(item.rolled === undefined ? {} : { rolled: item.rolled }),
84
+ })),
85
+ }));
86
+ return { sets, physical: readSettings(root).dice === "physical" };
87
+ }
88
+ function shownOption(world, knowledge, option) {
89
+ const parts = optionParts(option);
90
+ const page = parts.pages.length === 0 ? undefined : findPage(world, parts.pages[0]);
91
+ const introduction = page === undefined ? "" : knowledge === undefined ? withoutComments(introductionText(page.translated ?? page.body)) : knownIntroduction(world, knowledge, page);
92
+ const opening = firstSentence(linkWords(world, introduction).replace(/\s+/g, " ").trim());
93
+ return {
94
+ text: option,
95
+ label: linkWords(world, parts.label).trim(),
96
+ ...(parts.notation === undefined ? {} : { notation: parts.notation }),
97
+ ...(page === undefined ? {} : { page: { name: page.name, opening } }),
98
+ };
99
+ }
100
+ /** A text's links as their words; one without words as its page's name in the campaign's language, a system page's title (D-542). */
101
+ function linkWords(world, text) {
102
+ return text.replace(/\[\[([^\]|#]+)(?:#[^\]|]*)?(?:\|([^\]]*))?\]\]/g, (_, name, words) => words ?? findPage(world, name)?.title ?? name);
103
+ }
104
+ /** The player's pick for an item, before the confirm: options of the item, as many as it allows; never one that rolls, nor in place of a roll made. */
105
+ function answer(root, id, index, picked) {
106
+ const { sets, set, item } = waiting(root, id, index);
107
+ const unique = [...new Set(picked)];
108
+ if (item.rolled !== undefined) {
109
+ throw new Error("A roll made stays: this choice is answered.");
110
+ }
111
+ if (unique.some((option) => !item.options.includes(option) || optionParts(option).notation !== undefined)) {
112
+ throw new Error("Pick among the options of this choice; one that rolls is rolled.");
113
+ }
114
+ if (unique.length > item.pick.most) {
115
+ throw new Error(`This choice takes at most ${item.pick.most}.`);
116
+ }
117
+ write(root, sets, set, index, { ...item, answer: unique });
118
+ }
119
+ /** An option that rolls, picked: the engine rolls it, or reads the player's own dice, logs it as the player's roll, and keeps it as the answer. */
120
+ function roll(root, served, id, index, option, faces) {
121
+ const { sets, set, item } = waiting(root, id, index);
122
+ const notation = item.options.includes(option) ? optionParts(option).notation : undefined;
123
+ if (notation === undefined) {
124
+ throw new Error("That option does not roll.");
125
+ }
126
+ if (item.rolled !== undefined) {
127
+ throw new Error("A roll made stays: this choice is answered.");
128
+ }
129
+ const physical = readSettings(root).dice === "physical";
130
+ if (physical !== (faces !== undefined)) {
131
+ throw new Error(physical ? "The player rolls their own dice here: send the faces." : "The engine rolls the dice here: send no faces.");
132
+ }
133
+ const diceRoll = rollDice(notation, faces === undefined ? { random: served.context.random } : { values: faces });
134
+ // The roll reads by its question, as Hit points, on the dashboard's list of rolls.
135
+ const why = `${item.question}: ${optionParts(option).label}`;
136
+ const data = { notation: diceRoll.notation, total: diceRoll.total, result: diceRoll.text, why, check: item.question, who: set.who, physical, dice: diceRoll.dice };
137
+ appendLogEntry(root, newDatedLogEntry(root, { ...served.context, actor: "player" }, "roll", "public", data));
138
+ write(root, sets, set, index, { ...item, answer: [option], rolled: diceRoll.text });
139
+ }
140
+ /** The confirm: every choice answered as it allows; the set waits for the master with its answers, and the player's sentence rings for them. */
141
+ function confirm(root, served, id, said) {
142
+ const { sets, set } = waiting(root, id, 0);
143
+ const open = set.items.find((item) => (item.answer ?? []).length < item.pick.least || (optionParts(item.answer?.[0] ?? "").notation !== undefined && item.rolled === undefined));
144
+ if (open !== undefined) {
145
+ throw new Error(`${open.question} still waits for an answer.`);
146
+ }
147
+ const confirmed = { ...set, confirmed: served.context.now().toISOString().slice(0, 10) };
148
+ writeChoices(root, sets.map((other) => (other.id === id ? confirmed : other)));
149
+ appendLogEntry(root, newDatedLogEntry(root, { ...served.context, actor: "player" }, "choices-confirmed", "public", { who: set.who, title: set.title }));
150
+ const text = actText(said);
151
+ if (text !== "") {
152
+ served.acts.pending.push({ id: served.context.newId(), text });
153
+ deliverActs(served);
154
+ }
155
+ }
156
+ /** A set still waiting for the player, by its id, with one of its items. */
157
+ function waiting(root, id, index) {
158
+ const sets = readChoices(root);
159
+ const set = sets.find((candidate) => candidate.id === id);
160
+ if (set === undefined) {
161
+ throw new Error("These choices are no longer there: the master took them away or heard them.");
162
+ }
163
+ if (set.confirmed !== undefined) {
164
+ throw new Error("These choices are confirmed: they are the master's now.");
165
+ }
166
+ const item = set.items[index];
167
+ if (item === undefined) {
168
+ throw new Error("No such choice in this set.");
169
+ }
170
+ return { sets, set, item };
171
+ }
172
+ function write(root, sets, set, index, item) {
173
+ writeChoices(root, sets.map((other) => (other.id === set.id ? { ...set, items: set.items.map((one, at) => (at === index ? item : one)) } : other)));
174
+ }
@@ -248,7 +248,8 @@ export async function pageWords(request, response, served, url) {
248
248
  sendJson(response, 400, { error: "Send the language and the phrases the page lacks now, { language, first }." });
249
249
  return;
250
250
  }
251
- served.words.ask(parsed.data.language.toLowerCase(), parsed.data.first);
251
+ // Through the session, which keeps the system's words translated on this computer (D-539).
252
+ withFiles(served.session, () => served.words.ask(parsed.data.language.toLowerCase(), parsed.data.first));
252
253
  sendJson(response, 202, {});
253
254
  return;
254
255
  }
@@ -262,7 +263,7 @@ export async function pageWords(request, response, served, url) {
262
263
  const found = root === undefined ? undefined : campaignSystem(root, served.context);
263
264
  return found === undefined ? undefined : { name: found.name, folder: found.folder };
264
265
  });
265
- sendJson(response, 200, served.words.read(language.toLowerCase(), system));
266
+ sendJson(response, 200, withFiles(served.session, () => served.words.read(language.toLowerCase(), system)));
266
267
  }
267
268
  /** A request's body as bytes, up to `most`; undefined when it is more. */
268
269
  export async function readBytes(request, most) {
@@ -2,7 +2,7 @@ import { type ServerResponse } from "node:http";
2
2
  import type { PlayerSetting } from "../../commands/config.ts";
3
3
  import type { Catalog } from "../../commands/shared/packages/catalog.ts";
4
4
  import { type PageTranslator } from "../../commands/shared/page-words.ts";
5
- import type { Context, Player } from "../../core/context.ts";
5
+ import type { Context, Player, SystemTexts } from "../../core/context.ts";
6
6
  import type { SessionStore } from "../../core/session-store.ts";
7
7
  import { type Acts } from "../player-acts.ts";
8
8
  import { type Asked, type ShownCard } from "./player.ts";
@@ -85,6 +85,8 @@ export interface Served {
85
85
  notify(): void;
86
86
  /** The page in a language the package does not ship, translated on the fly (D-406). */
87
87
  words: PageTranslator;
88
+ /** The game system's pages in the campaign's language, translated as the page reads them (D-539): the page's alone, never the master's calls. */
89
+ texts: SystemTexts;
88
90
  /** The package the player is adding, updating or taking away on the page, while npm works (D-475): one at a time. */
89
91
  packageWork?: {
90
92
  name: string;
@@ -8,6 +8,7 @@ import { importShown } from "../../commands/import/import.js";
8
8
  import { loadCampaignCode } from "../../commands/shared/packages/code.js";
9
9
  import { campaignWidgets, packageWidget } from "../../commands/shared/packages/widgets.js";
10
10
  import { pageTranslator } from "../../commands/shared/page-words.js";
11
+ import { systemTexts } from "../../commands/shared/system-texts.js";
11
12
  import { view } from "../../commands/view/view.js";
12
13
  import { isBoolean } from "../../core/registry.js";
13
14
  import { withFiles } from "../../core/store.js";
@@ -15,6 +16,7 @@ import { notationParts } from "../../dice/index.js";
15
16
  import { helperCommand, queueInCodex } from "../../helpers/index.js";
16
17
  import { loadSystemCode } from "../../systems/index.js";
17
18
  import { newActs } from "../player-acts.js";
19
+ import { choicesNews, choicesRequest } from "./choices.js";
18
20
  import { builtPage, packagePageFile, pageFile, pageHtml, pageModulesOf, pagePolicy, pageWords, securityHeaders, send, sendFile, sendImage, sendJson, sendPacked, sendThemeFile, themeAddress, themeNow, vendorModule } from "./files.js";
19
21
  import { act, deliverActs, keepProblems, listenForBell, notes, pageNews, setupWord, story } from "./news.js";
20
22
  import { answerAsked, closeCard, listenForChanges, pagePlayer, pageSeen, rollNamesOf, spendShown } from "./player.js";
@@ -66,6 +68,7 @@ export async function startDashboard(context, session, options = {}) {
66
68
  shared: new Map(),
67
69
  notify: () => undefined,
68
70
  words: pageTranslator(context, options.page ?? builtPage, () => served.notify()),
71
+ texts: systemTexts(context, () => served.notify()),
69
72
  acts: newActs(),
70
73
  queue: options.queue ?? codexQueue(),
71
74
  };
@@ -139,7 +142,18 @@ function serve(server, served) {
139
142
  return {
140
143
  url: `http://127.0.0.1:${served.port}`,
141
144
  player: pagePlayer(served),
142
- news: (told) => pageNews(served, told),
145
+ news: (told) => {
146
+ // The player's doings on the page, then the choices they confirmed (D-556).
147
+ const page = pageNews(served, told);
148
+ const confirmed = choicesNews(served, told);
149
+ return {
150
+ lines: [...page.lines, ...confirmed.lines],
151
+ restore: () => {
152
+ page.restore();
153
+ confirmed.restore();
154
+ },
155
+ };
156
+ },
143
157
  close: () => new Promise((done) => {
144
158
  stopListening();
145
159
  clearInterval(importLook);
@@ -189,6 +203,10 @@ async function answer(request, response, served) {
189
203
  await answerAsked(request, response, served);
190
204
  return;
191
205
  }
206
+ if (path === "/api/choices" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
207
+ await choicesRequest(request, response, served);
208
+ return;
209
+ }
192
210
  if (path === "/api/act" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
193
211
  await act(request, response, served);
194
212
  return;
@@ -380,7 +398,7 @@ async function runCommand(name, parameters, response, served) {
380
398
  }
381
399
  try {
382
400
  await served.session.ready();
383
- const result = await command.run(parsed.data, served.context);
401
+ const result = await command.run(parsed.data, { ...served.context, texts: served.texts });
384
402
  keepProblems(served, result);
385
403
  sendJson(response, 200, isSetup(result) ? { ...result, left: result.questions.filter((question) => served.left.has(question.name) && question.value === undefined && question.items === undefined).map((question) => question.name) } : result);
386
404
  }
@@ -1,6 +1,7 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { spawn } from "node:child_process";
4
+ import { join } from "node:path";
4
5
  import { z } from "zod";
5
6
  import { findCampaign, hasCharacterAgent, readTextSetting, refreshHostFiles } from "../campaign/index.js";
6
7
  import { commands } from "../commands/index.js";
@@ -134,7 +135,8 @@ export async function startMcpServer() {
134
135
  };
135
136
  // The systems' code, loaded once for the session, as the engine's own: a system changed since needs the server started again (D-448).
136
137
  context.systemCode = await loadSystemCode(context.systemFolders);
137
- const session = new SessionStore({ systemFolders: context.systemFolders });
138
+ // The game systems, and what this computer translated of them, written only through the session (D-539).
139
+ const session = new SessionStore({ systemFolders: [...context.systemFolders, ...(context.home === undefined ? [] : [join(context.home, "systems")])] });
138
140
  const served = { ...context, files: session };
139
141
  server = createMcpServer(served, process.env, dashboardOpener(served, session).open);
140
142
  // The extensions' tools are there in the first list the host asks for.