rpg-engine 0.9.1 → 0.11.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 (171) hide show
  1. package/README.md +1 -1
  2. package/dist/adventures/placement.js +4 -0
  3. package/dist/adventures/source.js +6 -5
  4. package/dist/campaign/find-campaign.js +18 -0
  5. package/dist/campaign/host-files.js +8 -6
  6. package/dist/campaign/index.d.ts +1 -1
  7. package/dist/campaign/index.js +1 -1
  8. package/dist/campaign/settings.d.ts +2 -0
  9. package/dist/campaign/settings.js +12 -5
  10. package/dist/commands/advance.js +1 -1
  11. package/dist/commands/ask.js +1 -1
  12. package/dist/commands/config.js +21 -32
  13. package/dist/commands/import/import.js +1 -1
  14. package/dist/commands/instructions.js +1 -1
  15. package/dist/commands/mode.js +1 -1
  16. package/dist/commands/mood.js +2 -3
  17. package/dist/commands/move.js +1 -1
  18. package/dist/commands/package.d.ts +3 -3
  19. package/dist/commands/package.js +74 -37
  20. package/dist/commands/reveal.js +1 -1
  21. package/dist/commands/roll/roll.js +6 -12
  22. package/dist/commands/rules.js +0 -1
  23. package/dist/commands/scene.js +6 -8
  24. package/dist/commands/shared/adventures.js +21 -12
  25. package/dist/commands/shared/images.js +3 -1
  26. package/dist/commands/shared/knowledge.d.ts +8 -0
  27. package/dist/commands/shared/knowledge.js +41 -18
  28. package/dist/commands/shared/library.js +13 -5
  29. package/dist/commands/shared/mode.d.ts +7 -4
  30. package/dist/commands/shared/mode.js +28 -15
  31. package/dist/commands/shared/packages/catalog.d.ts +2 -0
  32. package/dist/commands/shared/packages/catalog.js +1 -0
  33. package/dist/commands/shared/packages/code.js +13 -2
  34. package/dist/commands/shared/page-words.d.ts +2 -0
  35. package/dist/commands/shared/page-words.js +13 -0
  36. package/dist/commands/shared/sheet.d.ts +3 -2
  37. package/dist/commands/shared/sheet.js +8 -5
  38. package/dist/commands/show.js +1 -1
  39. package/dist/commands/status.js +9 -5
  40. package/dist/commands/view/place.d.ts +2 -0
  41. package/dist/commands/view/place.js +17 -5
  42. package/dist/commands/write/write.js +4 -3
  43. package/dist/core/archive-paths.js +1 -1
  44. package/dist/core/context.d.ts +2 -0
  45. package/dist/core/package-api.d.ts +1 -1
  46. package/dist/core/package-declarations.d.ts +3 -3
  47. package/dist/core/package-declarations.js +3 -3
  48. package/dist/core/refusal.d.ts +12 -0
  49. package/dist/core/refusal.js +17 -0
  50. package/dist/core/store.d.ts +4 -0
  51. package/dist/core/store.js +20 -1
  52. package/dist/dashboard/api.js +37 -81
  53. package/dist/dashboard/app.js +10 -3
  54. package/dist/dashboard/asked.js +6 -3
  55. package/dist/dashboard/assets/master.svg +1 -2
  56. package/dist/dashboard/card.js +1 -1
  57. package/dist/dashboard/dice/load.js +6 -1
  58. package/dist/dashboard/dice/throw.js +5 -1
  59. package/dist/dashboard/dice/tray.js +5 -1
  60. package/dist/dashboard/footer.js +2 -2
  61. package/dist/dashboard/game-words.js +32 -32
  62. package/dist/dashboard/guide/ar.md +17 -17
  63. package/dist/dashboard/guide/cs.md +17 -17
  64. package/dist/dashboard/guide/da.md +16 -16
  65. package/dist/dashboard/guide/de.md +15 -15
  66. package/dist/dashboard/guide/el.md +19 -19
  67. package/dist/dashboard/guide/en.md +4 -4
  68. package/dist/dashboard/guide/es.md +17 -17
  69. package/dist/dashboard/guide/fi.md +19 -19
  70. package/dist/dashboard/guide/fr.md +16 -16
  71. package/dist/dashboard/guide/he.md +16 -16
  72. package/dist/dashboard/guide/hi.md +20 -20
  73. package/dist/dashboard/guide/hu.md +18 -18
  74. package/dist/dashboard/guide/is.md +16 -16
  75. package/dist/dashboard/guide/it.md +7 -7
  76. package/dist/dashboard/guide/ja.md +17 -17
  77. package/dist/dashboard/guide/ko.md +22 -22
  78. package/dist/dashboard/guide/nb.md +17 -17
  79. package/dist/dashboard/guide/nl.md +19 -19
  80. package/dist/dashboard/guide/pl.md +18 -18
  81. package/dist/dashboard/guide/pt.md +13 -13
  82. package/dist/dashboard/guide/ro.md +19 -19
  83. package/dist/dashboard/guide/ru.md +17 -17
  84. package/dist/dashboard/guide/sv.md +16 -16
  85. package/dist/dashboard/guide/tr.md +21 -21
  86. package/dist/dashboard/guide/uk.md +16 -16
  87. package/dist/dashboard/guide/zh.md +20 -20
  88. package/dist/dashboard/help/blocks.js +6 -0
  89. package/dist/dashboard/help/help.js +15 -3
  90. package/dist/dashboard/help/markdown.js +2 -1
  91. package/dist/dashboard/i18n/ar.json +54 -1
  92. package/dist/dashboard/i18n/cs.json +54 -1
  93. package/dist/dashboard/i18n/da.json +54 -1
  94. package/dist/dashboard/i18n/de.json +54 -1
  95. package/dist/dashboard/i18n/el.json +54 -1
  96. package/dist/dashboard/i18n/es.json +54 -1
  97. package/dist/dashboard/i18n/fi.json +54 -1
  98. package/dist/dashboard/i18n/fr.json +54 -1
  99. package/dist/dashboard/i18n/he.json +54 -1
  100. package/dist/dashboard/i18n/hi.json +54 -1
  101. package/dist/dashboard/i18n/hu.json +54 -1
  102. package/dist/dashboard/i18n/is.json +54 -1
  103. package/dist/dashboard/i18n/it.json +57 -4
  104. package/dist/dashboard/i18n/ja.json +54 -1
  105. package/dist/dashboard/i18n/ko.json +54 -1
  106. package/dist/dashboard/i18n/nb.json +54 -1
  107. package/dist/dashboard/i18n/nl.json +54 -1
  108. package/dist/dashboard/i18n/pl.json +54 -1
  109. package/dist/dashboard/i18n/pt.json +54 -1
  110. package/dist/dashboard/i18n/ro.json +54 -1
  111. package/dist/dashboard/i18n/ru.json +54 -1
  112. package/dist/dashboard/i18n/sv.json +54 -1
  113. package/dist/dashboard/i18n/tr.json +54 -1
  114. package/dist/dashboard/i18n/uk.json +54 -1
  115. package/dist/dashboard/i18n/zh.json +54 -1
  116. package/dist/dashboard/icons.js +2 -2
  117. package/dist/dashboard/journal.js +9 -4
  118. package/dist/dashboard/labels.js +5 -4
  119. package/dist/dashboard/language-choice.js +3 -3
  120. package/dist/dashboard/markdown.js +11 -4
  121. package/dist/dashboard/notes.js +4 -2
  122. package/dist/dashboard/notices.js +2 -2
  123. package/dist/dashboard/packages/ask-card.js +1 -1
  124. package/dist/dashboard/packages/packages.js +14 -10
  125. package/dist/dashboard/packages/page-code.js +11 -3
  126. package/dist/dashboard/packages/widgets.js +5 -5
  127. package/dist/dashboard/pages.js +3 -3
  128. package/dist/dashboard/place/map-sheet.js +4 -3
  129. package/dist/dashboard/place/map-view.js +17 -5
  130. package/dist/dashboard/refusals.js +61 -0
  131. package/dist/dashboard/rolls.js +3 -3
  132. package/dist/dashboard/settings.js +19 -5
  133. package/dist/dashboard/sheet.js +26 -7
  134. package/dist/dashboard/status.js +19 -13
  135. package/dist/dashboard/style.css +113 -16
  136. package/dist/dashboard/text.js +6 -2
  137. package/dist/dashboard/top.js +7 -9
  138. package/dist/dashboard/turns.js +7 -2
  139. package/dist/dashboard/world/lore.js +16 -15
  140. package/dist/dashboard/world/map.js +43 -1
  141. package/dist/dashboard/world/world.js +50 -15
  142. package/dist/dice/index.d.ts +1 -1
  143. package/dist/dice/oracle.d.ts +5 -3
  144. package/dist/dice/oracle.js +7 -6
  145. package/dist/extensions/extension.js +4 -1
  146. package/dist/helpers/codex.js +1 -1
  147. package/dist/packages/npm.js +17 -4
  148. package/dist/packages/tarball.js +8 -4
  149. package/dist/pages/index.d.ts +1 -1
  150. package/dist/pages/index.js +1 -1
  151. package/dist/pages/markdown.d.ts +2 -0
  152. package/dist/pages/markdown.js +21 -0
  153. package/dist/pages/world.js +4 -0
  154. package/dist/server/dashboard/index.js +8 -4
  155. package/dist/server/dashboard/writes.js +22 -13
  156. package/dist/server/mcp.d.ts +3 -1
  157. package/dist/server/mcp.js +20 -5
  158. package/dist/systems/game-system.d.ts +2 -0
  159. package/dist/systems/game-system.js +2 -0
  160. package/dist/systems/system-code.js +5 -0
  161. package/instructions/adventure.md +1 -1
  162. package/instructions/combat.md +1 -1
  163. package/instructions/core.md +2 -2
  164. package/instructions/import.md +1 -0
  165. package/instructions/session-zero.md +1 -1
  166. package/instructions/session.md +1 -1
  167. package/instructions/setup.md +1 -1
  168. package/package.json +2 -2
  169. package/systems/free/instructions/outcomes-rolled.md +1 -1
  170. package/systems/free/instructions/outcomes-tossed.md +1 -1
  171. package/systems/free/instructions/play.md +1 -2
