rpg-engine 0.5.0 → 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 (218) hide show
  1. package/dist/campaign/settings.d.ts +1 -0
  2. package/dist/campaign/settings.js +6 -5
  3. package/dist/command-line.js +12 -5
  4. package/dist/commands/advance.js +1 -1
  5. package/dist/commands/ask.d.ts +1 -1
  6. package/dist/commands/ask.js +66 -24
  7. package/dist/commands/change.js +28 -17
  8. package/dist/commands/config.d.ts +1 -1
  9. package/dist/commands/config.js +67 -21
  10. package/dist/commands/effect.js +42 -23
  11. package/dist/commands/find.js +1 -1
  12. package/dist/commands/game-adventures.js +2 -2
  13. package/dist/commands/game-catalog.d.ts +13 -0
  14. package/dist/commands/game-catalog.js +26 -2
  15. package/dist/commands/game-checks.js +23 -21
  16. package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
  17. package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
  18. package/dist/commands/game-effects.d.ts +12 -4
  19. package/dist/commands/game-effects.js +21 -13
  20. package/dist/commands/game-examples.d.ts +22 -0
  21. package/dist/commands/game-examples.js +72 -0
  22. package/dist/commands/game-extension-list.d.ts +31 -3
  23. package/dist/commands/game-extension-list.js +83 -7
  24. package/dist/commands/game-images.d.ts +1 -1
  25. package/dist/commands/game-images.js +3 -2
  26. package/dist/commands/game-library.d.ts +3 -0
  27. package/dist/commands/game-library.js +2 -2
  28. package/dist/commands/game-mode.js +1 -1
  29. package/dist/commands/game-package-code.d.ts +87 -0
  30. package/dist/commands/game-package-code.js +648 -0
  31. package/dist/commands/game-package-hooks.d.ts +37 -0
  32. package/dist/commands/game-package-hooks.js +116 -0
  33. package/dist/commands/game-recipes.js +2 -2
  34. package/dist/commands/game-reminders.d.ts +5 -2
  35. package/dist/commands/game-reminders.js +7 -4
  36. package/dist/commands/game-rules.d.ts +4 -1
  37. package/dist/commands/game-rules.js +7 -1
  38. package/dist/commands/game-upkeep.js +3 -3
  39. package/dist/commands/game-view-place.d.ts +8 -20
  40. package/dist/commands/game-view-place.js +16 -35
  41. package/dist/commands/game-widgets.d.ts +39 -10
  42. package/dist/commands/game-widgets.js +138 -35
  43. package/dist/commands/game-world.d.ts +17 -0
  44. package/dist/commands/game-world.js +70 -12
  45. package/dist/commands/image.js +1 -1
  46. package/dist/commands/init.js +2 -2
  47. package/dist/commands/mode.d.ts +1 -1
  48. package/dist/commands/package.d.ts +8 -0
  49. package/dist/commands/package.js +81 -24
  50. package/dist/commands/progression.d.ts +2 -0
  51. package/dist/commands/progression.js +7 -2
  52. package/dist/commands/roll.d.ts +2 -0
  53. package/dist/commands/roll.js +50 -24
  54. package/dist/commands/rules.js +6 -4
  55. package/dist/commands/scene.d.ts +1 -1
  56. package/dist/commands/scene.js +13 -10
  57. package/dist/commands/sheet.js +10 -1
  58. package/dist/commands/status.d.ts +1 -0
  59. package/dist/commands/status.js +14 -4
  60. package/dist/commands/trade.js +6 -4
  61. package/dist/commands/translate.js +2 -2
  62. package/dist/commands/travel.js +1 -1
  63. package/dist/commands/validate.js +2 -2
  64. package/dist/commands/view.d.ts +8 -4
  65. package/dist/commands/view.js +7 -6
  66. package/dist/commands/worked-out.js +11 -5
  67. package/dist/commands/write.d.ts +8 -1
  68. package/dist/commands/write.js +84 -25
  69. package/dist/core/command-reference.js +3 -2
  70. package/dist/core/consents.d.ts +18 -0
  71. package/dist/core/consents.js +93 -0
  72. package/dist/core/context.d.ts +51 -29
  73. package/dist/core/context.js +3 -1
  74. package/dist/core/examples.d.ts +25 -0
  75. package/dist/core/examples.js +19 -0
  76. package/dist/{extensions/api.d.ts → core/package-api.d.ts} +134 -32
  77. package/dist/core/package-declarations.d.ts +102 -0
  78. package/dist/core/package-declarations.js +81 -0
  79. package/dist/core/registry.d.ts +2 -0
  80. package/dist/core/text.d.ts +5 -0
  81. package/dist/core/text.js +12 -0
  82. package/dist/dashboard/acts.js +31 -24
  83. package/dist/dashboard/address.js +4 -1
  84. package/dist/dashboard/api.js +54 -0
  85. package/dist/dashboard/app.js +140 -96
  86. package/dist/dashboard/ask-card.js +76 -25
  87. package/dist/dashboard/asked-dice.js +57 -0
  88. package/dist/dashboard/dice/tray.js +3 -3
  89. package/dist/dashboard/extension-widgets.js +104 -10
  90. package/dist/dashboard/i18n/ar.json +25 -29
  91. package/dist/dashboard/i18n/cs.json +25 -29
  92. package/dist/dashboard/i18n/da.json +25 -29
  93. package/dist/dashboard/i18n/de.json +25 -29
  94. package/dist/dashboard/i18n/el.json +25 -29
  95. package/dist/dashboard/i18n/es.json +25 -29
  96. package/dist/dashboard/i18n/fi.json +25 -29
  97. package/dist/dashboard/i18n/fr.json +25 -29
  98. package/dist/dashboard/i18n/he.json +25 -29
  99. package/dist/dashboard/i18n/hi.json +25 -29
  100. package/dist/dashboard/i18n/hu.json +25 -29
  101. package/dist/dashboard/i18n/is.json +25 -29
  102. package/dist/dashboard/i18n/it.json +25 -29
  103. package/dist/dashboard/i18n/ja.json +25 -29
  104. package/dist/dashboard/i18n/ko.json +25 -29
  105. package/dist/dashboard/i18n/nb.json +25 -29
  106. package/dist/dashboard/i18n/nl.json +25 -29
  107. package/dist/dashboard/i18n/pl.json +25 -29
  108. package/dist/dashboard/i18n/pt.json +25 -29
  109. package/dist/dashboard/i18n/ro.json +25 -29
  110. package/dist/dashboard/i18n/ru.json +25 -29
  111. package/dist/dashboard/i18n/sv.json +25 -29
  112. package/dist/dashboard/i18n/tr.json +25 -29
  113. package/dist/dashboard/i18n/uk.json +25 -29
  114. package/dist/dashboard/i18n/zh.json +25 -29
  115. package/dist/dashboard/icons.js +4 -1
  116. package/dist/dashboard/kit.js +35 -0
  117. package/dist/dashboard/labels.js +1 -0
  118. package/dist/dashboard/pack-card.js +7 -2
  119. package/dist/dashboard/package-page.js +50 -0
  120. package/dist/dashboard/packages.js +172 -23
  121. package/dist/dashboard/page-code.js +248 -0
  122. package/dist/dashboard/party.js +13 -14
  123. package/dist/dashboard/people.js +4 -0
  124. package/dist/dashboard/person-panel.js +110 -0
  125. package/dist/dashboard/place-map-view.js +11 -6
  126. package/dist/dashboard/scene.js +12 -9
  127. package/dist/dashboard/settings.js +55 -9
  128. package/dist/dashboard/sheet.js +21 -13
  129. package/dist/dashboard/status.js +69 -15
  130. package/dist/dashboard/style.css +592 -825
  131. package/dist/dashboard/top.js +75 -25
  132. package/dist/dashboard/turns.js +34 -13
  133. package/dist/dashboard/widgets.js +9 -2
  134. package/dist/dashboard-server.js +189 -10
  135. package/dist/dice/roll-dice.js +1 -1
  136. package/dist/effects/effect.d.ts +7 -4
  137. package/dist/effects/effect.js +12 -9
  138. package/dist/extensions/engine.d.ts +4 -0
  139. package/dist/extensions/engine.js +74 -0
  140. package/dist/extensions/extension.d.ts +25 -37
  141. package/dist/extensions/extension.js +26 -48
  142. package/dist/extensions/index.d.ts +3 -2
  143. package/dist/extensions/index.js +4 -1
  144. package/dist/extensions/packages.d.ts +6 -0
  145. package/dist/extensions/packages.js +100 -11
  146. package/dist/index.d.ts +1 -3
  147. package/dist/mcp-server.js +51 -14
  148. package/dist/page-words.d.ts +4 -0
  149. package/dist/page-words.js +4 -4
  150. package/dist/page.d.ts +218 -0
  151. package/dist/page.js +2 -0
  152. package/dist/pages/load.d.ts +7 -1
  153. package/dist/pages/load.js +10 -5
  154. package/dist/pages/page-file.js +1 -1
  155. package/dist/pages/stack-writes.js +5 -4
  156. package/dist/pages/world.d.ts +8 -0
  157. package/dist/pages/world.js +9 -2
  158. package/dist/systems/game-system.d.ts +52 -26
  159. package/dist/systems/game-system.js +141 -42
  160. package/dist/systems/index.d.ts +3 -3
  161. package/dist/systems/index.js +3 -3
  162. package/dist/systems/system-code.d.ts +29 -88
  163. package/dist/systems/system-code.js +68 -23
  164. package/dist/systems/words.d.ts +2 -0
  165. package/dist/systems/words.js +11 -0
  166. package/dist/testing.d.ts +20 -5
  167. package/dist/testing.js +49 -14
  168. package/instructions/combat.md +2 -2
  169. package/instructions/core.md +2 -2
  170. package/instructions/dashboard.md +1 -1
  171. package/instructions/mentor-tutorial.md +1 -1
  172. package/instructions/play.md +2 -2
  173. package/instructions/setup.md +1 -1
  174. package/package.json +9 -1
  175. package/systems/5e/LICENSE.md +13 -3
  176. package/systems/5e/dist/dying.js +83 -16
  177. package/systems/5e/dist/index.js +2 -2
  178. package/systems/5e/dist/page-style.js +634 -0
  179. package/systems/5e/dist/page.js +166 -0
  180. package/systems/5e/dist/shown.js +23 -0
  181. package/systems/5e/instructions/combat.md +1 -0
  182. package/systems/5e/package.json +4 -2
  183. package/systems/5e/system.yaml +35 -7
  184. package/systems/5e/versions/srd-5.1/system.yaml +2 -0
  185. package/systems/5e/words/ar.yaml +30 -0
  186. package/systems/5e/words/cs.yaml +30 -0
  187. package/systems/5e/words/da.yaml +30 -0
  188. package/systems/5e/words/de.yaml +30 -0
  189. package/systems/5e/words/el.yaml +30 -0
  190. package/systems/5e/words/es.yaml +30 -0
  191. package/systems/5e/words/fi.yaml +30 -0
  192. package/systems/5e/words/fr.yaml +30 -0
  193. package/systems/5e/words/he.yaml +30 -0
  194. package/systems/5e/words/hi.yaml +30 -0
  195. package/systems/5e/words/hu.yaml +30 -0
  196. package/systems/5e/words/is.yaml +30 -0
  197. package/systems/5e/words/it.yaml +30 -0
  198. package/systems/5e/words/ja.yaml +30 -0
  199. package/systems/5e/words/ko.yaml +30 -0
  200. package/systems/5e/words/nb.yaml +30 -0
  201. package/systems/5e/words/nl.yaml +30 -0
  202. package/systems/5e/words/pl.yaml +30 -0
  203. package/systems/5e/words/pt.yaml +30 -0
  204. package/systems/5e/words/ro.yaml +30 -0
  205. package/systems/5e/words/ru.yaml +30 -0
  206. package/systems/5e/words/sv.yaml +30 -0
  207. package/systems/5e/words/tr.yaml +30 -0
  208. package/systems/5e/words/uk.yaml +30 -0
  209. package/systems/5e/words/zh.yaml +30 -0
  210. package/dist/commands/game-extensions.d.ts +0 -34
  211. package/dist/commands/game-extensions.js +0 -407
  212. package/dist/commands/game-system-code.d.ts +0 -33
  213. package/dist/commands/game-system-code.js +0 -188
  214. package/dist/dashboard/death-save.js +0 -67
  215. package/dist/dashboard/dying.js +0 -46
  216. package/dist/dashboard/save-outcome.js +0 -42
  217. package/dist/dashboard/spend.js +0 -115
  218. /package/dist/{extensions/api.js → core/package-api.js} +0 -0
