rpg-engine 0.4.1 → 0.6.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 (231) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/settings.d.ts +1 -0
  3. package/dist/campaign/settings.js +6 -5
  4. package/dist/command-line.js +12 -5
  5. package/dist/commands/advance.js +1 -1
  6. package/dist/commands/ask.d.ts +37 -2
  7. package/dist/commands/ask.js +106 -35
  8. package/dist/commands/change.js +28 -17
  9. package/dist/commands/config.d.ts +1 -1
  10. package/dist/commands/config.js +69 -21
  11. package/dist/commands/effect.js +42 -23
  12. package/dist/commands/find.js +1 -1
  13. package/dist/commands/game-adventures.js +2 -2
  14. package/dist/commands/game-catalog.d.ts +13 -0
  15. package/dist/commands/game-catalog.js +26 -2
  16. package/dist/commands/game-checks.js +23 -21
  17. package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
  18. package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
  19. package/dist/commands/game-effects.d.ts +12 -4
  20. package/dist/commands/game-effects.js +21 -13
  21. package/dist/commands/game-examples.d.ts +22 -0
  22. package/dist/commands/game-examples.js +72 -0
  23. package/dist/commands/game-extension-list.d.ts +31 -3
  24. package/dist/commands/game-extension-list.js +94 -6
  25. package/dist/commands/game-images.d.ts +1 -1
  26. package/dist/commands/game-images.js +3 -2
  27. package/dist/commands/game-library.d.ts +3 -0
  28. package/dist/commands/game-library.js +2 -2
  29. package/dist/commands/game-mode.js +1 -1
  30. package/dist/commands/game-package-code.d.ts +87 -0
  31. package/dist/commands/game-package-code.js +648 -0
  32. package/dist/commands/game-package-hooks.d.ts +37 -0
  33. package/dist/commands/game-package-hooks.js +116 -0
  34. package/dist/commands/game-recipes.js +2 -2
  35. package/dist/commands/game-reminders.d.ts +5 -2
  36. package/dist/commands/game-reminders.js +7 -4
  37. package/dist/commands/game-rules.d.ts +4 -1
  38. package/dist/commands/game-rules.js +7 -1
  39. package/dist/commands/game-upkeep.js +3 -3
  40. package/dist/commands/game-view-place.d.ts +8 -20
  41. package/dist/commands/game-view-place.js +16 -35
  42. package/dist/commands/game-widgets.d.ts +42 -8
  43. package/dist/commands/game-widgets.js +182 -31
  44. package/dist/commands/game-world.d.ts +32 -3
  45. package/dist/commands/game-world.js +113 -24
  46. package/dist/commands/image.js +1 -1
  47. package/dist/commands/init.js +2 -2
  48. package/dist/commands/mode.d.ts +1 -1
  49. package/dist/commands/package.d.ts +15 -1
  50. package/dist/commands/package.js +96 -24
  51. package/dist/commands/progression.d.ts +2 -0
  52. package/dist/commands/progression.js +7 -2
  53. package/dist/commands/roll.d.ts +2 -0
  54. package/dist/commands/roll.js +50 -24
  55. package/dist/commands/rules.js +6 -4
  56. package/dist/commands/scene.d.ts +2 -2
  57. package/dist/commands/scene.js +13 -10
  58. package/dist/commands/sheet.js +10 -1
  59. package/dist/commands/status.d.ts +1 -0
  60. package/dist/commands/status.js +14 -4
  61. package/dist/commands/trade.js +6 -4
  62. package/dist/commands/translate.js +2 -2
  63. package/dist/commands/travel.js +1 -1
  64. package/dist/commands/validate.js +2 -2
  65. package/dist/commands/view.d.ts +12 -4
  66. package/dist/commands/view.js +11 -8
  67. package/dist/commands/worked-out.js +11 -5
  68. package/dist/commands/write.d.ts +8 -1
  69. package/dist/commands/write.js +84 -25
  70. package/dist/core/command-reference.js +3 -2
  71. package/dist/core/consents.d.ts +18 -0
  72. package/dist/core/consents.js +93 -0
  73. package/dist/core/context.d.ts +68 -27
  74. package/dist/core/context.js +3 -1
  75. package/dist/core/examples.d.ts +25 -0
  76. package/dist/core/examples.js +19 -0
  77. package/dist/core/files.d.ts +2 -0
  78. package/dist/core/files.js +10 -1
  79. package/dist/core/package-api.d.ts +388 -0
  80. package/dist/core/package-declarations.d.ts +102 -0
  81. package/dist/core/package-declarations.js +81 -0
  82. package/dist/core/registry.d.ts +4 -0
  83. package/dist/core/text.d.ts +5 -0
  84. package/dist/core/text.js +12 -0
  85. package/dist/dashboard/acts.js +31 -24
  86. package/dist/dashboard/address.js +4 -1
  87. package/dist/dashboard/api.js +65 -3
  88. package/dist/dashboard/app.js +222 -98
  89. package/dist/dashboard/ask-card.js +169 -0
  90. package/dist/dashboard/asked-dice.js +57 -0
  91. package/dist/dashboard/dice/tray.js +6 -4
  92. package/dist/dashboard/extension-widgets.js +136 -16
  93. package/dist/dashboard/faces.js +6 -4
  94. package/dist/dashboard/help.js +10 -3
  95. package/dist/dashboard/i18n/ar.json +34 -29
  96. package/dist/dashboard/i18n/cs.json +34 -29
  97. package/dist/dashboard/i18n/da.json +34 -29
  98. package/dist/dashboard/i18n/de.json +34 -29
  99. package/dist/dashboard/i18n/el.json +34 -29
  100. package/dist/dashboard/i18n/es.json +34 -29
  101. package/dist/dashboard/i18n/fi.json +34 -29
  102. package/dist/dashboard/i18n/fr.json +34 -29
  103. package/dist/dashboard/i18n/he.json +34 -29
  104. package/dist/dashboard/i18n/hi.json +34 -29
  105. package/dist/dashboard/i18n/hu.json +34 -29
  106. package/dist/dashboard/i18n/is.json +34 -29
  107. package/dist/dashboard/i18n/it.json +34 -29
  108. package/dist/dashboard/i18n/ja.json +34 -29
  109. package/dist/dashboard/i18n/ko.json +34 -29
  110. package/dist/dashboard/i18n/nb.json +34 -29
  111. package/dist/dashboard/i18n/nl.json +34 -29
  112. package/dist/dashboard/i18n/pl.json +34 -29
  113. package/dist/dashboard/i18n/pt.json +34 -29
  114. package/dist/dashboard/i18n/ro.json +34 -29
  115. package/dist/dashboard/i18n/ru.json +34 -29
  116. package/dist/dashboard/i18n/sv.json +34 -29
  117. package/dist/dashboard/i18n/tr.json +34 -29
  118. package/dist/dashboard/i18n/uk.json +34 -29
  119. package/dist/dashboard/i18n/zh.json +34 -29
  120. package/dist/dashboard/icons.js +4 -1
  121. package/dist/dashboard/kit.js +35 -0
  122. package/dist/dashboard/labels.js +1 -0
  123. package/dist/dashboard/pack-card.js +97 -0
  124. package/dist/dashboard/package-page.js +50 -0
  125. package/dist/dashboard/packages.js +180 -24
  126. package/dist/dashboard/page-code.js +248 -0
  127. package/dist/dashboard/party.js +13 -14
  128. package/dist/dashboard/people.js +4 -0
  129. package/dist/dashboard/person-panel.js +110 -0
  130. package/dist/dashboard/place-map-view.js +11 -6
  131. package/dist/dashboard/rolls.js +2 -2
  132. package/dist/dashboard/scene.js +12 -9
  133. package/dist/dashboard/settings.js +55 -9
  134. package/dist/dashboard/sheet.js +21 -13
  135. package/dist/dashboard/status.js +69 -15
  136. package/dist/dashboard/style.css +859 -574
  137. package/dist/dashboard/top.js +75 -25
  138. package/dist/dashboard/turns.js +34 -13
  139. package/dist/dashboard/widgets.js +9 -2
  140. package/dist/dashboard-server.js +246 -11
  141. package/dist/dice/roll-dice.js +1 -1
  142. package/dist/effects/effect.d.ts +7 -4
  143. package/dist/effects/effect.js +12 -9
  144. package/dist/extensions/engine.d.ts +4 -0
  145. package/dist/extensions/engine.js +74 -0
  146. package/dist/extensions/extension.d.ts +28 -33
  147. package/dist/extensions/extension.js +37 -46
  148. package/dist/extensions/index.d.ts +4 -3
  149. package/dist/extensions/index.js +5 -2
  150. package/dist/extensions/packages.d.ts +14 -0
  151. package/dist/extensions/packages.js +148 -12
  152. package/dist/extensions/words.d.ts +2 -1
  153. package/dist/extensions/words.js +5 -4
  154. package/dist/index.d.ts +1 -3
  155. package/dist/mcp-server.js +52 -15
  156. package/dist/page-words.d.ts +4 -0
  157. package/dist/page-words.js +4 -4
  158. package/dist/page.d.ts +218 -0
  159. package/dist/page.js +2 -0
  160. package/dist/pages/index.d.ts +1 -1
  161. package/dist/pages/index.js +1 -1
  162. package/dist/pages/load.d.ts +7 -1
  163. package/dist/pages/load.js +10 -5
  164. package/dist/pages/page-file.js +1 -1
  165. package/dist/pages/stack-writes.js +5 -4
  166. package/dist/pages/standard-fields.d.ts +2 -0
  167. package/dist/pages/standard-fields.js +8 -1
  168. package/dist/pages/world.d.ts +8 -0
  169. package/dist/pages/world.js +9 -2
  170. package/dist/systems/game-system.d.ts +61 -30
  171. package/dist/systems/game-system.js +159 -50
  172. package/dist/systems/index.d.ts +3 -3
  173. package/dist/systems/index.js +3 -3
  174. package/dist/systems/system-code.d.ts +29 -88
  175. package/dist/systems/system-code.js +68 -23
  176. package/dist/systems/words.d.ts +2 -0
  177. package/dist/systems/words.js +11 -0
  178. package/dist/testing.d.ts +76 -0
  179. package/dist/testing.js +197 -0
  180. package/instructions/combat.md +2 -2
  181. package/instructions/core.md +2 -2
  182. package/instructions/dashboard.md +1 -1
  183. package/instructions/mentor-tutorial.md +1 -1
  184. package/instructions/play.md +2 -2
  185. package/instructions/setup.md +1 -1
  186. package/package.json +15 -2
  187. package/systems/5e/LICENSE.md +13 -3
  188. package/systems/5e/dist/dying.js +83 -16
  189. package/systems/5e/dist/index.js +2 -2
  190. package/systems/5e/dist/page-style.js +634 -0
  191. package/systems/5e/dist/page.js +166 -0
  192. package/systems/5e/dist/shown.js +23 -0
  193. package/systems/5e/instructions/combat.md +1 -0
  194. package/systems/5e/package.json +4 -2
  195. package/systems/5e/system.yaml +35 -7
  196. package/systems/5e/versions/srd-5.1/system.yaml +2 -0
  197. package/systems/5e/words/ar.yaml +30 -0
  198. package/systems/5e/words/cs.yaml +30 -0
  199. package/systems/5e/words/da.yaml +30 -0
  200. package/systems/5e/words/de.yaml +30 -0
  201. package/systems/5e/words/el.yaml +30 -0
  202. package/systems/5e/words/es.yaml +30 -0
  203. package/systems/5e/words/fi.yaml +30 -0
  204. package/systems/5e/words/fr.yaml +30 -0
  205. package/systems/5e/words/he.yaml +30 -0
  206. package/systems/5e/words/hi.yaml +30 -0
  207. package/systems/5e/words/hu.yaml +30 -0
  208. package/systems/5e/words/is.yaml +30 -0
  209. package/systems/5e/words/it.yaml +30 -0
  210. package/systems/5e/words/ja.yaml +30 -0
  211. package/systems/5e/words/ko.yaml +30 -0
  212. package/systems/5e/words/nb.yaml +30 -0
  213. package/systems/5e/words/nl.yaml +30 -0
  214. package/systems/5e/words/pl.yaml +30 -0
  215. package/systems/5e/words/pt.yaml +30 -0
  216. package/systems/5e/words/ro.yaml +30 -0
  217. package/systems/5e/words/ru.yaml +30 -0
  218. package/systems/5e/words/sv.yaml +30 -0
  219. package/systems/5e/words/tr.yaml +30 -0
  220. package/systems/5e/words/uk.yaml +30 -0
  221. package/systems/5e/words/zh.yaml +30 -0
  222. package/dist/commands/game-extensions.d.ts +0 -34
  223. package/dist/commands/game-extensions.js +0 -182
  224. package/dist/commands/game-system-code.d.ts +0 -25
  225. package/dist/commands/game-system-code.js +0 -172
  226. package/dist/dashboard/death-save.js +0 -67
  227. package/dist/dashboard/dying.js +0 -46
  228. package/dist/dashboard/save-outcome.js +0 -42
  229. package/dist/dashboard/spend.js +0 -115
  230. package/dist/extensions/api.d.ts +0 -155
  231. /package/dist/{extensions/api.js → core/package-api.js} +0 -0