@@ -2,7 +2,7 @@
2
2
  // with more than one player character, what any of them knows, and who (VIEW-12).
3
3
  import { readLog } from "../../core/log.js";
4
4
  import { comparableText } from "../../core/text.js";
5
- import { baseChain, inheritedByBase, introductionText, isPartyMember, isPlayerCharacter, links, locate, pagesWithNameOrAlias, parsePageReference, partContent, playerCharacters, readSection, secretNames, stacksOf, systemPageNamed, textParts, textsIn, withLinksAsWords, withoutComments, } from "../../pages/index.js";
5
+ import { baseChain, inheritedByBase, introductionText, isPartyMember, isPlayerCharacter, links, locate, pagesWithNameOrAlias, parsePageReference, partContent, playerCharacters, readSection, secretNames, stacksOf, systemPageNamed, textParts, textsIn, withLinksAsWords, withoutComments, withoutUnreadSecrets, } from "../../pages/index.js";
6
6
  import { readOpenScene } from "./scene.js";
7
7
  /** The player character: the first living character with role pc, else the first dead one; undefined before there is one. */
8
8
  export function playerCharacter(world) {
@@ -87,6 +87,22 @@ export function knownText(world, knowledge, page) {
87
87
  ].filter((part) => isShown(knowledge, page, part));
88
88
  return inKnownWords(world, knowledge, withoutComments([knownIntroduction(world, knowledge, page), ...parts.map((part) => part.text)].filter((text) => text !== "").join("\n\n")));
89
89
  }
90
+ /**
91
+ * A text as the character may read it (VIEW-3): a link to a page it does not know, or to none, written as its words, so that no name tells the page exists; a link
92
+ * to a secret it has not discovered too, so that the secret's name tells nothing, and to a section that tells it nothing but its title, as one over a secret; a
93
+ * secret written so that the engine does not read it as one, left out.
94
+ */
95
+ export function inKnownWords(world, knowledge, text) {
96
+ return withLinksAsWords(withoutUnreadSecrets(text), (link) => readsLink(world, knowledge, link));
97
+ }
98
+ /** Whether the character may read where a link points (VIEW-3): a page it knows, and of it a secret it discovered or a section that tells it more than its title. */
99
+ export function readsLink(world, knowledge, link) {
100
+ const known = [...pagesWithNameOrAlias(world, link.page), systemPageNamed(world, link.page)].filter((page) => page !== undefined && knowsPage(knowledge, page));
101
+ const wanted = comparableText(link.section ?? "");
102
+ const secrets = wanted === "" ? [] : known.flatMap((page) => secretNames(page.body).filter((name) => comparableText(name) === wanted).map((name) => secretKey(page.name, name)));
103
+ const empty = wanted !== "" && secrets.length === 0 && known.length > 0 && known.every((page) => saysNothing(world, knowledge, page, link.section ?? ""));
104
+ return known.length > 0 && !empty && (secrets.length === 0 || secrets.some((key) => knowledge.secrets.has(key)));
105
+ }
90
106
  /** The secrets a page's text shows (VIEW-3) that only some of the player characters discovered, when more than one is played, each by its name and with who (VIEW-12). */
