rpg-engine 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/campaign/settings.d.ts +1 -0
- package/dist/campaign/settings.js +6 -5
- package/dist/command-line.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.d.ts +1 -1
- package/dist/commands/ask.js +66 -24
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +67 -21
- package/dist/commands/effect.js +42 -23
- package/dist/commands/find.js +1 -1
- package/dist/commands/game-adventures.js +2 -2
- package/dist/commands/game-catalog.d.ts +13 -0
- package/dist/commands/game-catalog.js +26 -2
- package/dist/commands/game-checks.js +23 -21
- package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
- package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
- package/dist/commands/game-effects.d.ts +12 -4
- package/dist/commands/game-effects.js +21 -13
- package/dist/commands/game-examples.d.ts +22 -0
- package/dist/commands/game-examples.js +72 -0
- package/dist/commands/game-extension-list.d.ts +31 -3
- package/dist/commands/game-extension-list.js +83 -7
- package/dist/commands/game-images.d.ts +1 -1
- package/dist/commands/game-images.js +3 -2
- package/dist/commands/game-library.d.ts +3 -0
- package/dist/commands/game-library.js +2 -2
- package/dist/commands/game-mode.js +1 -1
- package/dist/commands/game-package-code.d.ts +87 -0
- package/dist/commands/game-package-code.js +648 -0
- package/dist/commands/game-package-hooks.d.ts +37 -0
- package/dist/commands/game-package-hooks.js +116 -0
- package/dist/commands/game-recipes.js +2 -2
- package/dist/commands/game-reminders.d.ts +5 -2
- package/dist/commands/game-reminders.js +7 -4
- package/dist/commands/game-rules.d.ts +4 -1
- package/dist/commands/game-rules.js +7 -1
- package/dist/commands/game-upkeep.js +3 -3
- package/dist/commands/game-view-place.d.ts +8 -20
- package/dist/commands/game-view-place.js +16 -35
- package/dist/commands/game-widgets.d.ts +39 -10
- package/dist/commands/game-widgets.js +138 -35
- package/dist/commands/game-world.d.ts +17 -0
- package/dist/commands/game-world.js +70 -12
- package/dist/commands/image.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package.d.ts +8 -0
- package/dist/commands/package.js +81 -24
- package/dist/commands/progression.d.ts +2 -0
- package/dist/commands/progression.js +7 -2
- package/dist/commands/roll.d.ts +2 -0
- package/dist/commands/roll.js +50 -24
- package/dist/commands/rules.js +6 -4
- package/dist/commands/scene.d.ts +1 -1
- package/dist/commands/scene.js +13 -10
- package/dist/commands/sheet.js +10 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +14 -4
- package/dist/commands/trade.js +6 -4
- package/dist/commands/translate.js +2 -2
- package/dist/commands/travel.js +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/view.d.ts +8 -4
- package/dist/commands/view.js +7 -6
- package/dist/commands/worked-out.js +11 -5
- package/dist/commands/write.d.ts +8 -1
- package/dist/commands/write.js +84 -25
- package/dist/core/command-reference.js +3 -2
- package/dist/core/consents.d.ts +18 -0
- package/dist/core/consents.js +93 -0
- package/dist/core/context.d.ts +51 -29
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/{extensions/api.d.ts → core/package-api.d.ts} +134 -32
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +2 -0
- package/dist/core/text.d.ts +5 -0
- package/dist/core/text.js +12 -0
- package/dist/dashboard/acts.js +31 -24
- package/dist/dashboard/address.js +4 -1
- package/dist/dashboard/api.js +54 -0
- package/dist/dashboard/app.js +140 -96
- package/dist/dashboard/ask-card.js +76 -25
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +3 -3
- package/dist/dashboard/extension-widgets.js +104 -10
- package/dist/dashboard/i18n/ar.json +25 -29
- package/dist/dashboard/i18n/cs.json +25 -29
- package/dist/dashboard/i18n/da.json +25 -29
- package/dist/dashboard/i18n/de.json +25 -29
- package/dist/dashboard/i18n/el.json +25 -29
- package/dist/dashboard/i18n/es.json +25 -29
- package/dist/dashboard/i18n/fi.json +25 -29
- package/dist/dashboard/i18n/fr.json +25 -29
- package/dist/dashboard/i18n/he.json +25 -29
- package/dist/dashboard/i18n/hi.json +25 -29
- package/dist/dashboard/i18n/hu.json +25 -29
- package/dist/dashboard/i18n/is.json +25 -29
- package/dist/dashboard/i18n/it.json +25 -29
- package/dist/dashboard/i18n/ja.json +25 -29
- package/dist/dashboard/i18n/ko.json +25 -29
- package/dist/dashboard/i18n/nb.json +25 -29
- package/dist/dashboard/i18n/nl.json +25 -29
- package/dist/dashboard/i18n/pl.json +25 -29
- package/dist/dashboard/i18n/pt.json +25 -29
- package/dist/dashboard/i18n/ro.json +25 -29
- package/dist/dashboard/i18n/ru.json +25 -29
- package/dist/dashboard/i18n/sv.json +25 -29
- package/dist/dashboard/i18n/tr.json +25 -29
- package/dist/dashboard/i18n/uk.json +25 -29
- package/dist/dashboard/i18n/zh.json +25 -29
- package/dist/dashboard/icons.js +4 -1
- package/dist/dashboard/kit.js +35 -0
- package/dist/dashboard/labels.js +1 -0
- package/dist/dashboard/pack-card.js +7 -2
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +172 -23
- package/dist/dashboard/page-code.js +248 -0
- package/dist/dashboard/party.js +13 -14
- package/dist/dashboard/people.js +4 -0
- package/dist/dashboard/person-panel.js +110 -0
- package/dist/dashboard/place-map-view.js +11 -6
- package/dist/dashboard/scene.js +12 -9
- package/dist/dashboard/settings.js +55 -9
- package/dist/dashboard/sheet.js +21 -13
- package/dist/dashboard/status.js +69 -15
- package/dist/dashboard/style.css +592 -825
- package/dist/dashboard/top.js +75 -25
- package/dist/dashboard/turns.js +34 -13
- package/dist/dashboard/widgets.js +9 -2
- package/dist/dashboard-server.js +189 -10
- package/dist/dice/roll-dice.js +1 -1
- package/dist/effects/effect.d.ts +7 -4
- package/dist/effects/effect.js +12 -9
- package/dist/extensions/engine.d.ts +4 -0
- package/dist/extensions/engine.js +74 -0
- package/dist/extensions/extension.d.ts +25 -37
- package/dist/extensions/extension.js +26 -48
- package/dist/extensions/index.d.ts +3 -2
- package/dist/extensions/index.js +4 -1
- package/dist/extensions/packages.d.ts +6 -0
- package/dist/extensions/packages.js +100 -11
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +51 -14
- package/dist/page-words.d.ts +4 -0
- package/dist/page-words.js +4 -4
- package/dist/page.d.ts +218 -0
- package/dist/page.js +2 -0
- package/dist/pages/load.d.ts +7 -1
- package/dist/pages/load.js +10 -5
- package/dist/pages/page-file.js +1 -1
- package/dist/pages/stack-writes.js +5 -4
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +52 -26
- package/dist/systems/game-system.js +141 -42
- package/dist/systems/index.d.ts +3 -3
- package/dist/systems/index.js +3 -3
- package/dist/systems/system-code.d.ts +29 -88
- package/dist/systems/system-code.js +68 -23
- package/dist/systems/words.d.ts +2 -0
- package/dist/systems/words.js +11 -0
- package/dist/testing.d.ts +20 -5
- package/dist/testing.js +49 -14
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/setup.md +1 -1
- package/package.json +9 -1
- 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 -407
- package/dist/commands/game-system-code.d.ts +0 -33
- package/dist/commands/game-system-code.js +0 -188
- package/dist/dashboard/death-save.js +0 -67
- package/dist/dashboard/dying.js +0 -46
- package/dist/dashboard/save-outcome.js +0 -42
- package/dist/dashboard/spend.js +0 -115
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
10
|
+
// A package's page code (D-510, D-511): its module, loaded once by its address, draws inside the places the page keeps for it, each a shadow root that
|
|
11
|
+
// takes the page's style sheet, with the page's own Preact: a count or a lead of its widget, the whole inside of its card of a roll, its cards in the pages
|
|
12
|
+
// and its own pages. Each drawing is given the page's language, direction, theme and motion, its package's words, and the people the page knows, for their
|
|
13
|
+
// portraits. When it breaks, its place says the error and whose it is, for whoever fixes it. The shapes are rpg-engine/page's, which src/page.ts declares.
|
|
14
|
+
import { Component, createContext, render } from "preact";
|
|
15
|
+
import { useContext, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
|
|
16
|
+
import { readWidgetData, runCommand } from "./api.js";
|
|
17
|
+
import { fieldLabel } from "./labels.js";
|
|
18
|
+
import { PeopleContext } from "./people.js";
|
|
19
|
+
import { isolated, numberText, pageDirection } from "./text.js";
|
|
20
|
+
import { shownTheme } from "./theme.js";
|
|
21
|
+
/** The pages of the dashboard a package's card stands in (D-511), after their own cards: as src/page.ts declares them to the packages. */
|
|
22
|
+
export const cardPages = ["scene", "sheet", "world", "journal"];
|
|
23
|
+
/** The packages' own pages in the order of their modules, the system's first, each where it says, the menu when it says nothing (D-512); none of a module coming or broken. */
|
|
24
|
+
export function navPagesOf(loaded) {
|
|
25
|
+
return loaded.flatMap(({ module, loaded: one }) => one === undefined || one instanceof Error
|
|
26
|
+
? []
|
|
27
|
+
: Object.entries(one.pages ?? {}).map(([name, page]) => ({
|
|
28
|
+
package: module.package,
|
|
29
|
+
name,
|
|
30
|
+
title: page.title,
|
|
31
|
+
...(page.icon === undefined ? {} : { icon: page.icon }),
|
|
32
|
+
nav: page.nav === "tab" ? "tab" : "menu",
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
35
|
+
/** The packages' own pages once their modules came, drawn again as they come. */
|
|
36
|
+
export function useNavPages(shown) {
|
|
37
|
+
const [, setCome] = useState(0);
|
|
38
|
+
const key = shown.map((module) => module.address).join(" ");
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
let live = true;
|
|
41
|
+
void Promise.all(shown.map((module) => moduleAt(module.address))).then(() => live && setCome((count) => count + 1));
|
|
42
|
+
return () => {
|
|
43
|
+
live = false;
|
|
44
|
+
};
|
|
45
|
+
}, [key]);
|
|
46
|
+
return navPagesOf(shown.map((module) => ({ module, loaded: modules.get(module.address) })));
|
|
47
|
+
}
|
|
48
|
+
/** A package's page as the navigation and the address name it: package/name. */
|
|
49
|
+
export function ownKey(page) {
|
|
50
|
+
return `${page.package}/${page.name}`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The data a widget of a package gives a card or a page of its page code that names it, for the character it shows (D-514): undefined until it comes, or when
|
|
54
|
+
* the card names none or its hook gives nothing. Read again each time the page reads the game again (`reading`, the widgets as last read), the data drawn
|
|
55
|
+
* kept until the new comes; for another widget or character, none until theirs comes.
|
|
56
|
+
*/
|
|
57
|
+
export function useWidgetData(owner, widget, who, reading) {
|
|
58
|
+
const [data, setData] = useState(undefined);
|
|
59
|
+
useEffect(() => setData(undefined), [owner, widget, who]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
let current = true;
|
|
62
|
+
if (widget !== undefined) {
|
|
63
|
+
void readWidgetData(owner, widget, who).then((shows) => current && setData(shows?.data), () => undefined);
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
current = false;
|
|
67
|
+
};
|
|
68
|
+
}, [owner, widget, who, reading]);
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
/** The page modules of the campaign's packages whose code runs, its system's first (D-511), as last read. */
|
|
72
|
+
export const ModulesContext = createContext([]);
|
|
73
|
+
/** A package's page module as a widget's or a card's owner knows it. */
|
|
74
|
+
export function codeOfModule(module) {
|
|
75
|
+
return { extension: module.package, version: module.version, module: module.address, figures: module.figures, ...(module.words === undefined ? {} : { words: module.words }) };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A package's cards in a page of the dashboard (D-511), in their order: none while its module comes; the error of a module that did not load, which the
|
|
79
|
+
* page says in a card of the package's in each of its pages, as a figure or a body says it in its place (D-510 (5)).
|
|
80
|
+
*/
|
|
81
|
+
export function cardsIn(loaded, page) {
|
|
82
|
+
if (loaded instanceof Error) {
|
|
83
|
+
return loaded;
|
|
84
|
+
}
|
|
85
|
+
return Object.entries(loaded?.cards ?? {}).filter(([, card]) => card.page === page).sort(([, first], [, second]) => (first.order ?? 0) - (second.order ?? 0));
|
|
86
|
+
}
|
|
87
|
+
/** A package's own page by its name (D-511): undefined while its module comes or when it has no such page; the error of a module that did not load. */
|
|
88
|
+
export function ownPageIn(loaded, page) {
|
|
89
|
+
return loaded instanceof Error ? loaded : loaded?.pages?.[page];
|
|
90
|
+
}
|
|
91
|
+
/** Starts loading these page modules, so that a card of a roll finds its own there when it comes. */
|
|
92
|
+
export function preloadModules(owners) {
|
|
93
|
+
for (const owner of owners) {
|
|
94
|
+
if (owner.module !== undefined) {
|
|
95
|
+
void moduleAt(owner.module);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** A widget's page module as it stands, drawn again once it comes. */
|
|
100
|
+
export function usePageModule(owner) {
|
|
101
|
+
const address = owner?.module;
|
|
102
|
+
const [, setCome] = useState(0);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (address === undefined || modules.has(address)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
let live = true;
|
|
108
|
+
void moduleAt(address).then(() => live && setCome((count) => count + 1));
|
|
109
|
+
return () => {
|
|
110
|
+
live = false;
|
|
111
|
+
};
|
|
112
|
+
}, [address]);
|
|
113
|
+
return address === undefined ? undefined : modules.get(address);
|
|
114
|
+
}
|
|
115
|
+
/** What the page gives every drawing of this package, now: its language, direction, theme, motion, words, numbers, and its commands. */
|
|
116
|
+
export function pagePropsOf(owner) {
|
|
117
|
+
return {
|
|
118
|
+
words: (text, values) => filled(owner.words?.[text] ?? text, values),
|
|
119
|
+
number: numberText,
|
|
120
|
+
language: document.documentElement.lang || "en",
|
|
121
|
+
dir: pageDirection(),
|
|
122
|
+
theme: shownTheme(),
|
|
123
|
+
reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches,
|
|
124
|
+
run: runCommand,
|
|
125
|
+
field: (name) => fieldLabel(name),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** The room of a figure its extension declares, or the room it is given when it declares none. */
|
|
129
|
+
export function figureSize(owner, name) {
|
|
130
|
+
return owner.figures?.[name] ?? { width: 320, height: 120 };
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The place of an extension's drawing: an element of the page with a shadow root, the page's style sheet in it, where the drawing renders with the page's
|
|
134
|
+
* Preact; the room of a figure kept while its module comes. A drawing that throws, or a module that does not load, leaves the error and whose it is.
|
|
135
|
+
*/
|
|
136
|
+
export function ExtensionRoot({ widget, loaded, kind, size, draw }) {
|
|
137
|
+
const element = useRef(null);
|
|
138
|
+
const people = useContext(PeopleContext);
|
|
139
|
+
const [sheet, setSheet] = useState(pageSheet);
|
|
140
|
+
const owner = `${widget.extension}${widget.version === undefined ? "" : ` ${widget.version}`}`;
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (sheet === undefined) {
|
|
143
|
+
void loadPageSheet().then(setSheet);
|
|
144
|
+
}
|
|
145
|
+
}, []);
|
|
146
|
+
useLayoutEffect(() => {
|
|
147
|
+
const box = element.current;
|
|
148
|
+
if (box === null || sheet === undefined) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const root = box.shadowRoot ?? box.attachShadow({ mode: "open" });
|
|
152
|
+
const own = loaded === undefined || loaded instanceof Error ? undefined : moduleSheet(loaded);
|
|
153
|
+
root.adoptedStyleSheets = own === undefined ? [sheet] : [sheet, own];
|
|
154
|
+
const inside = loaded === undefined
|
|
155
|
+
? null
|
|
156
|
+
: loaded instanceof Error
|
|
157
|
+
? _jsx(Broken, { owner: owner, error: loaded })
|
|
158
|
+
: (_jsx(Boundary, { owner: owner, children: _jsx(Drawing, { draw: draw, module: loaded }) }));
|
|
159
|
+
render(_jsx(PeopleContext.Provider, { value: people, children: inside }), root);
|
|
160
|
+
});
|
|
161
|
+
useEffect(() => () => {
|
|
162
|
+
const root = element.current?.shadowRoot;
|
|
163
|
+
if (root !== null && root !== undefined) {
|
|
164
|
+
render(null, root);
|
|
165
|
+
}
|
|
166
|
+
}, []);
|
|
167
|
+
const room = size === undefined ? undefined : { "--figure-width": `${size.width}px`, "--figure-ratio": String(size.width / size.height) };
|
|
168
|
+
const classes = ["ext-root", kind, size?.mirror === true ? "mirrored" : ""].filter((name) => name !== "").join(" ");
|
|
169
|
+
return _jsx("div", { ref: element, class: classes, style: room });
|
|
170
|
+
}
|
|
171
|
+
/** The first element of the selector in this element, its extensions' drawings included: the focus's next stop after a button pressed in one. */
|
|
172
|
+
export function deepQuery(element, selector) {
|
|
173
|
+
const found = element.querySelector(selector);
|
|
174
|
+
if (found !== null) {
|
|
175
|
+
return found;
|
|
176
|
+
}
|
|
177
|
+
for (const host of element.querySelectorAll(".ext-root")) {
|
|
178
|
+
const inside = host.shadowRoot?.querySelector(selector);
|
|
179
|
+
if (inside !== null && inside !== undefined) {
|
|
180
|
+
return inside;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
/** Words of an extension with their {names} filled, numbers as the page writes them, each set apart right to left. */
|
|
186
|
+
export function filled(text, values = {}) {
|
|
187
|
+
return text.replace(/\{(\w+)\}/g, (whole, name) => {
|
|
188
|
+
const value = values[name];
|
|
189
|
+
return value === undefined ? whole : isolated(typeof value === "number" ? numberText(value) : value);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// The modules by their address, once asked for; what came of each.
|
|
193
|
+
const loading = new Map();
|
|
194
|
+
const modules = new Map();
|
|
195
|
+
function moduleAt(address) {
|
|
196
|
+
let promise = loading.get(address);
|
|
197
|
+
if (promise === undefined) {
|
|
198
|
+
promise = import(__rewriteRelativeImportExtension(address)).then((loaded) => {
|
|
199
|
+
modules.set(address, loaded.default ?? new Error("its page module has no default export"));
|
|
200
|
+
}, (error) => {
|
|
201
|
+
modules.set(address, error instanceof Error ? error : new Error(String(error)));
|
|
202
|
+
});
|
|
203
|
+
loading.set(address, promise);
|
|
204
|
+
}
|
|
205
|
+
return promise;
|
|
206
|
+
}
|
|
207
|
+
// The page's style sheet, read once and adopted by every drawing's shadow root: the page's parts look the same inside.
|
|
208
|
+
let pageSheet;
|
|
209
|
+
let sheetLoading;
|
|
210
|
+
function loadPageSheet() {
|
|
211
|
+
sheetLoading ??= fetch("/style.css").then((response) => response.text()).then((text) => new CSSStyleSheet().replace(text)).then((sheet) => {
|
|
212
|
+
pageSheet = sheet;
|
|
213
|
+
return sheet;
|
|
214
|
+
});
|
|
215
|
+
return sheetLoading;
|
|
216
|
+
}
|
|
217
|
+
// Each module's own style sheet, made once.
|
|
218
|
+
const moduleSheets = new WeakMap();
|
|
219
|
+
/** A module's own style sheet, when it gives one. */
|
|
220
|
+
function moduleSheet(module) {
|
|
221
|
+
if (module.style === undefined) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
let sheet = moduleSheets.get(module);
|
|
225
|
+
if (sheet === undefined) {
|
|
226
|
+
sheet = new CSSStyleSheet();
|
|
227
|
+
sheet.replaceSync(module.style);
|
|
228
|
+
moduleSheets.set(module, sheet);
|
|
229
|
+
}
|
|
230
|
+
return sheet;
|
|
231
|
+
}
|
|
232
|
+
/** The drawing, called inside its boundary, which catches what it throws as well as what its components do. */
|
|
233
|
+
function Drawing({ draw, module }) {
|
|
234
|
+
return draw(module);
|
|
235
|
+
}
|
|
236
|
+
/** A drawing that threw: the error in its place, and whose code it is, from then on (D-510 (5)). */
|
|
237
|
+
class Boundary extends Component {
|
|
238
|
+
static getDerivedStateFromError(error) {
|
|
239
|
+
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
240
|
+
}
|
|
241
|
+
render() {
|
|
242
|
+
return this.state.error === undefined ? this.props.children : _jsx(Broken, { owner: this.props.owner, error: this.state.error });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** What the place says of a drawing that broke, for whoever fixes it: in English, as an error of code. */
|
|
246
|
+
function Broken({ owner, error }) {
|
|
247
|
+
return (_jsxs("p", { class: "ext-broken", role: "alert", lang: "en", dir: "ltr", children: [_jsx("b", { children: owner }), `: its page code broke. ${error.name}: ${error.message}`] }));
|
|
248
|
+
}
|
package/dist/dashboard/party.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// The party's strip (D-276): a link to each one's sheet, with their token and the pip of their state (D-419), their name, the first counter of their line and
|
|
3
|
+
// their effects; the dead go last.
|
|
4
|
+
import { useContext } from "preact/hooks";
|
|
5
|
+
import { WidgetsContext } from "./extension-widgets.js";
|
|
3
6
|
import { fieldLabel, initials, nameHue } from "./labels.js";
|
|
4
7
|
import { stripCounter } from "./layout.js";
|
|
8
|
+
import { personShown, PersonStrip } from "./person-panel.js";
|
|
5
9
|
import { tokenSymbolsPref, usePref } from "./prefs.js";
|
|
6
|
-
import { memberStatus, StatusPip, statusWords } from "./status.js";
|
|
10
|
+
import { besideWord, downTint, memberStatus, StatusPip, statusWords } from "./status.js";
|
|
7
11
|
import { t } from "./text.js";
|
|
8
12
|
import { Bar, Effects } from "./widgets.js";
|
|
9
13
|
/** The address of someone's sheet, which the AI can give the player too (D-276). */
|
|
@@ -11,29 +15,24 @@ export function sheetAddress(name) {
|
|
|
11
15
|
return `#/party/${encodeURIComponent(name)}`;
|
|
12
16
|
}
|
|
13
17
|
export function PartyStrip({ party, chosen, scene }) {
|
|
18
|
+
const widgets = useContext(WidgetsContext);
|
|
14
19
|
const ordered = [...party.filter((member) => !member.dead), ...party.filter((member) => member.dead)];
|
|
15
20
|
return (_jsx("nav", { class: "party", "aria-label": t("Party"), children: ordered.map((member) => {
|
|
16
21
|
const counter = stripCounter(member);
|
|
17
|
-
const status = memberStatus(member, scene);
|
|
22
|
+
const status = memberStatus(member, scene, widgets);
|
|
23
|
+
const person = personShown(widgets, member.name)[0];
|
|
18
24
|
// One name for a screen reader, which the drawing inside would say twice.
|
|
19
25
|
const said = [member.name, counter === undefined ? "" : `${fieldLabel(counter.field)} ${counter.text}`, ...statusWords(status)];
|
|
20
26
|
return (_jsxs("a", { href: sheetAddress(member.name), class: `member${member.dead ? " dead" : ""}`, "aria-current": member.name === chosen ? "page" : undefined, "aria-label": said.filter((part) => part !== "").join(", "), children: [_jsx(MemberToken, { member: member, status: status }), _jsx("span", { class: "name", children: member.name }), member.dead
|
|
21
27
|
? _jsx("span", { class: "dead-mark", children: t("dead") })
|
|
22
|
-
:
|
|
23
|
-
? _jsx(
|
|
24
|
-
: counter && _jsx(Bar, { value: counter, label: fieldLabel(counter.field) }), _jsx(Effects, { effects: member.effects, most: 2 })] }, member.name));
|
|
28
|
+
: person !== undefined
|
|
29
|
+
? _jsx(PersonStrip, { shown: person })
|
|
30
|
+
: counter && _jsx(Bar, { value: counter, label: fieldLabel(counter.field) }), _jsx(Effects, { effects: besideWord(member.effects, status.person), most: 2 })] }, member.name));
|
|
25
31
|
}) }));
|
|
26
32
|
}
|
|
27
|
-
/** One of the party at their dying point in the strip (D-461): the word of where they stand and their marks, small, in place of their bar. */
|
|
28
|
-
function MemberDying({ state, counters }) {
|
|
29
|
-
const successes = counters.find((counter) => counter.side === "successes");
|
|
30
|
-
const failures = counters.find((counter) => counter.side === "failures");
|
|
31
|
-
const marks = (counter, kind) => counter === undefined ? [] : Array.from({ length: counter.limit ?? Math.max(counter.value, 1) }, (_, index) => _jsx("span", { class: `strip-mark ${kind}${index < counter.value ? " marked" : ""}` }, `${kind}${index}`));
|
|
32
|
-
return (_jsxs("span", { class: `member-dying ${state}`, children: [_jsx("span", { class: "member-dying-word", children: dyingWord(state, counters) }), _jsx("span", { class: "strip-marks", "aria-hidden": "true", children: [...marks(successes, "success"), ...marks(failures, "failure")] })] }));
|
|
33
|
-
}
|
|
34
33
|
/** A party member's token with the pip of their state (D-419), in the strip and the sheet's band; never in the rolls. Their class in its tooltip (D-409). */
|
|
35
34
|
export function MemberToken({ member, large, status }) {
|
|
36
|
-
return (_jsx("span", { class: "token-holder", "data-tip": member.headline === undefined ? undefined : `${member.name} · ${member.headline}`, children: _jsx(Token, { member: member, large: large, side: sideOf(member.role), status: status, dying: status
|
|
35
|
+
return (_jsx("span", { class: "token-holder", "data-tip": member.headline === undefined ? undefined : `${member.name} · ${member.headline}`, children: _jsx(Token, { member: member, large: large, side: sideOf(member.role), status: status, dying: downTint(status) }) }));
|
|
37
36
|
}
|
|
38
37
|
/** The side of one of the party by their role; anyone else has none. */
|
|
39
38
|
export function sideOf(role) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// The people the page knows, for the portraits an extension's drawing shows (D-510): the party, then those at the character's place.
|
|
2
|
+
import { createContext } from "preact";
|
|
3
|
+
/** The party and those at the place, as their tokens show them. */
|
|
4
|
+
export const PeopleContext = createContext([]);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
+
// A package's widget on someone of the party (D-514, D-516). One that says their state (its chip) is drawn as a panel, as the 5e's death saves (D-461):
|
|
3
|
+
// its good counts on the start side as circles, its bad ones on the end side as squares, its lead's word between them with the package's figure over it,
|
|
4
|
+
// tinted by the lead's tone, greyed when dead by its rules; large under the name and in the card at hand, one line in a row of the turns, small in the
|
|
5
|
+
// party's strip; with one side only, the word beside it, the two in the middle. Any other is a small card of its package among the boxes of values under the
|
|
6
|
+
// name, as the rerolls of a lock.
|
|
7
|
+
import { useContext } from "preact/hooks";
|
|
8
|
+
import { Figure, textOf, Value, WidgetsContext } from "./extension-widgets.js";
|
|
9
|
+
import { statusIcons } from "./icons.js";
|
|
10
|
+
import { usePageModule } from "./page-code.js";
|
|
11
|
+
import { numberText, t } from "./text.js";
|
|
12
|
+
/** The widgets on someone of the party that say their state (a `chip`) and draw it, in their order: each the panel of A (D-516). */
|
|
13
|
+
export function personShown(widgets, name) {
|
|
14
|
+
return onPerson(widgets, name).filter((shown) => saysState(shown) && shown.shows.parts?.some((part) => "track" in part || "lead" in part) === true);
|
|
15
|
+
}
|
|
16
|
+
/** The other widgets on someone of the party, each boxes among the values under their name: a package's small card on them (D-516). */
|
|
17
|
+
export function personBoxes(widgets, name) {
|
|
18
|
+
return onPerson(widgets, name).filter((shown) => !saysState(shown) && boxParts(shown.shows).length > 0);
|
|
19
|
+
}
|
|
20
|
+
/** Whether a widget on someone says their state: its chip, from one made for each of the party; one the campaign moved there has the top's chip (D-516). */
|
|
21
|
+
export function saysState({ widget, shows }) {
|
|
22
|
+
return shows.chip !== undefined && widget.own.place === "person";
|
|
23
|
+
}
|
|
24
|
+
/** The widgets on someone of the party, from the page's widgets as last read: their panels and their boxes. */
|
|
25
|
+
export function usePerson(name) {
|
|
26
|
+
const widgets = useContext(WidgetsContext);
|
|
27
|
+
return { panels: personShown(widgets, name), boxes: personBoxes(widgets, name) };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A package's widget on someone as boxes of the line under their name, as the sheet's own values (D-516): a count with its label, its marks or its number; a
|
|
31
|
+
* lead under the widget's title, its words and value; each value under its label.
|
|
32
|
+
*/
|
|
33
|
+
export function PersonBoxes({ shown }) {
|
|
34
|
+
return (_jsx(_Fragment, { children: shown.flatMap(({ widget, shows }) => boxParts(shows).map((part, index) => (_jsxs("span", { class: "line-value person-box", children: [_jsx("span", { class: "label", dir: "auto", children: "track" in part ? textOf(part.track.label) : "lead" in part ? widget.title : textOf(part.label) }), _jsx("span", { class: "changing", children: "track" in part ? _jsx(BoxCount, { track: part.track }) : "lead" in part ? _jsx(BoxLead, { lead: part }) : _jsx(Value, { value: part.value }) })] }, `${widget.id} ${index}`)))) }));
|
|
35
|
+
}
|
|
36
|
+
/** The counters of the sheet the widgets on someone show (`track.field`), panels and boxes, which leave the line of values under their name. */
|
|
37
|
+
export function personFields(shown) {
|
|
38
|
+
return new Set(shown.flatMap(({ shows }) => tracksOf(shows).flatMap((track) => (track.field === undefined ? [] : [track.field]))));
|
|
39
|
+
}
|
|
40
|
+
/** The panel of a widget on someone: large, or in one line in a row of the turns. */
|
|
41
|
+
export function PersonPanel({ shown, compact = false }) {
|
|
42
|
+
const loaded = usePageModule(shown.widget);
|
|
43
|
+
const { start, end, lead } = sidesOf(shown.shows);
|
|
44
|
+
const one = start.length === 0 || end.length === 0;
|
|
45
|
+
const dead = shown.shows.dead === true;
|
|
46
|
+
const tint = dead ? "dead" : tintOf(lead?.tone);
|
|
47
|
+
const figure = lead?.figure !== undefined && shown.widget.module !== undefined ? lead : undefined;
|
|
48
|
+
const classes = ["person-panel", tint, one ? "one-side" : "", compact ? "compact" : "", figure === undefined ? "" : "figured"].filter((name) => name !== "").join(" ");
|
|
49
|
+
return (_jsxs("div", { class: classes, children: [start.map((track, index) => _jsx(Side, { track: track, side: "start" }, `start ${index}`)), lead !== undefined && (_jsxs("span", { class: "person-middle", children: [figure !== undefined && _jsx(Figure, { owner: { widget: shown.widget, loaded, data: shown.shows.data, place: "person" }, name: figure.figure ?? "", part: figure }), _jsxs("span", { class: "person-word", dir: "auto", children: [dead && _jsx(Skull, {}), textOf(lead.lead)] })] })), end.map((track, index) => _jsx(Side, { track: track, side: "end" }, `end ${index}`))] }));
|
|
50
|
+
}
|
|
51
|
+
/** A widget on someone in the party's strip, in place of their bar: its word and its counts' marks, small. */
|
|
52
|
+
export function PersonStrip({ shown }) {
|
|
53
|
+
const { start, end, lead } = sidesOf(shown.shows);
|
|
54
|
+
const marks = [...start, ...end].flatMap((track, at) => Array.from({ length: track.max }, (_, index) => _jsx("span", { class: `strip-mark ${goodOf(track, start.includes(track)) ? "success" : "failure"}${index < track.value ? " marked" : ""}` }, `${at} ${index}`)));
|
|
55
|
+
return (_jsxs("span", { class: `member-state ${shown.shows.dead === true ? "dead" : tintOf(lead?.tone)}`, children: [lead !== undefined && _jsx("span", { class: "member-state-word", dir: "auto", children: textOf(lead.lead) }), marks.length > 0 && _jsx("span", { class: "strip-marks", "aria-hidden": "true", children: marks })] }));
|
|
56
|
+
}
|
|
57
|
+
/** A count in a box, as the line draws a counter: its pips, up to ten, else its number of the most; named by its label and value. */
|
|
58
|
+
function BoxCount({ track }) {
|
|
59
|
+
const named = `${textOf(track.label)}: ${t("{value} of {max}", { value: track.value, max: track.max })}`;
|
|
60
|
+
return track.max <= 10 && track.look !== "bar"
|
|
61
|
+
? (_jsx("span", { class: track.tone === undefined ? "pips" : `pips ${track.tone}`, role: "img", "aria-label": named, children: Array.from({ length: track.max }, (_, index) => _jsx("span", { class: index < track.value ? "pip on" : "pip" }, index)) }))
|
|
62
|
+
: _jsx("span", { class: "num", role: "img", "aria-label": named, children: `${numberText(track.value)}/${numberText(track.max)}` });
|
|
63
|
+
}
|
|
64
|
+
/** A lead in a box: its words, and its value after them. */
|
|
65
|
+
function BoxLead({ lead }) {
|
|
66
|
+
return (_jsxs("span", { class: "person-box-lead", children: [_jsx("span", { dir: "auto", children: textOf(lead.lead) }), lead.value !== undefined && _jsx(Value, { value: lead.value })] }));
|
|
67
|
+
}
|
|
68
|
+
/** What of a widget a box draws: its counts, its leads, and each of its values. */
|
|
69
|
+
function boxParts(shows) {
|
|
70
|
+
return (shows.parts ?? []).flatMap((part) => ("track" in part || "lead" in part ? [part] : "values" in part ? part.values : []));
|
|
71
|
+
}
|
|
72
|
+
/** The widgets that show something on someone of the party, in their order. */
|
|
73
|
+
function onPerson(widgets, name) {
|
|
74
|
+
return widgets.filter((widget) => widget.place === "person").sort((first, second) => first.order - second.order).flatMap((widget) => {
|
|
75
|
+
const shows = widget.people?.[name];
|
|
76
|
+
return shows === undefined ? [] : [{ widget, shows }];
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/** A count on its side: good ones circles, bad ones squares; one without a tone as its side's. */
|
|
80
|
+
function Side({ track, side }) {
|
|
81
|
+
return _jsx(Marks, { kind: goodOf(track, side === "start") ? "successes" : "failures", label: textOf(track.label), value: track.value, most: track.max });
|
|
82
|
+
}
|
|
83
|
+
/** A side's marks under their label: good ones as circles, bad ones as squares, by shape as well as colour; a screen reader hears the count. */
|
|
84
|
+
function Marks({ kind, label, value, most }) {
|
|
85
|
+
return (_jsxs("div", { class: kind === "failures" ? "person-side bad" : "person-side good", children: [_jsx("span", { class: "eyebrow person-label", "aria-hidden": "true", children: label }), _jsxs("span", { class: "person-marks", children: [Array.from({ length: most }, (_, index) => _jsx("span", { class: index < value ? "person-mark marked" : "person-mark", "aria-hidden": "true" }, index)), _jsx("span", { class: "visually-hidden", children: `${label}: ${t("{value} of {max}", { value, max: most })}` })] })] }));
|
|
86
|
+
}
|
|
87
|
+
/** The red skull of the dead, as on their token (D-461), before the word. */
|
|
88
|
+
function Skull() {
|
|
89
|
+
return (_jsx("svg", { class: "person-skull", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: statusIcons.dead }) }));
|
|
90
|
+
}
|
|
91
|
+
/** A widget's counts by their side, the good ones and those at the stage's start first, and its first lead. */
|
|
92
|
+
function sidesOf(shows) {
|
|
93
|
+
const tracks = tracksOf(shows);
|
|
94
|
+
const atStart = (track) => track.stage === "start" || (track.stage !== "end" && track.tone === "good");
|
|
95
|
+
return {
|
|
96
|
+
start: tracks.filter(atStart),
|
|
97
|
+
end: tracks.filter((track) => !atStart(track)),
|
|
98
|
+
lead: shows.parts?.find((part) => "lead" in part),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function tracksOf(shows) {
|
|
102
|
+
return (shows.parts ?? []).flatMap((part) => ("track" in part ? [part.track] : []));
|
|
103
|
+
}
|
|
104
|
+
function goodOf(track, start) {
|
|
105
|
+
return track.tone === undefined ? start : track.tone === "good";
|
|
106
|
+
}
|
|
107
|
+
/** The panel's tint by its lead's tone: bad as dying, good as stable, none quiet. */
|
|
108
|
+
function tintOf(tone) {
|
|
109
|
+
return tone === "good" ? "stable" : tone === "bad" ? "dying" : "quiet";
|
|
110
|
+
}
|
|
@@ -4,26 +4,27 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
|
|
|
4
4
|
// square or by piece, doors and where squares lead, the squares' names; who stands where as coins, the one acting raised off the paper, a foe the master marked glowing (D-415); then the key, and who
|
|
5
5
|
// is where in words, the map's twin.
|
|
6
6
|
import { Fragment } from "preact";
|
|
7
|
-
import { useEffect, useRef, useState } from "preact/hooks";
|
|
7
|
+
import { useContext, useEffect, useRef, useState } from "preact/hooks";
|
|
8
8
|
import { TalkName, usePlayerActs } from "./act-names.js";
|
|
9
9
|
import { CardHead } from "./card.js";
|
|
10
|
+
import { WidgetsContext } from "./extension-widgets.js";
|
|
10
11
|
import { Glass, GlassDefs } from "./glass.js";
|
|
11
12
|
import { iconPath } from "./icons.js";
|
|
12
13
|
import { strangerLabel } from "./labels.js";
|
|
13
14
|
import { sideIcons, sideOf } from "./party.js";
|
|
14
15
|
import { columnName, exitSide, floorLoops, groundKinds, isSolid, isStandable, isWalled, kindAt, nextTo, piecesOf, squareName, squareOf, symbolAt, tracedLoop } from "./place-map.js";
|
|
15
16
|
import { conditionsPref, tokenSymbolsPref, useChoice, usePref } from "./prefs.js";
|
|
16
|
-
import {
|
|
17
|
-
import { statusMarks, statusWords } from "./status.js";
|
|
17
|
+
import { personState, statusMarks, statusWords } from "./status.js";
|
|
18
18
|
import { t } from "./text.js";
|
|
19
19
|
// How wide a square is drawn, in pixels.
|
|
20
20
|
const size = 40;
|
|
21
21
|
// The order of who is where under the map.
|
|
22
22
|
const roles = ["pc", "companion", "other"];
|
|
23
|
-
export function PlaceMap({ map, place, acting, picking, choosing, bare = false,
|
|
23
|
+
export function PlaceMap({ map, place, acting, picking, choosing, bare = false, self: selfName }) {
|
|
24
24
|
const svg = useRef(null);
|
|
25
25
|
const where = useRef(null);
|
|
26
26
|
const acts = usePlayerActs();
|
|
27
|
+
const widgets = useContext(WidgetsContext);
|
|
27
28
|
// On the page, a token touched starts talking to them, the focus coming back to their line of who is where (D-495).
|
|
28
29
|
const talking = acts === undefined || picking !== undefined ? undefined : {
|
|
29
30
|
onChoose: (name) => {
|
|
@@ -80,7 +81,7 @@ export function PlaceMap({ map, place, acting, picking, choosing, bare = false,
|
|
|
80
81
|
chosen: choosing !== undefined && choosing.selected === shown && shown !== undefined,
|
|
81
82
|
onChoose: () => tokens.onChoose(shown),
|
|
82
83
|
};
|
|
83
|
-
return (_jsx(Token, { one:
|
|
84
|
+
return (_jsx(Token, { one: standingOf(one, one.role === "other" ? undefined : personState(widgets, one.name)), index: index, acting: one.name === acting, hostile: one.hostile === true, x: middle(one)[0], y: middle(one)[1], scale: scale, ...(choice === undefined ? {} : { choice }) }, index));
|
|
84
85
|
}) }), picking !== undefined && (_jsx("g", { class: "lm-picks", children: squares.filter((square) => isStandable(map, square)).map((square) => (_jsx("rect", { class: picking.selected === squareName(square) ? "lm-pick selected" : "lm-pick", x: X(square.column) + 1, y: Y(square.row) + 1, width: size - 2, height: size - 2, rx: 4, onClick: () => picking.onSelect(squareName(square)), children: _jsx("title", { children: squareName(square) }) }, squareName(square)))) }))] }) }), !bare && _jsx(MapKey, { map: map, reach: reach.length > 0, self: selfName }), !bare && standing.length > 0 && (_jsx("ul", { ref: where, class: "lm-where", "aria-label": t("Who is where"), children: standing.toSorted((first, second) => measuredFirst(first, second, selfName === undefined ? undefined : self) || roles.indexOf(first.role) - roles.indexOf(second.role)).map((one, index) => (_jsxs("li", { class: `lm-where-${one.role}${one.hostile === true ? " hostile" : ""}`, children: [one.role === "pc"
|
|
85
86
|
? _jsx("span", { class: "lm-where-name", children: one.name })
|
|
86
87
|
: (_jsx(TalkName, { name: one.stranger ? strangerLabel(one.name) : one.name, children: _jsx("span", { class: "lm-where-name", children: one.stranger ? strangerLabel(one.name) : one.name }) })), _jsx("span", { class: "lm-key-square", children: one.square }), selfName !== undefined && one === self
|
|
@@ -311,9 +312,13 @@ function Token({ one, index, acting, hostile, x, y, scale, choice }) {
|
|
|
311
312
|
? _jsx("path", { class: "lm-stranger", d: "M12 3c-4 0-6.5 3.5-6.5 8v3.5L4 20.5h16l-1.5-6V11c0-4.5-2.5-8-6.5-8Z", transform: "translate(-10.8 -11) scale(0.9)" })
|
|
312
313
|
: _jsx("text", { class: "lm-number", y: 1, "text-anchor": "middle", "dominant-baseline": "middle", children: one.name.slice(0, 1).toUpperCase() }) })), _jsx(Glass, { x: x, y: y, r: r, prefix: "lm" }), _jsx("path", { class: "lm-bevel-lit", d: crescent(x, y, r, 1.5) }), _jsx("path", { class: "lm-bevel-shade", d: crescent(x, y, r, -1.5) })] }), pip !== undefined && _jsx(MapPip, { side: pip, icon: one.stranger ? undefined : one.icon, x: x - r * 0.725 + inward(pipRadius, pipPaper), y: y + r * 0.725 - inward(pipRadius, pipPaper), grow: below }), one.image !== undefined && number !== undefined && _jsx(MapNumber, { number: number, x: x + r * 0.725 - inward(numberRadius, 1.5, grow), y: y - r * 0.725 + inward(numberRadius, 1.5, grow), grow: grow }), _jsx(MapStatus, { one: one, x: x + r * 0.56 - inward(statusRadius, 1.5), y: y + r * 0.56 - inward(statusRadius, 1.5), grow: below })] }));
|
|
313
314
|
}
|
|
315
|
+
/** Someone on the map with what a widget on them says: dead by its rules too. */
|
|
316
|
+
function standingOf(one, person) {
|
|
317
|
+
return { ...one, party: one.role !== "other", person, ...(person?.dead === true ? { dead: true } : {}) };
|
|
318
|
+
}
|
|
314
319
|
/** At 0 a token greyed, until its counter rises again; dead, greyer and faded, as in the party's strip (D-461). */
|
|
315
320
|
function fallenOf(one) {
|
|
316
|
-
return one.dead === true
|
|
321
|
+
return one.dead === true ? "dead" : one.down === true ? "fallen" : "";
|
|
317
322
|
}
|
|
318
323
|
// The marks on a token as on one of 40 pixels on the page: the side's pip of 17, the state's of 12, a number's coin 13 high.
|
|
319
324
|
const pipRadius = size * 0.43 * (17 / 40);
|
package/dist/dashboard/scene.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
2
|
// The Scene section (D-309, VIEW-6, D-444): where the party is, its picture with the places around it, its name, what holds there and its text; the open
|
|
3
3
|
// scene and who is in it; outside a scene who is there of those the character knows; the map. While the scene goes by turns, the turns first.
|
|
4
|
-
import { useEffect, useRef, useState } from "preact/hooks";
|
|
4
|
+
import { useContext, useEffect, useRef, useState } from "preact/hooks";
|
|
5
5
|
import { TalkName } from "./act-names.js";
|
|
6
6
|
import { sectionAddress } from "./address.js";
|
|
7
|
-
import { WidgetCards } from "./extension-widgets.js";
|
|
7
|
+
import { WidgetCards, WidgetsContext } from "./extension-widgets.js";
|
|
8
8
|
import { effectLabel, sinceDateLabel, terrainLabel } from "./game-words.js";
|
|
9
9
|
import { cardIcons, Icon } from "./icons.js";
|
|
10
10
|
import { phraseLabel, sceneTypeLabel, strangerLabel } from "./labels.js";
|
|
@@ -13,7 +13,7 @@ import { InlineText, knowersOf, Markdown } from "./markdown.js";
|
|
|
13
13
|
import { sideOf, Token } from "./party.js";
|
|
14
14
|
import { PlaceMap } from "./place-map-view.js";
|
|
15
15
|
import { Card } from "./sheet.js";
|
|
16
|
-
import { StatusPip } from "./status.js";
|
|
16
|
+
import { downTint, personState, StatusPip } from "./status.js";
|
|
17
17
|
import { foldedText, t } from "./text.js";
|
|
18
18
|
import { CharacterCard, hasTurns, TurnBand, TurnsCard } from "./turns.js";
|
|
19
19
|
import { BiomeSwatch } from "./world.js";
|
|
@@ -32,7 +32,7 @@ export function SceneView({ place, scene, actor, foreground, several = false, pa
|
|
|
32
32
|
return (_jsxs("section", { class: "card upcoming", "aria-labelledby": "place-name", children: [_jsx("h2", { id: "place-name", children: t("In the open") }), _jsx("p", { children: t("The party is in no place the character knows, as on a road between two.") })] }));
|
|
33
33
|
}
|
|
34
34
|
const kinds = ["place-view", turns === undefined ? "" : "in-turns", scene === undefined && place?.map === undefined ? "" : "with-scene"];
|
|
35
|
-
return (_jsx("section", { class: kinds.filter((kind) => kind !== "").join(" "), "aria-labelledby": turns === undefined ? "place-name" : "turn-title", children: _jsxs("div", { class: "scene-body", children: [band && _jsx(TurnBand, { scene: band.scene, several: several, ...(band.motion === undefined ? {} : { motion: band.motion }) }, "band"), place && (turns === undefined ? _jsx(PlaceBand, { place: place }, "place") : _jsx(PlaceLine, { place: place }, `line ${turns.title}`)), scene && turns === undefined && _jsx(SceneCard, { scene: scene }, "scene"), turns && (_jsxs("div", { class: "turn-side", children: [!turnsBeside && _jsx(TurnsCard, { scene: turns, party: party, several: several }), _jsx(CharacterCard, { lead: actor, scene: turns, own: own, party: party, ...(several && onShowCard !== undefined ? { onShow: onShowCard } : {}) })] }, "side")), place?.map && _jsx(PlaceMap, { map: place.map, place: place.name, ...(turns?.turn === undefined ? {} : { acting: turns.turn }),
|
|
35
|
+
return (_jsx("section", { class: kinds.filter((kind) => kind !== "").join(" "), "aria-labelledby": turns === undefined ? "place-name" : "turn-title", children: _jsxs("div", { class: "scene-body", children: [band && _jsx(TurnBand, { scene: band.scene, several: several, ...(band.motion === undefined ? {} : { motion: band.motion }) }, "band"), place && (turns === undefined ? _jsx(PlaceBand, { place: place }, "place") : _jsx(PlaceLine, { place: place }, `line ${turns.title}`)), scene && turns === undefined && _jsx(SceneCard, { scene: scene }, "scene"), turns && (_jsxs("div", { class: "turn-side", children: [!turnsBeside && _jsx(TurnsCard, { scene: turns, party: party, several: several }), _jsx(CharacterCard, { lead: actor, scene: turns, own: own, party: party, ...(several && onShowCard !== undefined ? { onShow: onShowCard } : {}) })] }, "side")), place?.map && _jsx(PlaceMap, { map: place.map, place: place.name, ...(turns?.turn === undefined ? {} : { acting: turns.turn }), self: foreground }, "map"), turns === undefined && scene === undefined && place && place.here.length > 0 && place.map === undefined && (_jsx("div", { class: "groups", children: _jsx(Card, { name: "Here", title: t("Here"), icon: cardIcons.here, layout: "lore", preview: place.here.map((person) => person.name).join(" · "), children: _jsx(People, { people: place.here }) }) }, "groups")), _jsx(WidgetCards, { place: "page", page: "scene", who: foreground, view: place }, "widgets")] }) }));
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* The band while it comes and goes (D-444): with a scene that goes by turns, coming in when it starts while the page is open; kept a moment when they end, going
|
|
@@ -148,9 +148,16 @@ function SceneCard({ scene }) {
|
|
|
148
148
|
* master marked glows red a little (D-415); one of the party with the pip of their side (D-414); anyone with the pip of their state (D-419).
|
|
149
149
|
*/
|
|
150
150
|
function People({ people }) {
|
|
151
|
+
const widgets = useContext(WidgetsContext);
|
|
152
|
+
// One of the party with what a package's widget on them says of their state (D-514).
|
|
153
|
+
const statusOf = (person) => {
|
|
154
|
+
const party = person.role !== "other";
|
|
155
|
+
const said = party ? personState(widgets, person.name) : undefined;
|
|
156
|
+
return { ...person, party, ...(said === undefined ? {} : { person: said }) };
|
|
157
|
+
};
|
|
151
158
|
return (_jsx("ul", { class: "present", children: people.map((person, index) => (_jsxs("li", { class: person.role === "other" && index > 0 && people[index - 1].role !== "other" ? "after-party" : undefined, children: [person.stranger && person.image === undefined
|
|
152
159
|
? (_jsxs("span", { class: ["token stranger", letterOf(person.name) === undefined ? "" : "numbered", person.hostile === true ? "hostile" : ""].filter((name) => name !== "").join(" "), "aria-hidden": "true", children: [letterOf(person.name) ?? _jsx(Icon, { name: "stranger" }), _jsx(StatusPip, { status: { ...person, party: false } })] }))
|
|
153
|
-
: (_jsx(Token, { member: { name: person.name, role: person.role, ...(person.image === undefined ? {} : { image: person.image }), ...(person.icon === undefined ? {} : { icon: person.icon }) }, hostile: person.hostile === true, side: sideOf(person.role), status:
|
|
160
|
+
: (_jsx(Token, { member: { name: person.name, role: person.role, ...(person.image === undefined ? {} : { image: person.image }), ...(person.icon === undefined ? {} : { icon: person.icon }) }, hostile: person.hostile === true, side: sideOf(person.role), status: statusOf(person), dying: downTint(statusOf(person)), number: person.stranger ? letterOf(person.name) : undefined })), person.role === "pc"
|
|
154
161
|
? _jsx(PersonName, { person: person })
|
|
155
162
|
: (_jsx(TalkName, { name: person.stranger ? strangerLabel(person.name) : person.name, children: _jsx(PersonName, { person: person }) }))] }, `${person.name} ${index}`))) }));
|
|
156
163
|
}
|
|
@@ -162,7 +169,3 @@ function PersonName({ person }) {
|
|
|
162
169
|
function letterOf(name) {
|
|
163
170
|
return /^creature ([A-Z])$/.exec(name)?.[1];
|
|
164
171
|
}
|
|
165
|
-
/** Where those of the party at their dying point stand, by name, for their tokens on the map (D-461). */
|
|
166
|
-
function dyingOf(party) {
|
|
167
|
-
return new Map(party.flatMap((member) => (member.dying === undefined ? [] : [[member.name, member.dying]])));
|
|
168
|
-
}
|