@@ -3,20 +3,22 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
3
3
  import { spawn } from "node:child_process";
4
4
  import { z } from "zod";
5
5
  import { findCampaign, hasCharacterAgent, refreshHostFiles } from "./campaign/index.js";
6
- import { extensionCommands } from "./commands/game-extensions.js";
6
+ import { campaignExamples } from "./commands/game-examples.js";
7
7
  import { outsideNews, whileClosedNews } from "./commands/game-outside.js";
8
+ import { packageCommands } from "./commands/game-package-code.js";
8
9
  import { newChatText, wentBackTo } from "./commands/game-saves.js";
9
10
  import { campaignWorld } from "./commands/game-world.js";
10
11
  import { commands } from "./commands/index.js";
11
12
  import { systemConfirm } from "./confirm/index.js";
12
13
  import { defaultContext, packagesFolder } from "./core/context.js";
13
14
  import { downloadBytes } from "./core/download.js";
15
+ import { neutralExamples, withExamples } from "./core/examples.js";
14
16
  import { SessionStore } from "./core/session-store.js";
15
17
  import { FileStore, withFiles } from "./core/store.js";
16
18
  import { getVersion } from "./core/version.js";
17
19
  import { startDashboard } from "./dashboard-server.js";
18
20
  import { systemPageReader } from "./documents/index.js";