91
107
  export function knownSecretsApart(world, knowledge, page) {
92
108
  const parts = [...partsOf(page), ...inheritedByBase(world, page).flatMap((group) => group.parts.map((part) => ({ ...part, holder: group.base })))];
@@ -130,20 +146,8 @@ export function playerStory(page) {
130
146
  * from a base, only one it knows, or a secret it discovered. Undefined when it knows none.
131
147
  */
132
148
  export function knownPart(world, knowledge, page, name) {
133
- const wanted = comparableText(name.trim());
134
- for (const holder of [page, ...baseChain(world, page)]) {
135
- const part = partsOf(holder).find((candidate) => comparableText(candidate.name) === wanted);
136
- if (part === undefined) {
137
- continue;
138
- }
139
- if (!isShown(knowledge, page, part)) {
140
- return undefined;
141
- }
142
- const whole = isSecretText(part.text) ? part.text : (readSection(holder.body, part.name) ?? part.text);
143
- const kept = isSecretText(part.text) ? [part] : partsOf({ ...holder, body: whole }).map((inner) => ({ ...inner, holder })).filter((inner) => isShown(knowledge, page, inner));
144
- return inKnownWords(world, knowledge, withoutComments(kept.map((inner) => inner.text).join("\n\n")));
145
- }
146
- return undefined;
149
+ const kept = knownParts(world, knowledge, page, name);
150
+ return kept === undefined ? undefined : inKnownWords(world, knowledge, withoutComments(kept.map((inner) => inner.text).join("\n\n")));
147
151
  }
148
152
  /** Whether a page's own text, not its bases', tells the character something: its introduction, or a section or secret of it the character may read (VIEW-3). */
149
153
  export function writesKnownText(knowledge, page) {
@@ -188,9 +192,28 @@ function foregroundCharacter(root, world, wanted) {
188
192
  const named = (page, name) => name !== undefined && pagesWithNameOrAlias(world, parsePageReference(name).name)[0] === page;
189
193
  return living.find((page) => named(page, scene?.turn)) ?? living.find((page) => (scene?.with ?? []).some((link) => named(page, link))) ?? living[0] ?? players[0];
190
194
  }
191
- /** A text as the character may read it (VIEW-3): a link to a page it does not know, or to none, written as its words, so that no name tells the page exists. */
192
- function inKnownWords(world, knowledge, text) {
193
- return withLinksAsWords(text, (link) => [...pagesWithNameOrAlias(world, link.page), systemPageNamed(world, link.page)].some((page) => page !== undefined && knowsPage(knowledge, page)));
195
+ /** The parts of a page's section or secret by this name that the character may read, as knownPart gives them; undefined when it knows none. */
196
+ function knownParts(world, knowledge, page, name) {
197
+ const wanted = comparableText(name.trim());
198
+ for (const holder of [page, ...baseChain(world, page)]) {
199
+ const part = partsOf(holder).find((candidate) => comparableText(candidate.name) === wanted);
200
+ if (part === undefined) {
201
+ continue;
202
+ }
203
+ if (!isShown(knowledge, page, part)) {
204
+ return undefined;
205
+ }
206
+ const whole = isSecretText(part.text) ? part.text : (readSection(holder.body, part.name) ?? part.text);
207
+ return isSecretText(part.text) ? [part] : partsOf({ ...holder, body: whole }).map((inner) => ({ ...inner, holder })).filter((inner) => isShown(knowledge, page, inner));
208
+ }
209
+ return undefined;
210
+ }
211
+ /** Whether a section the character may read tells it nothing but its title, as a heading over secrets it has not discovered (VIEW-3). */
212
+ function saysNothing(world, knowledge, page, section) {
213
+ const kept = knownParts(world, knowledge, page, section);
214
+ // A section's text begins with its heading; a secret's with its mark, which names it.
215
+ const said = (part) => withoutComments(isSecretText(part.text) ? part.text : part.text.split("\n").slice(1).join("\n")).trim() !== "";
216
+ return kept !== undefined && !kept.some(said);
194
217
  }
195
218
  /** Whether a part shows to the player character: a secret it discovered, or a section of the page or of a base it knows (D-254). */
196
219
  function isShown(knowledge, page, part) {
@@ -2,6 +2,7 @@
2
2
  // finds in the books, after the game system's rules.
3
3
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
4
4
  import { campaignFileName, findCampaign, readListSetting, readTextSetting } from "../../campaign/index.js";
5
+ import { Refusal } from "../../core/refusal.js";
5
6
  import { comparableText } from "../../core/text.js";
6
7
  import { documentAt, documentKinds } from "../../documents/index.js";
7
8
  import { dropUnlisted, foldersIn, isWithin, libraryFolders, libraryReader, libraryState, mostBooks, samePath, saveLibraryFolders } from "../../library/index.js";
@@ -31,18 +32,23 @@ export async function libraryAdditions(root, context, given) {
31
32
  for (const entry of entries) {
32
33
  const found = documentAt(entry);
33
34
  if (found === undefined) {
34
- throw new Error(`There is no ${entry}: give the full path of a folder of the player's books, or of a book. Nothing changed.`);
35
+ throw new Refusal(`There is no ${entry}: give the full path of a folder of the player's books, or of a book. Nothing changed.`, "not-on-computer", { name: entry });
35
36
  }
36
37
  if (found === "file" && !documentKinds.some((kind) => entry.toLowerCase().endsWith(kind))) {
37
- throw new Error(`${basename(entry)} is no book the engine reads: give a ${documentKinds.join(", ")} file, or a folder of them. Nothing changed.`);
38
+ throw new Refusal(`${basename(entry)} is no book the engine reads: give a ${documentKinds.join(", ")} file, or a folder of them. Nothing changed.`, "not-a-book", {
39
+ name: basename(entry),
40
+ kinds: documentKinds.join(", "),
41
+ });
38
42
  }
39
43
  // A book is looked for from its folder: a file is no folder to hold a campaign.yaml, and Linux says so.
40
44
  const campaign = findCampaign(found === "file" ? dirname(entry) : entry);
41
45
  if (campaign !== undefined) {
42
- throw new Error(`${entry} is inside the campaign in ${campaign}: the library is the player's own books, outside every campaign. Nothing changed.`);
46
+ throw new Refusal(`${entry} is inside the campaign in ${campaign}: the library is the player's own books, outside every campaign. Nothing changed.`, "books-in-campaign", {
47
+ name: entry,
48
+ });
43
49
  }
44
50
  if (found === "folder" && context.bookIndex !== undefined && libraryState(context.bookIndex, [entry], libraryScope).crowded.length > 0) {
45
- throw new Error(`${entry} holds more than ${mostBooks} documents, and a shelf of a game's books has from 5 to 50: give the folder inside it with this game's books${insideOf(context, entry)}. Nothing changed.`);
51
+ throw new Refusal(`${entry} holds more than ${mostBooks} documents, and a shelf of a game's books has from 5 to 50: give the folder inside it with this game's books${insideOf(context, entry)}. Nothing changed.`, "books-crowded", { name: entry, count: String(mostBooks) });
46
52
  }
47
53
  }
48
54
  const index = context.bookIndex;
@@ -390,7 +396,9 @@ function onlyOne(items) {
390
396
  function libraryPath(context, given) {
391
397
  const entry = unquoted(given);
392
398
  if (!isAbsolute(entry) && context.terminal !== true) {
393
- throw new Error(`${entry} is no full path: give the whole path of a folder of the player's books, or of a book, from its drive or its root. Nothing changed.`);
399
+ throw new Refusal(`${entry} is no full path: give the whole path of a folder of the player's books, or of a book, from its drive or its root. Nothing changed.`, "not-full-path", {
400
+ name: entry,
401
+ });
394
402
  }
395
403
  return resolve(context.folder, entry);
396
404
  }
@@ -18,12 +18,15 @@ export declare function campaignMode(root: string, world: World): Mode;
18
18
  /** A mode written by hand in state.yaml that is no mode: it counts as none (MOD-1), and validate says how to fix it. */
19
19
  export declare function modeProblems(root: string): Problem[];
20
20
  /** The first checklist the campaign must complete before entering `mode`: the setup's, then session zero's; undefined when nothing stops it (MOD-2). */
21
- export declare function blockingMode(mode: Mode, root: string, context: Context, world: World): Blocked | undefined;
21
+ export declare function blockingMode(mode: Mode, root: string, context: Context, world: World, brief?: boolean): Blocked | undefined;
22
22
  /** "still to agree with the player: lethality (…); set each with config", or what session zero still has to make: what a checklist lacks, as outputs say it. */
23
23
  export declare function missingText(blocked: Blocked): string;
24
- /** What the campaign still needs, as init, config and status say it: before play, the checklist and the call that moves on; in play, the settings still missing (MOD-7). */
25
- export declare function campaignNote(root: string, context: Context): string;
24
+ /**
25
+ * What the campaign still needs, as init, config and status say it: before play, the checklist and the call that moves on; in play, the settings still missing (MOD-7).
26
+ * Brief, as config says it, the setup's settings by their values alone: status gives what they mean (T-168).
27
+ */
28
+ export declare function campaignNote(root: string, context: Context, brief?: boolean): string;
26
29
  /** Before play, what the next mode still needs and the call that enters it once the player confirms (MOD-7); undefined in play. */
27
- export declare function checklistLine(mode: Mode, root: string, context: Context, world: World): string | undefined;
30
+ export declare function checklistLine(mode: Mode, root: string, context: Context, world: World, brief?: boolean): string | undefined;
28
31
  /** The part of the instructions of a mode, the core's with the system's (MOD-5): the file setup, session-zero or play. */
29
32
  export declare function modePart(mode: Mode, system: GameSystem | undefined): string | undefined;
@@ -16,12 +16,12 @@ const settingLabels = {
16
16
  language: "language (a code, such as it)",
17
17
  mentor: "mentor (ask how well the player knows the game: never played, tutorial; a little, hints; well, off)",
18
18
  premise: "premise (the genre, the tone, a few elements of the world and what the player enjoys most in a game, such as fights, mysteries, talk or exploring, in the player's words)",
19
- preparation: `preparation (${preparations.join(", ")})`,
20
- difficulty: `difficulty (${difficulties.join(", ")})`,
21
- lethality: `lethality (${lethalities.join(", ")})`,
22
- saves: `saves (${saveModes.join(", ")})`,
23
- rigor: `rigor (${rigors.join(", ")})`,
24
- dice: `dice (${diceWays.join(", ")})`,
19
+ preparation: "preparation (on the fly: the world made just before it is needed; all at the start)",
20
+ difficulty: `difficulty (how hard the world plays: ${difficulties.join(", ")})`,
21
+ lethality: "lethality (what a fall means: narrative, the character never dies; epic, only when it matters; dice, the dice decide)",
22
+ saves: "saves (when the game may go back: permadeath, never but to the start; checkpoint, to the last end of a scene once the player character dies; free, to any save)",
23
+ rigor: "rigor (how closely travel, fatigue, food and the like follow the rules: smooth, glossed over; rules, as written; simulation, beyond them)",
24
+ dice: "dice (who rolls the player character's dice: digital, rpg; physical, the player, who tells you the values)",
25
25
  "master-rolls": `master-rolls (your rolls for foes and NPCs: ${masterRollWays.join(", ")}; suggest behind the screen)`,
26
26
  units: `units (${unitSystems.join(", ")})`,
27
27
  companions: `companions (${companionWays.join(", ")})`,
@@ -29,6 +29,15 @@ const settingLabels = {
29
29
  lines: 'lines ("none" is an answer)',
30
30
  veils: 'veils ("none" is an answer)',
31
31
  };
32
+ // The same settings by their values alone, as config's results give them in the setup: status gives their meanings (T-168).
33
+ const valueLabels = {
34
+ preparation: `preparation (${preparations.join(", ")})`,
35
+ difficulty: `difficulty (${difficulties.join(", ")})`,
36
+ lethality: `lethality (${lethalities.join(", ")})`,
37
+ saves: `saves (${saveModes.join(", ")})`,
38
+ rigor: `rigor (${rigors.join(", ")})`,
39
+ dice: `dice (${diceWays.join(", ")})`,
40
+ };
32
41
  /**
33
42
  * The mode the campaign is in: the one state.yaml keeps; for a campaign made before modes, or one whose mode is written wrongly, play once it has had a scene,
34
43
  * session zero once it has a player character, setup before (MOD-1).
@@ -54,11 +63,11 @@ export function modeProblems(root) {
54
63
  return [{ path: "state.yaml", message: `The mode in state.yaml, "${String(written)}", is not a mode: ${modes.join(", ")}.`, fix: "call mode with the one the campaign is in" }];
55
64
  }
56
65
  /** The first checklist the campaign must complete before entering `mode`: the setup's, then session zero's; undefined when nothing stops it (MOD-2). */
57
- export function blockingMode(mode, root, context, world) {
66
+ export function blockingMode(mode, root, context, world, brief = false) {
58
67
  if (mode === "setup") {
59
68
  return undefined;
60
69
  }
61
- const setup = setupMissing(root, context, world);
70
+ const setup = setupMissing(root, context, world, brief);
62
71
  if (setup.length > 0) {
63
72
  return { mode: "setup", missing: setup };
64
73
  }
@@ -71,19 +80,22 @@ export function missingText(blocked) {
71
80
  ? `still to agree with the player: ${blocked.missing.join(", ")}; set each with config`
72
81
  : `still to make with the player: ${blocked.missing.join("; ")}`;
73
82
  }
74
- /** What the campaign still needs, as init, config and status say it: before play, the checklist and the call that moves on; in play, the settings still missing (MOD-7). */
75
- export function campaignNote(root, context) {
83
+ /**
84
+ * What the campaign still needs, as init, config and status say it: before play, the checklist and the call that moves on; in play, the settings still missing (MOD-7).
85
+ * Brief, as config says it, the setup's settings by their values alone: status gives what they mean (T-168).
86
+ */
87
+ export function campaignNote(root, context, brief = false) {
76
88
  const world = campaignWorld(root, context);
77
- return checklistLine(campaignMode(root, world), root, context, world)
89
+ return checklistLine(campaignMode(root, world), root, context, world, brief)
78
90
  ?? missingSettingsNote(missingWithSystems(root, missingSettings(readSettings(root)), context).map((name) => offeredLabel(root, context, name) ?? name));
79
91
  }
80
92
  /** Before play, what the next mode still needs and the call that enters it once the player confirms (MOD-7); undefined in play. */
81
- export function checklistLine(mode, root, context, world) {
93
+ export function checklistLine(mode, root, context, world, brief = false) {
82
94
  if (mode === "play") {
83
95
  return undefined;
84
96
  }
85
97
  const next = mode === "setup" ? "session zero" : "play";
86
- const blocked = blockingMode(next, root, context, world);
98
+ const blocked = blockingMode(next, root, context, world, brief);
87
99
  const missing = blocked === undefined ? "nothing is missing" : missingText(blocked);
88
100
  const settings = readSettings(root);
89
101
  const unnamed = mode === "setup" && settings.premise !== undefined && comparableText(settings.name) === comparableText(basename(root));
@@ -113,9 +125,10 @@ function writtenMode(root) {
113
125
  }
114
126
  }
115
127
  /** What the setup still has to agree with the player, each setting with the values it takes, the system's own too (MOD-3). */
116
- function setupMissing(root, context, world) {
128
+ function setupMissing(root, context, world, brief) {
117
129
  const unanswered = unansweredSettings(readSettings(root), world.pages.length > 0);
118
- return missingWithSystems(root, unanswered, context).map((name) => offeredLabel(root, context, name) ?? settingLabels[name] ?? name);
130
+ const label = (name) => (brief ? valueLabels[name] : undefined) ?? settingLabels[name];
131
+ return missingWithSystems(root, unanswered, context).map((name) => offeredLabel(root, context, name) ?? label(name) ?? name);
119
132
  }
120
133
  /** What session zero still has to make (MOD-4): a living player character, the companions the setup said are made in it, and the sheets they keep, whole. */
121
134
  function sessionZeroMissing(root, context, world) {
@@ -21,6 +21,8 @@ export interface CatalogEntry {
21
21
  version: string;
22
22
  engine?: string;
23
23
  };
24
+ /** The game system an extension is made for, as its package.json says (D-548). */
25
+ system?: string;
24
26
  /** An adventure's levels, length and language, as its adventure.yaml says. */
25
27
  levels?: string;
26
28
  length?: string;
@@ -69,6 +69,7 @@ function npmEntry(found, installed) {
69
69
  ...(installed === undefined ? {} : { installed }),
70
70
  update: installed !== undefined && isNewerVersion(found.version, installed),
71
71
  ...(found.newer === undefined ? {} : { newer: found.newer }),
72
+ ...(found.kind === "extension" && found.system !== undefined ? { system: found.system } : {}),
72
73
  };
73
74
  }
74
75
  /** The version of this npm package installed here: an extension's, or a game system's. */
@@ -34,7 +34,7 @@ import { effectiveFields, effectsOf } from "../effect-layer.js";
34
34
  import { checkEffectsReadable, saveEffects } from "../effects.js";
35
35
  import { behindTheScreen, sealHiddenRoll } from "../master-rolls.js";
36
36
  import { keepingConditionNote } from "../reminders.js";
37
- import { readOpenScene } from "../scene.js";
37
+ import { copyName, copyPage, readOpenScene } from "../scene.js";
38
38
  import { calendarDayOf, newDatedLogEntry, presentDate } from "../time.js";
39
39
  import { formulaValue } from "../worked-out.js";
40
40
  import { campaignSystem, campaignSystemWords, campaignWorld } from "../world.js";
@@ -316,7 +316,8 @@ export function gameViewOf(root, context, code) {
316
316
  },
317
317
  page: (name) => {
318
318
  const world = campaignWorld(root, context);
319
- const found = pagesWithNameOrAlias(world, name);
319
+ const copy = sceneCopyOf(world, readOpenScene(root).scene, name);
320
+ const found = copy === undefined ? pagesWithNameOrAlias(world, name) : [copy];
320
321
  return found.length === 1 ? gamePage(world, found[0], campaignSystemWords(root, context)) : undefined;
321
322
  },
322
323
  scene: () => {
@@ -603,6 +604,16 @@ function gamePage(world, page, words) {
603
604
  },
604
605
  };
605
606
  }
607
+ /** The copy in the open scene a name gives, as a page that derives from its creature (INH-14); undefined for none, and for a copy a page shares its name with. */
608
+ function sceneCopyOf(world, scene, name) {
609
+ try {
610
+ const copy = copyName(world, scene, name);
611
+ return scene === undefined || copy === undefined ? undefined : copyPage(copy, scene.copies[copy]);
612
+ }
613
+ catch {
614
+ return undefined;
615
+ }
616
+ }
606
617
  /** A field's value as the API gives it: a number, text, or a list as text; undefined for anything else, as a map. */
607
618
  function plainValue(value) {
608
619
  if (typeof value === "number" || typeof value === "string") {
@@ -37,6 +37,8 @@ export interface ChatBatch {
37
37
  }
38
38
  /** Whether the built page in `page` ships a language: its own file, its base language's (pt-BR, pt), or English. */
39
39
  export declare function shipsLanguage(page: string, language: string): boolean;
40
+ /** A phrase of the page in a language: a language package's, then the page's own file, by its code or its base language, then this computer's; English when none has it. */
41
+ export declare function pagePhrase(context: Context, language: string | undefined, phrase: string): string;
40
42
  /** The next batch the master translates in the chat, the page's phrases first; undefined once the language lacks none. */
41
43
  export declare function chatBatch(home: string, page: string, language: string, system: WordsSystem | undefined): ChatBatch | undefined;
42
44
  /** Keeps what the master translated in the chat, by id, as the background work keeps its own; returns how many it kept, and the ids dropped for a lost {name}. */
@@ -77,6 +77,19 @@ export function shipsLanguage(page, language) {
77
77
  const base = language.toLowerCase().split("-")[0];
78
78
  return base === "en" || [language.toLowerCase(), base, base === "no" ? "nb" : ""].some((code) => code !== "" && existsSync(join(page, "i18n", `${code}.json`)));
79
79
  }
80
+ /** A phrase of the page in a language: a language package's, then the page's own file, by its code or its base language, then this computer's; English when none has it. */
81
+ export function pagePhrase(context, language, phrase) {
82
+ if (language === undefined || context.pageFolder === undefined) {
83
+ return phrase;
84
+ }
85
+ const page = context.pageFolder;
86
+ const code = language.toLowerCase();
87
+ const base = code.split("-")[0];
88
+ const pack = languagePackFor(context.extensionFolders ?? [], language);
89
+ const shipped = [code, base, base === "no" ? "nb" : ""].filter((candidate) => candidate !== "").map((candidate) => readJson(join(page, "i18n", `${candidate}.json`)));
90
+ const own = context.home === undefined ? {} : readJson(join(context.home, "i18n", `${language}.json`));
91
+ return [pack === undefined ? {} : packPhrases(pack), ...shipped, own].map((phrases) => phrases[phrase]).find((said) => typeof said === "string" && said !== "") ?? phrase;
92
+ }
80
93
  /** The next batch the master translates in the chat, the page's phrases first; undefined once the language lacks none. */
81
94
  export function chatBatch(home, page, language, system) {
82
95
  const pagePart = missingPhrases(home, page, language);
@@ -1,3 +1,4 @@
1
+ import type { Context } from "../../core/context.ts";
1
2
  import type { Problem } from "../../core/problem.ts";
2
3
  import { type Counter } from "../../counters/index.ts";
3
4
  import { type Page, type World } from "../../pages/index.ts";
@@ -20,9 +21,9 @@ export declare function sheetSummary(system: GameSystem): SheetSummary | undefin
20
21
  export declare function missingSheetFields(system: GameSystem | undefined, world: World, page: Page): string[];
21
22
  /**
22
23
  * What write says once when a character joins the party (DAT-2): the fields its sheet still lacks, then the system's notes on the groups of the sheet, such as
23
- * that the personality is the player's (D-206).
24
+ * that the personality is the player's (D-206); the notes once in a chat, the first character's to join (T-64).
24
25
  */
25
- export declare function joiningNotes(system: GameSystem | undefined, world: World, page: Page): string[];
26
+ export declare function joiningNotes(system: GameSystem | undefined, world: World, page: Page, context: Context): string[];
26
27
  /** A value of a character's sheet as data, which the dashboard draws (D-272), with the text the chat gives it. */
27
28
  export interface SheetValue {
28
29
  field: string;
@@ -1,4 +1,3 @@
1
- // The character sheet of the game system (D-204, D-207, DAT-2): its groups as show gives them, the fields a character still lacks, and the names a list takes (SYS-8).
2
1
  import { listItemNames, numberOf } from "../../core/formula.js";
3
2
  import { comparableText, valueNamed } from "../../core/text.js";
4
3
  import { readCounter } from "../../counters/index.js";
@@ -6,6 +5,7 @@ import { baseChain, carriedWeight, containerFieldOf, declaredKind, entryKind, en
6
5
  import { fieldName } from "../../progression/index.js";
7
6
  import { effectiveFields } from "./effect-layer.js";
8
7
  import { experienceOf, experienceText, levelNeed } from "./experience.js";
8
+ import { firstInChat } from "./parts.js";
9
9
  import { givenItems, progressionOf } from "./progression.js";
10
10
  import { carriedIn, counterLimits, formulaValue, hasSheet, isUse, itemLines, itemList, signedText, workedFields, workedLine, workedMaximum, workedParts } from "./worked-out.js";
11
11
  /** The sheet of the game system as status gives it before there is a player character (DAT-2); undefined when the system has none. */
@@ -46,15 +46,16 @@ export function missingSheetFields(system, world, page) {
46
46
  }
47
47
  /**
48
48
  * What write says once when a character joins the party (DAT-2): the fields its sheet still lacks, then the system's notes on the groups of the sheet, such as
49
- * that the personality is the player's (D-206).
49
+ * that the personality is the player's (D-206); the notes once in a chat, the first character's to join (T-64).
50
50
  */
51
- export function joiningNotes(system, world, page) {
51
+ export function joiningNotes(system, world, page, context) {
52
52
  if (system === undefined || !hasSheet(world, page)) {
53
53
  return [];
54
54
  }
55
55
  const missing = missingSheetFields(system, world, page);
56
56
  const lacks = missing.length === 0 ? [] : [`${page.name}'s sheet of the system ${system.name} still lacks, by these names: ${missing.join(", ")}.`];
57
- return [...lacks, ...system.sheet.flatMap((group) => (group.note === undefined ? [] : [`${group.name}: ${group.note}`]))];
57
+ const notes = context.told === undefined || firstInChat(context, "sheet-notes") ? system.sheet.flatMap((group) => (group.note === undefined ? [] : [`${group.name}: ${group.note}`])) : [];
58
+ return [...lacks, ...notes];
58
59
  }
59
60
  /**
60
61
  * The sheet of a player character or a companion as data, a group for each that has a value, as the character reads it, effects and formulas included (DAT-2).
@@ -264,7 +265,9 @@ export function checkListValues(system, lists, onSheet = false) {
264
265
  throw new Error(`${field} is a list in the system ${system.name}: give it as one, such as ${field}=[${example}]. Nothing changed.`);
265
266
  }
266
267
  if (system !== undefined && isOpenList(system, field) && isCommaText(value)) {
267
- throw new Error(`${field} is a list in the system ${system.name}: write its names apart, as ${field}=[${String(value)}]. Nothing changed.`);
268
+ // A name with a link quoted, so that it never reads as a list inside the list (T-167).
269
+ const names = String(value).split(",").map((name) => (name.includes("[[") ? JSON.stringify(name.trim()) : name.trim())).join(", ");
270
+ throw new Error(`${field} is a list in the system ${system.name}: write its names apart, as ${field}=[${names}]. Nothing changed.`);
268
271
  }
269
272
  const wrong = wrongValues(system, field, value, onSheet);
270
273
  const links = allowedValues(system, field, onSheet) === undefined ? [] : (Array.isArray(value) ? value : [value]).filter((item) => /\[\[/.test(String(item)));
@@ -19,7 +19,7 @@ const listedItems = 8;
19
19
  export const show = defineCommand({
20
20
  name: "show",
21
21
  description: "Show a page of the world, or one of its sections or secrets, with what it inherits from the pages it derives from. "
22
- + "It also says where the thing is and which pages link to it. Use it before describing anything that already exists, so that what you say matches what is written. "
22
+ + "It also says where the thing is and which pages link to it. "
23
23
  + "The player character and the companions show their sheet in groups, such as Abilities; Page#Group shows one group with how each number is made. "
24
24
  + 'Example: page "Old lighthouse#Cellar".',
25
25
  group: "game",
@@ -196,8 +196,7 @@ export const status = defineCommand({
196
196
  const companion = (member) => `${member.name}${member.with === undefined ? whereabouts(member) : `, with ${member.with}`}${memberCounters(member)}`;
197
197
  const state = [
198
198
  result.offerDashboard && result.dashboard !== undefined
199
- ? `Offer the player their dashboard in your first answer, with its link: ${result.dashboard}. Their sheet, their settings and the dice of the checks you ask `
200
- + "follow the game there, live; the link stays the same, and a page they keep open comes back by itself next time."
199
+ ? `Offer the player their dashboard's link in your first answer: ${result.dashboard}.`
201
200
  : "",
202
201
  result.campaign.join(" · "),
203
202
  ...result.meanings,
@@ -214,7 +213,7 @@ export const status = defineCommand({
214
213
  ...(result.players.length === 0 ? [`No player character yet.${sheetNote(result.sheet)}`] : result.players.map((member) => `PC: ${member.name}${whereabouts(member)}${memberCounters(member)}`)),
215
214
  ...result.around.map((one) => `Around ${one.who.join(" and ")}: ${one.text}`),
216
215
  namesLine("Companions", result.companions.map(companion), "find text companion, type character", "; "),
217
- result.dashboard === undefined || result.offerDashboard ? "" : `Dashboard: ${result.dashboard}, the player's sheet, their settings and the dice of the checks you ask, live.`,
216
+ result.dashboard === undefined || result.offerDashboard ? "" : `Dashboard: ${result.dashboard}.`,
218
217
  result.pictures ?? "",
219
218
  result.importing,
220
219
  result.translation ?? "",
@@ -232,10 +231,15 @@ export const status = defineCommand({
232
231
  result.clocks.length === 0 ? "" : `Clocks: ${result.clocks.join(" · ")}`,
233
232
  result.halfLoaded === undefined ? "" : `The load of save ${result.halfLoaded} stopped halfway: call save load to finish it, before anything else.`,
234
233
  ...result.contradictions,
235
- result.opening ? "Write nothing to the player until your message is ready: your first words are the opening itself." : "",
236
234
  result.problems === 0 ? "" : `${result.problems} ${result.problems === 1 ? "problem" : "problems"} in the campaign: validate lists them, with how to fix each.`,
237
235
  ];
238
- return [state.filter((line) => line !== "").join("\n"), ...result.sessionParts].join("\n\n");
236
+ // The opening's line last, after the session's parts, where the master reads it just before writing (T-64).
237
+ const opening = result.opening ? "Write nothing to the player until your message is ready: your first words are the opening itself." : "";
238
+ // At a session's opening with no planned event on a clock, the threats to set in motion, read before the opening's line (T-168).
239
+ const threats = result.sessionParts.length > 0 && result.clocks.length === 0
240
+ ? "No threat is in motion yet: before you open, write two or three, each a planned event with a clock and who makes it happen (by), the adventure's foe among them."
241
+ : "";
242
+ return [state.filter((line) => line !== "").join("\n"), ...result.sessionParts, threats, opening].filter((block) => block !== "").join("\n\n");
239
243
  },
240
244
  });
241
245
  /**
@@ -106,6 +106,8 @@ export interface Fighter {
106
106
  /** In a fight, marked by the master as attacking the party (D-415). */
107
107
  hostile?: true;
108
108
  stranger?: true;
109
+ /** Whose turn it is: the one of two strangers seen alike, as two hooded men, whom the turn's name alone cannot tell. */
110
+ acting?: true;
109
111
  health?: string;
110
112
  /** How hard a foe heard in words is hit: low in the lower half of the system's words, down at the last. */
111
113
  wound?: "low" | "down";
@@ -4,13 +4,13 @@ import { comparableText } from "../../core/text.js";
4
4
  import { readCounter } from "../../counters/index.js";
5
5
  import { reachable, squareName, squaresApart, withoutMapBlock } from "../../grid/index.js";
6
6
  import { hiddenImageName } from "../../images/index.js";
7
- import { environmentAt, isPlayerCharacter, locate, pagesWithName, pagesWithNameOrAlias, parsePageReference, placesAround } from "../../pages/index.js";
7
+ import { environmentAt, isPlayerCharacter, links, locate, pagesWithName, pagesWithNameOrAlias, parsePageReference, placesAround } from "../../pages/index.js";
8
8
  import { effectsOf } from "../shared/effect-layer.js";
9
9
  import { conditionMark, effectParts, keptEffects, systemNamed } from "../shared/effects.js";
10
10
  import { isTurnOf, movedThisTurn, sideOf, walkingSpeed } from "../shared/grid-moves.js";
11
11
  import { placeGrid, placeLook, standing } from "../shared/grids.js";
12
12
  import { imageFile, ownImage, shownImage } from "../shared/images.js";
13
- import { knownSecretsApart, knownText, knowsPage } from "../shared/knowledge.js";
13
+ import { inKnownWords, knownSecretsApart, knownText, knowsPage, readsLink } from "../shared/knowledge.js";
14
14
  import { pageCounters } from "../shared/page-counters.js";
15
15
  import { measuresOf } from "../shared/roads.js";
16
16
  import { copyPage, readOpenScene } from "../shared/scene.js";
@@ -28,7 +28,8 @@ export function shownPlace(sight) {
28
28
  const known = (holder) => (knowsPage(knowledge, holder) ? holder.name : undefined);
29
29
  const placed = (holder) => (known(holder) === undefined ? {} : { place: holder.name });
30
30
  const around = [
31
- ...environmentAt(world, place).map(({ entry, place: holder }) => ({ name: entry.name, value: entry.value, ...placed(holder) })),
31
+ ...environmentAt(world, place).filter(({ entry }) => !pointsToUnread(sight, entry.value))
32
+ .map(({ entry, place: holder }) => ({ name: entry.name, value: inKnownWords(world, knowledge, entry.value), ...placed(holder) })),
32
33
  ...placesAround(world, place).flatMap((holder) => effectsOf(holder).map((effect) => ({ effect: effect.name, ...(effect.end === undefined ? {} : { end: effect.end }), ...placed(holder) }))),
33
34
  ];
34
35
  const present = world.pages.filter((page) => page.type === "character" && page.fields.status !== "dead" && locate(world, page).chain[0] === place
@@ -233,7 +234,7 @@ function fightersOf(sight, scene) {
233
234
  const names = scene.order ?? [...scene.with.map((link) => parsePageReference(link).name), ...Object.keys(scene.copies)];
234
235
  return names.flatMap((name) => {
235
236
  const fighter = fighterOf(sight, scene, name);
236
- return fighter === undefined ? [] : [fighter];
237
+ return fighter === undefined ? [] : [scene.turn !== undefined && comparableText(name) === comparableText(scene.turn) ? { ...fighter, acting: true } : fighter];
237
238
  });
238
239
  }
239
240
  /** One in the fight (D-314): a copy as the character knows its creature, a character as it knows them; the party in full, the others by what anyone sees. */
@@ -343,6 +344,11 @@ function partyRole(sight, page) {
343
344
  function partyFirst(sight) {
344
345
  return [...sight.party.filter((page) => page === sight.knowledge.pc), ...sight.party.filter((page) => page !== sight.knowledge.pc)];
345
346
  }
347
+ /** Whether an entry of the environment is only a link to a section or secret the character cannot read, as the master's encounter table: it tells the player nothing. */
348
+ function pointsToUnread(sight, value) {
349
+ const pointed = links(value);
350
+ return /^\[\[[^\]]*\]\]$/.test(value.trim()) && pointed.length === 1 && pointed[0].section !== undefined && !readsLink(sight.world, sight.knowledge, pointed[0]);
351
+ }
346
352
  /** Someone the character knows, with their picture and their role. */
347
353
  function person(sight, page) {
348
354
  const role = partyRole(sight, page);
@@ -398,7 +404,13 @@ function strangerName(scene, copy) {
398
404
  }
399
405
  /** What the character sees of a character it does not know by name, as the master said (D-416); someone when the master said nothing. */
400
406
  function seenName(scene, name) {
401
- return (scene === undefined ? undefined : seenOf(scene, name)) ?? "someone";
407
+ const said = scene === undefined ? undefined : seenOf(scene, name);
408
+ if (scene === undefined || said === undefined) {
409
+ return "someone";
410
+ }
411
+ // Two seen alike are numbered as copies are, in the order the master named them, so that the player and the master tell them apart: uomo incappucciato 2.
412
+ const alike = Object.entries(scene.seen ?? {}).filter(([, words]) => comparableText(words) === comparableText(said)).map(([key]) => comparableText(key));
413
+ return alike.length < 2 ? said : `${said} ${alike.indexOf(comparableText(parsePageReference(name).name)) + 1}`;
402
414
  }
403
415
  /** What the master said the character sees of a character or a kind of creature, by its name. */
404
416
  function seenOf(scene, name) {
@@ -7,7 +7,7 @@ import { comparableText, sameName, valueNamed, withArticle } from "../../core/te
7
7
  import { formatCounter, readCounter } from "../../counters/index.js";
8
8
  import { readEffects } from "../../effects/index.js";
9
9
  import { formatAmount, namesCoins, readAmount } from "../../money/index.js";
10
- import { alwaysInList, baseFieldOf, baseValue, changedEnvironment, changedFields, checkFieldChange, concernsPlayer, containerFieldOf, countedText as countInText, declaredKind, derivedPages, environmentAt, equippedNotes, findPage, followersOf, formatEnvironmentEntry, goodsFieldProblems, hidingMessage, holdsField, inheritedFields, introductionFollowersOf, introductionText, isCounterField, isDeclaredUncounted, isEmptyField, isNeverInherited, isPartyMember, isPlayerCharacter, isStandardField, keepersOf, linksIn, listFieldNames, misspelledFieldProblem, misspelledStandardField, namesakes, newBaseProblem, newPageFields, ownFieldChange, pageNamed, pagesWithName, pageTypeNames, parsePageReference, readEntry, readEnvironment, readFieldValue, readOnlyMessage, removedFieldName, sameAsBase, sectionFollowersOf, systemKnowsReason, systemLabel, systemPageNamed, textParts, textsIn, withPage, writePage, writtenFieldName, } from "../../pages/index.js";
10
+ import { alwaysInList, baseFieldOf, baseValue, changedEnvironment, changedFields, checkFieldChange, concernsPlayer, containerFieldOf, countedText as countInText, declaredKind, derivedPages, environmentAt, equippedNotes, findPage, followersOf, formatEnvironmentEntry, goodsFieldProblems, hidingMessage, holdsField, inheritedFields, introductionFollowersOf, introductionText, isCounterField, isDeclaredUncounted, isEmptyField, isNeverInherited, isPartyMember, isPlayerCharacter, isStandardField, keepersOf, linkListItems, linksIn, listFieldNames, misspelledFieldProblem, misspelledStandardField, namesakes, newBaseProblem, newPageFields, ownFieldChange, pageNamed, pagesWithName, pageTypeNames, parsePageReference, readEntry, readEnvironment, readFieldValue, readOnlyMessage, removedFieldName, sameAsBase, sectionFollowersOf, systemKnowsReason, systemLabel, systemPageNamed, textParts, textsIn, withPage, writePage, writtenFieldName, } from "../../pages/index.js";
11
11
  import { featureParts, mergedFeatures } from "../../progression/index.js";
12
12
  import { bondNotes, checkBonds } from "../shared/bonds.js";
13
13
  import { effectiveFields, effectsField } from "../shared/effect-layer.js";
@@ -154,7 +154,7 @@ export const write = defineCommand({
154
154
  const result = { page: page.name, type: page.type, path: page.path, created, changed, ...writtenNames(world, existing, fields, page), section, mode, was };
155
155
  // Said when the character joins the party, here or by being created in it; then status says it until the sheet is whole (DAT-2).
156
156
  const joined = changed && (created || existing?.fields.role !== page.fields.role);
157
- const sheet = joined ? joiningNotes(system, now, page) : [];
157
+ const sheet = joined ? joiningNotes(system, now, page, context) : [];
158
158
  const gained = changed && existing !== undefined ? progressionNotes(context, system, world, now, existing, page, Object.keys(fields.set ?? {})) : [];
159
159
  const thresholds = changed && isPartyMember(page) ? writtenThresholdNotes(root, system, world, now, existing, page, fields.set ?? {}) : [];
160
160
  // Points that reach a level the classes have not, or fall short of the level's (PRO-6); a field the settings leave out (DAT-10).
@@ -1142,7 +1142,8 @@ function listFromText(name, value) {
1142
1142
  if (typeof value !== "string") {
1143
1143
  return value;
1144
1144
  }
1145
- const writtenAsList = /^\[(?!\[).*\]$/s.test(value.trim());
1145
+ // Links separated by commas are a list, as on the command line, for a list of the game system too, such as spells (T-167).
1146
+ const writtenAsList = /^\[(?!\[).*\]$/s.test(value.trim()) || linkListItems(value) !== undefined;
1146
1147
  return writtenAsList || listFieldNames.some((field) => comparableText(field) === comparableText(name)) ? readFieldValue(value) : value;
1147
1148
  }
1148
1149
  function readAssignment(assignment) {
@@ -2,7 +2,7 @@
2
2
  // when a file comes twice, so that what was read is what is written.
3
3
  import { resolve, sep } from "node:path";
4
4
  // Names Windows keeps for its devices, whatever their extension.
5
- const reserved = /^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i;
5
+ const reserved = /^(con|prn|aux|nul|com[\d¹²³]|lpt[\d¹²³])(\..*)?$/i;
6
6
  // What a file name on Windows cannot hold.
7
7
  const unwritable = /[<>:"|?*\u0000-\u001f]/;
8
8
  /** Whether a name is one Windows keeps for a device, as CON or nul.txt. */
@@ -103,6 +103,8 @@ export interface PackageInfo {
103
103
  kind?: string;
104
104
  /** The version of the extensions' API it is made for (D-441). */
105
105
  api?: number;
106
+ /** The game system an extension is made for, as its package.json says beside its kind, so that a catalog tells it before it is installed (D-548). */
107
+ system?: string;
106
108
  description?: string;
107
109
  /** Who wrote it, as npm gives it. */
108
110
  author?: string;
@@ -123,7 +123,7 @@ export interface GameView {
123
123
  pc: boolean;
124
124
  }[];
125
125
  } | undefined;
126
- /** A page by its name or alias (D-505); undefined when no page, or more than one, has it. */
126
+ /** A page by its name or alias (D-505), or a copy in the open scene by its name, as a foe's; undefined when no page, or more than one, has it. */
127
127
  page(name: string): GamePage | undefined;
128
128
  /** The open scene: its title, when it opened, and in a fight its round and whose turn it is (D-505); undefined when none is open. */
129
129
  scene(): {
@@ -3,11 +3,11 @@ import { type CardPage, type FigureSize } from "./package-api.ts";
3
3
  export type { CardPage, FigureSize };
4
4
  /**
5
5
  * The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
6
- * system.yaml may declare. It goes up with every addition a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
6
+ * system.yaml may declare. It goes up with every addition an older engine would refuse or misread, and the engine reads a range (D-515, D-549): 2 added the widgets, 3 an extension's
7
7
  * additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package, 6 the fields of
8
- * knowledge of a game system (sheet-knowledge), 7 what a page carries and the pictures of the dashboard's states.
8
+ * knowledge of a game system (sheet-knowledge), 7 what a page carries and the pictures of the dashboard's states, 8 where a game system's oracle says yes.
9
9
  */
10
- export declare const packageApi = 7;
10
+ export declare const packageApi = 8;
11
11
  /**
12
12
  * Our game systems (D-513): the name a campaign gives each, which package install takes alone, its package, and what it is; the setup offers them even when
13
13
  * npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.