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.
- package/README.md +1 -1
- 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 +37 -2
- package/dist/commands/ask.js +106 -35
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +69 -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 +94 -6
- 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 +42 -8
- package/dist/commands/game-widgets.js +182 -31
- package/dist/commands/game-world.d.ts +32 -3
- package/dist/commands/game-world.js +113 -24
- 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 +15 -1
- package/dist/commands/package.js +96 -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 +2 -2
- 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 +12 -4
- package/dist/commands/view.js +11 -8
- 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 +68 -27
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/core/files.d.ts +2 -0
- package/dist/core/files.js +10 -1
- package/dist/core/package-api.d.ts +388 -0
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +4 -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 +65 -3
- package/dist/dashboard/app.js +222 -98
- package/dist/dashboard/ask-card.js +169 -0
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +6 -4
- package/dist/dashboard/extension-widgets.js +136 -16
- package/dist/dashboard/faces.js +6 -4
- package/dist/dashboard/help.js +10 -3
- package/dist/dashboard/i18n/ar.json +34 -29
- package/dist/dashboard/i18n/cs.json +34 -29
- package/dist/dashboard/i18n/da.json +34 -29
- package/dist/dashboard/i18n/de.json +34 -29
- package/dist/dashboard/i18n/el.json +34 -29
- package/dist/dashboard/i18n/es.json +34 -29
- package/dist/dashboard/i18n/fi.json +34 -29
- package/dist/dashboard/i18n/fr.json +34 -29
- package/dist/dashboard/i18n/he.json +34 -29
- package/dist/dashboard/i18n/hi.json +34 -29
- package/dist/dashboard/i18n/hu.json +34 -29
- package/dist/dashboard/i18n/is.json +34 -29
- package/dist/dashboard/i18n/it.json +34 -29
- package/dist/dashboard/i18n/ja.json +34 -29
- package/dist/dashboard/i18n/ko.json +34 -29
- package/dist/dashboard/i18n/nb.json +34 -29
- package/dist/dashboard/i18n/nl.json +34 -29
- package/dist/dashboard/i18n/pl.json +34 -29
- package/dist/dashboard/i18n/pt.json +34 -29
- package/dist/dashboard/i18n/ro.json +34 -29
- package/dist/dashboard/i18n/ru.json +34 -29
- package/dist/dashboard/i18n/sv.json +34 -29
- package/dist/dashboard/i18n/tr.json +34 -29
- package/dist/dashboard/i18n/uk.json +34 -29
- package/dist/dashboard/i18n/zh.json +34 -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 +97 -0
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +180 -24
- 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/rolls.js +2 -2
- 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 +859 -574
- 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 +246 -11
- 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 +28 -33
- package/dist/extensions/extension.js +37 -46
- package/dist/extensions/index.d.ts +4 -3
- package/dist/extensions/index.js +5 -2
- package/dist/extensions/packages.d.ts +14 -0
- package/dist/extensions/packages.js +148 -12
- package/dist/extensions/words.d.ts +2 -1
- package/dist/extensions/words.js +5 -4
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +52 -15
- 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/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- 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/standard-fields.d.ts +2 -0
- package/dist/pages/standard-fields.js +8 -1
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +61 -30
- package/dist/systems/game-system.js +159 -50
- 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 +76 -0
- package/dist/testing.js +197 -0
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/setup.md +1 -1
- package/package.json +15 -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 +35 -7
- 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 -182
- package/dist/commands/game-system-code.d.ts +0 -25
- package/dist/commands/game-system-code.js +0 -172
- 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.d.ts +0 -155
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
package/dist/dashboard/dying.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
import { statusIcons } from "./icons.js";
|
|
3
|
-
import { fieldLabel, itemLabel } from "./labels.js";
|
|
4
|
-
import { dyingState, stableName } from "./save-outcome.js";
|
|
5
|
-
import { t } from "./text.js";
|
|
6
|
-
/** The panel of the dying, from its counters by their sides: large, or in one line in a row of the turns. */
|
|
7
|
-
export function DeathSaves({ dying, compact = false }) {
|
|
8
|
-
const state = dyingState(dying) ?? "dying";
|
|
9
|
-
const successes = dying.find((counter) => counter.side === "successes");
|
|
10
|
-
const failures = dying.find((counter) => counter.side === "failures");
|
|
11
|
-
return (_jsxs("div", { class: ["death-saves", state, compact ? "compact" : ""].filter((name) => name !== "").join(" "), children: [successes !== undefined && _jsx(Marks, { kind: "successes", label: sideLabel(successes), value: successes.value, most: successes.limit ?? Math.max(successes.value, 1), lit: 0 }), _jsxs("span", { class: "death-middle", children: [_jsx(HeartLine, { line: stateLines[state] }), _jsxs("span", { class: "death-word", children: [state === "dead" && _jsx(Skull, {}), dyingWord(state, dying)] })] }), failures !== undefined && _jsx(Marks, { kind: "failures", label: sideLabel(failures), value: failures.value, most: failures.limit ?? Math.max(failures.value, 1), lit: 0 })] }));
|
|
12
|
-
}
|
|
13
|
-
/** The red skull of the dead, as on their token (D-461), before the word. */
|
|
14
|
-
export function Skull() {
|
|
15
|
-
return (_jsx("svg", { class: "dying-skull", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: statusIcons.dead }) }));
|
|
16
|
-
}
|
|
17
|
-
/** Where someone at their dying point stands, in a word: stable as the system calls it, by their counters. */
|
|
18
|
-
export function dyingWord(state, counters) {
|
|
19
|
-
return state === "dead" ? t("Dead") : state === "stable" ? stableWord(counters) : t("Dying");
|
|
20
|
-
}
|
|
21
|
-
/** What the system calls one whose successes are full, in the page's language, as Stable; else the label of the successes. */
|
|
22
|
-
export function stableWord(counters) {
|
|
23
|
-
const name = stableName(counters);
|
|
24
|
-
return name === undefined ? fieldLabel(counters?.find((counter) => counter.side === "successes")?.field ?? "") : itemLabel(name);
|
|
25
|
-
}
|
|
26
|
-
/** The words of a side's marks, the system's short ones, as Successes, else its field's label. */
|
|
27
|
-
export function sideLabel(counter) {
|
|
28
|
-
return counter.mark === undefined ? fieldLabel(counter.field) : itemLabel(counter.mark);
|
|
29
|
-
}
|
|
30
|
-
/** A side's marks, named by the system: successes as circles, failures as squares; the last `lit` of those marked are new, lit as they come. */
|
|
31
|
-
export function Marks({ kind, label, value, most, lit }) {
|
|
32
|
-
return (_jsxs("div", { class: `dying-side dying-${kind}`, children: [_jsx("span", { class: "eyebrow dying-label", "aria-hidden": "true", children: label }), _jsxs("span", { class: "dying-marks", children: [Array.from({ length: most }, (_, index) => (_jsx("span", { class: ["dying-mark", index < value ? "marked" : "", index < value && index >= value - lit ? "new" : ""].filter((name) => name !== "").join(" "), "aria-hidden": "true" }, index))), _jsx("span", { class: "visually-hidden", children: `${label}: ${t("{value} of {max}", { value, max: most })}` })] })] }));
|
|
33
|
-
}
|
|
34
|
-
// The line of the heart, on a strip 420 wide and 60 high: a faint beat while dying, a stronger one at a success, weaker at a failure, flat at the last.
|
|
35
|
-
const heartLines = {
|
|
36
|
-
faint: "M0 30H130l6-6 5 10 4-4H170l5-16 7 28 5-12H260l5-5 4 8 4-3H420",
|
|
37
|
-
beat: "M0 30H120l8-4 6 4H170l6-26 8 50 6-24H240l8-4 6 4H330l6-22 8 42 6-20H420",
|
|
38
|
-
weak: "M0 30H140l6-8 6 14 4-6H300l4-6 4 8H420",
|
|
39
|
-
flat: "M0 30H420",
|
|
40
|
-
strong: "M0 30H120l8-6 6 6H160l8-34 10 60 8-30H250l8-6 6 6H320l8-30 10 54 8-24H420",
|
|
41
|
-
};
|
|
42
|
-
// The line of each state that stays.
|
|
43
|
-
const stateLines = { dying: "faint", stable: "beat", dead: "flat" };
|
|
44
|
-
export function HeartLine({ line }) {
|
|
45
|
-
return (_jsx("svg", { class: "dying-line", viewBox: "0 0 420 60", preserveAspectRatio: "none", "aria-hidden": "true", children: _jsx("path", { d: heartLines[line] }) }));
|
|
46
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The outcome of a death save from what its roll left (DIE-4): back above the dying point, failures added, the last of them dead, or a success, the last of
|
|
3
|
-
* them stable; none when it changed nothing, as when the system's code did not run.
|
|
4
|
-
*/
|
|
5
|
-
export function saveOutcome(save, after) {
|
|
6
|
-
if (after.dead === true) {
|
|
7
|
-
return { kind: "dead", successes: save.successes.value, failures: save.failures.most, count: Math.max(save.failures.most - save.failures.value, 1) };
|
|
8
|
-
}
|
|
9
|
-
if (after.dying === undefined) {
|
|
10
|
-
return { kind: "back", successes: 0, failures: 0, count: 0 };
|
|
11
|
-
}
|
|
12
|
-
const successes = sideValue(after.dying, "successes") ?? save.successes.value;
|
|
13
|
-
const failures = sideValue(after.dying, "failures") ?? save.failures.value;
|
|
14
|
-
if (failures > save.failures.value) {
|
|
15
|
-
const count = failures - save.failures.value;
|
|
16
|
-
return { kind: failures >= save.failures.most ? "dead" : count > 1 ? "failures" : "failure", successes, failures, count };
|
|
17
|
-
}
|
|
18
|
-
if (successes > save.successes.value) {
|
|
19
|
-
return { kind: successes >= save.successes.most ? "stable" : "success", successes, failures, count: 0 };
|
|
20
|
-
}
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
/** What the system calls one whose successes are full, as the 5e's Stable; none when it names nothing. */
|
|
24
|
-
export function stableName(counters) {
|
|
25
|
-
return counters?.find((counter) => counter.side === "successes")?.full;
|
|
26
|
-
}
|
|
27
|
-
/** Of someone's effects, those their marks say beside their state: never the one that names it stable, as the 5e's Stable, said once by the state (playtest 11). */
|
|
28
|
-
export function effectsBesideState(effects, counters) {
|
|
29
|
-
const stable = dyingState(counters) === "stable" ? stableName(counters)?.toLowerCase() : undefined;
|
|
30
|
-
return effects.filter((effect) => effect.name.toLowerCase() !== stable);
|
|
31
|
-
}
|
|
32
|
-
/** The state the panel of the dying says, from its counters by their sides; none when not dying. */
|
|
33
|
-
export function dyingState(counters) {
|
|
34
|
-
if (counters === undefined) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
const full = (side) => counters.some((counter) => counter.side === side && counter.limit !== undefined && counter.value >= counter.limit);
|
|
38
|
-
return full("failures") ? "dead" : full("successes") ? "stable" : "dying";
|
|
39
|
-
}
|
|
40
|
-
function sideValue(counters, side) {
|
|
41
|
-
return counters.find((counter) => counter.side === side)?.value;
|
|
42
|
-
}
|
package/dist/dashboard/spend.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
// The dice of a rest the master asks the player to spend (D-492, ASK-14): a card in the frame of the master's question that stays while the player rolls, one
|
|
3
|
-
// die at a time. Who rests and the points the dice give, as a bar that keeps where the rest began; a row for each kind of die with its pips and its button;
|
|
4
|
-
// the dice rolled as chips; the one button that ends it. What a roll changes shows once its dice land.
|
|
5
|
-
import { useEffect, useRef, useState } from "preact/hooks";
|
|
6
|
-
import { DieIcon, Icon } from "./icons.js";
|
|
7
|
-
import { fieldLabel, signed } from "./labels.js";
|
|
8
|
-
import { Token } from "./party.js";
|
|
9
|
-
import { t } from "./text.js";
|
|
10
|
-
// How long the points take to climb to what a die gave.
|
|
11
|
-
const climbTime = 400;
|
|
12
|
-
export function SpendCard({ asked, spend, member, flying, onSpend, onDone }) {
|
|
13
|
-
const card = useRef(null);
|
|
14
|
-
const done = useRef(null);
|
|
15
|
-
// A die asked of the engine, until its roll comes back: its counter, and how many rolls there were then.
|
|
16
|
-
const [sent, setSent] = useState();
|
|
17
|
-
const [leaving, setLeaving] = useState(false);
|
|
18
|
-
const waiting = (sent !== undefined && spend.rolls.length <= sent.rolls) || spend.rolls.some((roll) => roll.id === flying);
|
|
19
|
-
// What the card shows: the dice as they were until the last roll's dice land.
|
|
20
|
-
const steady = useRef(spend);
|
|
21
|
-
if (!waiting) {
|
|
22
|
-
steady.current = spend;
|
|
23
|
-
}
|
|
24
|
-
const shown = steady.current;
|
|
25
|
-
const { gives } = shown;
|
|
26
|
-
const value = useClimb(gives.value);
|
|
27
|
-
const gained = gives.value - gives.from;
|
|
28
|
-
const full = gives.max !== undefined && gives.value >= gives.max;
|
|
29
|
-
const left = shown.dice.some((dice) => dice.value > 0);
|
|
30
|
-
const last = shown.rolls.at(-1);
|
|
31
|
-
const busy = waiting || leaving;
|
|
32
|
-
// While it is there, the rolls beside the sheet stay in sight under it, as under the master's question (D-291).
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const element = card.current;
|
|
35
|
-
if (element === null) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const root = document.documentElement;
|
|
39
|
-
const observer = new ResizeObserver(() => root.style.setProperty("--asked-space", `${element.offsetHeight + 16}px`));
|
|
40
|
-
observer.observe(element);
|
|
41
|
-
return () => {
|
|
42
|
-
observer.disconnect();
|
|
43
|
-
root.style.removeProperty("--asked-space");
|
|
44
|
-
};
|
|
45
|
-
}, []);
|
|
46
|
-
// The last die spent, the focus that was on a button to roll goes to the one that ends it.
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (!left && card.current?.contains(document.activeElement) === true) {
|
|
49
|
-
done.current?.focus();
|
|
50
|
-
}
|
|
51
|
-
}, [left]);
|
|
52
|
-
const spendOne = async (field) => {
|
|
53
|
-
if (busy) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
setSent({ field, rolls: spend.rolls.length });
|
|
57
|
-
if (!await onSpend(field)) {
|
|
58
|
-
setSent(undefined);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const end = async () => {
|
|
62
|
-
if (busy) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
setLeaving(true);
|
|
66
|
-
if (!await onDone(card.current?.contains(document.activeElement) === true)) {
|
|
67
|
-
setLeaving(false);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
return (_jsxs("section", { ref: card, class: leaving ? "asked spend-card leaving" : "asked spend-card", "aria-labelledby": `spend-${asked.id}`, children: [_jsx("img", { class: "asked-robot", src: "/assets/favicon.svg", alt: "" }), _jsxs("div", { class: "asked-body", children: [_jsx("p", { class: "eyebrow asked-turn", children: asked.title }), _jsx("p", { id: `spend-${asked.id}`, class: "asked-question", role: "alert", children: asked.question }), _jsxs("div", { class: "spend-play", children: [_jsxs("div", { class: "spend-life", children: [_jsx("span", { class: "spend-token", children: member !== undefined && _jsx(Token, { member: member }) }), _jsxs("div", { class: "spend-points", children: [_jsxs("span", { class: "spend-points-head", children: [_jsx("span", { class: "eyebrow spend-points-name", children: fieldLabel(gives.field) }), _jsxs("span", { class: "spend-points-number", children: [_jsx("b", { children: value }), gives.max !== undefined && _jsxs("span", { class: "spend-points-max", children: ["/", gives.max] })] }), gained > 0 && _jsxs("span", { class: "spend-gain", children: ["+", gained] }), full && (_jsxs("span", { class: "spend-full", children: [_jsx(Icon, { name: "check" }), t("at the maximum")] }))] }), gives.max !== undefined && gives.max > 0 && (_jsxs("span", { class: "bar spend-bar", role: "meter", "aria-label": fieldLabel(gives.field), "aria-valuemin": 0, "aria-valuemax": gives.max, "aria-valuenow": gives.value, "aria-valuetext": t("{value} of {max}", { value: gives.value, max: gives.max }), children: [_jsx("span", { class: "fill spend-now", style: { "--fill": String(share(gives.value, gives.max)) } }), gives.from > 0 && _jsx("span", { class: "fill spend-before", style: { "--fill": String(share(gives.from, gives.max)) } })] }))] })] }), _jsx("ul", { class: "spend-rows", children: shown.dice.map((dice) => {
|
|
71
|
-
const out = dice.value <= 0;
|
|
72
|
-
const label = fieldLabel(dice.field);
|
|
73
|
-
return (_jsxs("li", { class: out ? "spend-row out" : "spend-row", children: [_jsx("span", { class: "spend-row-name", children: label }), dice.max <= 10
|
|
74
|
-
? (_jsx("span", { class: "pips spend-pips", role: "img", "aria-label": `${label}: ${t("{value} of {max}", { value: dice.value, max: dice.max })}`, children: Array.from({ length: dice.max }, (_, index) => (_jsx("span", { class: ["pip", index < dice.value ? "on" : "", last?.field === dice.field && index === dice.value ? "fresh" : ""].filter((name) => name !== "").join(" ") }, index))) }))
|
|
75
|
-
: _jsx("span", { class: "spend-count", children: t("{value} of {max}", { value: dice.value, max: dice.max }) }), _jsxs("button", { type: "button", class: sent?.field === dice.field && waiting ? "spend-roll sent" : "spend-roll", "aria-disabled": out || busy ? "true" : undefined, onClick: () => !out && void spendOne(dice.field), children: [_jsx(DieIcon, { sides: dice.sides }), _jsx("span", { class: "asked-check-name", children: out ? t("None left") : t("Roll") }), !out && dice.adds !== 0 && _jsx("span", { class: "asked-dice", children: signed(dice.adds) }), _jsx("span", { class: "visually-hidden", children: label })] })] }, dice.field));
|
|
76
|
-
}) })] }), _jsxs("div", { class: "spend-foot", children: [shown.rolls.length === 0
|
|
77
|
-
? _jsx("p", { class: "spend-hint", children: t("One die at a time: stop when you like.") })
|
|
78
|
-
: (_jsx("ol", { class: "spend-chips", "aria-label": t("Dice rolled"), children: shown.rolls.map((roll) => (_jsxs("li", { class: roll.id === last?.id ? "spend-chip fresh" : "spend-chip", children: [_jsxs("span", { class: "die-chip", children: [_jsx(DieIcon, { sides: shown.dice.find((dice) => dice.field === roll.field)?.sides ?? 6 }), roll.face] }), roll.adds !== 0 && _jsx("span", { class: "spend-chip-adds", children: signed(roll.adds) }), _jsxs("span", { class: "spend-chip-total", children: ["= ", roll.total] })] }, roll.id))) })), _jsx("button", { ref: done, type: "button", class: left ? "spend-done" : "spend-done last", "aria-disabled": busy ? "true" : undefined, onClick: () => void end(), children: shown.rolls.length === 0 ? t("I spend none") : t("Done") })] }), _jsx("p", { class: "visually-hidden", role: "status", children: last === undefined ? "" : landedText(shown, last) })] })] }));
|
|
79
|
-
}
|
|
80
|
-
/** "Hit dice d8: 6 +2 = 8. HP: 22 of 27. Left: 1.": a die as it landed, for a screen reader. */
|
|
81
|
-
function landedText(spend, roll) {
|
|
82
|
-
const dice = spend.dice.find((counter) => counter.field === roll.field);
|
|
83
|
-
const points = spend.gives.max === undefined ? String(spend.gives.value) : t("{value} of {max}", { value: spend.gives.value, max: spend.gives.max });
|
|
84
|
-
const rolled = `${roll.face}${roll.adds === 0 ? "" : ` ${signed(roll.adds)}`} = ${roll.total}`;
|
|
85
|
-
return `${fieldLabel(roll.field)}: ${rolled}. ${fieldLabel(spend.gives.field)}: ${points}.${dice === undefined ? "" : ` ${t("Left: {count}", { count: dice.value })}`}`;
|
|
86
|
-
}
|
|
87
|
-
/** A value's share of its maximum, from 0 to 1. */
|
|
88
|
-
function share(value, max) {
|
|
89
|
-
return Math.min(1, Math.max(0, value / max));
|
|
90
|
-
}
|
|
91
|
-
/** A number that climbs to its new value in a moment, at once for a player who asked for less motion. */
|
|
92
|
-
function useClimb(target) {
|
|
93
|
-
const [value, setValue] = useState(target);
|
|
94
|
-
const from = useRef(target);
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
const start = from.current;
|
|
97
|
-
from.current = target;
|
|
98
|
-
if (start === target || window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
99
|
-
setValue(target);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const began = performance.now();
|
|
103
|
-
let frame = 0;
|
|
104
|
-
const step = (now) => {
|
|
105
|
-
const part = Math.min(1, (now - began) / climbTime);
|
|
106
|
-
setValue(Math.round(start + (target - start) * part));
|
|
107
|
-
if (part < 1) {
|
|
108
|
-
frame = requestAnimationFrame(step);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
frame = requestAnimationFrame(step);
|
|
112
|
-
return () => cancelAnimationFrame(frame);
|
|
113
|
-
}, [target]);
|
|
114
|
-
return value;
|
|
115
|
-
}
|
package/dist/extensions/api.d.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
/** What an extension's code gets when it loads: zod, to describe its commands' input with the same library the engine checks them with. */
|
|
3
|
-
export interface ExtensionKit {
|
|
4
|
-
z: typeof z;
|
|
5
|
-
}
|
|
6
|
-
/** The default export of an extension's code: given the kit, its commands and what it does when time passes. */
|
|
7
|
-
export type ExtensionEntry = (kit: ExtensionKit) => ExtensionCode;
|
|
8
|
-
/** What an extension's code gives rpg-engine. */
|
|
9
|
-
export interface ExtensionCode {
|
|
10
|
-
/** Its commands, which the command line and the MCP server give the master beside the core's (D-63). */
|
|
11
|
-
commands?: ExtensionCommand<any>[];
|
|
12
|
-
/** After advance or travel moved the game date: lines for their output, such as the weather of a new morning (D-436). */
|
|
13
|
-
timePassed?(passage: TimePassage, game: Game): string[] | Promise<string[]>;
|
|
14
|
-
/**
|
|
15
|
-
* What each widget its extension.yaml declares shows now, by the widget's name there (D-502): called as the dashboard reads the game, it only reads; nothing
|
|
16
|
-
* shows for undefined.
|
|
17
|
-
*/
|
|
18
|
-
widgets?: Record<string, (game: GameView) => Widget | undefined | Promise<Widget | undefined>>;
|
|
19
|
-
}
|
|
20
|
-
/** A command of an extension: its name is the extension's, or starts with it and a hyphen, as weather or weather-set (D-63). */
|
|
21
|
-
export interface ExtensionCommand<Input extends z.ZodObject = z.ZodObject> {
|
|
22
|
-
name: string;
|
|
23
|
-
/** Written for an AI: what it does (the first sentence), when to use it, an example. */
|
|
24
|
-
description: string;
|
|
25
|
-
input: Input;
|
|
26
|
-
/** It changes nothing: hosts may run it without asking. */
|
|
27
|
-
readOnly?: boolean;
|
|
28
|
-
/** Fields the command line takes as positional arguments, in order: weather-set 2. */
|
|
29
|
-
positionals?: string[];
|
|
30
|
-
/** The text the master reads; an error thrown says what went wrong and how to fix it. */
|
|
31
|
-
run(input: z.infer<Input>, game: Game): string | Promise<string>;
|
|
32
|
-
}
|
|
33
|
-
/** A moment of the story: its game date as written, day 3, 06:00; the day and the minute of the day; the day of the calendar, when the story starts on one. */
|
|
34
|
-
export interface GameMoment {
|
|
35
|
-
date: string;
|
|
36
|
-
day: number;
|
|
37
|
-
minute?: number;
|
|
38
|
-
calendar?: CalendarDay;
|
|
39
|
-
}
|
|
40
|
-
/** A day of the world's calendar (TIM-8). */
|
|
41
|
-
export interface CalendarDay {
|
|
42
|
-
day: number;
|
|
43
|
-
month: string;
|
|
44
|
-
season?: string;
|
|
45
|
-
year?: number;
|
|
46
|
-
}
|
|
47
|
-
/** The time an advance or a travel let pass. */
|
|
48
|
-
export interface TimePassage {
|
|
49
|
-
from: GameMoment;
|
|
50
|
-
to: GameMoment;
|
|
51
|
-
}
|
|
52
|
-
/** The campaign as a widget reads it (D-502): what the code's commands reach, without the dice, the log or writing. */
|
|
53
|
-
export interface GameView {
|
|
54
|
-
/** Now, in the game; undefined before the game has a date. */
|
|
55
|
-
now(): GameMoment | undefined;
|
|
56
|
-
/** The day of the calendar a game day falls on; undefined when the story counts only the days. */
|
|
57
|
-
calendarDay(day: number): CalendarDay | undefined;
|
|
58
|
-
/** The units of measure the campaign tells the story in. */
|
|
59
|
-
units(): "metric" | "imperial";
|
|
60
|
-
/** Where the party is: the first living player character's places, in the order of the pages, the nearest first, and what holds there by the places' environment, such as biome: desert. */
|
|
61
|
-
party(): {
|
|
62
|
-
places: string[];
|
|
63
|
-
environment: Record<string, string>;
|
|
64
|
-
} | undefined;
|
|
65
|
-
/** The extension's own state, kept in the campaign. */
|
|
66
|
-
state: {
|
|
67
|
-
read(): unknown;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/** The campaign as an extension's code reaches it: only through these, and only its own state is written (D-428, D-436). */
|
|
71
|
-
export interface Game extends GameView {
|
|
72
|
-
/** Rolls with the engine's dice, as 1d6 or 4d6kh3: the total, each die's face, and the roll as one line. */
|
|
73
|
-
roll(notation: string): {
|
|
74
|
-
total: number;
|
|
75
|
-
faces: number[];
|
|
76
|
-
text: string;
|
|
77
|
-
};
|
|
78
|
-
state: {
|
|
79
|
-
read(): unknown;
|
|
80
|
-
write(value: unknown): void;
|
|
81
|
-
};
|
|
82
|
-
/** A line in the campaign's log: public when the player may see it, hidden when only the master may. */
|
|
83
|
-
log(text: string, visibility?: "public" | "hidden"): void;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* What a widget shows now (D-502), in the dashboard's own parts: in the top, its icon and its chip, what it says whole in the chip's tip; in a card, under the
|
|
87
|
-
* widget's title, its note and its parts. The server checks it, and keeps it short.
|
|
88
|
-
*/
|
|
89
|
-
export interface Widget {
|
|
90
|
-
/** One of the icons of extension.yaml, in place of the widget's own. */
|
|
91
|
-
icon?: string;
|
|
92
|
-
/** The few words of a chip in the top, as 10–15 °C. */
|
|
93
|
-
chip?: WidgetText;
|
|
94
|
-
/** What it says whole, in a sentence: the chip's tip, and its name for a screen reader. */
|
|
95
|
-
says?: WidgetText;
|
|
96
|
-
/** A note at the end of a card's head. */
|
|
97
|
-
note?: WidgetText;
|
|
98
|
-
parts?: WidgetPart[];
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Words of the extension, written in its language: translated whole by its words/<code>.yaml, as "Light fog this morning"; or a phrase whose {names} are values
|
|
102
|
-
* the page writes in its own language, as {text: "From {low} to {high}", values: {low: 10, high: 15}}.
|
|
103
|
-
*/
|
|
104
|
-
export type WidgetText = string | {
|
|
105
|
-
text: string;
|
|
106
|
-
values: Record<string, WidgetValue>;
|
|
107
|
-
};
|
|
108
|
-
/** A value the page writes: a number; a word, translated; a number with its unit, as 12 km; a range, as 10–15 °C. */
|
|
109
|
-
export type WidgetValue = number | string | {
|
|
110
|
-
number: number;
|
|
111
|
-
unit?: string;
|
|
112
|
-
} | {
|
|
113
|
-
from: number;
|
|
114
|
-
to: number;
|
|
115
|
-
unit?: string;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* A part of a widget's card: one thing large, with its icon and its value; text; facts, as chips; values, each in a box under its label; a count as pips or a
|
|
119
|
-
* bar; rows of a label, a value and a note; a table; a picture of the extension's images/.
|
|
120
|
-
*/
|
|
121
|
-
export type WidgetPart = {
|
|
122
|
-
lead: WidgetText;
|
|
123
|
-
icon?: string;
|
|
124
|
-
value?: WidgetValue;
|
|
125
|
-
} | {
|
|
126
|
-
text: WidgetText;
|
|
127
|
-
} | {
|
|
128
|
-
facts: WidgetText[];
|
|
129
|
-
} | {
|
|
130
|
-
values: {
|
|
131
|
-
label: WidgetText;
|
|
132
|
-
value: WidgetValue;
|
|
133
|
-
}[];
|
|
134
|
-
} | {
|
|
135
|
-
track: {
|
|
136
|
-
label: WidgetText;
|
|
137
|
-
value: number;
|
|
138
|
-
max: number;
|
|
139
|
-
look?: "pips" | "bar";
|
|
140
|
-
};
|
|
141
|
-
} | {
|
|
142
|
-
rows: {
|
|
143
|
-
label: WidgetText;
|
|
144
|
-
value?: WidgetValue;
|
|
145
|
-
note?: WidgetText;
|
|
146
|
-
}[];
|
|
147
|
-
} | {
|
|
148
|
-
table: {
|
|
149
|
-
head: WidgetText[];
|
|
150
|
-
rows: WidgetValue[][];
|
|
151
|
-
};
|
|
152
|
-
} | {
|
|
153
|
-
image: string;
|
|
154
|
-
alt: WidgetText;
|
|
155
|
-
};
|
|
File without changes
|