rpg-engine 0.5.0 → 0.6.1
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.
- package/dist/campaign/settings.d.ts +1 -0
- package/dist/campaign/settings.js +6 -5
- package/dist/command-line.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.d.ts +1 -1
- package/dist/commands/ask.js +66 -24
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +67 -21
- package/dist/commands/effect.js +42 -23
- package/dist/commands/find.js +1 -1
- package/dist/commands/game-adventures.js +2 -2
- package/dist/commands/game-catalog.d.ts +13 -0
- package/dist/commands/game-catalog.js +26 -2
- package/dist/commands/game-checks.js +23 -21
- package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
- package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
- package/dist/commands/game-effects.d.ts +12 -4
- package/dist/commands/game-effects.js +21 -13
- package/dist/commands/game-examples.d.ts +22 -0
- package/dist/commands/game-examples.js +72 -0
- package/dist/commands/game-extension-list.d.ts +31 -3
- package/dist/commands/game-extension-list.js +83 -7
- package/dist/commands/game-images.d.ts +1 -1
- package/dist/commands/game-images.js +3 -2
- package/dist/commands/game-library.d.ts +3 -0
- package/dist/commands/game-library.js +2 -2
- package/dist/commands/game-mode.js +1 -1
- package/dist/commands/game-package-code.d.ts +87 -0
- package/dist/commands/game-package-code.js +648 -0
- package/dist/commands/game-package-hooks.d.ts +37 -0
- package/dist/commands/game-package-hooks.js +116 -0
- package/dist/commands/game-recipes.js +2 -2
- package/dist/commands/game-reminders.d.ts +5 -2
- package/dist/commands/game-reminders.js +7 -4
- package/dist/commands/game-rules.d.ts +4 -1
- package/dist/commands/game-rules.js +7 -1
- package/dist/commands/game-upkeep.js +3 -3
- package/dist/commands/game-view-place.d.ts +8 -20
- package/dist/commands/game-view-place.js +16 -35
- package/dist/commands/game-widgets.d.ts +39 -10
- package/dist/commands/game-widgets.js +138 -35
- package/dist/commands/game-world.d.ts +17 -0
- package/dist/commands/game-world.js +70 -12
- package/dist/commands/image.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package.d.ts +8 -0
- package/dist/commands/package.js +81 -24
- package/dist/commands/progression.d.ts +2 -0
- package/dist/commands/progression.js +7 -2
- package/dist/commands/roll.d.ts +2 -0
- package/dist/commands/roll.js +50 -24
- package/dist/commands/rules.js +6 -4
- package/dist/commands/scene.d.ts +1 -1
- package/dist/commands/scene.js +13 -10
- package/dist/commands/sheet.js +10 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +14 -4
- package/dist/commands/trade.js +6 -4
- package/dist/commands/translate.js +2 -2
- package/dist/commands/travel.js +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/view.d.ts +8 -4
- package/dist/commands/view.js +7 -6
- package/dist/commands/worked-out.js +11 -5
- package/dist/commands/write.d.ts +8 -1
- package/dist/commands/write.js +84 -25
- package/dist/core/command-reference.js +3 -2
- package/dist/core/consents.d.ts +18 -0
- package/dist/core/consents.js +93 -0
- package/dist/core/context.d.ts +51 -29
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/{extensions/api.d.ts → core/package-api.d.ts} +134 -32
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +2 -0
- package/dist/core/text.d.ts +5 -0
- package/dist/core/text.js +12 -0
- package/dist/dashboard/acts.js +31 -24
- package/dist/dashboard/address.js +4 -1
- package/dist/dashboard/api.js +54 -0
- package/dist/dashboard/app.js +140 -96
- package/dist/dashboard/ask-card.js +76 -25
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +3 -3
- package/dist/dashboard/extension-widgets.js +104 -10
- package/dist/dashboard/i18n/ar.json +25 -29
- package/dist/dashboard/i18n/cs.json +25 -29
- package/dist/dashboard/i18n/da.json +25 -29
- package/dist/dashboard/i18n/de.json +25 -29
- package/dist/dashboard/i18n/el.json +25 -29
- package/dist/dashboard/i18n/es.json +25 -29
- package/dist/dashboard/i18n/fi.json +25 -29
- package/dist/dashboard/i18n/fr.json +25 -29
- package/dist/dashboard/i18n/he.json +25 -29
- package/dist/dashboard/i18n/hi.json +25 -29
- package/dist/dashboard/i18n/hu.json +25 -29
- package/dist/dashboard/i18n/is.json +25 -29
- package/dist/dashboard/i18n/it.json +25 -29
- package/dist/dashboard/i18n/ja.json +25 -29
- package/dist/dashboard/i18n/ko.json +25 -29
- package/dist/dashboard/i18n/nb.json +25 -29
- package/dist/dashboard/i18n/nl.json +25 -29
- package/dist/dashboard/i18n/pl.json +25 -29
- package/dist/dashboard/i18n/pt.json +25 -29
- package/dist/dashboard/i18n/ro.json +25 -29
- package/dist/dashboard/i18n/ru.json +25 -29
- package/dist/dashboard/i18n/sv.json +25 -29
- package/dist/dashboard/i18n/tr.json +25 -29
- package/dist/dashboard/i18n/uk.json +25 -29
- package/dist/dashboard/i18n/zh.json +25 -29
- package/dist/dashboard/icons.js +4 -1
- package/dist/dashboard/kit.js +35 -0
- package/dist/dashboard/labels.js +1 -0
- package/dist/dashboard/pack-card.js +7 -2
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +172 -23
- package/dist/dashboard/page-code.js +248 -0
- package/dist/dashboard/party.js +13 -14
- package/dist/dashboard/people.js +4 -0
- package/dist/dashboard/person-panel.js +110 -0
- package/dist/dashboard/place-map-view.js +11 -6
- package/dist/dashboard/scene.js +12 -9
- package/dist/dashboard/settings.js +55 -9
- package/dist/dashboard/sheet.js +21 -13
- package/dist/dashboard/status.js +69 -15
- package/dist/dashboard/style.css +592 -825
- package/dist/dashboard/top.js +75 -25
- package/dist/dashboard/turns.js +34 -13
- package/dist/dashboard/widgets.js +9 -2
- package/dist/dashboard-server.js +189 -10
- package/dist/dice/roll-dice.js +1 -1
- package/dist/effects/effect.d.ts +7 -4
- package/dist/effects/effect.js +12 -9
- package/dist/extensions/engine.d.ts +4 -0
- package/dist/extensions/engine.js +74 -0
- package/dist/extensions/extension.d.ts +25 -37
- package/dist/extensions/extension.js +26 -48
- package/dist/extensions/index.d.ts +3 -2
- package/dist/extensions/index.js +4 -1
- package/dist/extensions/packages.d.ts +6 -0
- package/dist/extensions/packages.js +100 -11
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +51 -14
- package/dist/page-words.d.ts +4 -0
- package/dist/page-words.js +4 -4
- package/dist/page.d.ts +218 -0
- package/dist/page.js +2 -0
- package/dist/pages/load.d.ts +7 -1
- package/dist/pages/load.js +10 -5
- package/dist/pages/page-file.js +1 -1
- package/dist/pages/stack-writes.js +5 -4
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +52 -26
- package/dist/systems/game-system.js +141 -42
- package/dist/systems/index.d.ts +3 -3
- package/dist/systems/index.js +3 -3
- package/dist/systems/system-code.d.ts +29 -88
- package/dist/systems/system-code.js +68 -23
- package/dist/systems/words.d.ts +2 -0
- package/dist/systems/words.js +11 -0
- package/dist/testing.d.ts +20 -5
- package/dist/testing.js +49 -14
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +2 -2
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +3 -3
- package/instructions/setup.md +1 -1
- package/package.json +10 -2
- package/systems/5e/LICENSE.md +13 -3
- package/systems/5e/dist/dying.js +83 -16
- package/systems/5e/dist/index.js +2 -2
- package/systems/5e/dist/page-style.js +634 -0
- package/systems/5e/dist/page.js +166 -0
- package/systems/5e/dist/shown.js +23 -0
- package/systems/5e/instructions/combat.md +1 -0
- package/systems/5e/package.json +4 -2
- package/systems/5e/system.yaml +37 -9
- package/systems/5e/versions/srd-5.1/system.yaml +2 -0
- package/systems/5e/words/ar.yaml +30 -0
- package/systems/5e/words/cs.yaml +30 -0
- package/systems/5e/words/da.yaml +30 -0
- package/systems/5e/words/de.yaml +30 -0
- package/systems/5e/words/el.yaml +30 -0
- package/systems/5e/words/es.yaml +30 -0
- package/systems/5e/words/fi.yaml +30 -0
- package/systems/5e/words/fr.yaml +30 -0
- package/systems/5e/words/he.yaml +30 -0
- package/systems/5e/words/hi.yaml +30 -0
- package/systems/5e/words/hu.yaml +30 -0
- package/systems/5e/words/is.yaml +30 -0
- package/systems/5e/words/it.yaml +30 -0
- package/systems/5e/words/ja.yaml +30 -0
- package/systems/5e/words/ko.yaml +30 -0
- package/systems/5e/words/nb.yaml +30 -0
- package/systems/5e/words/nl.yaml +30 -0
- package/systems/5e/words/pl.yaml +30 -0
- package/systems/5e/words/pt.yaml +30 -0
- package/systems/5e/words/ro.yaml +30 -0
- package/systems/5e/words/ru.yaml +30 -0
- package/systems/5e/words/sv.yaml +30 -0
- package/systems/5e/words/tr.yaml +30 -0
- package/systems/5e/words/uk.yaml +30 -0
- package/systems/5e/words/zh.yaml +30 -0
- package/dist/commands/game-extensions.d.ts +0 -34
- package/dist/commands/game-extensions.js +0 -407
- package/dist/commands/game-system-code.d.ts +0 -33
- package/dist/commands/game-system-code.js +0 -188
- package/dist/dashboard/death-save.js +0 -67
- package/dist/dashboard/dying.js +0 -46
- package/dist/dashboard/save-outcome.js +0 -42
- package/dist/dashboard/spend.js +0 -115
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
package/systems/5e/dist/dying.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
168
|
-
function
|
|
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
|
+
}
|
package/systems/5e/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const fifthEdition = () =>
|
|
1
|
+
import { dyingCode } from "./dying.js";
|
|
2
|
+
const fifthEdition = () => dyingCode;
|
|
3
3
|
export default fifthEdition;
|