19
- import { npmPackages } from "./extensions/index.js";
21
+ import { npmEngine, npmPackages } from "./extensions/index.js";
20
22
  import { hostInstructions, startInstructions } from "./instructions/index.js";
21
23
  import { libraryRunner } from "./library-reader.js";
22
24
  import { computerHelpers, hostPictures, hostReader, hostWriter } from "./pictures/index.js";
@@ -53,11 +55,20 @@ export function createMcpServer(context = defaultContext(), environment = proces
53
55
  askingTools.filter((tool) => !tool.enabled).forEach((tool) => tool.enable());
54
56
  }
55
57
  };
58
+ // The examples of the descriptions in the names of the campaign's system, read without the session's store before the host asks for the tools (D-518).
59
+ const examples = { shown: examplesFor(context, new FileStore(context.systemFolders)) };
60
+ const coreTools = new Map();
61
+ // After every call the descriptions follow the campaign's system, as after init or config system, and the extensions' tools follow campaign.yaml.
62
+ const afterCall = () => {
63
+ refreshExamples(coreTools, examples, examplesFor(context, context.files ?? new FileStore(context.systemFolders)));
64
+ return extensions();
65
+ };
56
66
  // The tools of the campaign's extensions, kept in step after every call, as one that installs an extension or makes the campaign (D-63).
57
- const extensions = extensionTools(server, context, (command) => (input, extra) => runTool(command, input, context, extra, prepare, outside).finally(extensions));
67
+ const extensions = extensionTools(server, context, (command) => (input, extra) => runTool(command, input, context, extra, prepare, outside, examples).finally(afterCall));
58
68
  firstExtensions.set(server, extensions());
