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/app.js
CHANGED
|
@@ -2,16 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
|
|
|
2
2
|
// The player's dashboard (D-269, D-272, D-276): the master and the campaign on top, the party's strip, what the master asks, the sheet of whom the address
|
|
3
3
|
// names and the table beside it, the turns of a fight, the followed quest and the rolls (D-279), read again whenever the server says something changed.
|
|
4
4
|
import { render } from "preact";
|
|
5
|
-
import { useEffect, useRef, useState } from "preact/hooks";
|
|
5
|
+
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
6
6
|
import { PlayerActsContext } from "./act-names.js";
|
|
7
7
|
import { ActSheet } from "./act-sheet.js";
|
|
8
8
|
import { ActStrip } from "./act-strip.js";
|
|
9
|
-
import { saidStates } from "./acts.js";
|
|
9
|
+
import { saidStates, setSystemVerbs } from "./acts.js";
|
|
10
10
|
import { readAddress, sectionAddress } from "./address.js";
|
|
11
|
-
import { answer, readActs, readAsked, readView, readWidgets, sayAct, sendSeen, withdrawAct } from "./api.js";
|
|
11
|
+
import { answer, closeCard, readActs, readAsked, readModules, readView, readWidgets, sayAct, sendSeen, withdrawAct } from "./api.js";
|
|
12
|
+
import { AskCard } from "./ask-card.js";
|
|
13
|
+
import { AskedDice } from "./asked-dice.js";
|
|
12
14
|
import { AskedBanner } from "./asked.js";
|
|
13
15
|
import { useMedia } from "./card.js";
|
|
14
|
-
import { DeathSaveCard } from "./death-save.js";
|
|
15
16
|
import { DiceTray } from "./dice/tray.js";
|
|
16
17
|
import { WidgetCards, WidgetsContext } from "./extension-widgets.js";
|
|
17
18
|
import { PageFoot } from "./footer.js";
|
|
@@ -19,20 +20,23 @@ import { readFree, withFree, writeFree } from "./free-rolls.js";
|
|
|
19
20
|
import { Help } from "./help.js";
|
|
20
21
|
import { Icon } from "./icons.js";
|
|
21
22
|
import { FollowedQuests, JournalView, QuestEndings } from "./journal.js";
|
|
23
|
+
import { checkOf } from "./labels.js";
|
|
22
24
|
import { gameNotices, importNotices, Notices } from "./notices.js";
|
|
25
|
+
import { inCard, nextPackCard } from "./pack-card.js";
|
|
26
|
+
import { PackagePage } from "./package-page.js";
|
|
23
27
|
import { PackagesPage } from "./packages.js";
|
|
28
|
+
import { codeOfModule, ModulesContext, ownKey, preloadModules, useNavPages } from "./page-code.js";
|
|
24
29
|
import { About } from "./pages.js";
|
|
25
30
|
import { PartyStrip } from "./party.js";
|
|
31
|
+
import { PeopleContext } from "./people.js";
|
|
26
32
|
import { rollReaction } from "./reactions.js";
|
|
27
33
|
import { requestedOf, RequestedRoll } from "./requested.js";
|
|
28
34
|
import { RollLog } from "./rolls.js";
|
|
29
|
-
import { saveOutcome } from "./save-outcome.js";
|
|
30
35
|
import { SavesView } from "./saves.js";
|
|
31
36
|
import { SceneView } from "./scene.js";
|
|
32
37
|
import { SettingsView } from "./settings.js";
|
|
33
38
|
import { SetupView, useSetup } from "./setup.js";
|
|
34
39
|
import { MemberSheet } from "./sheet.js";
|
|
35
|
-
import { SpendCard } from "./spend.js";
|
|
36
40
|
import { PlayTable, tableBeside, TableTab, useTableAway } from "./table.js";
|
|
37
41
|
import { browserLanguage, pageDirection, setLanguage, setSystemWords, t } from "./text.js";
|
|
38
42
|
import { restoreTheme } from "./theme.js";
|
|
@@ -43,7 +47,7 @@ import { WorldView } from "./world.js";
|
|
|
43
47
|
const productName = "RPG Engine";
|
|
44
48
|
// How many of the last rolls the page reads at first, and how many more each time the player asks for older ones (D-302).
|
|
45
49
|
const firstRolls = 20;
|
|
46
|
-
// How long at most what a
|
|
50
|
+
// How long at most what a roll from a card or a die of a rest changed waits for its dice, when they never land.
|
|
47
51
|
const longestHold = 15_000;
|
|
48
52
|
// How long a sentence the master heard, or one copied for the chat, stays in the strip (D-495).
|
|
49
53
|
const heardTime = 6000;
|
|
@@ -72,15 +76,8 @@ function App() {
|
|
|
72
76
|
const [sheetThrow, setSheetThrow] = useState();
|
|
73
77
|
// The question answered from the sheet or the tray, while the engine rolls it (D-330); the free rolls, in this browser alone.
|
|
74
78
|
const [answering, setAnswering] = useState();
|
|
75
|
-
// The
|
|
76
|
-
// with what the system's code wrote of it.
|
|
77
|
-
const [saving, setSaving] = useState();
|
|
78
|
-
const savingNow = useRef(saving);
|
|
79
|
-
savingNow.current = saving;
|
|
80
|
-
// The roll that answers it while its dice fly: what it changes of the sheet waits for them (D-461).
|
|
79
|
+
// The roll that answers a card, or a die of a rest, while its dice fly: what it changes of the sheet waits for them (D-461).
|
|
81
80
|
const holding = useRef();
|
|
82
|
-
// The party as last read, never held back: what a death save's roll left of them.
|
|
83
|
-
const partyNow = useRef([]);
|
|
84
81
|
const [free, setFree] = useState([]);
|
|
85
82
|
// On a wide screen the table stands beside the page, unless the player folded it; folded, or under that width, the turns and the followed quest go back to
|
|
86
83
|
// the page.
|
|
@@ -100,7 +97,17 @@ function App() {
|
|
|
100
97
|
// The widgets of the campaign's extensions (D-502), read beside the rest and shown as they come, so that a slow hook never holds the page back; kept as they
|
|
101
98
|
// were when a reading of them fails, and an answer older than one shown left out.
|
|
102
99
|
const [widgets, setWidgets] = useState([]);
|
|
100
|
+
const [modules, setModules] = useState([]);
|
|
103
101
|
const widgetReading = useRef({ asked: 0, shown: 0 });
|
|
102
|
+
const moduleReading = useRef({ asked: 0, shown: 0 });
|
|
103
|
+
// The card of a package's question as last read, even while the dice that changed it fly; the attempts the player let go, with the question then (D-507).
|
|
104
|
+
const packNow = useRef();
|
|
105
|
+
const packsGone = useRef(new Map());
|
|
106
|
+
// In the card of a rest's dice, how many dice were rolled as the player pressed one, until its roll lands.
|
|
107
|
+
const restSent = useRef();
|
|
108
|
+
// The widgets as read while a card's dice fly, which show only once they land, as the rest of what the roll changed: a panel on the party never tells the
|
|
109
|
+
// outcome of a death save before its die (D-461).
|
|
110
|
+
const widgetsHeld = useRef();
|
|
104
111
|
// Reads view again for whom the address names, or the player character the master calls, and what the master asks; an answer that comes after a newer one
|
|
105
112
|
// is left out.
|
|
106
113
|
const read = async () => {
|
|
@@ -109,18 +116,35 @@ function App() {
|
|
|
109
116
|
void readWidgets().then((read) => {
|
|
110
117
|
if (widgetsAsked > widgetReading.current.shown) {
|
|
111
118
|
widgetReading.current.shown = widgetsAsked;
|
|
112
|
-
|
|
119
|
+
// Their extensions' page code comes before a card of a roll needs it (D-510).
|
|
120
|
+
preloadModules(read);
|
|
121
|
+
if (holding.current !== undefined || packNow.current?.sent !== undefined) {
|
|
122
|
+
widgetsHeld.current = read;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
widgetsHeld.current = undefined;
|
|
126
|
+
setWidgets(read);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, () => undefined);
|
|
130
|
+
// The page modules of the system and the extensions, for their cards in the pages and their own pages (D-511).
|
|
131
|
+
const modulesAsked = ++moduleReading.current.asked;
|
|
132
|
+
void readModules().then((read) => {
|
|
133
|
+
if (modulesAsked <= moduleReading.current.shown) {
|
|
134
|
+
return;
|
|
113
135
|
}
|
|
136
|
+
moduleReading.current.shown = modulesAsked;
|
|
137
|
+
preloadModules(read.map(codeOfModule));
|
|
138
|
+
setModules((before) => (JSON.stringify(before) === JSON.stringify(read) ? before : read));
|
|
114
139
|
}, () => undefined);
|
|
115
140
|
try {
|
|
116
|
-
const [first,
|
|
117
|
-
const asked =
|
|
141
|
+
const [first, askedNow, actsNow] = await Promise.all([readView(undefined, rollsAsked.current), readAsked().catch(() => undefined), readActs().catch(() => undefined)]);
|
|
142
|
+
const asked = askedNow === undefined ? undefined : askedNow.asked ?? undefined;
|
|
118
143
|
// With more than one player character, a question for one elsewhere puts them in the foreground: the place, the map and the squares are theirs (VIEW-12).
|
|
119
144
|
const here = first.kind === "overview" && (first.place?.here ?? []).some((one) => one.name === asked?.who);
|
|
120
145
|
const focus = first.kind === "overview" && first.foreground !== undefined && asked?.who !== first.foreground && !here ? playerNamed(first.party, asked?.who)?.name : undefined;
|
|
121
146
|
const overview = focus === undefined ? first : await readView(undefined, rollsAsked.current, focus).catch(() => first);
|
|
122
147
|
const party = overview.kind === "overview" ? overview.party : [];
|
|
123
|
-
partyNow.current = party;
|
|
124
148
|
const rolls = overview.kind === "overview" ? overview.rolls : [];
|
|
125
149
|
const address = readAddress(window.location.hash);
|
|
126
150
|
const scene = overview.kind === "overview" ? overview.openScene : undefined;
|
|
@@ -142,6 +166,7 @@ function App() {
|
|
|
142
166
|
const language = (overview.kind === "overview" || overview.kind === "none" ? overview.language : undefined) ?? browserLanguage();
|
|
143
167
|
await setLanguage(language);
|
|
144
168
|
setSystemWords(overview.kind === "overview" ? overview.words : undefined);
|
|
169
|
+
setSystemVerbs(overview.kind === "overview" ? overview.verbs : undefined);
|
|
145
170
|
if (number === reading.current) {
|
|
146
171
|
document.documentElement.lang = language ?? "en";
|
|
147
172
|
document.documentElement.dir = pageDirection();
|
|
@@ -172,15 +197,19 @@ function App() {
|
|
|
172
197
|
setThrown(asking);
|
|
173
198
|
setHeld(asking.id);
|
|
174
199
|
}
|
|
175
|
-
// A
|
|
176
|
-
|
|
177
|
-
// Dice landed before what the system's code wrote was read: the outcome as soon as it is.
|
|
178
|
-
const shownCard = card?.roll !== undefined && card.outcome === undefined ? toldCard(card, party) : card;
|
|
179
|
-
savingNow.current = shownCard;
|
|
180
|
-
setSaving(shownCard);
|
|
181
|
-
// So does a die of a rest the player spends, whose card shows it once it lands (D-492).
|
|
200
|
+
// A roll from a package's card, as a death save, holds back what it changes until its dice land, its marks too (D-461, D-507); so does a die of a
|
|
201
|
+
// rest the player spends (D-492).
|
|
182
202
|
const spent = asked?.spend?.rolls.some((roll) => roll.id === asking?.id) === true;
|
|
183
|
-
|
|
203
|
+
const packRolled = packNow.current?.sent !== undefined;
|
|
204
|
+
const next = askedNow === undefined ? packNow.current : packOf(askedNow);
|
|
205
|
+
// The roll that answers a card is its last, for its drawing to tell (D-510).
|
|
206
|
+
const pack = packRolled && asking !== undefined && next !== undefined ? { ...next, rolled: { total: asking.total, faces: asking.dice.map((die) => die.value) } } : next;
|
|
207
|
+
packNow.current = pack;
|
|
208
|
+
// A die of a rest's card whose roll came with none to wait for, as with no dice to throw: its buttons free at once.
|
|
209
|
+
if (restSent.current !== undefined && (pack?.asked?.spend?.rolls.length ?? 0) > restSent.current && !spent) {
|
|
210
|
+
window.setTimeout(unpressRest);
|
|
211
|
+
}
|
|
212
|
+
if (asking !== undefined && (spent || packRolled) && holding.current === undefined) {
|
|
184
213
|
holding.current = { roll: asking, timer: window.setTimeout(() => land(asking.id), longestHold) };
|
|
185
214
|
}
|
|
186
215
|
setShown((before) => withHeld(before, {
|
|
@@ -203,6 +232,7 @@ function App() {
|
|
|
203
232
|
place: overview.kind === "overview" ? overview.place : undefined,
|
|
204
233
|
openScene: overview.kind === "overview" ? overview.openScene : undefined,
|
|
205
234
|
asked,
|
|
235
|
+
pack,
|
|
206
236
|
version: before.version + 1,
|
|
207
237
|
readAt: new Date(),
|
|
208
238
|
noCharacter: overview.kind === "none",
|
|
@@ -217,7 +247,105 @@ function App() {
|
|
|
217
247
|
}
|
|
218
248
|
}
|
|
219
249
|
};
|
|
220
|
-
// The
|
|
250
|
+
// The card of a package's question after a reading (D-507): an attempt asked again is no longer let go; one whose card went unanswered is.
|
|
251
|
+
const packOf = (told) => {
|
|
252
|
+
const key = told.asked?.card?.key;
|
|
253
|
+
if (key !== undefined && packsGone.current.has(key) && packsGone.current.get(key) !== told.asked?.id) {
|
|
254
|
+
packsGone.current.delete(key);
|
|
255
|
+
}
|
|
256
|
+
const next = nextPackCard(packNow.current, told, packsGone.current);
|
|
257
|
+
if (next.let !== undefined) {
|
|
258
|
+
packsGone.current.set(next.let, undefined);
|
|
259
|
+
}
|
|
260
|
+
packNow.current = next.card;
|
|
261
|
+
return next.card;
|
|
262
|
+
};
|
|
263
|
+
// The card shown, and as last read, the same: pressed, closed.
|
|
264
|
+
const setPack = (pack) => {
|
|
265
|
+
packNow.current = pack;
|
|
266
|
+
setShown((before) => ({ ...before, pack, ...(before.pending === undefined ? {} : { pending: { ...before.pending, pack } }) }));
|
|
267
|
+
};
|
|
268
|
+
// A button of a package's card (D-507): the card waits with it pressed while the answer goes; the core's change of mind takes the card away with it.
|
|
269
|
+
const answerPack = async (index) => {
|
|
270
|
+
const card = packNow.current;
|
|
271
|
+
const asked = card?.asked;
|
|
272
|
+
if (card === undefined || asked === undefined || card.ended === true || card.sent !== undefined) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (asked.spend !== undefined) {
|
|
276
|
+
await spendFromCard(card, asked, index);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const leaves = checkOf(asked.labels[index] ?? "", asked.title) === undefined && (asked.buttons?.[index] ?? undefined) === undefined;
|
|
280
|
+
if (leaves) {
|
|
281
|
+
packsGone.current.set(card.key, asked.id);
|
|
282
|
+
}
|
|
283
|
+
setPack(leaves ? undefined : { ...card, sent: index });
|
|
284
|
+
try {
|
|
285
|
+
await answer(asked.id, index);
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
packsGone.current.delete(card.key);
|
|
289
|
+
setPack({ ...card, sent: undefined });
|
|
290
|
+
}
|
|
291
|
+
void read();
|
|
292
|
+
};
|
|
293
|
+
// A button of the card of a rest's dice (ASK-14): a die of a counter, which the question keeps; the last, the end, which takes the card away with it.
|
|
294
|
+
const spendFromCard = async (card, asked, index) => {
|
|
295
|
+
const dice = asked.spend?.dice[index];
|
|
296
|
+
// The die's button waits, pressed, until its roll lands (or the engine refuses it).
|
|
297
|
+
if (dice !== undefined) {
|
|
298
|
+
restSent.current = asked.spend?.rolls.length;
|
|
299
|
+
setPack({ ...card, sent: index });
|
|
300
|
+
if (!await answerSpend(asked.id, { spend: dice.field })) {
|
|
301
|
+
restSent.current = undefined;
|
|
302
|
+
setPack(packNow.current === undefined ? undefined : { ...packNow.current, sent: undefined });
|
|
303
|
+
}
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const focused = (document.activeElement?.closest(".ask-card") ?? null) !== null;
|
|
307
|
+
packsGone.current.set(card.key, asked.id);
|
|
308
|
+
setPack(undefined);
|
|
309
|
+
if (await answerSpend(asked.id, 0)) {
|
|
310
|
+
if (focused) {
|
|
311
|
+
focusAfterCard();
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
packsGone.current.delete(card.key);
|
|
316
|
+
setPack(card);
|
|
317
|
+
};
|
|
318
|
+
// The player's own words in place of a button (ASK-10): taken, the card goes with its question, as the master hears them.
|
|
319
|
+
const sayPack = async (text, focused) => {
|
|
320
|
+
const card = packNow.current;
|
|
321
|
+
const asked = card?.asked;
|
|
322
|
+
if (card === undefined || asked === undefined || card.ended === true || card.sent !== undefined) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
const taken = await answer(asked.id, text).catch(() => false);
|
|
326
|
+
if (taken) {
|
|
327
|
+
packsGone.current.set(card.key, asked.id);
|
|
328
|
+
setPack(undefined);
|
|
329
|
+
if (focused) {
|
|
330
|
+
focusAfterCard();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
void read();
|
|
334
|
+
return taken;
|
|
335
|
+
};
|
|
336
|
+
const closePack = (focused) => {
|
|
337
|
+
const key = packNow.current?.key;
|
|
338
|
+
if (key !== undefined) {
|
|
339
|
+
packsGone.current.set(key, undefined);
|
|
340
|
+
// Closed for the server too: no reading, here or on another page, brings it back.
|
|
341
|
+
void closeCard(key);
|
|
342
|
+
}
|
|
343
|
+
setPack(undefined);
|
|
344
|
+
if (focused) {
|
|
345
|
+
focusAfterCard();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
// The dice of a card's roll, or a rest's die, have landed: the card and the sheet as the roll left them (D-461, D-492).
|
|
221
349
|
const land = (roll) => {
|
|
222
350
|
const held = holding.current;
|
|
223
351
|
if (held === undefined || held.roll.id !== roll) {
|
|
@@ -225,13 +353,25 @@ function App() {
|
|
|
225
353
|
}
|
|
226
354
|
window.clearTimeout(held.timer);
|
|
227
355
|
holding.current = undefined;
|
|
228
|
-
setSaving((before) => {
|
|
229
|
-
if (before === undefined || before.roll !== undefined) {
|
|
230
|
-
return before;
|
|
231
|
-
}
|
|
232
|
-
return { ...toldCard(before, partyNow.current), roll: held.roll };
|
|
233
|
-
});
|
|
234
356
|
setShown((before) => (before.pending === undefined ? before : { ...before, ...before.pending, pending: undefined }));
|
|
357
|
+
unpressRest();
|
|
358
|
+
};
|
|
359
|
+
// The card of a rest's dice, its die landed: its buttons free again, and the widgets read meanwhile shown.
|
|
360
|
+
const unpressRest = () => {
|
|
361
|
+
const card = packNow.current;
|
|
362
|
+
restSent.current = undefined;
|
|
363
|
+
showHeldWidgets();
|
|
364
|
+
if (card?.asked?.spend !== undefined && card.sent !== undefined) {
|
|
365
|
+
setPack({ ...card, sent: undefined });
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
// The widgets read while a card's dice flew, once they have landed.
|
|
369
|
+
const showHeldWidgets = () => {
|
|
370
|
+
const held = widgetsHeld.current;
|
|
371
|
+
widgetsHeld.current = undefined;
|
|
372
|
+
if (held !== undefined) {
|
|
373
|
+
setWidgets(held);
|
|
374
|
+
}
|
|
235
375
|
};
|
|
236
376
|
// A card of the master's closed, the focus goes to the notice of the turn, or else to the page (D-461, D-492).
|
|
237
377
|
const focusAfterCard = () => {
|
|
@@ -241,25 +381,6 @@ function App() {
|
|
|
241
381
|
(document.querySelector(".turn-notice") ?? page)?.focus({ preventScroll: true });
|
|
242
382
|
});
|
|
243
383
|
};
|
|
244
|
-
const closeSave = () => {
|
|
245
|
-
setSaving(undefined);
|
|
246
|
-
focusAfterCard();
|
|
247
|
-
};
|
|
248
|
-
// The player rolls the death save from its card, as from a check's button.
|
|
249
|
-
const rollSave = async () => {
|
|
250
|
-
const id = saving?.asked.id;
|
|
251
|
-
if (id === undefined) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
setSaving((before) => (before === undefined ? before : { ...before, sent: true }));
|
|
255
|
-
try {
|
|
256
|
-
await answer(id, 0);
|
|
257
|
-
}
|
|
258
|
-
catch {
|
|
259
|
-
setSaving((before) => (before === undefined ? before : { ...before, sent: false }));
|
|
260
|
-
}
|
|
261
|
-
void read();
|
|
262
|
-
};
|
|
263
384
|
// A new roll's face on the robot, for a moment, when the roll is remarkable (D-305, 7).
|
|
264
385
|
const react = (roll, party) => {
|
|
265
386
|
const reaction = rollReaction(roll, party.map((member) => member.name));
|
|
@@ -346,7 +467,12 @@ function App() {
|
|
|
346
467
|
void read();
|
|
347
468
|
return taken;
|
|
348
469
|
};
|
|
349
|
-
|
|
470
|
+
// The packages' own pages, as tabs or in their menu (D-512).
|
|
471
|
+
const ownPages = useNavPages(modules);
|
|
472
|
+
// Whose portraits an extension's drawing may show (D-510): the party, then those at the place.
|
|
473
|
+
const people = [...shown.party, ...(shown.place?.here ?? []).filter((one) => !shown.party.some((member) => member.name === one.name))];
|
|
474
|
+
// A package's question is answered from its card alone (D-507).
|
|
475
|
+
const requested = live ? requestedOf(answering === shown.asked?.id || inCard(shown.asked) ? undefined : shown.asked, (index) => void answerFrom(index)) : undefined;
|
|
350
476
|
// The open scene goes by turns, as a fight, and whether the turn is a player character's (D-314, D-315, D-444); whose, by name, when there are more.
|
|
351
477
|
const fight = hasTurns(shown.openScene);
|
|
352
478
|
const turnOf = fight ? playerNamed(shown.party, shown.openScene?.turn) : undefined;
|
|
@@ -354,7 +480,6 @@ function App() {
|
|
|
354
480
|
const turnName = several ? turnOf?.name : undefined;
|
|
355
481
|
// The player character the master's question is for, named on it when there are more (D-480 (7)).
|
|
356
482
|
const asker = several ? playerNamed(shown.party, shown.asked?.who) : undefined;
|
|
357
|
-
const dying = shown.party.find((candidate) => candidate.name === saving?.asked.who) ?? lead;
|
|
358
483
|
// The game gone, what the master had not heard is lost with the chat: the strip says so, even once the game is back (D-495).
|
|
359
484
|
useEffect(() => {
|
|
360
485
|
if (!live) {
|
|
@@ -376,7 +501,7 @@ function App() {
|
|
|
376
501
|
setActProblem(undefined);
|
|
377
502
|
};
|
|
378
503
|
// With a question of the master's open, the sentence answers it (ASK-10); else it rings the master, or, in a chat that hears nothing by itself, is copied.
|
|
379
|
-
const question =
|
|
504
|
+
const question = shown.asked !== undefined && shown.asked.spend === undefined && shown.asked.forced !== true ? shown.asked : undefined;
|
|
380
505
|
const reply = question !== undefined ? "answer" : acts?.bell === true ? "tell" : "copy";
|
|
381
506
|
const sendAct = async (text) => {
|
|
382
507
|
setActProblem(undefined);
|
|
@@ -433,6 +558,10 @@ function App() {
|
|
|
433
558
|
document.title = shown.asked === undefined ? name : `● ${shown.asked.title} · ${name}`;
|
|
434
559
|
}, [shown.campaign, shown.asked?.id]);
|
|
435
560
|
const setup = useSetup(shown.version);
|
|
561
|
+
// While a package's card is there, its widget beside the page would show the same twice (D-507); the same list until either changes, as the cards that
|
|
562
|
+
// read their widget's data read it again when it does.
|
|
563
|
+
const packWidget = shown.pack?.widget;
|
|
564
|
+
const pageWidgets = useMemo(() => (packWidget === undefined ? widgets : widgets.filter((widget) => widget.id !== packWidget)), [widgets, packWidget]);
|
|
436
565
|
// While the campaign is in its setup, the page is its first configuration, as a portal's (D-370).
|
|
437
566
|
const inSetup = setup?.mode === "setup";
|
|
438
567
|
// The page's own messages, over it (D-298): a problem, the game away, a word to know.
|
|
@@ -456,41 +585,41 @@ function App() {
|
|
|
456
585
|
setFree([]);
|
|
457
586
|
writeFree(shown.campaign, []);
|
|
458
587
|
} }, shown.campaign));
|
|
459
|
-
return (_jsx(RequestedRoll.Provider, { value: requested, children: _jsx(WidgetsContext.Provider, { value:
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
588
|
+
return (_jsx(ModulesContext.Provider, { value: modules, children: _jsx(PeopleContext.Provider, { value: people, children: _jsx(RequestedRoll.Provider, { value: requested, children: _jsx(WidgetsContext.Provider, { value: pageWidgets, children: _jsx(PlayerActsContext.Provider, { value: playerActs, children: _jsxs("div", { class: live ? "page" : "page stale", children: [!inSetup && (_jsx(Top, { campaign: shown.campaign, product: productName, system: shown.system?.name, now: shown.now, calendar: shown.calendar, path: shown.place === undefined ? undefined : [...shown.place.within, shown.place.name], live: live, mood: shown.masterMood, moment: moment, asleep: !live && shown.readAt !== undefined, section: address.section, fight: fight, yourTurn: yourTurn, turnName: turnName, ownPages: ownPages, ownShown: address.section === "pkg" && address.tab !== undefined && address.name !== undefined ? ownKey({ package: address.tab, name: address.name }) : undefined })), inSetup && _jsx(SetupCorner, { live: live }), _jsx(Notices, { notices: notices }), live && shown.pack !== undefined && (_jsx(AskCard, { card: shown.pack, name: several ? playerNamed(shown.party, shown.pack.asked?.who)?.name ?? turnName : undefined, widget: widgets.find((widget) => widget.id === shown.pack?.widget), onAnswer: (index) => void answerPack(index), onWords: sayPack, onClose: closePack }, shown.pack.key)), live && shown.pack === undefined && shown.asked?.spend !== undefined && !inCard(shown.asked) && (_jsx(AskedDice, { asked: shown.asked, spend: shown.asked.spend, flying: holding.current?.roll.id, onSpend: (field) => answerSpend(shown.asked?.id, { spend: field }), onDone: async (focused) => {
|
|
589
|
+
const taken = await answerSpend(shown.asked?.id, 0);
|
|
590
|
+
if (taken && focused) {
|
|
591
|
+
focusAfterCard();
|
|
592
|
+
}
|
|
593
|
+
return taken;
|
|
594
|
+
} }, shown.asked.id)), live && shown.pack === undefined && shown.asked && shown.asked.spend === undefined && !inCard(shown.asked) && (_jsx(AskedBanner, { asked: shown.asked, yourTurn: yourTurn && (asker === undefined || asker.name === turnOf?.name), who: asker, turnName: turnName, map: shown.place?.map, place: shown.place?.name, answered: answering === shown.asked.id, onAnswered: () => void read() })), inSetup
|
|
595
|
+
? _jsx(SetupView, { setup: setup })
|
|
596
|
+
: (_jsxs(_Fragment, { children: [live && yourTurn && address.section !== "scene" && shown.asked === undefined && shown.pack === undefined && (_jsxs("a", { class: "turn-notice", href: sectionAddress("scene"), children: [_jsx(Icon, { name: "combat" }), _jsx("span", { children: [turnWords(turnName), shown.openScene?.round === undefined ? "" : t("Round {round}", { round: shown.openScene.round })].filter((part) => part !== "").join(" · ") }), _jsx("span", { class: "turn-notice-go", children: t("Go to the scene") })] })), _jsx(Notices, { notices: importing }), !table && _jsx(QuestEndings, { version: shown.version, campaign: shown.campaign }), address.section === "party" && _jsx(PartyStrip, { party: shown.party, chosen: shown.chosen, scene: shown.openScene }), _jsxs("div", { class: "body", children: [_jsxs("main", { children: [address.section === "about" && _jsx(About, { product: productName, system: shown.system }), address.section === "help" && _jsx(Help, {}), !table && address.section === "scene" && _jsx(FollowedQuests, { version: shown.version, campaign: shown.campaign }), address.section === "scene" && (_jsx(SceneView, { place: shown.place, scene: shown.openScene, actor: actor, foreground: shown.foreground, several: several, party: shown.party, turnsBeside: table, onShowCard: (name) => {
|
|
597
|
+
handed.current = { who: name, turn: turnKey(shown.openScene) };
|
|
598
|
+
void read();
|
|
599
|
+
}, own: {
|
|
600
|
+
sheet: shown.chosen === actor?.name ? shown.sheet : [],
|
|
601
|
+
cards: shown.cards,
|
|
602
|
+
version: shown.version,
|
|
603
|
+
onRoll: throwFromSheet,
|
|
604
|
+
} })), address.section === "world" && _jsx(WorldView, { version: shown.version, lead: lead, players: many ? players : undefined, tab: address.tab, item: address.name }), address.section === "settings" && _jsx(SettingsView, { version: shown.version, several: many }), address.section === "saves" && _jsx(SavesView, { version: shown.version, campaign: shown.campaign, several: many }), address.section === "packages" && _jsx(PackagesPage, { version: shown.version, tab: address.tab }), address.section === "pkg" && _jsx(PackagePage, { name: address.tab, page: address.name }), address.section === "journal" && _jsx(JournalView, { version: shown.version, campaign: shown.campaign, tab: address.tab, item: address.name }), address.section === "party" && member && (_jsx(PlayerActsContext.Provider, { value: member.role === "pc" || playerActs === undefined ? playerActs : { ...playerActs, actions: {} }, children: _jsx(MemberSheet, { member: member, headline: shown.headline, sheet: shown.sheet, cards: shown.cards, text: shown.text, knownBy: shown.knownBy, story: shown.story, version: shown.version, onRoll: throwFromSheet, scene: shown.openScene }, member.name) }))] }), table
|
|
605
|
+
? (_jsxs(PlayTable, { entering: tableMoved, onFold: () => {
|
|
606
|
+
setTableMoved(true);
|
|
607
|
+
setTableAway(true);
|
|
608
|
+
}, children: [fight && _jsx(TurnsCard, { scene: shown.openScene, party: shown.party, several: several, beside: true }), _jsx(QuestEndings, { version: shown.version, campaign: shown.campaign, beside: true }), _jsx(FollowedQuests, { version: shown.version, campaign: shown.campaign, beside: true }), _jsx(WidgetCards, { place: "side" }), rolls] }))
|
|
609
|
+
: wide
|
|
610
|
+
? (_jsx(TableTab, { fight: fight, focused: tableMoved, onOpen: () => {
|
|
611
|
+
setTableMoved(true);
|
|
612
|
+
setTableAway(false);
|
|
613
|
+
} }))
|
|
614
|
+
: (_jsxs(_Fragment, { children: [_jsx(WidgetCards, { place: "side" }), rolls] }))] }), _jsx(PageFoot, { product: productName, system: shown.system })] })), _jsx(DiceTray, { requested: thrown, sheetThrow: sheetThrow, party: shown.party, onLanded: land, onShown: (id) => {
|
|
615
|
+
setHeld((now) => (now === id ? undefined : now));
|
|
616
|
+
if (thrown?.id === id) {
|
|
617
|
+
react(thrown, shown.party);
|
|
618
|
+
}
|
|
619
|
+
}, onFree: (roll) => {
|
|
620
|
+
setFree((before) => withFree(shown.campaign, before, roll));
|
|
621
|
+
setFresh((before) => new Set([...before, roll.id]));
|
|
622
|
+
} }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: (id, text) => void copyAct(text).then((done) => (done ? dismissAct(id) : setActProblem(t("Copy did not work: select the words and copy them yourself.")))), onDismiss: dismissAct })] }) }) }) }) }) }));
|
|
494
623
|
}
|
|
495
624
|
/** The player character of the party by their name; undefined for anyone else, or none. */
|
|
496
625
|
function playerNamed(party, name) {
|
|
@@ -509,13 +638,7 @@ function calledOf(party, section, asked, scene, foreground) {
|
|
|
509
638
|
function turnKey(scene) {
|
|
510
639
|
return hasTurns(scene) ? `${scene.title} ${scene.since ?? ""} ${scene.round ?? ""} ${scene.turn ?? ""}` : "";
|
|
511
640
|
}
|
|
512
|
-
/**
|
|
513
|
-
function toldCard(card, party) {
|
|
514
|
-
const who = card.asked.who;
|
|
515
|
-
const after = party.find((member) => (who === undefined ? member.role === "pc" : member.name === who));
|
|
516
|
-
return { ...card, outcome: after === undefined ? undefined : saveOutcome(card.save, after) };
|
|
517
|
-
}
|
|
518
|
-
/** The page as read now; while a death save's dice fly, with the sheet and the fight as they were, what the roll changed kept until they land (D-461). */
|
|
641
|
+
/** The page as read now; while a card's dice fly, with the sheet and the fight as they were, what the roll changed kept until they land (D-461). */
|
|
519
642
|
function withHeld(before, next, hold) {
|
|
520
643
|
if (!hold) {
|
|
521
644
|
return { ...next, pending: undefined };
|
|
@@ -530,6 +653,7 @@ function withHeld(before, next, hold) {
|
|
|
530
653
|
knownBy: shown.knownBy,
|
|
531
654
|
story: shown.story,
|
|
532
655
|
openScene: shown.openScene,
|
|
656
|
+
pack: shown.pack,
|
|
533
657
|
});
|
|
534
658
|
return { ...next, ...steady(before), pending: steady(next) };
|
|
535
659
|
}
|