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
|
@@ -5,16 +5,17 @@ import { changeSetting, readSettings } from "./api.js";
|
|
|
5
5
|
import { diceEdgesPref, diceLook, diceSetPref, diceSets, texturePath } from "./dice/sets.js";
|
|
6
6
|
import { WidgetsContext } from "./extension-widgets.js";
|
|
7
7
|
import { DieSwatch, Icon } from "./icons.js";
|
|
8
|
-
import { settingLabel, valueLabel } from "./labels.js";
|
|
8
|
+
import { phraseLabel, settingLabel, valueLabel } from "./labels.js";
|
|
9
9
|
import { LanguageChoice, languageLine } from "./language-choice.js";
|
|
10
10
|
import { PageHead } from "./pages.js";
|
|
11
11
|
import { byHandPref, conditionsPref, soundPref, tokenSymbolsPref, useChoice, usePref, usePrefChange } from "./prefs.js";
|
|
12
|
+
import { Confirm } from "./saves.js";
|
|
12
13
|
import { arrowStep, t } from "./text.js";
|
|
13
14
|
import { pickTheme, shownTheme } from "./theme.js";
|
|
14
15
|
// The groups of the campaign's settings, in order; a setting the game system adds goes with the dice, as whether the master's rolls are shown (D-287). How the
|
|
15
16
|
// master plays holds who voices the characters (D-490) and how much the master thinks (D-462) too.
|
|
16
17
|
const groups = [
|
|
17
|
-
{ names: ["difficulty", "lethality", "saves", "rigor"] },
|
|
18
|
+
{ names: ["ruleset", "difficulty", "lethality", "saves", "rigor"] },
|
|
18
19
|
{ names: ["mentor", "learned"] },
|
|
19
20
|
{ names: ["prose", "story", "author", "style", "voices", "effort"] },
|
|
20
21
|
{ names: ["dice", "master-rolls", "units"], system: true },
|
|
@@ -76,17 +77,44 @@ function SettingRow({ setting, off, several = false, onChange }) {
|
|
|
76
77
|
const said = useSaid();
|
|
77
78
|
const value = picked ?? setting.value;
|
|
78
79
|
const id = `setting-${idOf(setting.name)}`;
|
|
80
|
+
// The version of the rules changes the game's rules: it asks first (D-514 (2)).
|
|
81
|
+
const [asking, setAsking] = useState();
|
|
82
|
+
const rules = setting.name === rulesetSetting;
|
|
79
83
|
useEffect(() => setPicked(undefined), [setting]);
|
|
80
84
|
// A choice the arrows left still resting goes when the section closes.
|
|
81
85
|
useEffect(() => () => {
|
|
82
86
|
if (resting.current !== undefined) {
|
|
83
87
|
clearTimeout(resting.current.timer);
|
|
84
|
-
|
|
88
|
+
// Never the rules without the player's yes.
|
|
89
|
+
if (!rules) {
|
|
90
|
+
void onChange({ setting: setting.name, value: resting.current.choice });
|
|
91
|
+
}
|
|
85
92
|
}
|
|
86
93
|
}, []);
|
|
94
|
+
const row = useRef(null);
|
|
95
|
+
// The focus on the value chosen, once the dialog that asked is gone.
|
|
96
|
+
const focusChosen = () => {
|
|
97
|
+
requestAnimationFrame(() => row.current?.querySelector("[role=radio][aria-checked=true]")?.focus());
|
|
98
|
+
};
|
|
87
99
|
const send = (change) => {
|
|
100
|
+
// The arrows that rest back on the rules played change nothing, and ask nothing.
|
|
101
|
+
if (rules && "value" in change) {
|
|
102
|
+
if (change.value === setting.value) {
|
|
103
|
+
setPicked(undefined);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
setAsking(change.value);
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
88
110
|
void onChange(change).then(said.show);
|
|
89
111
|
};
|
|
112
|
+
// Not changed after all: the rules played show again, with the focus.
|
|
113
|
+
const keep = () => {
|
|
114
|
+
setAsking(undefined);
|
|
115
|
+
setPicked(undefined);
|
|
116
|
+
focusChosen();
|
|
117
|
+
};
|
|
90
118
|
// A click chooses at once; the arrows show each value and send the one they rest on, so that the game is changed once.
|
|
91
119
|
const choose = (choice, byKey) => {
|
|
92
120
|
setPicked(choice);
|
|
@@ -105,13 +133,30 @@ function SettingRow({ setting, off, several = false, onChange }) {
|
|
|
105
133
|
const chosen = setting.choices?.find((choice) => choice.value === value);
|
|
106
134
|
const unset = setting.most === undefined && (setting.choices === undefined ? setting.items === undefined && setting.value === undefined : chosen === undefined);
|
|
107
135
|
const described = [`${id}-about`, ...(chosen?.means === undefined ? [] : [`${id}-means`]), ...(off === undefined ? [] : [`${id}-off`])].join(" ");
|
|
108
|
-
return (_jsxs("div", { class: off === undefined ? "setting" : "setting off", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: settingLabel(setting.name) }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: t(setting.about) })] }), setting.choices !== undefined
|
|
109
|
-
? (_jsx(Segmented, { label: id, described: described, options: setting.choices.map((choice) => ({ value: choice.value, label:
|
|
136
|
+
return (_jsxs("div", { ref: row, class: off === undefined ? "setting" : "setting off", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: settingLabel(setting.name) }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: t(setting.about) })] }), setting.choices !== undefined
|
|
137
|
+
? (_jsx(Segmented, { label: id, described: described, options: setting.choices.map((choice) => ({ value: choice.value, label: choiceLabel(setting.name, choice) })), value: value, onPick: choose }))
|
|
110
138
|
: setting.name === "language"
|
|
111
139
|
? _jsx(LanguageChoice, { value: value, labelledBy: id, describedBy: `${id}-about`, onPick: (code) => choose(code, false) })
|
|
112
140
|
: setting.most !== undefined
|
|
113
141
|
? _jsx(TextSetting, { setting: setting, label: id, onChange: send })
|
|
114
|
-
: _jsx(ListSetting, { setting: setting, label: id, onChange: send }), _jsxs("div", { class: "setting-after", children: [off !== undefined && _jsx("p", { class: "setting-off", id: `${id}-off`, children: off }), chosen?.means !== undefined && (_jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [valueLabel(chosen.value), ":"] }), " ", meansText(setting.name, chosen.value, chosen.means, several)] })), setting.name === "language" && value !== undefined && _jsx("p", { class: "setting-means", children: languageLine(value) }), unset && _jsx("p", { class: "setting-unset", children: setting.choices === undefined ? t("Not answered yet: add them here, or the master asks you.") : t("Not chosen yet: choose here, or the master asks you.") }), setting.note !== undefined && _jsx(SettingNote, { note: setting.note }), _jsx("p", { class: said.now?.problem ? "setting-said problem" : "setting-said", role: "status", children: said.now?.text })] })
|
|
142
|
+
: _jsx(ListSetting, { setting: setting, label: id, onChange: send }), _jsxs("div", { class: "setting-after", children: [off !== undefined && _jsx("p", { class: "setting-off", id: `${id}-off`, children: off }), chosen?.means !== undefined && !rules && (_jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [valueLabel(chosen.value), ":"] }), " ", meansText(setting.name, chosen.value, chosen.means, several)] })), setting.name === "language" && value !== undefined && _jsx("p", { class: "setting-means", children: languageLine(value) }), unset && _jsx("p", { class: "setting-unset", children: setting.choices === undefined ? t("Not answered yet: add them here, or the master asks you.") : t("Not chosen yet: choose here, or the master asks you.") }), setting.note !== undefined && _jsx(SettingNote, { note: setting.note }), _jsx("p", { class: said.now?.problem ? "setting-said problem" : "setting-said", role: "status", children: said.now?.text })] }), asking !== undefined && (_jsxs(Confirm, { title: t("Play by {rules}?", { rules: choiceLabel(setting.name, setting.choices?.find((choice) => choice.value === asking) ?? { value: asking }, false) }), onClose: keep, children: [_jsx("p", { children: t("The game follows these rules from the master's next move: the sheets are worked out with them, and the master reads them.") }), _jsx("p", { class: "confirm-note", children: t("What is already in play stays as it is, and you can go back whenever you want.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: keep, children: t("Cancel") }), _jsx("button", { type: "button", class: "button gold", onClick: () => {
|
|
143
|
+
setAsking(undefined);
|
|
144
|
+
focusChosen();
|
|
145
|
+
void onChange({ setting: setting.name, value: asking }).then(said.show);
|
|
146
|
+
}, children: t("Change the rules") })] })] }))] }));
|
|
147
|
+
}
|
|
148
|
+
// The engine's setting of the version of a game system's rules, whatever the system (VER-1).
|
|
149
|
+
const rulesetSetting = "ruleset";
|
|
150
|
+
/**
|
|
151
|
+
* A value of a setting on its button: a version of the rules by what it is to the player ("The 2014 rules"), as its name says little; any other by its label.
|
|
152
|
+
* `capital` false keeps it as written, for inside a sentence.
|
|
153
|
+
*/
|
|
154
|
+
function choiceLabel(setting, choice, capital = true) {
|
|
155
|
+
if (setting !== rulesetSetting || choice.means === undefined) {
|
|
156
|
+
return valueLabel(choice.value);
|
|
157
|
+
}
|
|
158
|
+
const means = t(choice.means);
|
|
159
|
+
return capital ? phraseLabel(means) : means;
|
|
115
160
|
}
|
|
116
161
|
/** What a change said, in its row: saved for a few seconds, what went wrong until the next change. */
|
|
117
162
|
function useSaid() {
|
|
@@ -310,10 +355,11 @@ function PageSettings() {
|
|
|
310
355
|
}
|
|
311
356
|
/**
|
|
312
357
|
* Where the page shows the extensions' widgets (D-502), for the campaign: each in the top, the table's column, a page, or nowhere, and which page; the place its
|
|
313
|
-
* extension gives it sends it back there. None without a widget.
|
|
358
|
+
* extension gives it sends it back there. None without a widget; never one on each of the party.
|
|
314
359
|
*/
|
|
315
360
|
function WidgetSettings({ onChange }) {
|
|
316
|
-
|
|
361
|
+
// One on each of the party stands where its package puts it: there is nowhere else for it (D-514).
|
|
362
|
+
const widgets = useContext(WidgetsContext).filter((widget) => widget.own.place !== "person" && widget.own.place !== "card");
|
|
317
363
|
if (widgets.length === 0) {
|
|
318
364
|
return null;
|
|
319
365
|
}
|
|
@@ -387,7 +433,7 @@ function exampleOf(name) {
|
|
|
387
433
|
const examples = {
|
|
388
434
|
lines: t("Add, e.g. spiders"),
|
|
389
435
|
veils: t("Add, e.g. torture"),
|
|
390
|
-
learned: t("Add what you know, e.g.
|
|
436
|
+
learned: t("Add what you know, e.g. Initiative"),
|
|
391
437
|
author: t("An author's name"),
|
|
392
438
|
style: t("e.g. third person, past tense; more dialogue"),
|
|
393
439
|
};
|
package/dist/dashboard/sheet.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useRef, useState } from "preact/hooks";
|
|
2
|
+
import { useContext, useEffect, useId, useRef, useState } from "preact/hooks";
|
|
3
3
|
import { ActName, usePlayerActs } from "./act-names.js";
|
|
4
4
|
import { itemVerbs } from "./acts.js";
|
|
5
5
|
import { readExplanations } from "./api.js";
|
|
6
6
|
import { CardHeader, useOpen } from "./card.js";
|
|
7
7
|
import { FixedColumns } from "./columns.js";
|
|
8
|
-
import {
|
|
9
|
-
import { WidgetCards } from "./extension-widgets.js";
|
|
8
|
+
import { WidgetCards, WidgetsContext } from "./extension-widgets.js";
|
|
10
9
|
import { besideLabel, memberPlaceLabel } from "./game-words.js";
|
|
11
10
|
import { cardIcons, DieIcon, Icon } from "./icons.js";
|
|
12
11
|
import { fieldLabel, groupLabels, phraseLabel, readableIds, rollLabel, shownNotation, shownText } from "./labels.js";
|
|
@@ -14,8 +13,9 @@ import { arrangedGroups, groupLayout, orderedValues, widgetOf } from "./layout.j
|
|
|
14
13
|
import { knowersOf, Markdown, plainLine } from "./markdown.js";
|
|
15
14
|
import { MoodFace, moodLabel } from "./mood.js";
|
|
16
15
|
import { MemberToken } from "./party.js";
|
|
16
|
+
import { PersonBoxes, personBoxes, personFields, PersonPanel, personShown } from "./person-panel.js";
|
|
17
17
|
import { requestedRow, useRequested } from "./requested.js";
|
|
18
|
-
import { memberStatus } from "./status.js";
|
|
18
|
+
import { besideWord, memberStatus } from "./status.js";
|
|
19
19
|
import { StoryBox } from "./story.js";
|
|
20
20
|
import { arrowStep, listText, systemWord, t } from "./text.js";
|
|
21
21
|
import { Effects, ProgressBar, ValueDrawing } from "./widgets.js";
|
|
@@ -26,30 +26,38 @@ export function MemberSheet({ member, headline, sheet, cards, text, knownBy, sto
|
|
|
26
26
|
const { rail, others } = arrangedGroups(sheet, cards);
|
|
27
27
|
const fields = sheetFields(member, sheet);
|
|
28
28
|
const group = (shown) => _jsx(Group, { member: member.name, group: shown, fields: fields, version: version, onRoll: onRoll, first: shown === others[0] }, shown.name);
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
const widgets = useContext(WidgetsContext);
|
|
30
|
+
const status = memberStatus(member, scene, widgets);
|
|
31
|
+
// At 0 the panels of the packages' widgets that say their state, large, under the name, their counters out of the line (D-310 (7), D-516). The others
|
|
32
|
+
// are small cards of their packages among the line's boxes, the counters they count left out of it.
|
|
33
|
+
const person = personShown(widgets, member.name);
|
|
34
|
+
const boxes = personBoxes(widgets, member.name);
|
|
35
|
+
const shownApart = personFields([...person, ...boxes]);
|
|
31
36
|
// The player character's story has its own card: the rest of the page's text is its description (D-386).
|
|
32
37
|
const described = story !== undefined && story.trim() !== "" && text.startsWith(story) ? text.slice(story.length).trimStart() : text;
|
|
33
|
-
return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(MemberToken, { member: member, large: true, status:
|
|
38
|
+
return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(MemberToken, { member: member, large: true, status: status }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
|
|
34
39
|
? (_jsxs("p", { class: "headline", children: [headline, headline !== undefined && headline !== "" && member.mood !== undefined && " · ", member.mood !== undefined && (_jsxs("span", { class: "mood-word", children: [_jsx(MoodFace, { mood: member.mood }), moodLabel(member.mood)] }))] }))
|
|
35
|
-
: null, member.place && (_jsxs("p", { class: "place", children: [_jsx(Icon, { name: "place" }), memberPlaceLabel(member.place)] }))] })] }),
|
|
40
|
+
: null, member.place && (_jsxs("p", { class: "place", children: [_jsx(Icon, { name: "place" }), memberPlaceLabel(member.place)] }))] })] }), person.map((shown) => _jsx(PersonPanel, { shown: shown }, shown.widget.id)), _jsx(ValueLine, { values: member.counters.filter((value) => !shownApart.has(value.field)), fields: fields, boxes: boxes }), _jsx(Effects, { effects: besideWord(member.effects, status.person) })] }), _jsxs("div", { class: "sheet-body", children: [rail.length > 0 && _jsx("div", { class: "rail", children: rail.map(group) }), _jsxs("div", { class: "sheet-main", children: [_jsx(FixedColumns, { cards: others.map((shown) => ({ key: shown.name, node: group(shown) })) }), _jsxs("div", { class: "wide-cards", children: [story !== undefined && (_jsxs(Card, { name: backstoryCard, title: t("Backstory"), icon: cardIcons.backstory, layout: "lore", preview: plainLine(story) ?? t("Not written yet"), children: [story.trim() !== "" && _jsx(Markdown, { text: story }), _jsx(StoryBox, { story: story, who: member.name })] })), described.trim() !== "" && (_jsx(Card, { name: descriptionCard, title: t("Description"), icon: cardIcons.description, layout: "lore", preview: plainLine(described), children: _jsx(Markdown, { text: described, secretKnowers: knowersOf(knownBy) }) }))] }), _jsx(WidgetCards, { place: "page", page: "sheet", who: member.name, view: member })] })] })] }));
|
|
36
41
|
}
|
|
37
42
|
/** What of someone's sheet the Combat section keeps at hand (D-315): the fields it names in a line of boxes, as under the name, then the groups it names as their cards. */
|
|
38
43
|
export function SheetAtHand({ member, sheet, names, version, onRoll }) {
|
|
39
44
|
const fields = sheetFields(member, sheet);
|
|
40
45
|
const same = (name, wanted) => name.toLowerCase() === wanted.toLowerCase();
|
|
41
|
-
|
|
46
|
+
// The packages' small cards on them too, as under the name (D-516), the counters they count left out.
|
|
47
|
+
const boxes = personBoxes(useContext(WidgetsContext), member.name);
|
|
48
|
+
const counted = personFields(boxes);
|
|
49
|
+
const line = names.flatMap((wanted) => sheet.flatMap((group) => group.values).filter((value) => same(value.field, wanted) && !counted.has(value.field)));
|
|
42
50
|
const groups = names.flatMap((wanted) => sheet.filter((group) => same(group.name, wanted)));
|
|
43
|
-
return (_jsxs(_Fragment, { children: [line.length > 0 && _jsx(ValueLine, { values: line, fields: fields }), groups.map((group) => _jsx(Group, { member: member.name, group: group, fields: fields, version: version, onRoll: onRoll }, group.name))] }));
|
|
51
|
+
return (_jsxs(_Fragment, { children: [(line.length > 0 || boxes.length > 0) && _jsx(ValueLine, { values: line, fields: fields, boxes: boxes }), groups.map((group) => _jsx(Group, { member: member.name, group: group, fields: fields, version: version, onRoll: onRoll }, group.name))] }));
|
|
44
52
|
}
|
|
45
53
|
/** What a row shows beside its value, when it says something more: a written speed equal to the one that counts now says nothing. */
|
|
46
54
|
function shownBeside(value) {
|
|
47
55
|
const beside = besideLabel(value);
|
|
48
56
|
return beside === value.text ? undefined : beside;
|
|
49
57
|
}
|
|
50
|
-
/** Values in a line of boxes, as under someone's name (D-299): each its label and its drawing, flashing when it changes. */
|
|
51
|
-
function ValueLine({ values, fields }) {
|
|
52
|
-
return (
|
|
58
|
+
/** Values in a line of boxes, as under someone's name (D-299): each its label and its drawing, flashing when it changes; then the packages' boxes (D-516). */
|
|
59
|
+
function ValueLine({ values, fields, boxes = [] }) {
|
|
60
|
+
return (_jsxs("div", { class: "line", children: [values.map((value) => (_jsxs("span", { class: "line-value", children: [_jsx("span", { class: "label", children: fieldLabel(value.field, fields) }), _jsx(Changing, { text: value.text, children: _jsx(ValueDrawing, { value: value, label: fieldLabel(value.field, fields) }) }), shownBeside(value) !== undefined && widgetOf(value) !== "progress" && _jsx("span", { class: "beside num", children: shownText(shownBeside(value) ?? "") })] }, value.field))), _jsx(PersonBoxes, { shown: boxes })] }));
|
|
53
61
|
}
|
|
54
62
|
/** A group of the sheet as its card; the `first` after the rail starts open on a phone too, the one play needs most as the system orders them. */
|
|
55
63
|
function Group({ member, group, fields, version, onRoll, first }) {
|
package/dist/dashboard/status.js
CHANGED
|
@@ -1,31 +1,67 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
-
import { stableWord } from "./dying.js";
|
|
3
2
|
import { effectLabel } from "./game-words.js";
|
|
4
3
|
import { statusIcons } from "./icons.js";
|
|
4
|
+
import { saysState } from "./person-panel.js";
|
|
5
5
|
import { conditionsPref, useChoice } from "./prefs.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { numberText, t } from "./text.js";
|
|
7
|
+
/**
|
|
8
|
+
* The state of someone of the party as the first widget on them that gives a word says it (D-514): its chip, the icon it shows or the widget's, its lead's
|
|
9
|
+
* tone; none where no widget on them gives one.
|
|
10
|
+
*/
|
|
11
|
+
export function personState(widgets, name) {
|
|
12
|
+
const shown = widgets.filter((widget) => widget.place === "person").sort((first, second) => first.order - second.order)
|
|
13
|
+
.flatMap((widget) => (widget.people?.[name] === undefined ? [] : [{ widget, shows: widget.people[name] }])).find(saysState);
|
|
14
|
+
if (shown?.shows.chip === undefined) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const icon = shown.shows.icon ?? shown.widget.icon;
|
|
18
|
+
const tone = shown.shows.parts?.find((part) => "lead" in part && part.tone !== undefined);
|
|
19
|
+
return {
|
|
20
|
+
word: wordOf(shown.shows.chip),
|
|
21
|
+
...(icon === undefined ? {} : { icon }),
|
|
22
|
+
...(tone !== undefined && "lead" in tone && tone.tone !== undefined ? { tone: tone.tone } : {}),
|
|
23
|
+
...(shown.shows.dead === true ? { dead: true } : {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
8
26
|
/** The marks of someone's state, the one that counts most first: dead, at 0, kept from acting, then the conditions, the last put on first; with `all`, their other effects after them. */
|
|
9
27
|
export function statusMarks(status, all = false) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
// Never the effect the word of their state already says, as a widget's Down beside the condition Down, or the 5e's Stable (D-514, playtest 11).
|
|
29
|
+
const effects = besideWord(status.effects ?? [], status.party === true ? status.person : undefined);
|
|
30
|
+
// At 0 one of the party has the word a package's widget on them gives, its tone tinting it (D-514); anyone else, or one of the party with none, falls to
|
|
31
|
+
// the ground. The dead a red skull (D-461).
|
|
32
|
+
const person = status.party === true ? status.person : undefined;
|
|
33
|
+
const down = person !== undefined
|
|
34
|
+
? { icon: person.icon ?? statusIcons.fallen, label: person.word, kind: "state", tone: toneState(person.tone) }
|
|
14
35
|
: { icon: statusIcons.fallen, label: t("down"), kind: "state", tone: "down" };
|
|
15
|
-
const states = status.dead === true
|
|
36
|
+
const states = status.dead === true
|
|
16
37
|
? [{ icon: statusIcons.dead, label: t("dead"), kind: "state", tone: "dead", filled: true }]
|
|
17
38
|
: [
|
|
18
39
|
...(status.down === true ? [down] : []),
|
|
19
40
|
...(status.inactive === true ? [{ icon: statusIcons.inactive, label: t("Can't act"), kind: "state" }] : []),
|
|
20
41
|
];
|
|
21
42
|
const conditions = effects.filter((effect) => effect.condition === true).reverse().map((effect) => ({ icon: effect.icon ?? statusIcons.condition, label: effectLabel(effect), kind: "condition" }));
|
|
22
|
-
const others = all ? effects.filter((effect) => effect.condition !== true).map((effect) => ({ icon: statusIcons.condition, label: effectLabel(effect), kind: "other" })) : [];
|
|
43
|
+
const others = all ? effects.filter((effect) => effect.condition !== true).map((effect) => ({ icon: effect.icon ?? statusIcons.condition, label: effectLabel(effect), kind: "other" })) : [];
|
|
23
44
|
return [...states, ...conditions, ...others];
|
|
24
45
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The state of one of the party: their effects, whether dead or at the system's down point, whether the open scene says they cannot act, and what a package's
|
|
48
|
+
* widget on them says of it (D-514), dead by its rules too (D-516).
|
|
49
|
+
*/
|
|
50
|
+
export function memberStatus(member, scene, widgets = []) {
|
|
27
51
|
const inScene = scene?.fighters?.find((fighter) => fighter.name === member.name) ?? scene?.who.find((person) => person.name === member.name);
|
|
28
|
-
|
|
52
|
+
const person = personState(widgets, member.name);
|
|
53
|
+
return {
|
|
54
|
+
effects: member.effects,
|
|
55
|
+
dead: member.dead || person?.dead === true,
|
|
56
|
+
down: member.down === true,
|
|
57
|
+
inactive: inScene?.inactive === true,
|
|
58
|
+
party: true,
|
|
59
|
+
...(person === undefined ? {} : { person }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** How someone at 0 is tinted, on their token and in their marks: dead; by the tone of a widget on them; else as fallen. */
|
|
63
|
+
export function downTint(status) {
|
|
64
|
+
return status.dead === true ? "dead" : status.down !== true ? undefined : status.person !== undefined ? toneState(status.person.tone) : "down";
|
|
29
65
|
}
|
|
30
66
|
/** The pip of someone's state on their token, its marks in its tooltip; none without a mark, or while the player keeps them off. */
|
|
31
67
|
export function StatusPip({ status }) {
|
|
@@ -41,13 +77,31 @@ export function StatusPip({ status }) {
|
|
|
41
77
|
* Each mark of someone's state as an icon with its words, for a screen reader too and for the keyboard, as Combat's order shows them (D-419); a foe's fall only
|
|
42
78
|
* drawn when its words already say it.
|
|
43
79
|
*/
|
|
44
|
-
export function StatusIcons({ status,
|
|
80
|
+
export function StatusIcons({ status, said = [] }) {
|
|
45
81
|
const marks = statusMarks(status, true);
|
|
46
82
|
return marks.length === 0 ? null : (_jsx("span", { class: "status-icons", children: marks.map((mark, index) => {
|
|
47
|
-
|
|
48
|
-
|
|
83
|
+
// A state the row already says in words, hidden from a screen reader.
|
|
84
|
+
const hidden = mark.kind === "state" && mark.tone !== undefined && said.includes(mark.tone);
|
|
85
|
+
return (_jsx("span", { class: ["status-icon", mark.kind, mark.tone ?? ""].filter((name) => name !== "").join(" "), ...(hidden ? { "aria-hidden": "true" } : { role: "img", "aria-label": mark.label, tabIndex: 0 }), "data-tip": mark.label, children: _jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: mark.icon, class: mark.filled ? "filled" : undefined }) }) }, `${mark.label} ${index}`));
|
|
49
86
|
}) }));
|
|
50
87
|
}
|
|
88
|
+
/** Someone's effects but the one the word of their state already says, as a widget's Down beside the condition Down (D-514). */
|
|
89
|
+
export function besideWord(effects, person) {
|
|
90
|
+
const said = person?.word.toLowerCase();
|
|
91
|
+
return said === undefined ? effects : effects.filter((effect) => effectLabel(effect).toLowerCase() !== said);
|
|
92
|
+
}
|
|
93
|
+
/** A tone of a widget as the tint of a state: good as stable, bad as dying, none as fallen. */
|
|
94
|
+
function toneState(tone) {
|
|
95
|
+
return tone === "good" ? "stable" : tone === "bad" ? "dying" : "down";
|
|
96
|
+
}
|
|
97
|
+
/** A widget's words as one string, its values as they are: a mark's tooltip and name. */
|
|
98
|
+
function wordOf(text) {
|
|
99
|
+
return typeof text === "string" ? text : text.text.replace(/\{(\w+)\}/g, (whole, name) => (name in text.values ? valueWord(text.values[name]) : whole));
|
|
100
|
+
}
|
|
101
|
+
/** A value of a widget's words in a word: a number as the page writes it. */
|
|
102
|
+
function valueWord(value) {
|
|
103
|
+
return typeof value === "number" ? numberText(value) : typeof value === "string" ? value : "number" in value ? numberText(value.number) : `${numberText(value.from)}–${numberText(value.to)}`;
|
|
104
|
+
}
|
|
51
105
|
/** The words of someone's state for a screen reader, as a token's name says them. */
|
|
52
106
|
export function statusWords(status) {
|
|
53
107
|
return statusMarks(status, true).map((mark) => mark.label);
|