59
69
  for (const command of commands) {
60
- const tool = server.registerTool(command.name, toolConfig(command), (input, extra) => runTool(command, input, context, extra, prepare, outside).finally(extensions));
70
+ const tool = server.registerTool(command.name, toolConfig(command, examples.shown), (input, extra) => runTool(command, input, context, extra, prepare, outside, examples).finally(afterCall));
71
+ coreTools.set(command, tool);
61
72
  if (command.needsPlayer && context.player === undefined) {
62
73
  tool.disable();
63
74
  askingTools.push(tool);
@@ -101,6 +112,7 @@ export async function startMcpServer() {
101
112
  importRunner: (root) => spawn(process.execPath, [process.argv[1] ?? "", "import"], { cwd: root, detached: true, stdio: "ignore", windowsHide: true, env: { ...process.env, RPG_HOST: host() ?? "" } }).unref(),
102
113
  helpers: computerHelpers(),
103
114
  packages: npmPackages(packagesFolder()),
115
+ engine: npmEngine(),
104
116
  confirm: systemConfirm(process.platform, process.env),
105
117
  ocr: systemPageReader(process.platform, process.env),
106
118
  readLibrary: libraryRunner(),
@@ -173,7 +185,7 @@ function extensionTools(server, context, handler) {
173
185
  const store = context.files ?? new FileStore(context.systemFolders);
174
186
  const own = await withFiles(store, async () => {
175
187
  const root = findCampaign(context.folder);
176
- return root === undefined ? { commands: [], sources: {} } : await extensionCommands(root, context, taken);
188
+ return root === undefined ? { commands: [], sources: {} } : await packageCommands(root, context, taken);
177
189
  });
178
190
  for (const command of own.commands) {
179
191
  const kept = registered.get(command.name);
@@ -182,7 +194,7 @@ function extensionTools(server, context, handler) {
182
194
  kept.tool.remove();
183
195
  }
184
196
  if (kept === undefined || kept.source !== source) {
185
- registered.set(command.name, { tool: server.registerTool(command.name, toolConfig(command), handler(command)), source });
197
+ registered.set(command.name, { tool: server.registerTool(command.name, toolConfig(command, neutralExamples), handler(command)), source });
186
198
  }
187
199
  else if (!kept.tool.enabled) {
188
200
  kept.tool.enable();
@@ -201,30 +213,55 @@ function extensionTools(server, context, handler) {
201
213
  * The host is shown each tool's parameters as they are, strict; the SDK lets any object through, so that runTool checks it and says how to call the tool:
202
214
  * a master who calls one without loading its schema reads its parameters in the answer, not zod's words before our handler.
203
215
  */
204
- function toolConfig(command) {
216
+ function toolConfig(command, examples) {
205
217
  const annotations = command.readOnly ? { readOnlyHint: true } : undefined;
206
218
  const meta = command.alwaysLoad ? { "anthropic/alwaysLoad": true } : undefined;
207
- return { description: command.description, inputSchema: z.looseObject({}).meta(shownInput(command)), annotations, _meta: meta };
219
+ return { description: withExamples(command.description, examples), inputSchema: shownSchema(command, examples), annotations, _meta: meta };
220
+ }
221
+ /** The examples for the campaign of the server's folder, read through a store; neutral where it has none, or where it does not read. */
222
+ function examplesFor(context, store) {
223
+ try {
224
+ return withFiles(store, () => campaignExamples(findCampaign(context.folder), context));
225
+ }
226
+ catch {
227
+ return neutralExamples;
228
+ }
229
+ }
230
+ /** Gives the core's tools the examples of a system other than the one shown, as after config system: the host hears that the list changed. */
231
+ function refreshExamples(tools, examples, now) {
232
+ if (JSON.stringify(now) === JSON.stringify(examples.shown)) {
233
+ return;
234
+ }
235
+ examples.shown = now;
236
+ for (const [command, tool] of tools) {
237
+ tool.inputSchema = shownSchema(command, now);
238
+ tool.update({ description: withExamples(command.description, now) });
239
+ }
240
+ }
241
+ function shownSchema(command, examples) {
242
+ return z.looseObject({}).meta(shownInput(command, examples));
208
243
  }
209
244
  // The JSON schema of each command's input, as the SDK would write it from the strict schema.
210
245
  const shownInputs = new WeakMap();
211
- function shownInput(command) {
246
+ function shownInput(command, examples) {
212
247
  let shown = shownInputs.get(command);
213
248
  if (shown === undefined) {
214
249
  shown = z.toJSONSchema(command.input.strict(), { target: "draft-7", io: "input" });
215
250
  shownInputs.set(command, shown);
216
251
  }
217
- return shown;
252
+ const fields = shown.properties ?? {};
253
+ const properties = Object.entries(fields).map(([name, field]) => [name, field.description === undefined ? field : { ...field, description: withExamples(field.description, examples) }]);
254
+ return shown.properties === undefined ? shown : { ...shown, properties: Object.fromEntries(properties) };
218
255
  }
219
256
  /** The command's input, checked as its schema says; what is wrong comes with every parameter the tool takes, for a call made without the schema. */
220
- function checkedInput(command, input) {
257
+ function checkedInput(command, input, examples) {
221
258
  const parsed = command.input.strict().safeParse(input ?? {});
222
259
  if (parsed.success) {
223
260
  return parsed.data;
224
261
  }
225
262
  const given = typeof input === "object" && input !== null ? input : {};
226
263
  const wrong = parsed.error.issues.map((issue) => inputIssue(command.name, issue, given));
227
- const shown = shownInput(command);
264
+ const shown = shownInput(command, examples);
228
265
  const required = shown.required ?? [];
229
266
  const parameters = Object.entries(shown.properties ?? {}).map(([name, field]) => `- ${name}${required.includes(name) ? "" : " (optional)"}${field.description === undefined ? "" : `: ${field.description}`}`);
230
267
  const takes = parameters.length === 0 ? `${command.name} takes no parameters.` : `${command.name} takes:\n${parameters.join("\n")}`;
@@ -242,8 +279,8 @@ function inputIssue(tool, issue, given) {
242
279
  }
243
280
  return path === "" ? `${issue.message}.` : `${path}: ${issue.message}.`;
244
281
  }
245
- async function runTool(command, input, context, extra, prepare, outside) {
246
- const keepAlive = command.needsPlayer
282
+ async function runTool(command, input, context, extra, prepare, outside, examples) {
283
+ const keepAlive = command.needsPlayer || command.waitsForPlayer
247
284
  ? reportProgress(extra, () => (context.page?.asking?.() === true ? "waiting for the player's click on the dashboard" : "waiting for the player"))
248
285
  : command.slow === true
249
286
  ? reportProgress(extra, () => "still working")
@@ -272,7 +309,7 @@ async function runTool(command, input, context, extra, prepare, outside) {
272
309
  news = context.news?.();
273
310
  return { content: [{ type: "text", text: [...(news?.lines ?? []), back.refused].join("\n\n") }], isError: true };
274
311
  }
275
- const checked = checkedInput(command, input);
312
+ const checked = checkedInput(command, input, examples.shown);
276
313
  // What changed outside the chat comes before the command runs on it, its events fired (OUT-3).
277
314
  changedOutside = outside.take();
278
315
  // The call's own context, with its cancel, as the user stopping it (ASK-9).
@@ -11,6 +11,10 @@ export interface PageWords {
11
11
  export interface WordsSystem {
12
12
  name: string;
13
13
  folder: string;
14
+ /** The version of its rules the campaign plays, whose words go over the common ones (VER-3). */
15
+ version?: {
16
+ folder: string;
17
+ };
14
18
  }
15
19
  /** The page's words on the fly: what a language has, and the phrases the page asks first; `notify` tells the pages when more have come. */
16
20
  export interface PageTranslator {
@@ -6,7 +6,7 @@ import { dirname, join } from "node:path";
6
6
  import { stringify } from "yaml";
7
7
  import { files } from "./core/store.js";
8
8
  import { languagePackFor, packPhrases } from "./languages/index.js";
9
- import { systemWords } from "./systems/index.js";
9
+ import { layeredSystemWords, systemContentFolders, systemWords } from "./systems/index.js";
10
10
  // How many phrases go in one request.
11
11
  const batchSize = 130;
12
12
  // How long a language whose translation stopped short waits before it is tried again, so that a writer that fails is not called at every reading.
@@ -114,13 +114,13 @@ export function homeSystemWords(home, system, language) {
114
114
  }
115
115
  /** The system's words a language still lacks in the player's data folder, against its Italian list. */
116
116
  function systemMissing(home, language, system) {
117
- const italian = systemWords(system.folder, "it");
117
+ const italian = layeredSystemWords(systemContentFolders(system), "it");
118
118
  const own = homeSystemWords(home, system, language);
119
119
  return italian !== undefined && Object.keys(wordEntries(italian)).some((id) => !(id in wordEntries(own ?? { groups: {}, fields: {}, words: {} })));
120
120
  }
121
121
  /** The game system's words translated at once, all in one request so that one concept has one term, after its Italian list. */
122
122
  async function translateSystem(writer, home, language, system) {
123
- const italian = systemWords(system.folder, "it");
123
+ const italian = layeredSystemWords(systemContentFolders(system), "it");
124
124
  if (italian === undefined || !systemMissing(home, language, system)) {
125
125
  return;
126
126
  }
@@ -142,7 +142,7 @@ function missingPhrases(home, page, language) {
142
142
  }
143
143
  /** The game system's words a language still lacks on this computer, each by a short id from its place in the system's Italian list, with what it is. */
144
144
  function missingWords(home, language, system) {
145
- const italian = systemWords(system.folder, "it");
145
+ const italian = layeredSystemWords(systemContentFolders(system), "it");
146
146
  const own = wordEntries(homeSystemWords(home, system, language) ?? { groups: {}, fields: {}, words: {} });
147
147
  return Object.entries(italian === undefined ? {} : wordEntries(italian)).flatMap(([key, word], index) => {
148
148
  const section = key.includes(": ") ? key.slice(0, key.indexOf(": ")) : key;
package/dist/page.d.ts ADDED
@@ -0,0 +1,218 @@
1
+ import type { ComponentChildren, ComponentType, JSX } from "preact";
2
+ import type { DieTone, Track, WidgetText, WidgetValue } from "./core/package-api.ts";
3
+ export type { DieTone, Track, WidgetText, WidgetValue } from "./core/package-api.ts";
4
+ /** The room a figure takes on a wide screen, as its extension.yaml or system.yaml declares it; on a phone it shrinks to the width there is, keeping its shape. */
5
+ export interface FigureSize {
6
+ width: number;
7
+ height: number;
8
+ mirror?: boolean;
9
+ }
10
+ /** Where a figure is drawn: a chip in the top, a card beside the rolls, a card in a page, a roll's card, or the panel on someone of the party (D-516). */
11
+ export type FigurePlace = "top" | "side" | "page" | "ask" | "person";
12
+ /** The part a figure draws in place of the dashboard's own, its words translated: what the dashboard says of it to a screen reader. */
13
+ export type FigurePart = {
14
+ track: Track;
15
+ } | {
16
+ lead: WidgetText;
17
+ icon?: string;
18
+ value?: WidgetValue;
19
+ tone?: DieTone;
20
+ };
21
+ /** What every drawing of a package gets (D-510, D-511): its words and numbers in the dashboard's language, its direction, theme and motion, its commands. */
22
+ export interface PageProps {
23
+ /** The package's words in the dashboard's language, its {names} filled. */
24
+ words(text: string, values?: Record<string, string | number>): string;
25
+ /** A number as the dashboard's language writes it. */
26
+ number(value: number): string;
27
+ language: string;
28
+ dir: "ltr" | "rtl";
29
+ theme: "light" | "dark";
30
+ reducedMotion: boolean;
31
+ /** Runs a command of the package marked player, as the player: what it said (D-510); one marked readOnly tells the master nothing. */
32
+ run(command: string, input?: Record<string, unknown>): Promise<string>;
33
+ /** A field of the game system's sheet as the dashboard names it in its language, as PF for hp in Italian. */
34
+ field(name: string): string;
35
+ }
36
+ /** What the component of a figure gets (D-510). */
37
+ export interface FigureProps extends PageProps {
38
+ /** Its name, as its extension.yaml or system.yaml declares it. */
39
+ name: string;
40
+ /** What the widget's hook gave for the page code: in a roll's card, as it is after the dice, given once they land. */
41
+ data: unknown;
42
+ /** The data it drew before, once what it draws changed: in a roll's card, before the dice; for the figure to move from it. */
43
+ before?: unknown;
44
+ /** The part it draws, when it stands for one. */
45
+ part?: FigurePart;
46
+ place: FigurePlace;
47
+ size: FigureSize;
48
+ }
49
+ /** The pages of the dashboard a package's card or widget stands in, after their own cards (D-502, D-511): the Scene, the sheet, the World and the Journal. */
50
+ export declare const cardPages: readonly ["scene", "sheet", "world", "journal"];
51
+ export type CardPage = (typeof cardPages)[number];
52
+ /** A card a package puts in a page of the dashboard (D-511): its title and icon (a path on a grid of 24) in the dashboard's frame, its order, its inside. */
53
+ export interface PageCard {
54
+ page: CardPage;
55
+ title: string;
56
+ icon?: string;
57
+ order?: number;
58
+ /** One of its package's widgets, whose hook gives the card its data, for the character the card shows (D-514). */
59
+ widget?: string;
60
+ draw: ComponentType<PageCardProps>;
61
+ }
62
+ /** What a package's card in a page gets: its name and page; on the sheet whose sheet it is, in the Scene the player character in front; what the page shows there. */
63
+ export interface PageCardProps extends PageProps {
64
+ name: string;
65
+ page: CardPage;
66
+ who?: string;
67
+ /** On the sheet the character shown, in the Scene their place, as the dashboard's view gives them. */
68
+ view?: unknown;
69
+ /** The data its widget's hook gives for who, once it came, when the card names a widget. */
70
+ data?: unknown;
71
+ }
72
+ /** A page of a package's own (D-511), at #/pkg/<package>/<name>, linked from its row in Packages: its title and icon in the page's head, its whole inside. */
73
+ export interface OwnPage {
74
+ title: string;
75
+ icon?: string;
76
+ /**
77
+ * Where the dashboard's navigation has it (D-512): a tab beside Party, Scene, Journal and World, for what is central to a game, as a system's spells;
78
+ * the menu, the default, in the menu of the packages' icon at the top.
79
+ */
80
+ nav?: "tab" | "menu";
81
+ /** One of its package's widgets, whose hook gives the page its data (D-514). */
82
+ widget?: string;
83
+ draw: ComponentType<OwnPageProps>;
84
+ }
85
+ /** What a package's own page gets. */
86
+ export interface OwnPageProps extends PageProps {
87
+ name: string;
88
+ /** The data its widget's hook gives, once it came, when the page names a widget. */
89
+ data?: unknown;
90
+ }
91
+ /**
92
+ * What the component that draws the whole inside of a roll's card gets (D-510): a figure's props, and the question's buttons it draws with the dashboard's
93
+ * components, the dashboard keeping the question and the field for the player's own words.
94
+ */
95
+ export interface BodyProps extends FigureProps {
96
+ /** The widget's parts, its words translated. */
97
+ parts: unknown[];
98
+ /** The dice of a rest the card asks (ASK-14), as they stand: its buttons are then a die of each counter, in their order, and last the one that ends it. */
99
+ rest?: RestDice;
100
+ /** The last roll made from it, once its dice landed: its total and its faces. */
101
+ rolled?: {
102
+ total: number;
103
+ faces: number[];
104
+ };
105
+ /** The question's buttons, as the kit's Choices draws them. */
106
+ buttons: CardButton[];
107
+ /** The question a die asks over the buttons, as "A 1 came up: reroll?", when it is not the card's title. */
108
+ prompt?: string;
109
+ /** The rule under the buttons, in a line. */
110
+ rule?: string;
111
+ /** The button pressed, while its answer goes: the others wait. */
112
+ sent?: number;
113
+ /** The call that asked in it is over: no buttons, and its outcome. */
114
+ ended: boolean;
115
+ /** Answers the question with one of its buttons, by its place among them. */
116
+ answer(button: number): void;
117
+ }
118
+ /**
119
+ * The dice of a rest the player spends one at a time (ASK-14): whose they are; each counter of dice with its die and what a die adds; the counter they give to
120
+ * as it was at the question and as it is; the dice rolled so far, each by the id of its roll.
121
+ */
122
+ export interface RestDice {
123
+ who: string;
124
+ dice: {
125
+ field: string;
126
+ sides: number;
127
+ value: number;
128
+ max: number;
129
+ adds: number;
130
+ }[];
131
+ gives: {
132
+ field: string;
133
+ from: number;
134
+ value: number;
135
+ max?: number;
136
+ };
137
+ rolls: {
138
+ id: string;
139
+ field: string;
140
+ face: number;
141
+ adds: number;
142
+ total: number;
143
+ }[];
144
+ }
145
+ /** A button of a question: its name, the note after it, its dice when it rolls; danger when what it does loses something, as "it resets". */
146
+ export interface CardButton {
147
+ name: string;
148
+ note?: string;
149
+ dice?: string;
150
+ danger?: boolean;
151
+ }
152
+ /**
153
+ * The default export of a package's page module (D-510, D-511): by name, the components of its figures (declared in its extension.yaml or system.yaml) and of its cards'
154
+ * insides, its cards in the dashboard's pages and its own pages.
155
+ */
156
+ export interface PageModule {
157
+ figures?: Record<string, ComponentType<FigureProps>>;
158
+ bodies?: Record<string, ComponentType<BodyProps>>;
159
+ cards?: Record<string, PageCard>;
160
+ pages?: Record<string, OwnPage>;
161
+ /** Its own style sheet, which each of its drawings takes after the dashboard's: the layout and motion of its own parts, with the dashboard's tokens. */
162
+ style?: string;
163
+ }
164
+ /** A button of words: gold for the one main action, quiet for a secondary one, danger for one that loses something; disabled waits, keeping the focus. */
165
+ export declare function Button(props: {
166
+ children: ComponentChildren;
167
+ onClick(): void;
168
+ kind?: "gold" | "quiet" | "danger";
169
+ disabled?: boolean;
170
+ tip?: string;
171
+ }): JSX.Element;
172
+ /** A button of an icon, a path on a grid of 24, named by its words, which its tooltip shows. */
173
+ export declare function IconButton(props: {
174
+ path: string;
175
+ label: string;
176
+ onClick(): void;
177
+ }): JSX.Element;
178
+ /** An icon, a path on a grid of 24, stroked in the accent. */
179
+ export declare function Icon(props: {
180
+ path: string;
181
+ }): JSX.Element;
182
+ /** The dice of a notation as the dashboard draws them, as a d20 for 1d20+5. */
183
+ export declare function Dice(props: {
184
+ notation: string;
185
+ }): JSX.Element;
186
+ /** Things of a list, as chips. */
187
+ export declare function Chips(props: {
188
+ items: WidgetText[];
189
+ }): JSX.Element;
190
+ /** Someone's portrait as a coin: the party and those at the place by name, with their picture, else their initials. */
191
+ export declare function Portrait(props: {
192
+ name: string;
193
+ large?: boolean;
194
+ }): JSX.Element;
195
+ /** Who acts, as "Ettore picks": their portrait, their name and what they do. */
196
+ export declare function Who(props: {
197
+ who: string;
198
+ does?: WidgetText;
199
+ }): JSX.Element;
200
+ /** A count as pips, a bar or steps, with its label; in a card of a roll, its place there; a screen reader hears its name and value. */
201
+ export declare function Track(props: {
202
+ track: Track;
203
+ place?: "start" | "center" | "end";
204
+ }): JSX.Element;
205
+ /** Words of the package, their values written in the dashboard's language. */
206
+ export declare function Text(props: {
207
+ text: WidgetText;
208
+ }): JSX.Element;
209
+ /** A value written in the dashboard's language, set apart right to left. */
210
+ export declare function Value(props: {
211
+ value: WidgetValue;
212
+ }): JSX.Element;
213
+ /** The buttons of a question in a card of a roll: a roll in gold with its dice, a choice that loses something with a red edge; the one pressed marked. */
214
+ export declare function Choices(props: {
215
+ buttons: CardButton[];
216
+ sent?: number;
217
+ onChoose(button: number): void;
218
+ }): JSX.Element;
package/dist/page.js ADDED
@@ -0,0 +1,2 @@
1
+ /** The pages of the dashboard a package's card or widget stands in, after their own cards (D-502, D-511): the Scene, the sheet, the World and the Journal. */
2
+ export const cardPages = ["scene", "sheet", "world", "journal"];
@@ -12,7 +12,7 @@ export { applyRename, planRename, type Renamed, renamedLinks, type RenamePlan }
12
12
  export { readStops, type Stops, stopsHelp } from "./roads.ts";
13
13
  export { countedText, entryOfKind, type EntryReading, isStackEntry, readEntry, stackEntry, withStackCount } from "./stack-entry.ts";
14
14
  export { canCount, carriesKind, entryKind, entryPage, goodsNamed, type HeldStack, heldStacks, heldStacksOfKind, isKind, kindNamed, notKindReason, ownStack, type Stack, stackName, stacksOf } from "./stacks.ts";
15
- export { canHold, containerFieldOf, containerFields, heldTypesText, isCounterField, isEmptyField, isFieldName, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues, } from "./standard-fields.ts";
15
+ export { canHold, containerFieldOf, containerFields, heldTypesText, isCoreField, isCounterField, isEmptyField, isFieldName, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues, } from "./standard-fields.ts";
16
16
  export { alwaysInList, alwaysInMessage, declaredKind, heldSystemPageMessage, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.ts";
17
17
  export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, heldNames, 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";
18
18
  export { checkFieldChange, type PageChange, writePage } from "./write-page.ts";
@@ -13,7 +13,7 @@ export { applyRename, planRename, renamedLinks } from "./rename-page.js";
13
13
  export { readStops, stopsHelp } from "./roads.js";
14
14
  export { countedText, entryOfKind, isStackEntry, readEntry, stackEntry, withStackCount } from "./stack-entry.js";
15
15
  export { canCount, carriesKind, entryKind, entryPage, goodsNamed, heldStacks, heldStacksOfKind, isKind, kindNamed, notKindReason, ownStack, stackName, stacksOf } from "./stacks.js";
16
- export { canHold, containerFieldOf, containerFields, heldTypesText, isCounterField, isEmptyField, isFieldName, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues, } from "./standard-fields.js";
16
+ export { canHold, containerFieldOf, containerFields, heldTypesText, isCoreField, isCounterField, isEmptyField, isFieldName, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues, } from "./standard-fields.js";
17
17
  export { alwaysInList, alwaysInMessage, declaredKind, heldSystemPageMessage, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.js";
18
18
  export { backlinks, bonusPages, concernsPlayer, createWorld, findPage, heldNames, 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";
19
19
  export { checkFieldChange, writePage } from "./write-page.js";
@@ -1,11 +1,17 @@
1
1
  import { type Page, type World } from "./world.ts";
2
- /** How a system weighs what one carries: the field of an item's weight, how many coins make one unit of weight, and the field of an item whose contents weigh nothing. */
2
+ /**
3
+ * How a system weighs what one carries: the field of an item's weight, how many coins make one unit of weight, the field of an item whose contents weigh
4
+ * nothing, and the field of how many pieces one of a kind sold by the bundle holds, its weight the bundle's.
5
+ */
3
6
  export interface LoadRule {
4
7
  field: string;
5
8
  coins?: number;
6
9
  weightless?: string;
10
+ bundle?: string;
7
11
  }
8
12
  /** The weight a holder carries, coins included (LOAD-1). */
9
13
  export declare function carriedWeight(world: World, rule: LoadRule, holder: Page): number;
10
14
  /** The unit the system's weights are written in, as lb; undefined when no page says. */
11
15
  export declare function weightUnit(world: World, field: string): string | undefined;
16
+ /** How many pieces one of a kind holds, by the field the system declares for its bundle: 1 for a kind not sold by the bundle (STK-2). */
17
+ export declare function bundleOf(field: string | undefined, kind: Page): number;
@@ -28,8 +28,7 @@ function carriedLoad(world, rule, holder, seen = new Set()) {
28
28
  if (stack !== undefined) {
29
29
  const first = !counted.has(stack.kind);
30
30
  counted.add(stack.kind);
31
- const bundle = Number(stack.kind.fields.bundle);
32
- return first ? total + (weightOf(world, rule.field, stack.kind) * stack.count) / (Number.isSafeInteger(bundle) && bundle > 1 ? bundle : 1) : total;
31
+ return first ? total + (weightOf(world, rule.field, stack.kind) * stack.count) / bundleOf(rule.bundle, stack.kind) : total;
33
32
  }
34
33
  const read = readEntry(entry);
35
34
  const page = read.shape === "text" ? undefined : entryPage(world, read.page);
@@ -41,18 +40,19 @@ function carriedLoad(world, rule, holder, seen = new Set()) {
41
40
  return total + weightOf(world, rule.field, page) + (weightless ? 0 : carriedLoad(world, rule, page, seen));
42
41
  }, 0);
43
42
  }
44
- /** A page's weight as a number of the system's unit, its own or its base's: 1 lb, 1/2 lb, 1½ lb, 1,000 lb; 0 when it has none. */
43
+ /** A page's weight as a number of the system's unit, its own or its base's: 1 lb, 1/2 lb, 1½ lb, 1,000 lb, 0.5 kg, 0,5 kg; 0 when it has none. */
45
44
  function weightOf(world, field, page) {
46
45
  const value = valueNamed(inheritedFields(world, page), field);
47
46
  // A note may follow the unit, as a waterskin's 5 lb (full).
48
- const match = typeof value === "string" ? /^\s*([\d,]*)\s*(½|¼|¾|\d+\/\d+)?\s*[\p{L}.]*\s*(?:\([^()]*\))?\s*$/u.exec(value) : null;
47
+ const match = typeof value === "string" ? /^\s*([\d,]*(?:\.\d+)?)\s*(½|¼|¾|\d+\/\d+)?\s*[\p{L}.]*\s*(?:\([^()]*\))?\s*$/u.exec(value) : null;
49
48
  if (typeof value === "number") {
50
49
  return value;
51
50
  }
52
51
  if (match === null || (match[1] === "" && match[2] === undefined)) {
53
52
  return 0;
54
53
  }
55
- const whole = match[1] === "" ? 0 : Number(match[1].replace(/,/g, ""));
54
+ // A comma before three digits groups thousands, as 1,000; any other is a decimal comma, as 0,5.
55
+ const whole = match[1] === "" ? 0 : Number(match[1].replace(/,(?=\d{3}(?!\d))/g, "").replace(",", "."));
56
56
  const part = match[2] === undefined ? 0 : { "½": 0.5, "¼": 0.25, "¾": 0.75 }[match[2]] ?? Number(match[2].split("/")[0]) / Number(match[2].split("/")[1]);
57
57
  return whole + part;
58
58
  }
@@ -63,6 +63,11 @@ function coinsWeight(fields, perUnit) {
63
63
  const coins = typeof money === "string" ? [...money.matchAll(/(\d{1,3}(?:,\d{3})+|\d+)\s*\p{L}+/gu)].reduce((total, match) => total + Number(match[1].replace(/,/g, "")), 0) : 0;
64
64
  return perUnit === undefined ? 0 : coins / perUnit;
65
65
  }
66
+ /** How many pieces one of a kind holds, by the field the system declares for its bundle: 1 for a kind not sold by the bundle (STK-2). */
67
+ export function bundleOf(field, kind) {
68
+ const pieces = field === undefined ? Number.NaN : Number(valueNamed(kind.fields, field));
69
+ return Number.isSafeInteger(pieces) && pieces > 1 ? pieces : 1;
70
+ }
66
71
  /** Whether a field is true, as YAML reads it or as text written by hand. */
67
72
  function isTrue(value) {
68
73
  return value === true || (typeof value === "string" && value.trim().toLowerCase() === "true");
@@ -171,7 +171,7 @@ function parseFrontmatter(frontmatter, path) {
171
171
  // Only the first line of the parser's message: the rest quotes the file, which may hold secrets.
172
172
  const message = `The frontmatter of ${path} is not valid YAML; fix it by hand: ${document.errors[0].message.split("\n")[0]}`;
173
173
  // A stack written by hand without quotes, - [[Torch]] 7, reads as a list inside a list (STK-13).
174
- const stack = /(?:^\s*-\s*|\[)\[\[[^\]]+\]\][ \t]+\d/m.test(frontmatter) ? ` A stack in a list goes in quotes, such as - "[[Torch]] 7".` : "";
174
+ const stack = /(?:^\s*-\s*|\[)\[\[[^\]]+\]\][ \t]+\d/m.test(frontmatter) ? ` A stack in a list goes in quotes, such as - "[[Name]] 7".` : "";
175
175
  throw new Error(`${message}${stack}`);
176
176
  }
177
177
  return document;
@@ -1,5 +1,6 @@
1
1
  // What write may do to the stacks of a container's list (STK-10): count only kinds, one stack of each, whose counts change only with change.
2
2
  import { comparableText } from "../core/text.js";
3
+ import { bundleOf } from "./load.js";
3
4
  import { countedText, countOf, readEntry } from "./stack-entry.js";
4
5
  import { canCount, entryKind, entryPage, goodsNamed, isKind, notKindReason, stacksOf } from "./stacks.js";
5
6
  import { containerFieldOf } from "./standard-fields.js";
@@ -75,7 +76,7 @@ function checkCounted(world, holder, field, read, page) {
75
76
  throw new Error(`${page.name} is no kind to count: ${reason}. Nothing changed.`);
76
77
  }
77
78
  if (!isKind(world, page) && elsewhere.length > 0) {
78
- throw new Error(`${page.name} is in ${elsewhere[0].name} as one thing with a story of its own: a count goes only beside a kind, as [[Torch]] 7. Nothing changed.`);
79
+ throw new Error(`${page.name} is in ${elsewhere[0].name} as one thing with a story of its own: a count goes only beside a kind, as [[Name]] 7. Nothing changed.`);
79
80
  }
80
81
  }
81
82
  /** Text with a count at one end, as Torch 7, is a count inside a text (STK-10): refused when the rest names a kind, with its stack. */
@@ -93,9 +94,9 @@ function checkCountedText(world, holder, field, entry) {
93
94
  export function missingKindMessage(world, holder, field, read) {
94
95
  const named = goodsNamed(world, read.page);
95
96
  if (named !== undefined) {
96
- const bundle = Number(named.fields.bundle);
97
- const pieces = Number.isSafeInteger(bundle) && bundle > 1 ? read.count * bundle : read.count;
98
- const unit = Number.isSafeInteger(bundle) && bundle > 1 ? `counted in pieces, ${bundle} for each bought` : "counted in the units the system sells it in";
97
+ const bundle = bundleOf(world.system?.load?.bundle, named);
98
+ const pieces = read.count * bundle;
99
+ const unit = bundle > 1 ? `counted in pieces, ${bundle} for each bought` : "counted in the units the system sells it in";
99
100
  return `There is no page named ${read.page}, but it is a name of ${named.name}, ${unit}: write ${holder.name}, add ${field}="[[${named.name}]] ${pieces}".`;
100
101
  }
101
102
  const campaignKind = `Only what the system lacks becomes a kind of the campaign, written first: write "${read.page}", type item.`;
@@ -15,6 +15,8 @@ export declare function isFieldName(name: string): boolean;
15
15
  export declare const listFieldNames: string[];
16
16
  /** Whether a field has a fixed meaning on pages of this type, such as an event's date: such a field is never a counter, but for an event's clock. */
17
17
  export declare function isStandardField(type: PageType | undefined, name: string): boolean;
18
+ /** Whether the core itself reads a field on some page, as role, status or contains: an extension's field never takes its name (D-505). */
19
+ export declare function isCoreField(name: string): boolean;
18
20
  /** Whether a standard field is a counter, changed with change like any other: an event's clock (EVT-2). */
19
21
  export declare function isCounterField(type: PageType | undefined, name: string): boolean;
20
22
  /** The values a standard field takes on pages of a type, such as a quest's statuses; undefined when it takes any. */
@@ -1,6 +1,6 @@
1
1
  import { readLength } from "../core/length.js";
2
2
  import { moods } from "../core/mood.js";
3
- import { sameName } from "../core/text.js";
3
+ import { comparableText, sameName } from "../core/text.js";
4
4
  import { mapHelp, readMapField } from "./maps.js";
5
5
  import { positionHelp, readPosition } from "./positions.js";
6
6
  import { readStops } from "./roads.js";
@@ -54,6 +54,13 @@ export const listFieldNames = [
54
54
  export function isStandardField(type, name) {
55
55
  return Object.hasOwn(commonRules, name) || (type !== undefined && Object.hasOwn(typeRules[type] ?? {}, name));
56
56
  }
57
+ // The other fields the core reads on pages: effects, a page's kind, a quest's deadline and clock, a vehicle's riders and how long it travelled, who is hostile.
58
+ const otherCoreFields = ["effects", "kind", "deadline", "clock-name", "riders", "travelled", "hostile", "type", "title"];
59
+ /** Whether the core itself reads a field on some page, as role, status or contains: an extension's field never takes its name (D-505). */
60
+ export function isCoreField(name) {
61
+ const key = comparableText(name);
62
+ return [...Object.keys(commonRules), ...Object.values(typeRules).flatMap((rules) => Object.keys(rules ?? {})), ...otherCoreFields].some((field) => comparableText(field) === key);
63
+ }
57
64
  /** Whether a standard field is a counter, changed with change like any other: an event's clock (EVT-2). */
58
65
  export function isCounterField(type, name) {
59
66
  const rules = rulesOf(type);
@@ -28,6 +28,8 @@ export interface World {
28
28
  system?: SystemPages;
29
29
  /** The language the campaign is played in, as a code such as it, when campaign.yaml says it. */
30
30
  language?: string;
31
+ /** The game system's words in that language, by their English names, as Prone: Prono: an effect named with one is the system's (D-403). */
32
+ words?: Record<string, string>;
31
33
  /** The game system campaign.yaml names when it is not installed: none of its pages can be found (SYS-1). */
32
34
  missingSystem?: string;
33
35
  /** Whether campaign.yaml names no game system yet (D-167): a link may be to a page of the one it will name. */
@@ -65,6 +67,8 @@ export interface SystemInfo {
65
67
  field: string;
66
68
  limit: Formula;
67
69
  coins?: number;
70
+ weightless?: string;
71
+ bundle?: string;
68
72
  };
69
73
  /** The unit its computed lengths are in, as ft (SPD-1). */
70
74
  lengthUnit?: string;
@@ -96,8 +100,12 @@ export declare function createWorld(root: string): void;
96
100
  export declare function loadWorld(root: string, options?: {
97
101
  system?: SystemInfo & {
98
102
  folder: string;
103
+ version?: {
104
+ folder: string;
105
+ };
99
106
  };
100
107
  language?: string;
108
+ words?: Record<string, string>;
101
109
  missingSystem?: string;
102
110
  noSystem?: boolean;
103
111
  rigor?: string;