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
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Context } from "../core/context.ts";
2
+ import { type Context } from "../core/context.ts";
3
3
  export declare const config: import("../core/registry.ts").Command<z.ZodObject<{
4
4
  setting: z.ZodOptional<z.ZodString>;
5
5
  value: z.ZodOptional<z.ZodString>;
@@ -2,8 +2,10 @@ import { join } from "node:path";
2
2
  import { parse, stringify } from "yaml";
3
3
  import { z } from "zod";
4
4
  import { changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, checkSettingName, clearSetting, companionWays, diceWays, difficulties, efforts, entrySettingNames, lethalities, listSettingNames, mapSettingNames, masterRollWays, mentorWays, pictureWays, preparations, proseWays, readCampaignData, readSettings, readTextSetting, refreshHostFiles, requireCampaign, rigors, saveModes, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unitSystems, voiceWays, writeEffortFiles, } from "../campaign/index.js";
5
+ import { engineSystemsFolder } from "../core/context.js";
5
6
  import { appendLogEntry } from "../core/log.js";
6
7
  import { defineCommand } from "../core/registry.js";
8
+ import { files, isInside } from "../core/store.js";
7
9
  import { comparableText } from "../core/text.js";
8
10
  import { getVersion } from "../core/version.js";
9
11
  import { readYamlValues } from "../core/yaml-file.js";
@@ -11,24 +13,25 @@ import { hostInstructions } from "../instructions/index.js";
11
13
  import { coinList, readAmount, readCoins } from "../money/index.js";
12
14
  import { declaredKind } from "../pages/index.js";
13
15
  import { claudeSays, codexSays } from "../pictures/index.js";
14
- import { campaignDataNames, findCampaignSystem, findSystem, installedSystems, systemFileName } from "../systems/index.js";
16
+ import { campaignDataNames, findCampaignSystem, findSystem, installedSystems, rulesetSetting, systemFileName, systemPackage } from "../systems/index.js";
15
17
  import { readCalendar, readCalendarStart } from "../time/index.js";
16
18
  import { libraryAdditions, libraryRemovals, libraryShown, startLibraryReading } from "./game-library.js";
17
19
  import { campaignNote } from "./game-mode.js";
18
20
  import { campaignCoins, coinsShown } from "./game-money.js";
21
+ import { loadNewSystemCode } from "./game-package-code.js";
19
22
  import { readOpenScene } from "./game-scene.js";
20
23
  import { campaignCalendar, newDatedLogEntry } from "./game-time.js";
21
24
  import { checkWidgetSpots } from "./game-widgets.js";
22
- import { campaignSystem, campaignWorld, countedByGame, installedSystemName, systemSetting, systemSettingValue, valuesText } from "./game-world.js";
25
+ import { campaignSystem, campaignWorld, countedByGame, installedSystemName, playedRules, playedSettingValue, playersOfTheGame, systemLayers, systemSetting, valuesText } from "./game-world.js";
23
26
  import { mentorPart, stylePart } from "./parts.js";
24
27
  // A use whose maximum reads what gives it, in quotes for its commas (CAM-1).
25
- const counterExample = 'bulwark-dice: {max: "4 * has(features, Bulwark)", refill: short rest}';
28
+ const counterExample = 'bulwark-dice: {max: "4 * has(features, Bulwark)", refill: rest}';
26
29
  export const config = defineCommand({
27
30
  name: "config",
28
31
  description: "Show or change the campaign settings. "
29
32
  + "Without a setting it shows them all and which are missing; with a setting and a value it changes that one. "
30
33
  + "Use it at the start of a campaign, to learn what to ask the player, and whenever the player changes a setting. "
31
- + "system: one of the installed game systems, listed while it is missing. difficulty, how hard the world plays: story, easy, normal, hard, brutal. "
34
+ + "system: one of the installed game systems, listed while it is missing; fixed once there is a player character. difficulty, how hard the world plays: story, easy, normal, hard, brutal. "
32
35
  + "lethality, what a fall means: narrative (the character never dies), epic (only when it matters), dice (the dice decide). "
33
36
  + "saves, when the game may go back: permadeath (never, only to the start, the campaign starting over), checkpoint (to the last end of a scene, once the player character dies), free (to any save, and saves when the player asks). "
34
37
  + "rigor, how closely travel, fatigue, food and the like follow the rules: smooth (you gloss over them), rules (as written), simulation (beyond them). "
@@ -51,7 +54,7 @@ export const config = defineCommand({
51
54
  + "text, or PDFs whose text can be selected, read best: a scan is read from its pictures, on Windows only, slowly. "
52
55
  + 'coins, for a game with money whose system does not give them: each coin with its value in the smallest coin, other names after a slash, "rare" for a coin never given as change; totals count in the first. '
53
56
  + "widgets: where the dashboard shows the extensions' widgets, which the player arranges in its Settings, such as value 'weather.today: side' (top, side, scene, sheet, world, journal or off); remove gives one back its extension's place. "
54
- + "The game system may add settings, such as advancement for 5e: config lists them with what each value means. "
57
+ + "The game system may add settings of its own: config lists them with what each value means; ruleset, the version of its rules, is the player's: change it only when they ask. "
55
58
  + "fields, tables, computed, counters and recipes add to the game system what it lacks, or change it as a house rule: the value gives entries by name, written as in system.yaml, "
56
59
  + "each replacing the system's one of that name (a recipe adds to the system's); remove takes their names. status-line adds fields to the player character's line. "
57
60
  + "A formula with commas goes in quotes; a use's max reads what gives it, so that only who has it has it. "
@@ -73,7 +76,9 @@ export const config = defineCommand({
73
76
  if (input.setting?.trim() === "library" && (input.add !== undefined || input.remove !== undefined)) {
74
77
  return changeLibrary(input, context);
75
78
  }
76
- return configure(input, context);
79
+ const result = configure(input, context);
80
+ // A system installed in this chat, as in the setup, brings its code once the campaign plays it (D-513 (1)).
81
+ return input.setting?.trim() === "system" && input.value !== undefined ? loadNewSystemCode(context).then(() => result) : result;
77
82
  },
78
83
  format(result) {
79
84
  const lines = Object.entries(result.settings).map(([name, value]) => `${name}: ${formatValue(value)}`);
@@ -123,6 +128,9 @@ function configure(input, context) {
123
128
  const unwritten = writeEffortFiles(root, context.platform, true);
124
129
  return { settings: { effort: shownValue(root, context, readSettings(root), "effort") }, note: "", replaced: ["Taken away for Claude Code and Codex: from the next chat each keeps its own.", ...unwritten], part: "" };
125
130
  }
131
+ if (input.setting?.trim() === "system" && input.value !== undefined) {
132
+ checkSystemOpen(root, context, input.value);
133
+ }
126
134
  const shown = input.setting === undefined ? settingNames : [checkSettingName(input.setting)];
127
135
  const mapped = input.setting !== undefined && mapSettingNames.includes(checkSettingName(input.setting));
128
136
  let replaced = [];
@@ -193,7 +201,7 @@ function configure(input, context) {
193
201
  ? mentorPart(root, context, settings.mentor)
194
202
  : [cleared === undefined ? "" : `${cleared.charAt(0).toUpperCase()}${cleared.slice(1)}.`, style].filter((text) => text !== "").join("\n\n");
195
203
  return {
196
- settings: { ...Object.fromEntries(listed.map((name) => [name, shownValue(root, context, settings, name)])), ...Object.fromEntries(system.map((setting) => [setting.name, systemShownValue(root, setting)])) },
204
+ settings: { ...Object.fromEntries(listed.map((name) => [name, shownValue(root, context, settings, name)])), ...Object.fromEntries(system.map((setting) => [setting.name, systemShownValue(root, context, setting)])) },
197
205
  note: campaignNote(root, context),
198
206
  replaced,
199
207
  part,
@@ -413,7 +421,7 @@ export function shownPlayerSettings(root, context) {
413
421
  export function playerSettings(root, context) {
414
422
  const settings = readSettings(root);
415
423
  const own = (campaignSystem(root, context)?.settings ?? []).map((setting) => {
416
- const value = systemSettingValue(root, setting);
424
+ const value = playedSettingValue(root, context, setting);
417
425
  const choices = setting.values.map((one) => ({ value: one.value, ...(one.player === undefined ? {} : { means: one.player }) }));
418
426
  return { name: setting.name, about: setting.about ?? "a setting of the game system", ...(value === undefined ? {} : { value }), choices };
419
427
  });
@@ -510,15 +518,24 @@ function systemSettingResult(root, context, setting, input) {
510
518
  if (value === undefined) {
511
519
  throw new Error(`"${given}" is not a value of ${setting.name}, which takes ${setting.values.map((candidate) => `${candidate.value} (${candidate.means})`).join("; or ")}. Nothing changed.`);
512
520
  }
521
+ const before = campaignSystem(root, context)?.version?.name;
513
522
  if (changeOtherSetting(root, setting.name, value.value)) {
514
523
  appendLogEntry(root, newDatedLogEntry(root, context, "config-changed", "public", { setting: setting.name, value: value.value }));
515
524
  }
525
+ // Another version of the rules holds from the next read; what is written stays (VER-4).
526
+ if (setting.name === rulesetSetting && before !== undefined && comparableText(before) !== comparableText(value.value)) {
527
+ return {
528
+ settings: { [setting.name]: systemShownValue(root, context, setting) },
529
+ note: campaignNote(root, context),
530
+ replaced: [`From now on the campaign plays the rules ${value.value}, in place of ${before}: the pages already written stay as they are.`],
531
+ };
532
+ }
516
533
  }
517
- return { settings: { [setting.name]: systemShownValue(root, setting) }, note: campaignNote(root, context), replaced: [] };
534
+ return { settings: { [setting.name]: systemShownValue(root, context, setting) }, note: campaignNote(root, context), replaced: [] };
518
535
  }
519
536
  /** A setting of the system as config shows it: its value with what it means, or missing with every value and what it means (DAT-10). */
520
- function systemShownValue(root, setting) {
521
- const value = systemSettingValue(root, setting);
537
+ function systemShownValue(root, context, setting) {
538
+ const value = playedSettingValue(root, context, setting);
522
539
  const chosen = setting.values.find((candidate) => candidate.value === value);
523
540
  return chosen === undefined ? `(missing; ${setting.values.map((candidate) => `${candidate.value}: ${candidate.means}`).join("; ")})` : `${chosen.value}: ${chosen.means}`;
524
541
  }
@@ -553,7 +570,7 @@ function shownValue(root, context, settings, name) {
553
570
  if (settings[name] === undefined && Object.hasOwn(own, name)) {
554
571
  return own[name];
555
572
  }
556
- return name === "coins" ? coinsShown(root, context) : name === "system" ? systemShown(settings.system, context) : settings[name];
573
+ return name === "coins" ? coinsShown(root, context) : name === "system" ? systemShown(root, settings.system, context) : settings[name];
557
574
  }
558
575
  /** A setting's value as config writes it: an installed system by the name it is installed under (D-167), the coins read and checked (MON-1), anything else as given. */
559
576
  function settingValue(root, setting, value, context) {
@@ -571,6 +588,23 @@ function settingValue(root, setting, value, context) {
571
588
  }
572
589
  return setting === "coins" ? newCoins(root, value, context) : setting === "system" ? installedSystemName(value, context, "config") : value;
573
590
  }
591
+ /**
592
+ * The system stays once the campaign has a player character, whose sheet is written in it, whatever the mode (D-519): another installed one, or none, is
593
+ * refused, with a new campaign as the way; the same one, by any case, is no change.
594
+ */
595
+ function checkSystemOpen(root, context, value) {
596
+ const current = readTextSetting(root, "system");
597
+ // A name that is no installed system is said as such first; none takes the system away.
598
+ const asked = value.trim().toLowerCase() === "none" ? value : installedSystemName(value, context, "config");
599
+ if (current === undefined || comparableText(current) === comparableText(asked)) {
600
+ return;
601
+ }
602
+ const players = playersOfTheGame(root, context);
603
+ if (players.length > 0) {
604
+ const name = readSettings(root).name;
605
+ throw new Error(`The system of ${name} is ${current}, and the game has begun with ${players.join(", ")}: a campaign keeps its system. To play another, start a new campaign with init. Nothing changed.`);
606
+ }
607
+ }
574
608
  /** When the story starts, day 1 or a day of the campaign's calendar (TIM-8), checked and written as given. */
575
609
  function calendarStartValue(root, context, value) {
576
610
  try {
@@ -581,15 +615,23 @@ function calendarStartValue(root, context, value) {
581
615
  }
582
616
  return value.trim().replace(/\s+/g, " ");
583
617
  }
584
- /** The system as config shows it: what it is and which version brings it (D-173); missing or not installed, with those that are (D-167). */
585
- function systemShown(system, context) {
618
+ /**
619
+ * The system as config shows it (D-173): what it is, the version of its rules it is played with (VER-1), and the package that brings it with its version, or the
620
+ * engine for one it ships without a package; missing or not installed, with those that are (D-167).
621
+ */
622
+ function systemShown(root, system, context) {
586
623
  const installed = `installed: ${installedSystems(context.systemFolders).map((installedSystem) => installedSystem.name).join(", ") || "none"}`;
587
624
  if (system === undefined) {
588
625
  return `(missing; ${installed})`;
589
626
  }
590
- // The systems come with the engine until they are packages of their own (D-171).
591
- const found = findSystem(context.systemFolders, system);
592
- return found === undefined ? `${system} (not installed; ${installed})` : `${found.name}, ${found.title} (rpg-engine ${getVersion()})`;
627
+ const found = findSystem(context.systemFolders, system, readTextSetting(root, rulesetSetting));
628
+ if (found === undefined) {
629
+ return `${system} (not installed; ${installed})`;
630
+ }
631
+ const own = systemPackage(found.folder);
632
+ const shipped = isInside(engineSystemsFolder, found.folder);
633
+ const from = own !== undefined ? ` (${own.package} ${own.version})` : shipped ? ` (rpg-engine ${getVersion()})` : "";
634
+ return `${found.name}, ${found.title}${playedRules(root, context, found)}${from}`;
593
635
  }
594
636
  /** The coins given to config, refused when money already written in the world would no longer read as money with them (MON-1). */
595
637
  function newCoins(root, text, context) {
@@ -647,9 +689,13 @@ function replacedEntries(root, context, setting, names) {
647
689
  if (system === undefined || setting === "recipes") {
648
690
  return [];
649
691
  }
650
- const data = readYamlValues(join(system.folder, systemFileName), "what the system is");
651
- const own = data !== null && typeof data === "object" ? data[setting] : undefined;
652
- const entries = own !== null && typeof own === "object" && !Array.isArray(own) ? Object.entries(own) : [];
692
+ // Its version's entries over its own (VER-3).
693
+ const version = campaignSystem(root, context)?.version?.folder;
694
+ const entries = [system.folder, ...(version === undefined ? [] : [version])].flatMap((folder) => {
695
+ const data = files().exists(join(folder, systemFileName)) ? readYamlValues(join(folder, systemFileName), "what the system is") : undefined;
696
+ const own = data !== null && typeof data === "object" ? data[setting] : undefined;
697
+ return own !== null && typeof own === "object" && !Array.isArray(own) ? Object.entries(own) : [];
698
+ }).reverse();
653
699
  return names.flatMap((name) => {
654
700
  const [found, value] = entries.find(([other]) => comparableText(other) === comparableText(name)) ?? [];
655
701
  return found === undefined ? [] : [`${setting} ${name} takes the place of the system ${system.name}'s ${found}, ${formatValue(value)}: what this one leaves out of it is gone.`];
@@ -665,7 +711,9 @@ function checkAdditions(root, context, setting, change) {
665
711
  const held = data[setting] !== null && typeof data[setting] === "object" && !Array.isArray(data[setting]) ? data[setting] : {};
666
712
  const dropped = [...(change.remove ?? []), ...Object.keys(change.set ?? {})];
667
713
  const entries = { ...Object.fromEntries(Object.entries(held).filter(([name]) => !dropped.some((other) => comparableText(other) === comparableText(name)))), ...change.set };
668
- const problem = findCampaignSystem(context.systemFolders, system, { ...data, [setting]: entries }).problem;
714
+ // Over what the campaign's extensions add, as the campaign plays it (CAM-2).
715
+ const layers = systemLayers(root, context, { ...data, [setting]: entries });
716
+ const problem = findCampaignSystem(context.systemFolders, system, layers, readTextSetting(root, rulesetSetting)).refused.find((layer) => layer.from === layers.at(-1)?.from)?.problem;
669
717
  if (problem !== undefined) {
670
718
  throw new Error(`With this, the system ${system} would not read: ${problem} Nothing changed.`);
671
719
  }
@@ -3,17 +3,17 @@ import { requireCampaign } from "../campaign/index.js";
3
3
  import { factorOf, numberOf } from "../core/formula.js";
4
4
  import { appendLogEntry } from "../core/log.js";
5
5
  import { defineCommand } from "../core/registry.js";
6
- import { comparableText, sameName, valueNamed } from "../core/text.js";
6
+ import { comparableText, sameName, sameWord, valueNamed } from "../core/text.js";
7
7
  import { readCounter } from "../counters/index.js";
8
8
  import { effectNamed, formatEffect, formatEnd, isSceneDuration, readEffect, readRounds, withEffect } from "../effects/index.js";
9
9
  import { concernsPlayer, declaredKind, environmentAt, isDeclaredUncounted, isKind, isNeverInherited, isStandardField, parsePageReference, readFieldValue, textsIn } from "../pages/index.js";
10
10
  import { addDuration, formatGameDate, readDuration } from "../time/index.js";
11
11
  import { effectGiving, effectiveFields, effectsOf, valuesChanged, withEffects } from "./effect-layer.js";
12
- import { checkEffectsReadable, endEffects, keptBy, saveEffects } from "./game-effects.js";
12
+ import { checkEffectsReadable, endEffects, keptBy, saveEffects, systemNamed } from "./game-effects.js";
13
+ import { allSaid, packagesEffectAdded } from "./game-package-hooks.js";
13
14
  import { keepingConditionNote, secondKeptNote } from "./game-reminders.js";
14
15
  import { houseRules, ruleBlock, ruleTitled } from "./game-rules.js";
15
16
  import { checkNotSystemPage, pageOrCopy, readOpenScene } from "./game-scene.js";
16
- import { allSaid, systemEffectAdded } from "./game-system-code.js";
17
17
  import { newDatedLogEntry, presentDate } from "./game-time.js";
18
18
  import { burning, burnOne } from "./game-upkeep.js";
19
19
  import { campaignSystem, campaignWorld, missingSystemHint, occasionsOf } from "./game-world.js";
@@ -26,18 +26,18 @@ export const effect = defineCommand({
26
26
  description: "Put a condition or an effect on a character, a place or a copy in the open scene, or end one: frightened, prone, a spell, a form. "
27
27
  + "On a place, such as rain or magical darkness, it holds for all inside by its name, and its values are the place's own. "
28
28
  + "Beyond the values it gives, what it does in play is yours to rule. It ends by itself, and advance or scene says so; end takes it away sooner. "
29
- + 'Example: action add, page Ennio, name "Scudo della fede", for 10m, by [[Lena]], set bonus-ac=2.',
29
+ + 'Example: action add, page Ennio, name "Protezione", for 10m, by [[Lena]], set {{bonus}}=2.',
30
30
  group: "game",
31
31
  positionals: ["action", "page", "name"],
32
32
  input: z.object({
33
33
  action: z.enum(actions).describe("add or end"),
34
34
  page: z.string().optional().describe("who has it: a page, or a copy in the open scene such as Annegato 2"),
35
- name: z.string().optional().describe("the effect's name, such as Benedizione; a condition of the game system always by its name there, such as Frightened"),
36
- for: z.string().optional().describe("add: how long it lasts: 10m, 1h, 1d 6h; in a scene with turns, rounds from the current turn, such as 1 round; scene, until it ends; or an occasion of the game system its recipe brings, such as long rest. "
35
+ name: z.string().optional().describe("the effect's name, such as Benedizione; a condition of the game system by its name there, such as Frightened, or by the system's word for it in the campaign's language, such as Spaventato"),
36
+ for: z.string().optional().describe("add: how long it lasts: 10m, 1h, 1d 6h; in a scene with turns, rounds from the current turn, such as 1 round; scene, until it ends; or an occasion of the game system its recipe brings, such as {{rest}}. "
37
37
  + "Left out, until it is ended: so for one that ends with something in the story, such as breathing clean air; end it then"),
38
38
  until: z.string().optional().describe("add, in a scene with turns: whose next turn ends it when it starts, such as Ennio, instead of for"),
39
39
  by: z.string().optional().describe("add: who keeps it alive, if someone must (concentration), such as [[Lena]]; end: take away every effect they keep, on everyone"),
40
- set: fieldValues.optional().describe("add: the values it gives while it lasts, field=value, repeatable, such as speed=20; for a field the game system declares a bonus, what it adds, such as bonus-ac=2. "
40
+ set: fieldValues.optional().describe("add: the values it gives while it lasts, field=value, repeatable, such as speed=20; for a field the game system declares a bonus, what it adds, such as {{bonus}}=2. "
41
41
  + "What must outlive it, such as hit points it adds, change on the page instead"),
42
42
  why: z.string().optional().describe("what caused it, or ended it"),
43
43
  }),
@@ -74,7 +74,7 @@ export const effect = defineCommand({
74
74
  if (input.for !== undefined || input.until !== undefined || input.set !== undefined || input.by !== undefined) {
75
75
  throw new Error("end takes the page and the effect's name, or by alone: nothing else.");
76
76
  }
77
- const ended = effectNamed(current, input.name);
77
+ const ended = effectNamed(current, input.name, world.words);
78
78
  if (ended === undefined) {
79
79
  const held = current.length === 0 ? `${holder.page.name} has no effects.` : `Its effects: ${current.map((effect) => effect.name).join(", ")}.`;
80
80
  throw new Error(`${holder.page.name} has no effect named ${input.name.trim()}. ${held}`);
@@ -99,24 +99,25 @@ export const effect = defineCommand({
99
99
  checkPlaceValues(world, holder, values);
100
100
  const keeper = input.by === undefined ? undefined : keeperLink(world, open.scene, input.by);
101
101
  const system = campaignSystem(root, context);
102
+ const words = world.words;
102
103
  checkNotCounter(system, holder.page, name);
103
- checkNotImmune(world, system, holder.page, name);
104
+ checkNotImmune(world, system, holder.page, name, words);
104
105
  // Something that burns, as a torch, spends one of what the holder carries and lasts as long as it burns, unless told otherwise (UPK-3).
105
106
  const lit = holder.copy ? undefined : burning(system, world, holder.page, name);
106
107
  const lasting = input.for ?? (input.until === undefined ? lit?.lasts : undefined);
107
108
  const added = { name, ...(keeper === undefined ? {} : { by: keeper }), values, ...withEnd(root, open.scene, lasting, input.until, system, inScene(open.scene, holder), missingSystemHint(world)) };
108
109
  checkLine(added);
109
- const replaced = effectNamed(current, name);
110
- const effects = withEffect(current, added);
110
+ const replaced = effectNamed(current, name, words);
111
+ const effects = withEffect(current, added, words);
111
112
  const changed = valuesChanged(world, holder.page, withEffects(holder.page, effects), added);
112
113
  // What the condition may break that the holder keeps alive, and what the keeper already keeps, read before the effect is written (EFF-14).
113
- const keeping = [keepingConditionNote(world, open.scene, system, holder.page.name, name), secondKeptNote(world, open.scene, system, added)].filter((note) => note !== "");
114
- const notes = [...addNotes(world, holder.page, current, added, open.scene, system), ...conditionNote(root, system, name), ...roundsNote(input.for, added.end, system), ...keeping];
114
+ const keeping = [keepingConditionNote(world, open.scene, system, holder.page.name, name, words), secondKeptNote(world, open.scene, system, added)].filter((note) => note !== "");
115
+ const notes = [...addNotes(world, holder.page, current, added, open.scene, system), ...conditionNote(root, system, name, words), ...roundsNote(input.for, added.end, system), ...keeping];
115
116
  saveEffects(root, context, world, holder, effects);
116
117
  appendLogEntry(root, newDatedLogEntry(root, context, "effect-added", visibility, { page: holder.page.name, copy: holder.copy ? true : undefined, effect: formatEffect(added), why }));
117
118
  const burnt = lit === undefined ? [] : [burnOne(root, context, holder.page.name, lit.kind)].filter((note) => note !== "");
118
119
  // One dying made stable, as by a companion's Medicine: its death saves end (DIE-6).
119
- const stable = holder.copy ? [] : allSaid(systemEffectAdded(root, context, { page: holder.page.name, effect: name }));
120
+ const stable = holder.copy ? [] : allSaid(packagesEffectAdded(root, context, { page: holder.page.name, effect: name }));
120
121
  const instead = [...(replaced === undefined ? [] : [`It takes the place of ${formatEffect(replaced)}.`]), ...burnt, ...stable];
121
122
  return { action: "add", page: holder.page.name, effect: added.name, end: added.end === undefined ? undefined : formatEnd(added.end), values: changed, ended: [], notes: [...instead, ...notes] };
122
123
  },
@@ -154,11 +155,14 @@ function checkNotCounter(system, page, name) {
154
155
  throw new Error(`${field} is a counter of the system ${system.name}, kept on the page: change it, such as page ${page.name}, field ${field}, by 1. Nothing changed.`);
155
156
  }
156
157
  }
157
- /** Refuses a condition of the system that the page's list of immunities names, as poisoned on a zombie (D-454, EFF-17); before anything is written. */
158
- function checkNotImmune(world, system, page, name) {
159
- const condition = (system?.conditions ?? []).find((candidate) => comparableText(candidate) === comparableText(name));
158
+ /**
159
+ * Refuses a condition of the system that the page's list of immunities names, as poisoned on a zombie (D-454, EFF-17); before anything is written. Either may be
160
+ * in the campaign's language, Avvelenato for Poisoned (D-403).
161
+ */
162
+ function checkNotImmune(world, system, page, name, words) {
163
+ const condition = systemNamed(system?.conditions ?? [], name, words);
160
164
  const list = system?.immune;
161
- const immune = condition !== undefined && list !== undefined && textsIn(valueNamed(effectiveFields(world, page), list)).some((item) => comparableText(item) === comparableText(condition));
165
+ const immune = condition !== undefined && list !== undefined && textsIn(valueNamed(effectiveFields(world, page), list)).some((item) => systemNamed([condition], item, words) !== undefined);
162
166
  if (immune) {
163
167
  throw new Error(`${page.name} is immune to ${condition}, in its ${list}: it does not take it. Nothing changed.`);
164
168
  }
@@ -267,9 +271,23 @@ function readValues(world, page, set) {
267
271
  }
268
272
  const text = String(value).trim();
269
273
  checkValue(world, page, fields, field, text);
274
+ checkFieldKnown(world, page, fields, field);
270
275
  return [field, text];
271
276
  });
272
277
  }
278
+ /**
279
+ * On a character or a creature of a system that declares bonuses, a value for a field neither the page nor the system has changes nothing: refused, with the
280
+ * fields an effect adds to (D-518). A place, and a game without bonuses, keep any value.
281
+ */
282
+ function checkFieldKnown(world, page, fields, field) {
283
+ const system = world.system;
284
+ const bonuses = Object.keys(system?.fields ?? {}).filter((name) => declaredKind(world, name) === "bonus");
285
+ const known = declaredKind(world, field) !== undefined || valueNamed(fields, field) !== undefined || computedField(world, field, fields) !== undefined;
286
+ if (system !== undefined && bonuses.length > 0 && (page.type === "character" || page.type === "creature") && !known) {
287
+ throw new Error(`${field} is no field of ${page.name} nor of the system ${system.name}, so the effect would change nothing. The fields an effect adds to in ${system.name}: ${bonuses.join(", ")}. `
288
+ + "A field of the story alone goes on the page first, with write. Nothing changed.");
289
+ }
290
+ }
273
291
  /** A value reads as a page would hold it, and a field the page reads as a counter gets a counter: the value it reads, not a bonus. */
274
292
  function checkValue(world, page, fields, field, text) {
275
293
  let value;
@@ -348,7 +366,7 @@ function checkLine(added) {
348
366
  * effect's; a duration in time in a scene whose turns do not move time (EFF-3, EFF-4).
349
367
  */
350
368
  function addNotes(world, page, current, added, scene, system) {
351
- const others = withEffects(page, current.filter((effect) => comparableText(effect.name) !== comparableText(added.name)));
369
+ const others = withEffects(page, current.filter((effect) => !sameWord(effect.name, added.name, world.words)));
352
370
  const fields = effectiveFields(world, others);
353
371
  const read = (field) => String(valueNamed(fields, field) ?? "none");
354
372
  const counters = added.values.filter(([field, value]) => !isDeclaredUncounted(world, field) && readCounter(value)?.max !== undefined).map(([field]) => field);
@@ -369,10 +387,10 @@ function addNotes(world, page, current, added, scene, system) {
369
387
  }
370
388
  /**
371
389
  * The text of a condition of the game system, when the effect bears its name (DAT-6): who believes they know a rule does not look it up. A house rule
372
- * on it comes first, with the precedents on it.
390
+ * on it comes first, with the precedents on it. A name in the campaign's language says the system's beside it, Prone (Prono) (D-403).
373
391
  */
374
- function conditionNote(root, system, name) {
375
- const condition = system?.conditions.find((candidate) => comparableText(candidate) === comparableText(name));
392
+ function conditionNote(root, system, name, words) {
393
+ const condition = system === undefined ? undefined : systemNamed(system.conditions, name, words);
376
394
  if (system === undefined || condition === undefined) {
377
395
  return [];
378
396
  }
@@ -381,7 +399,8 @@ function conditionNote(root, system, name) {
381
399
  return [];
382
400
  }
383
401
  const source = rule.source === houseRules ? ", by a house rule of the campaign" : "";
384
- return [`${condition} is a condition of the system ${system.name}${source}:\n${ruleBlock(rule)}`];
402
+ const written = sameName([condition], name) === undefined ? ` (${name.trim()})` : "";
403
+ return [`${condition}${written} is a condition of the system ${system.name}${source}:\n${ruleBlock(rule)}`];
385
404
  }
386
405
  /** "1m is 10 rounds of 6 seconds.": a duration in time that became rounds, in a scene with turns (DAT-7). */
387
406
  function roundsNote(duration, end, system) {
@@ -48,7 +48,7 @@ function systemNote(result, listed) {
48
48
  }
49
49
  const named = result.language;
50
50
  if (!result.withText && result.systemMore > 0) {
51
- const what = result.type === undefined ? "pages" : `${result.type}s`;
51
+ const what = `${result.type ?? "page"}${result.systemMore === 1 ? "" : "s"}`;
52
52
  const language = named === undefined ? "" : `, named in ${named}`;
53
53
  return `The system ${result.system} has ${result.systemMore}${listed ? " more" : ""} ${what}${language}: give part of a name${named === undefined ? "" : `, in ${named},`} to find them.`;
54
54
  }
@@ -16,7 +16,7 @@ import { unpackFiles } from "../saves/index.js";
16
16
  import { formatGameDate, readGameDate } from "../time/index.js";
17
17
  import { listedExtensions } from "./game-extension-list.js";
18
18
  import { campaignMode } from "./game-mode.js";
19
- import { houseRules } from "./game-rules.js";
19
+ import { houseRules, systemRuleBook } from "./game-rules.js";
20
20
  import { campaignSaves, exportsFolderName, resetSave, savesFolderName, savesWhy } from "./game-saves.js";
21
21
  import { newDatedLogEntry, readPresent } from "./game-time.js";
22
22
  import { campaignSystem, campaignWorld } from "./game-world.js";
@@ -218,7 +218,7 @@ function planInstall(root, context, adventure, shift) {
218
218
  const ownNames = new Map();
219
219
  const houseTitles = new Set(readRuleBook(join(root, houseRulesFolderName), houseRules).map((section) => comparableText(section.path.at(-1) ?? "")));
220
220
  const system = campaignSystem(root, context);
221
- const systemTitles = new Map((system === undefined ? [] : readRuleBook(join(system.folder, "rules"), system.name)).map((section) => [comparableText(section.path.at(-1) ?? ""), section.path.at(-1) ?? ""]));
221
+ const systemTitles = new Map((system === undefined ? [] : systemRuleBook(system)).map((section) => [comparableText(section.path.at(-1) ?? ""), section.path.at(-1) ?? ""]));
222
222
  for (const [path, original] of Object.entries(adventure.files)) {
223
223
  const target = adventureTarget(path, folder);
224
224
  const bytes = path.startsWith(`${worldFolderName}/`) ? movedDates(original, shift) : original;
@@ -16,6 +16,11 @@ export interface CatalogEntry {
16
16
  /** The version here, when it is installed. */
17
17
  installed?: string;
18
18
  update: boolean;
19
+ /** Its latest version, when it needs a newer rpg-engine than this one, which version offers the newest it reads (D-515 (2)): with the first engine that reads it. */
20
+ newer?: {
21
+ version: string;
22
+ engine?: string;
23
+ };
19
24
  /** An adventure's levels, length and language, as its adventure.yaml says. */
20
25
  levels?: string;
21
26
  length?: string;
@@ -30,6 +35,14 @@ export interface Catalog {
30
35
  github?: string;
31
36
  };
32
37
  }
38
+ /** A game system one may install for a campaign (D-513 (1)): its name, as package install takes it, what it is, and whether it is ours. */
39
+ export interface InstallableSystem {
40
+ name: string;
41
+ title: string;
42
+ verified: boolean;
43
+ }
44
+ /** The game systems npm has that this computer has not, ours first; ours from the engine's list when npm does not answer in time (D-513 (1)). */
45
+ export declare function installableSystems(context: Context): Promise<InstallableSystem[]>;
33
46
  /** The topic a GitHub repository carries to be found as an adventure (D-485 (4)). */
34
47
  export declare const adventureTopic = "rpg-engine-adventure";
35
48
  /** What npm and GitHub offer now, ours first, then by title; each source asked once, side by side. */
@@ -2,13 +2,35 @@
2
2
  // GitHub has by their topic, each with what the player needs to trust it and whether it is here already.
3
3
  import { join } from "node:path";
4
4
  import { readManifest } from "../adventures/index.js";
5
+ import { ourSystems, readsApi } from "../core/package-declarations.js";
5
6
  import { files } from "../core/store.js";
6
7
  import { comparableText } from "../core/text.js";
7
8
  import { isNewerVersion } from "../core/version.js";
8
- import { installedExtensions, isVerified, readExtension, readsApi, shortName } from "../extensions/index.js";
9
+ import { installedExtensions, isVerified, readExtension, shortName } from "../extensions/index.js";
9
10
  import { installedLanguages } from "../languages/index.js";
10
11
  import { systemFolders } from "../systems/index.js";
11
12
  import { installedAdventures } from "./game-adventures.js";
13
+ // How long the setup waits for npm before it offers ours alone.
14
+ const systemsWait = 5000;
15
+ /** The game systems npm has that this computer has not, ours first; ours from the engine's list when npm does not answer in time (D-513 (1)). */
16
+ export async function installableSystems(context) {
17
+ let timer;
18
+ const late = new Promise((done) => (timer = setTimeout(() => done({ failed: "npm took too long" }), systemsWait)));
19
+ const searched = context.packages === undefined ? { failed: "no npm here" } : await Promise.race([context.packages.search().catch(() => ({ failed: "npm failed" })), late]);
20
+ clearTimeout(timer);
21
+ const npm = "failed" in searched ? [] : searched.filter((one) => one.kind === "system" && readsApi(one.api, "system"));
22
+ // Ours by their name alone, as package install takes it; another's by its npm name.
23
+ const found = npm.map((one) => {
24
+ const title = ourSystems.find((system) => system.package === one.name)?.title ?? one.description ?? shortName(one.name);
25
+ return isVerified(one.name, false)
26
+ ? { name: shortName(one.name).replace(/^system-/, ""), title, verified: true }
27
+ : { name: one.name.startsWith("@") ? one.name : `npm:${one.name}`, title, verified: false };
28
+ });
29
+ const listed = "failed" in searched ? ourSystems.map((ours) => ({ name: ours.name, title: ours.title, verified: true })) : found;
30
+ const here = systemFolders(context.systemFolders).map((one) => comparableText(one.name));
31
+ const installedName = (system) => comparableText(shortName(system.name.replace(/^npm:/, "")).replace(/^system-/, ""));
32
+ return listed.filter((system) => !here.includes(installedName(system))).sort((first, second) => Number(second.verified) - Number(first.verified) || first.name.localeCompare(second.name));
33
+ }
12
34
  /** The topic a GitHub repository carries to be found as an adventure (D-485 (4)). */
13
35
  export const adventureTopic = "rpg-engine-adventure";
14
36
  // How many repositories are read, each with its adventure.yaml: GitHub answers without a login only so many times an hour.
@@ -25,7 +47,8 @@ async function npmEntries(root, context) {
25
47
  if ("failed" in searched) {
26
48
  return { entries: [], failed: searched.failed };
27
49
  }
28
- const listed = searched.filter((one) => kinds.has(one.kind ?? "") && (one.kind !== "extension" || readsApi(one.api)));
50
+ // A package made for an API this engine does not read is not offered (D-515).
51
+ const listed = searched.filter((one) => kinds.has(one.kind ?? "") && (one.kind === "language" || readsApi(one.api, one.kind === "system" ? "system" : "extension")));
29
52
  return { entries: listed.map((one) => npmEntry(one, installedVersion(root, context, one))) };
30
53
  }
31
54
  function npmEntry(found, installed) {
@@ -42,6 +65,7 @@ function npmEntry(found, installed) {
42
65
  source: ours ? shortName(found.name) : found.name.startsWith("@") ? found.name : `npm:${found.name}`,
43
66
  ...(installed === undefined ? {} : { installed }),
44
67
  update: installed !== undefined && isNewerVersion(found.version, installed),
68
+ ...(found.newer === undefined ? {} : { newer: found.newer }),
45
69
  };
46
70
  }
47
71
  /** The version of this npm package installed here: an extension's, or a game system's. */
@@ -1,11 +1,11 @@
1
- import { comparableText, sameName, valueNamed } from "../core/text.js";
1
+ import { comparableText, sameWord, valueNamed } from "../core/text.js";
2
2
  import { formatCounter, readCounter } from "../counters/index.js";
3
3
  import { keeperOf } from "../effects/index.js";
4
4
  import { inheritedFields, isPartyMember, pagesWithName, parsePageReference } from "../pages/index.js";
5
5
  import { effectsOf } from "./effect-layer.js";
6
- import { keptEffects } from "./game-effects.js";
6
+ import { keptEffects, systemNamed } from "./game-effects.js";
7
7
  import { readOpenScene } from "./game-scene.js";
8
- import { campaignSystem, campaignWorld } from "./game-world.js";
8
+ import { campaignSystem, campaignSystemWords, campaignWorld } from "./game-world.js";
9
9
  /** Every contradiction now (CHK-3), for status and validate. */
10
10
  export function allStateChecks(root, context) {
11
11
  const system = campaignSystem(root, context);
@@ -14,10 +14,12 @@ export function allStateChecks(root, context) {
14
14
  }
15
15
  const world = campaignWorld(root, context);
16
16
  const scene = readOpenScene(root).scene;
17
+ // Effects written in the campaign's language are the system's by its words, A terra its Down (D-403).
18
+ const words = campaignSystemWords(root, context);
17
19
  return checkedPages(world, scene).flatMap((page) => [
18
- ...said("kept-broken", page, keptWhileBroken(world, scene, system, page)),
19
- ...said("awake-at-dying", page, awakeAtDying(world, system, page)),
20
- ...system.checks.flatMap((check, index) => said(`system-${index}`, page, systemCheck(world, check, page))),
20
+ ...said("kept-broken", page, keptWhileBroken(world, scene, system, page, words)),
21
+ ...said("awake-when-down", page, awakeWhenDown(world, system, page, words)),
22
+ ...system.checks.flatMap((check, index) => said(`system-${index}`, page, systemCheck(world, check, page, words))),
21
23
  ]);
22
24
  }
23
25
  /** The contradictions not yet told in this chat, for scene next and advance (CHK-3): each once while it lasts, again when it comes back; every one without a chat. */
@@ -57,40 +59,40 @@ function checkedPages(world, scene) {
57
59
  return [...new Set([...world.pages.filter(isPartyMember), ...inScene].filter((page) => page.type === "character" && page.system === undefined))];
58
60
  }
59
61
  /** Who keeps an effect alive while a condition that breaks it is on them (EFF-14), as concentration held while Unconscious. */
60
- function keptWhileBroken(world, scene, system, page) {
62
+ function keptWhileBroken(world, scene, system, page, words) {
61
63
  const keeping = system.keeping;
62
- const condition = effectsOf(page).find((effect) => sameName(keeping?.conditions ?? [], effect.name) !== undefined)?.name;
64
+ const condition = effectsOf(page).find((effect) => systemNamed(keeping?.conditions ?? [], effect.name, words) !== undefined)?.name;
63
65
  const kept = keeping === undefined || condition === undefined ? [] : keptEffects(world, scene, page.name);
64
66
  return kept.length === 0 ? undefined : `${page.name} keeps ${kept.join(" · ")} but is ${condition}, which breaks it: effect end, by [[${page.name}]]. Read rules ${keeping?.rules}.`;
65
67
  }
66
68
  /**
67
- * One of the party at the system's dying value, or below, with none of the conditions that keep from acting (DIE-1), as when one was ended by hand; never anyone
69
+ * One of the party at the system's down value, or below, with none of the conditions that keep from acting (DIE-1), as when one was ended by hand; never anyone
68
70
  * else, as a foe at 0 is dead in the game's rules (review of 19 October).
69
71
  */
70
- function awakeAtDying(world, system, page) {
71
- const dying = system.dying;
72
+ function awakeWhenDown(world, system, page, words) {
73
+ const down = system.down;
72
74
  if (!isPartyMember(page)) {
73
75
  return undefined;
74
76
  }
75
77
  const inactive = system.combat?.inactive ?? [];
76
78
  // The page's own counter: what a form that gives it holds is not the page's (DIE-8).
77
- const counter = dying === undefined ? undefined : readCounter(valueNamed(inheritedFields(world, page), dying.field));
78
- if (dying === undefined || counter === undefined || counter.value > dying.value || inactive.length === 0 || page.fields.status === "dead") {
79
+ const counter = down === undefined ? undefined : readCounter(valueNamed(inheritedFields(world, page), down.field));
80
+ if (down === undefined || counter === undefined || counter.value > down.value || inactive.length === 0 || page.fields.status === "dead") {
79
81
  return undefined;
80
82
  }
81
- if (effectsOf(page).some((effect) => sameName(inactive, effect.name) !== undefined)) {
83
+ if (effectsOf(page).some((effect) => systemNamed(inactive, effect.name, words) !== undefined)) {
82
84
  return undefined;
83
85
  }
84
- const rule = system.thresholds.find((threshold) => comparableText(threshold.field) === comparableText(dying.field) && threshold.value === dying.value)?.rule;
86
+ const rule = system.thresholds.find((threshold) => comparableText(threshold.field) === comparableText(down.field) && threshold.value === down.value)?.rule;
85
87
  const read = rule === undefined ? "" : ` Read rules ${rule}.`;
86
- return `${page.name} is at ${dying.field} ${formatCounter(counter)}, not marked dead, with none of ${inactive.join(", ")}: raise its ${dying.field} as its rules say, `
88
+ return `${page.name} is at ${down.field} ${formatCounter(counter)}, not marked dead, with none of ${inactive.join(", ")}: raise its ${down.field} as its rules say, `
87
89
  + `give it one of them back, or write status=dead.${read}`;
88
90
  }
89
91
  /** A check of the system (CHK-2): its line when `when` holds and `needs` does not; nothing when a field it reads is not on the page. */
90
- function systemCheck(world, check, page) {
92
+ function systemCheck(world, check, page, words) {
91
93
  const fields = inheritedFields(world, page);
92
- const when = holds(page, fields, check.when);
93
- const needs = holds(page, fields, check.needs);
94
+ const when = holds(page, fields, check.when, words);
95
+ const needs = holds(page, fields, check.needs, words);
94
96
  if (when !== true || needs !== false) {
95
97
  return undefined;
96
98
  }
@@ -103,9 +105,9 @@ function systemCheck(world, check, page) {
103
105
  });
104
106
  }
105
107
  /** Whether an atom holds on a page: an effect without end or keeper on it, or a field against a number; undefined when the field is not there. */
106
- function holds(page, fields, atom) {
108
+ function holds(page, fields, atom, words) {
107
109
  if ("effect" in atom) {
108
- return effectsOf(page).some((effect) => comparableText(effect.name) === comparableText(atom.effect) && effect.end === undefined && keeperOf(effect) === undefined);
110
+ return effectsOf(page).some((effect) => sameWord(atom.effect, effect.name, words) && effect.end === undefined && keeperOf(effect) === undefined);
109
111
  }
110
112
  const value = readCounter(valueNamed(fields, atom.field))?.value;
111
113
  return value === undefined ? undefined : compare(value, atom.op, atom.value);
@@ -10,7 +10,7 @@ export interface DiceSpent {
10
10
  total: number;
11
11
  id: string;
12
12
  }
13
- /** A counter of dice a recipe lets a page spend, as hit-dice-d8 3/5: its die, what each adds, and the counter it gives to. */
13
+ /** A counter of dice a recipe lets a page spend, as stamina-d6 3/5: its die, what each adds, and the counter it gives to. */
14
14
  export interface RestDice {
15
15
  field: string;
16
16
  sides: number;
@@ -20,7 +20,7 @@ export interface RestDice {
20
20
  gives: string;
21
21
  }
22
22
  /**
23
- * Spends dice of a counter named after its die, as hit-dice-d8, in a recipe that lets one (D-449): each die rolled with what the recipe adds, at least 0, the
23
+ * Spends dice of a counter named after its die, as stamina-d6, in a recipe that lets one (D-449): each die rolled with what the recipe adds, at least 0, the
24
24
  * total given to its counter up to the maximum, the dice taken from theirs, each on the effect that gives it, if one does (EFF-7); the line that says it, with the
25
25
  * rules a party member's counters touch (DAT-3). `how` gives the why, the check that names the roll in the log, as the player's own rolls are named (ASK-14),
26
26
  * and the faces of physical dice, one for each die (ASK-8). Refused when the recipe spends no such counter, there are not as many, or the faces are not one a die.
@@ -35,5 +35,5 @@ export declare function spendDice(root: string, context: Context, world: World,
35
35
  }): DiceSpent;
36
36
  /** The counters of dice a recipe lets this page spend, as the page reads them, with a maximum above 0: those at 0 too, as a page shows them spent. */
37
37
  export declare function restDice(world: World, recipe: Recipe, page: Page): RestDice[];
38
- /** The counters of dice worth spending, as hit-dice-d8 2/3: some left, and the counter they give to below its maximum, where they would give something. */
38
+ /** The counters of dice worth spending, as stamina-d6 2/3: some left, and the counter they give to below its maximum, where they would give something. */
39
39
  export declare function spendableDice(world: World, recipe: Recipe, page: Page): string[];