@@ -6,13 +6,25 @@ const successes = { field: "death-successes", most: 3 };
6
6
  const failures = { field: "death-failures", most: 3 };
7
7
  const save = { dice: "1d20", sides: 20, atLeast: 10, highest: { field: hp, value: 1 }, lowest: 2 };
8
8
  const rules = { instant: "Instant Death", saves: "Death Saving Throws" };
9
- /** The dying point's hooks. */
10
- export const dyingHooks = {
9
+ // The counters of the hit dice a rest spends, by the die of each class (p. 56).
10
+ const hitDice = "hit-dice-";
11
+ // The words of each state on the dashboard, translated by the 5e's words.
12
+ const stateWords = { dying: "Dying", stable: "Stable", dead: "Dead" };
13
+ /** The dying point's hooks and its widgets, and how its death saves and hit dice are asked on the dashboard. */
14
+ export const dyingCode = {
11
15
  counterChanged: (change, game) => afterHitPoints(change, game),
12
16
  turnStarted: ({ who }, game) => turnOf(who, game),
13
17
  rolled: (roll, game) => playersSave(roll, game),
14
18
  effectAdded: ({ page, effect }, game) => (game.sameName(effect, stableEffect) ? stabilized(page, game) : []),
15
- asking: ({ who, notations }, game) => saveAsked(who, notations, game),
19
+ // A death save is asked in its card, with no button to turn it down (D-460); the hit dice of a rest in theirs (ASK-14).
20
+ asking: ({ who, checks, notations, recipe }, game) => recipe !== undefined
21
+ ? checks.length > 0 && checks.every((field) => field.toLowerCase().startsWith(hitDice)) ? { card: { widget: "hit-dice", key: `${who} ${game.now()?.date ?? ""}` } } : undefined
22
+ : saveAsking(who, notations, game),
23
+ widgets: {
24
+ "dying": (game, asked) => dyingWidget(game, asked?.who),
25
+ "death-save": (game, asked) => (asked?.key === undefined ? undefined : saveWidget(game, asked.who)),
26
+ "hit-dice": (_game, asked) => (asked?.key === undefined ? undefined : { body: "hit-dice", says: "Hit Dice" }),
27
+ },
16
28
  };
17
29
  /** Whether a party member is dying now (DIE-4): at 0 hit points, neither stable by its successes nor dead by its failures. */
18
30
  function isDying(page) {
@@ -35,7 +47,7 @@ function afterHitPoints(change, game) {
35
47
  const failed = counted(page, failures.field);
36
48
  // The dead, at their most failures, are not brought back by hit points: they go back to 0, and only what the rules say brings them back (DIE-7).
37
49
  if (change.after > 0 && change.before <= 0 && failed >= failures.most) {
38
- game.set(name, { [hp]: 0 }, "the dead regain nothing");
50
+ setCounters(game, name, { [hp]: 0 }, "the dead regain nothing");
39
51
  return [
40
52
  `${name} is dead, with ${failures.field} ${failed}: what this change gave is undone, ${hp} back to 0, as ${hp} regained brings no one back. To bring ${name} back as the rules say, as a spell does: `
41
53
  + `first change ${failures.field} to 0, then give the ${hp}.`,
@@ -54,14 +66,14 @@ function afterHitPoints(change, game) {
54
66
  const past = change.lost - Math.max(change.before, 0);
55
67
  // Damage past 0 as large as the maximum kills at once (DIE-2), one stable too (DIE-6).
56
68
  if (change.lost > 0 && change.max !== undefined && past >= change.max) {
57
- game.set(name, { [failures.field]: failures.most, ...(wasStable ? { [successes.field]: 0 } : {}) }, "instant death");
69
+ setCounters(game, name, { [failures.field]: failures.most, ...(wasStable ? { [successes.field]: 0 } : {}) }, "instant death");
58
70
  const unstable = wasStable && game.endEffect(name, stableEffect, "instant death");
59
71
  lines.push(`${name} dies at once: ${past} past 0 is at least the maximum, ${change.max}; ${failures.field} ${failed} → ${failures.most}${unstable ? `, ${stableEffect} ended` : ""}. Read rules ${rules.instant}.`);
60
72
  }
61
73
  else if (change.lost > 0 && change.before <= 0) {
62
74
  // Damage at 0 counts a failure (DIE-2); a critical hit counts two, which only the master knows. One stable is dying again (DIE-6).
63
75
  const after = Math.min(failed + 1, failures.most);
64
- game.set(name, { [failures.field]: after, ...(wasStable ? { [successes.field]: 0 } : {}) }, `damage at 0 ${hp}`);
76
+ setCounters(game, name, { [failures.field]: after, ...(wasStable ? { [successes.field]: 0 } : {}) }, `damage at 0 ${hp}`);
65
77
  const unstable = wasStable && game.endEffect(name, stableEffect, `damage at 0 ${hp}`);
66
78
  const dead = after >= failures.most;
67
79
  const again = wasStable
@@ -84,7 +96,7 @@ function back(page, game) {
84
96
  const name = page.name;
85
97
  const reset = [successes.field, failures.field].filter((field) => counted(page, field) !== 0);
86
98
  const was = Object.fromEntries(reset.map((field) => [field, counted(page, field)]));
87
- game.set(name, Object.fromEntries(reset.map((field) => [field, 0])), `${hp} above 0`);
99
+ setCounters(game, name, Object.fromEntries(reset.map((field) => [field, 0])), `${hp} above 0`);
88
100
  const ended = game.endEffect(name, unconscious, "hit points regained");
89
101
  const stable = game.endEffect(name, stableEffect, "hit points regained");
90
102
  const parts = [...reset.map((field) => `${field} ${was[field]} → 0`), ...(ended ? [`${unconscious} ended`] : []), ...(stable ? [`${stableEffect} ended`] : [])];
@@ -106,7 +118,7 @@ function turnOf(who, game) {
106
118
  return [`${page.name} is dying: the turn starts with their death save, the player's to roll: ask them, with ask, a check of ${save.dice}; the engine writes its outcome.${stabilize}${read}`];
107
119
  }
108
120
  const rolled = game.roll(save.dice, { who: page.name, why: "death save" });
109
- const lines = saved(page, { who: page.name, notation: save.dice, total: rolled.total, dice: rolled.dice }, game);
121
+ const lines = saved(page, { ...rolled, who: page.name }, game);
110
122
  const still = isDying(game.page(page.name)) ? stabilize : "";
111
123
  return [`${page.name} is dying: the engine rolled its death save, ${rolled.text}, so never roll it again. ${lines.join(" ")} ${tellingOf(game.setting("mentor"))}${still}${read}`];
112
124
  }
@@ -127,7 +139,7 @@ function saved(page, roll, game) {
127
139
  const name = page.name;
128
140
  if (natural === save.sides) {
129
141
  const own = page.counter(hp);
130
- game.set(name, { [hp]: save.highest.value }, "death save");
142
+ setCounters(game, name, { [hp]: save.highest.value }, "death save");
131
143
  const shown = (value) => `${value}${own?.max === undefined ? "" : `/${own.max}`}`;
132
144
  return [`${name}'s death save: ${natural}, the highest face: ${hp} ${shown(own?.value ?? 0)} → ${shown(save.highest.value)}.`, ...back(page, game)];
133
145
  }
@@ -136,7 +148,7 @@ function saved(page, roll, game) {
136
148
  const after = Math.min(before + 1, successes.most);
137
149
  const failed = counted(page, failures.field);
138
150
  const stable = after >= successes.most;
139
- game.set(name, { [successes.field]: after, ...(stable && failed > 0 ? { [failures.field]: 0 } : {}) }, "death save");
151
+ setCounters(game, name, { [successes.field]: after, ...(stable && failed > 0 ? { [failures.field]: 0 } : {}) }, "death save");
140
152
  if (stable) {
141
153
  game.addEffect(name, stableEffect, "death save");
142
154
  }
@@ -147,7 +159,7 @@ function saved(page, roll, game) {
147
159
  const before = counted(page, failures.field);
148
160
  const lost = natural === 1 ? save.lowest : 1;
149
161
  const after = Math.min(before + lost, failures.most);
150
- game.set(name, { [failures.field]: after }, "death save");
162
+ setCounters(game, name, { [failures.field]: after }, "death save");
151
163
  const dead = after >= failures.most ? ` ${name} dies: a moment of its own in the story.` : "";
152
164
  return [`${name}'s death save: ${roll.total}, ${lost > 1 ? `the lowest face, ${lost} failures` : "a failure"}; ${failures.field} ${before} → ${after}.${dead}`];
153
165
  }
@@ -159,25 +171,74 @@ function stabilized(name, game) {
159
171
  }
160
172
  const succeeded = counted(page, successes.field);
161
173
  const failed = counted(page, failures.field);
162
- game.set(page.name, { [successes.field]: successes.most, [failures.field]: 0 }, `${stableEffect} given`);
174
+ setCounters(game, page.name, { [successes.field]: successes.most, [failures.field]: 0 }, `${stableEffect} given`);
163
175
  return [
164
176
  `${page.name} is stable: ${successes.field} ${succeeded} → ${successes.most}, ${failures.field} ${failed} → 0; no more death saves, still ${unconscious} until it regains ${hp}.`,
165
177
  ];
166
178
  }
167
- /** The death save a question asks of a dying player character (D-460): every check the save's die, with the counters as they stand, for the page to draw. */
168
- function saveAsked(who, notations, game) {
179
+ /** The death save a question asks of a dying player character (D-460): every check the save's die, asked in its card, forced. */
180
+ function saveAsking(who, notations, game) {
169
181
  const page = game.page(who);
170
182
  if (!isDying(page) || !page.pc || notations.length === 0 || !notations.every(isSaveRoll)) {
171
183
  return undefined;
172
184
  }
185
+ const marks = `${counted(page, successes.field)}/${counted(page, failures.field)}`;
186
+ return { card: { widget: "death-save", key: `${page.name} ${game.now()?.date ?? ""} ${marks}` }, decline: false };
187
+ }
188
+ /** Where one of the party at 0 stands: dying, stable at the last success, dead at the last failure; none above 0, or marked dead. */
189
+ function stateOf(page) {
190
+ const counter = page?.counter(hp);
191
+ if (page === undefined || !page.party || counter === undefined || counter.value > 0 || page.value("status") === "dead") {
192
+ return undefined;
193
+ }
194
+ return counted(page, failures.field) >= failures.most ? "dead" : counted(page, successes.field) >= successes.most ? "stable" : "dying";
195
+ }
196
+ /**
197
+ * One of the party at 0 hit points, on them (D-516): the word of their state, red dying, green stable, dead greyed; the successes on one side and the
198
+ * failures on the other, which leave the line of values; the line of the heart over the word.
199
+ */
200
+ function dyingWidget(game, who) {
201
+ const page = who === undefined ? undefined : game.page(who);
202
+ const state = stateOf(page);
203
+ if (page === undefined || state === undefined) {
204
+ return undefined;
205
+ }
206
+ const [succeeded, failed] = [counted(page, successes.field), counted(page, failures.field)];
207
+ const data = { state };
173
208
  return {
209
+ icon: "heartbeat",
210
+ chip: stateWords[state],
211
+ ...(state === "dead" ? { dead: true } : {}),
212
+ says: { text: "{who}: {state}", values: { who: page.name, state: stateWords[state] } },
213
+ data,
214
+ parts: [
215
+ { track: { label: "Successes", value: succeeded, max: successes.most, tone: "good", stage: "start", field: successes.field } },
216
+ { lead: stateWords[state], ...(state === "dead" ? {} : { tone: state === "stable" ? "good" : "bad" }), figure: "heartbeat" },
217
+ { track: { label: "Failures", value: failed, max: failures.most, tone: "bad", stage: "end", field: failures.field } },
218
+ ],
219
+ };
220
+ }
221
+ /** The card of a death save, for who rolls it, before and after the dice: their counters, whether still at 0 and whether dead, and what the save's faces do. */
222
+ function saveWidget(game, who) {
223
+ const page = who === undefined ? undefined : game.page(who);
224
+ if (page === undefined) {
225
+ return undefined;
226
+ }
227
+ const failed = counted(page, failures.field);
228
+ const data = {
229
+ who: page.name,
230
+ successes: { value: counted(page, successes.field), most: successes.most },
231
+ failures: { value: failed, most: failures.most },
232
+ down: (page.counter(hp)?.value ?? 0) <= 0,
233
+ dead: failed >= failures.most || page.value("status") === "dead",
174
234
  sides: save.sides,
175
235
  atLeast: save.atLeast,
176
- successes: { field: successes.field, value: counted(page, successes.field), most: successes.most },
177
- failures: { field: failures.field, value: counted(page, failures.field), most: failures.most },
178
236
  lowest: save.lowest,
179
237
  highest: save.highest,
180
238
  };
239
+ // The card in the tint of the moment (D-461, D-517): red while dying, green stable, gold back on their feet, grey dead.
240
+ const tint = data.dead ? "muted" : !data.down ? "gold" : data.successes.value >= successes.most ? "ally" : "low";
241
+ return { body: "death-save", says: "Death Saving Throw", tint, data };
181
242
  }
182
243
  /** How the master tells a companion's death save (D-460): with the mentor off, the story alone, never naming it; else the roll in brackets, explained once in the tutorial. */
183
244
  function tellingOf(mentor) {
@@ -191,3 +252,9 @@ function isSaveRoll(notation) {
191
252
  const compact = notation.toLowerCase().replace(/\s+/g, "").replace(/(^|[+-])d/g, "$11d");
192
253
  return compact.startsWith(save.dice) && compact.slice(save.dice.length).split(/(?=[+-])/).filter((term) => term !== "").every((term) => /^[+-]\d*d\d+$/.test(term));
193
254
  }
255
+ /** Counters changed as the change command changes them, one by one, each to its value: the rules watch them, so they are never just written (D-514). */
256
+ function setCounters(game, page, values, why) {
257
+ for (const [field, value] of Object.entries(values)) {
258
+ game.change(page, field, { to: value }, why);
259
+ }
260
+ }
@@ -1,3 +1,3 @@
1
- import { dyingHooks } from "./dying.js";
2
- const fifthEdition = () => dyingHooks;
1
+ import { dyingCode } from "./dying.js";
2
+ const fifthEdition = () => dyingCode;
3
3
  export default fifthEdition;