rpg-engine 0.9.1 → 0.11.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/adventures/placement.js +4 -0
- package/dist/adventures/source.js +6 -5
- package/dist/campaign/find-campaign.js +18 -0
- package/dist/campaign/host-files.js +8 -6
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +2 -0
- package/dist/campaign/settings.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.js +1 -1
- package/dist/commands/config.js +21 -32
- package/dist/commands/import/import.js +1 -1
- package/dist/commands/instructions.js +1 -1
- package/dist/commands/mode.js +1 -1
- package/dist/commands/mood.js +2 -3
- package/dist/commands/move.js +1 -1
- package/dist/commands/package.d.ts +3 -3
- package/dist/commands/package.js +74 -37
- package/dist/commands/reveal.js +1 -1
- package/dist/commands/roll/roll.js +6 -12
- package/dist/commands/rules.js +0 -1
- package/dist/commands/scene.js +6 -8
- package/dist/commands/shared/adventures.js +21 -12
- package/dist/commands/shared/images.js +3 -1
- package/dist/commands/shared/knowledge.d.ts +8 -0
- package/dist/commands/shared/knowledge.js +41 -18
- package/dist/commands/shared/library.js +13 -5
- package/dist/commands/shared/mode.d.ts +7 -4
- package/dist/commands/shared/mode.js +28 -15
- package/dist/commands/shared/packages/catalog.d.ts +2 -0
- package/dist/commands/shared/packages/catalog.js +1 -0
- package/dist/commands/shared/packages/code.js +13 -2
- package/dist/commands/shared/page-words.d.ts +2 -0
- package/dist/commands/shared/page-words.js +13 -0
- package/dist/commands/shared/sheet.d.ts +3 -2
- package/dist/commands/shared/sheet.js +8 -5
- package/dist/commands/show.js +1 -1
- package/dist/commands/status.js +9 -5
- package/dist/commands/view/place.d.ts +2 -0
- package/dist/commands/view/place.js +17 -5
- package/dist/commands/write/write.js +4 -3
- package/dist/core/archive-paths.js +1 -1
- package/dist/core/context.d.ts +2 -0
- package/dist/core/package-api.d.ts +1 -1
- package/dist/core/package-declarations.d.ts +3 -3
- package/dist/core/package-declarations.js +3 -3
- package/dist/core/refusal.d.ts +12 -0
- package/dist/core/refusal.js +17 -0
- package/dist/core/store.d.ts +4 -0
- package/dist/core/store.js +20 -1
- package/dist/dashboard/api.js +37 -81
- package/dist/dashboard/app.js +10 -3
- package/dist/dashboard/asked.js +6 -3
- package/dist/dashboard/assets/master.svg +1 -2
- package/dist/dashboard/card.js +1 -1
- package/dist/dashboard/dice/load.js +6 -1
- package/dist/dashboard/dice/throw.js +5 -1
- package/dist/dashboard/dice/tray.js +5 -1
- package/dist/dashboard/footer.js +2 -2
- package/dist/dashboard/game-words.js +32 -32
- package/dist/dashboard/guide/ar.md +17 -17
- package/dist/dashboard/guide/cs.md +17 -17
- package/dist/dashboard/guide/da.md +16 -16
- package/dist/dashboard/guide/de.md +15 -15
- package/dist/dashboard/guide/el.md +19 -19
- package/dist/dashboard/guide/en.md +4 -4
- package/dist/dashboard/guide/es.md +17 -17
- package/dist/dashboard/guide/fi.md +19 -19
- package/dist/dashboard/guide/fr.md +16 -16
- package/dist/dashboard/guide/he.md +16 -16
- package/dist/dashboard/guide/hi.md +20 -20
- package/dist/dashboard/guide/hu.md +18 -18
- package/dist/dashboard/guide/is.md +16 -16
- package/dist/dashboard/guide/it.md +7 -7
- package/dist/dashboard/guide/ja.md +17 -17
- package/dist/dashboard/guide/ko.md +22 -22
- package/dist/dashboard/guide/nb.md +17 -17
- package/dist/dashboard/guide/nl.md +19 -19
- package/dist/dashboard/guide/pl.md +18 -18
- package/dist/dashboard/guide/pt.md +13 -13
- package/dist/dashboard/guide/ro.md +19 -19
- package/dist/dashboard/guide/ru.md +17 -17
- package/dist/dashboard/guide/sv.md +16 -16
- package/dist/dashboard/guide/tr.md +21 -21
- package/dist/dashboard/guide/uk.md +16 -16
- package/dist/dashboard/guide/zh.md +20 -20
- package/dist/dashboard/help/blocks.js +6 -0
- package/dist/dashboard/help/help.js +15 -3
- package/dist/dashboard/help/markdown.js +2 -1
- package/dist/dashboard/i18n/ar.json +54 -1
- package/dist/dashboard/i18n/cs.json +54 -1
- package/dist/dashboard/i18n/da.json +54 -1
- package/dist/dashboard/i18n/de.json +54 -1
- package/dist/dashboard/i18n/el.json +54 -1
- package/dist/dashboard/i18n/es.json +54 -1
- package/dist/dashboard/i18n/fi.json +54 -1
- package/dist/dashboard/i18n/fr.json +54 -1
- package/dist/dashboard/i18n/he.json +54 -1
- package/dist/dashboard/i18n/hi.json +54 -1
- package/dist/dashboard/i18n/hu.json +54 -1
- package/dist/dashboard/i18n/is.json +54 -1
- package/dist/dashboard/i18n/it.json +57 -4
- package/dist/dashboard/i18n/ja.json +54 -1
- package/dist/dashboard/i18n/ko.json +54 -1
- package/dist/dashboard/i18n/nb.json +54 -1
- package/dist/dashboard/i18n/nl.json +54 -1
- package/dist/dashboard/i18n/pl.json +54 -1
- package/dist/dashboard/i18n/pt.json +54 -1
- package/dist/dashboard/i18n/ro.json +54 -1
- package/dist/dashboard/i18n/ru.json +54 -1
- package/dist/dashboard/i18n/sv.json +54 -1
- package/dist/dashboard/i18n/tr.json +54 -1
- package/dist/dashboard/i18n/uk.json +54 -1
- package/dist/dashboard/i18n/zh.json +54 -1
- package/dist/dashboard/icons.js +2 -2
- package/dist/dashboard/journal.js +9 -4
- package/dist/dashboard/labels.js +5 -4
- package/dist/dashboard/language-choice.js +3 -3
- package/dist/dashboard/markdown.js +11 -4
- package/dist/dashboard/notes.js +4 -2
- package/dist/dashboard/notices.js +2 -2
- package/dist/dashboard/packages/ask-card.js +1 -1
- package/dist/dashboard/packages/packages.js +14 -10
- package/dist/dashboard/packages/page-code.js +11 -3
- package/dist/dashboard/packages/widgets.js +5 -5
- package/dist/dashboard/pages.js +3 -3
- package/dist/dashboard/place/map-sheet.js +4 -3
- package/dist/dashboard/place/map-view.js +17 -5
- package/dist/dashboard/refusals.js +61 -0
- package/dist/dashboard/rolls.js +3 -3
- package/dist/dashboard/settings.js +19 -5
- package/dist/dashboard/sheet.js +26 -7
- package/dist/dashboard/status.js +19 -13
- package/dist/dashboard/style.css +113 -16
- package/dist/dashboard/text.js +6 -2
- package/dist/dashboard/top.js +7 -9
- package/dist/dashboard/turns.js +7 -2
- package/dist/dashboard/world/lore.js +16 -15
- package/dist/dashboard/world/map.js +43 -1
- package/dist/dashboard/world/world.js +50 -15
- package/dist/dice/index.d.ts +1 -1
- package/dist/dice/oracle.d.ts +5 -3
- package/dist/dice/oracle.js +7 -6
- package/dist/extensions/extension.js +4 -1
- package/dist/helpers/codex.js +1 -1
- package/dist/packages/npm.js +17 -4
- package/dist/packages/tarball.js +8 -4
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/markdown.d.ts +2 -0
- package/dist/pages/markdown.js +21 -0
- package/dist/pages/world.js +4 -0
- package/dist/server/dashboard/index.js +8 -4
- package/dist/server/dashboard/writes.js +22 -13
- package/dist/server/mcp.d.ts +3 -1
- package/dist/server/mcp.js +20 -5
- package/dist/systems/game-system.d.ts +2 -0
- package/dist/systems/game-system.js +2 -0
- package/dist/systems/system-code.js +5 -0
- package/instructions/adventure.md +1 -1
- package/instructions/combat.md +1 -1
- package/instructions/core.md +2 -2
- package/instructions/import.md +1 -0
- package/instructions/session-zero.md +1 -1
- package/instructions/session.md +1 -1
- package/instructions/setup.md +1 -1
- package/package.json +2 -2
- package/systems/free/instructions/outcomes-rolled.md +1 -1
- package/systems/free/instructions/outcomes-tossed.md +1 -1
- package/systems/free/instructions/play.md +1 -2
|
@@ -15,7 +15,7 @@ import { Component, createContext, render } from "preact";
|
|
|
15
15
|
import { useContext, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
|
|
16
16
|
import { readWidgetData, runCommand } from "../api.js";
|
|
17
17
|
import { fieldLabel } from "../labels.js";
|
|
18
|
-
import { isolated, numberText, pageDirection } from "../text.js";
|
|
18
|
+
import { isolated, numberText, pageDirection, pageLocale } from "../text.js";
|
|
19
19
|
import { shownTheme } from "../theme.js";
|
|
20
20
|
import { PeopleContext } from "./people.js";
|
|
21
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. */
|
|
@@ -117,7 +117,7 @@ export function pagePropsOf(owner) {
|
|
|
117
117
|
return {
|
|
118
118
|
words: (text, values) => filled(owner.words?.[text] ?? text, values),
|
|
119
119
|
number: numberText,
|
|
120
|
-
language:
|
|
120
|
+
language: pageLocale(),
|
|
121
121
|
dir: pageDirection(),
|
|
122
122
|
theme: shownTheme(),
|
|
123
123
|
reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches,
|
|
@@ -236,9 +236,17 @@ function hasLayer(rules) {
|
|
|
236
236
|
let pageSheet;
|
|
237
237
|
let sheetLoading;
|
|
238
238
|
function loadPageSheet() {
|
|
239
|
-
|
|
239
|
+
// One that did not come is asked again by the next drawing, never kept as failed.
|
|
240
|
+
sheetLoading ??= fetch("/style.css").then(async (response) => {
|
|
241
|
+
if (!response.ok) {
|
|
242
|
+
throw new Error(`/style.css did not come (${response.status}).`);
|
|
243
|
+
}
|
|
244
|
+
const sheet = await new CSSStyleSheet().replace(await response.text());
|
|
240
245
|
pageSheet = sheet;
|
|
241
246
|
return sheet;
|
|
247
|
+
}).catch((error) => {
|
|
248
|
+
sheetLoading = undefined;
|
|
249
|
+
throw error;
|
|
242
250
|
});
|
|
243
251
|
return sheetLoading;
|
|
244
252
|
}
|
|
@@ -7,7 +7,7 @@ import { sectionAddress } from "../address.js";
|
|
|
7
7
|
import { CardHead } from "../card.js";
|
|
8
8
|
import { iconPath } from "../icons.js";
|
|
9
9
|
import { sideOf, Token } from "../party.js";
|
|
10
|
-
import { isolated, numberText, pageDirection, t } from "../text.js";
|
|
10
|
+
import { isolated, numberText, pageDirection, pageLocale, t } from "../text.js";
|
|
11
11
|
import { cardsIn, codeOfModule, ExtensionRoot, figureSize, ModulesContext, pagePropsOf, usePageModule, useWidgetData } from "./page-code.js";
|
|
12
12
|
import { PeopleContext } from "./people.js";
|
|
13
13
|
/** The widgets of the campaign's extensions, as last read: every part of the page that holds some takes its own from here. */
|
|
@@ -67,7 +67,7 @@ export function widgetSaid(widget) {
|
|
|
67
67
|
}
|
|
68
68
|
/** A widget's text as one string, its values written in the page's language: for a tip or a name. */
|
|
69
69
|
export function textOf(text) {
|
|
70
|
-
return typeof text === "string" ? text : text.text.replace(/\{(\w+)\}/g, (whole, name) => (
|
|
70
|
+
return typeof text === "string" ? text : text.text.replace(/\{(\w+)\}/g, (whole, name) => (Object.hasOwn(text.values, name) ? isolated(valueOf(text.values[name])) : whole));
|
|
71
71
|
}
|
|
72
72
|
/** The widgets of a place, of a page for a card in one, in their order; one turned off is in none. */
|
|
73
73
|
function inPlace(widgets, place, page) {
|
|
@@ -219,7 +219,7 @@ export function Figure({ owner, name, part }) {
|
|
|
219
219
|
}
|
|
220
220
|
const before = looks.current.before;
|
|
221
221
|
const size = figureSize(owner.widget, name);
|
|
222
|
-
return (_jsx(ExtensionRoot, { widget: owner.widget, loaded: owner.loaded, kind: `ext-figure at-${owner.place}`, size: size, draw: (module) => {
|
|
222
|
+
return (_jsx(ExtensionRoot, { widget: owner.widget, loaded: owner.loaded, kind: `ext-figure at-${owner.place}${size.height <= 40 ? " small" : ""}`, size: size, draw: (module) => {
|
|
223
223
|
const Drawing = module.figures?.[name];
|
|
224
224
|
if (Drawing === undefined) {
|
|
225
225
|
throw new Error(`its page module has no figure ${name}`);
|
|
@@ -248,7 +248,7 @@ export function Text({ text }) {
|
|
|
248
248
|
}
|
|
249
249
|
const pieces = text.text.split(/(\{\w+\})/).filter((piece) => piece !== "").map((piece, index) => {
|
|
250
250
|
const name = /^\{(\w+)\}$/.exec(piece)?.[1];
|
|
251
|
-
return name !== undefined &&
|
|
251
|
+
return name !== undefined && Object.hasOwn(text.values, name) ? _jsx(Value, { value: text.values[name] }, index) : piece;
|
|
252
252
|
});
|
|
253
253
|
return _jsx(_Fragment, { children: pieces });
|
|
254
254
|
}
|
|
@@ -271,7 +271,7 @@ function valueOf(value) {
|
|
|
271
271
|
}
|
|
272
272
|
/** Two numbers as a range, as the page's language writes it: 10–15, −5 – 0. */
|
|
273
273
|
function rangeText(from, to) {
|
|
274
|
-
const format = new Intl.NumberFormat(
|
|
274
|
+
const format = new Intl.NumberFormat(pageLocale(), { numberingSystem: "latn", useGrouping: false, maximumFractionDigits: 2 });
|
|
275
275
|
return typeof format.formatRange === "function" ? format.formatRange(from, to) : `${numberText(from)}–${numberText(to)}`;
|
|
276
276
|
}
|
|
277
277
|
/** An extension's icon, drawn as the page strokes its own. */
|
package/dist/dashboard/pages.js
CHANGED
|
@@ -3,7 +3,7 @@ import { sectionLabel } from "./address.js";
|
|
|
3
3
|
import { CardHeader } from "./card.js";
|
|
4
4
|
import { footLinks } from "./footer.js";
|
|
5
5
|
import { Icon, iconPath } from "./icons.js";
|
|
6
|
-
import { systemTitleLabel } from "./labels.js";
|
|
6
|
+
import { systemNameLabel, systemTitleLabel } from "./labels.js";
|
|
7
7
|
import { t } from "./text.js";
|
|
8
8
|
/** A page's head, out of Party and Scene: its section's icon and its title, both in the accent (D-409). */
|
|
9
9
|
export function PageHead({ section, id, title }) {
|
|
@@ -14,9 +14,9 @@ export function PageHead({ section, id, title }) {
|
|
|
14
14
|
* Stefano's motto, as in the READMEs; a card of the licences and the system's credits; then, out of the cards and small, the copyright.
|
|
15
15
|
*/
|
|
16
16
|
export function About({ product, system }) {
|
|
17
|
-
return (_jsxs("section", { class: "page-stack about", "aria-labelledby": "about-title", children: [_jsx(PageHead, { section: "about", id: "about-title" }), _jsxs("article", { class: "about-hero", children: [_jsx("img", { src: "/assets/icon-180.png", alt: "" }), _jsxs("div", { children: [_jsx("h3", { children: product }), _jsx("p", { children: t("The dashboard of the campaign, beside the chat where you play.") }), _jsxs("p", { class: "about-links", children: [_jsxs("a", { class: "about-link", href: footLinks.github, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "github" }), "GitHub"] }), _jsxs("a", { class: "about-link", href: footLinks.npm, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "npm" }), "npm"] }), _jsxs("a", { class: "about-link", href: footLinks.support, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "heart" }), t("Support {product}", { product })] })] })] })] }), system && (_jsxs("details", { class: "group about-card about-system", open: true, children: [_jsx(CardHeader, { icon: iconPath("dice"), title: _jsx("h3", { children: t("Game system") }), open: true, onToggle: () => undefined, fixed: true }), _jsxs("p", { children: [_jsx("span", { class: "system-chip", children: system.name }), systemTitleLabel(system.title)] })] })), _jsxs("details", { class: "group about-card", open: true, children: [_jsx(CardHeader, { icon: iconPath("pencil"), title: _jsx("h3", { children: t("Development notes") }), open: true, onToggle: () => undefined, fixed: true }), _jsx("p", { children: t("Developed with the help of AI coding agents. Everything is designed, reviewed and tested by the project's human maintainer.") }), _jsxs("p", { class: "about-motto", children: [_jsx("strong", { children: t("We encourage everyone to use AI for their own purposes.") }), _jsx("br", {}), t("The means of production should belong to the people."), _jsx("br", {}), t("Fight corporate control of technology, not our right to use it.")] })] }), _jsxs("details", { class: "group about-card", open: true, children: [_jsx(CardHeader, { icon: iconPath("licence"), title: _jsx("h3", { children: t("Licence") }), open: true, onToggle: () => undefined, fixed: true }), _jsxs("div", { class: "about-licence", children: [_jsx(Icon, { name: "github" }), _jsxs("div", { children: [_jsx("h4", { children: product }), _jsx("p", { children: t("Open source, under the MIT licence.") }), _jsxs("a", { class: "about-link", href: mitLicence, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "licence" }), t("Read the MIT licence")] })] })] }), system?.attribution && (_jsxs("div", { class: "about-licence", children: [_jsx(Icon, { name: "dice" }), _jsxs("div", { children: [_jsx("h4", { children: `${t("Credits")} · ${system.name}` }), _jsx("p", { class: "about-credits", children: withLinks(system.attribution) })] })] })), _jsxs("div", { class: "about-licence", children: [_jsx(Icon, { name: "journal" }), _jsxs("div", { children: [_jsx("h4", { children: t("Your game") }), _jsx("p", { children: t("{product} ships only original or open-licensed content. Anything else that appears in your game is written by your AI or by you, as pages of your campaign on your computer: it is not part of {product}, and we do not distribute it.", { product }) })] })] })] })
|
|
17
|
+
return (_jsxs("section", { class: "page-stack about", "aria-labelledby": "about-title", children: [_jsx(PageHead, { section: "about", id: "about-title" }), _jsxs("article", { class: "about-hero", children: [_jsx("img", { src: "/assets/icon-180.png", alt: "" }), _jsxs("div", { children: [_jsx("h3", { children: product }), _jsx("p", { children: t("The dashboard of the campaign, beside the chat where you play.") }), _jsxs("p", { class: "about-links", children: [_jsxs("a", { class: "about-link", href: footLinks.github, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "github" }), "GitHub"] }), _jsxs("a", { class: "about-link", href: footLinks.npm, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "npm" }), "npm"] }), _jsxs("a", { class: "about-link", href: footLinks.support, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "heart" }), t("Support {product}", { product })] })] })] })] }), system && (_jsxs("details", { class: "group about-card about-system", open: true, children: [_jsx(CardHeader, { icon: iconPath("dice"), title: _jsx("h3", { children: t("Game system") }), open: true, onToggle: () => undefined, fixed: true }), _jsxs("p", { children: [_jsx("span", { class: "system-chip", children: systemNameLabel(system.name) }), systemTitleLabel(system.title)] })] })), _jsxs("details", { class: "group about-card", open: true, children: [_jsx(CardHeader, { icon: iconPath("pencil"), title: _jsx("h3", { children: t("Development notes") }), open: true, onToggle: () => undefined, fixed: true }), _jsx("p", { children: t("Developed with the help of AI coding agents. Everything is designed, reviewed and tested by the project's human maintainer.") }), _jsxs("p", { class: "about-motto", children: [_jsx("strong", { children: t("We encourage everyone to use AI for their own purposes.") }), _jsx("br", {}), t("The means of production should belong to the people."), _jsx("br", {}), t("Fight corporate control of technology, not our right to use it.")] })] }), _jsxs("details", { class: "group about-card", open: true, children: [_jsx(CardHeader, { icon: iconPath("licence"), title: _jsx("h3", { children: t("Licence") }), open: true, onToggle: () => undefined, fixed: true }), _jsxs("div", { class: "about-licence", children: [_jsx(Icon, { name: "github" }), _jsxs("div", { children: [_jsx("h4", { children: product }), _jsx("p", { children: t("Open source, under the MIT licence.") }), _jsxs("a", { class: "about-link", href: mitLicence, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "licence" }), t("Read the MIT licence")] })] })] }), system?.attribution && (_jsxs("div", { class: "about-licence", children: [_jsx(Icon, { name: "dice" }), _jsxs("div", { children: [_jsx("h4", { children: `${t("Credits")} · ${systemNameLabel(system.name)}` }), _jsx("p", { class: "about-credits", children: withLinks(system.attribution) })] })] })), _jsxs("div", { class: "about-licence", children: [_jsx(Icon, { name: "journal" }), _jsxs("div", { children: [_jsx("h4", { children: t("Your game") }), _jsx("p", { children: t("{product} ships only original or open-licensed content. Anything else that appears in your game is written by your AI or by you, as pages of your campaign on your computer: it is not part of {product}, and we do not distribute it.", { product }) })] })] })] })] }));
|
|
18
18
|
}
|
|
19
|
-
/** The MIT licence's text, where it is read
|
|
19
|
+
/** The MIT licence's text, where it is read. */
|
|
20
20
|
const mitLicence = "https://opensource.org/license/mit";
|
|
21
21
|
/** A credit's text with its addresses as links, the full stop after one left out of it. */
|
|
22
22
|
function withLinks(text) {
|
|
@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from "preact/hooks";
|
|
|
5
5
|
import { Icon } from "../icons.js";
|
|
6
6
|
import { t } from "../text.js";
|
|
7
7
|
import { PlaceMap } from "./map-view.js";
|
|
8
|
-
import { isStandable, squareOf } from "./map.js";
|
|
8
|
+
import { isStandable, squareName, squareOf } from "./map.js";
|
|
9
9
|
export function MapSheet({ map, place, question, onPick, onClose }) {
|
|
10
10
|
const [selected, setSelected] = useState();
|
|
11
11
|
const [typed, setTyped] = useState("");
|
|
@@ -24,8 +24,9 @@ export function MapSheet({ map, place, question, onPick, onClose }) {
|
|
|
24
24
|
};
|
|
25
25
|
const send = (event) => {
|
|
26
26
|
event.preventDefault();
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// As the map names it, A1 for a01 or A0001, which the master reads and the engine takes.
|
|
28
|
+
if (square !== undefined && standable) {
|
|
29
|
+
onPick(squareName(square));
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
return (_jsxs("dialog", { ref: dialog, class: "map-sheet", "aria-labelledby": "map-sheet-title", onClose: onClose, children: [_jsxs("header", { class: "map-sheet-head", children: [_jsx("h2", { id: "map-sheet-title", children: question }), _jsx("button", { type: "button", class: "icon-button tip-left", "aria-label": t("Close"), "data-tip": t("Close"), onClick: () => dialog.current?.close(), children: _jsx(Icon, { name: "close" }) })] }), _jsx("div", { class: "map-sheet-body", children: _jsx(PlaceMap, { map: map, place: place, picking: { selected: written === "" ? selected : undefined, onSelect: pick } }) }), _jsxs("form", { class: "map-sheet-bar", onSubmit: send, children: [_jsx("input", { type: "text", value: typed, maxLength: 5, placeholder: selected ?? "E4", "aria-label": t("The square, such as E4"), onInput: (event) => setTyped(event.currentTarget.value) }), _jsx("button", { type: "submit", class: "map-sheet-go", disabled: !standable, children: chosen === undefined ? t("Touch a square") : standable ? t("Move to {square}", { square: chosen }) : t("{square}: no one stands there", { square: chosen }) })] })] }));
|
|
@@ -9,12 +9,12 @@ import { TalkName, usePlayerActs } from "../acts/names.js";
|
|
|
9
9
|
import { CardHead } from "../card.js";
|
|
10
10
|
import { Glass, GlassDefs } from "../glass.js";
|
|
11
11
|
import { iconPath } from "../icons.js";
|
|
12
|
-
import { strangerLabel } from "../labels.js";
|
|
12
|
+
import { shownText, strangerLabel } from "../labels.js";
|
|
13
13
|
import { WidgetsContext } from "../packages/widgets.js";
|
|
14
14
|
import { sideIcons, sideOf } from "../party.js";
|
|
15
15
|
import { conditionsPref, tokenSymbolsPref, useChoice, usePref } from "../prefs.js";
|
|
16
16
|
import { personState, statusMarks, statusWords } from "../status.js";
|
|
17
|
-
import { t } from "../text.js";
|
|
17
|
+
import { pageDirection, t } from "../text.js";
|
|
18
18
|
import { columnName, exitSide, floorLoops, groundKinds, isSolid, isStandable, isWalled, kindAt, nextTo, piecesOf, squareName, squareOf, symbolAt, tracedLoop } from "./map.js";
|
|
19
19
|
// How wide a square is drawn, in pixels.
|
|
20
20
|
const size = 40;
|
|
@@ -68,8 +68,20 @@ export function PlaceMap({ map, place, acting, picking, choosing, bare = false,
|
|
|
68
68
|
: Array.from({ length: (self.side ?? 1) ** 2 }, (_, index) => ({ column: self.at.column + (index % (self.side ?? 1)), row: self.at.row + Math.floor(index / (self.side ?? 1)) }))),
|
|
69
69
|
];
|
|
70
70
|
const letters = Math.max(11, 11 / scale);
|
|
71
|
+
const frame = useRef(null);
|
|
72
|
+
// On a phone the map keeps squares a finger can read and scrolls aside (D-547): it opens with the player's character in the middle.
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const box = frame.current;
|
|
75
|
+
if (box === null || self === undefined || box.scrollWidth <= box.clientWidth) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const [x] = middle(self);
|
|
79
|
+
const shown = box.scrollWidth / width;
|
|
80
|
+
// The frame keeps its squares left to right in every language, so its scroll does too.
|
|
81
|
+
box.scrollLeft = Math.max(0, x * shown - box.clientWidth / 2);
|
|
82
|
+
}, [map.columns, map.rows, self?.at.column, self?.at.row]);
|
|
71
83
|
const drawn = (_jsxs(_Fragment, { children: [_jsx("path", { class: "lm-floor-fill", d: floor, "fill-rule": "evenodd" }), _jsx("g", { class: "lm-ground", "clip-path": "url(#lm-open)", children: open.filter((square) => groundKinds.includes(kindAt(map, square))).map((square) => _jsx(Ground, { kind: kindAt(map, square), x: X(square.column), y: Y(square.row), side: size, seed: square }, squareName(square))) }), _jsx("path", { class: "lm-grid", d: open.map((square) => `M${X(square.column)} ${Y(square.row)}h${size}v${size}h${-size}z`).join(""), "clip-path": "url(#lm-open)" }), open.filter((square) => featureAt(square)?.difficult).map((square) => _jsx(Corner, { x: X(square.column), y: Y(square.row), side: size }, squareName(square))), things.map((feature) => piecesOf(map, feature.symbol, feature.kind).map((piece) => (_jsxs("g", { class: `lm-thing ${feature.kind}`, children: [_jsx("title", { children: [featureName(feature), feature.blocks ? t("blocks") : "", feature.difficult ? t("difficult") : ""].filter((part) => part !== "").join(", ") }), _jsx(Thing, { kind: feature.kind, symbol: feature.symbol, x: X(piece.left), y: Y(piece.top), w: (piece.right - piece.left) * size, h: (piece.bottom - piece.top) * size, cells: piece.squares.map((square) => [X(square.column), Y(square.row)]) })] }, `${feature.symbol} ${piece.left} ${piece.top}`)))), _jsx("path", { class: "lm-shade", d: outline, "clip-path": "url(#lm-open)", filter: "url(#lm-blur)" })] }));
|
|
72
|
-
return (_jsxs("section", { class: "lm", "aria-labelledby": "lm-title", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "lm-title", children: t("Map") }), note: place }), _jsx("div", { class: picking === undefined && choosing === undefined ? "lm-frame" : "lm-frame panned", children: _jsxs("svg", { ref: svg, class: `lm-svg lm-look-${map.ground}`, viewBox: `0 0 ${width} ${height}`, ...(picking === undefined && choosing === undefined ? {} : { width: width * 1.2 }), role: "img", "aria-label": t("Map of {place}", { place }), children: [_jsxs("defs", { children: [_jsx(Patterns, {}), _jsx(GlassDefs, { prefix: "lm" }), _jsxs("radialGradient", { id: "lm-hostile-glow", children: [_jsx("stop", { offset: "0.75", "stop-color": "#c8321f", "stop-opacity": "0.3" }), _jsx("stop", { offset: "1", "stop-color": "#c8321f", "stop-opacity": "0" })] }), _jsx("clipPath", { id: "lm-open", children: _jsx("path", { d: floor, "clip-rule": "evenodd" }) }), !walled && (_jsx("mask", { id: "lm-fade", maskUnits: "userSpaceOnUse", x: 0, y: 0, width: width, height: height, children: _jsx("rect", { x: X(0) + size * 0.35, y: Y(0) + size * 0.35, width: map.columns * size - size * 0.7, height: map.rows * size - size * 0.7, fill: "#fff", filter: "url(#lm-soft)" }) })), standing.map((one, index) => (_jsx("clipPath", { id: `lm-token-${index}`, children: _jsx("circle", { cx: middle(one)[0], cy: middle(one)[1], r: size * (one.side ?? 1) * 0.43 }) }, index)))] }), _jsx("rect", { class: "lm-paper", width: width, height: height }), _jsx("g", { class: "lm-walls", children: squares.filter((square) => ["wall", "rock", "window"].includes(kindAt(map, square)) && nearRoom(square)).map((square) => (_jsxs(Fragment, { children: [_jsx("rect", { class: "lm-wall-under", x: X(square.column), y: Y(square.row), width: size, height: size }), _jsx("rect", { class: `lm-wall ${kindAt(map, square)}`, x: X(square.column), y: Y(square.row), width: size, height: size })] }, squareName(square)))) }), walled ? drawn : _jsx("g", { mask: "url(#lm-fade)", children: drawn }), reach.length > 0 && (_jsx("g", { class: "lm-out", "aria-hidden": "true", "clip-path": "url(#lm-open)", children: open.filter((square) => !reach.some((near) => near.column === square.column && near.row === square.row)).map((square) => (_jsx("rect", { x: X(square.column), y: Y(square.row), width: size, height: size }, squareName(square)))) })), _jsx("path", { class: "lm-outline", d: outline, filter: "url(#lm-ink)" }), squares.filter((square) => ["door", "open-door", "secret-door"].includes(kindAt(map, square))).map((square) => (_jsx(Door, { kind: kindAt(map, square), name: featureAt(square)?.name ?? "door", square: square, map: map, x: X(square.column), y: Y(square.row) }, squareName(square)))), map.exits.map((exit, index) => {
|
|
84
|
+
return (_jsxs("section", { class: "lm", "aria-labelledby": "lm-title", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "lm-title", children: t("Map") }), note: place }), _jsx("div", { ref: frame, class: picking === undefined && choosing === undefined ? "lm-frame" : "lm-frame panned", style: { "--map-width": String(width) }, children: _jsxs("svg", { ref: svg, class: `lm-svg lm-look-${map.ground}`, viewBox: `0 0 ${width} ${height}`, ...(picking === undefined && choosing === undefined ? {} : { width: width * 1.2 }), role: "img", "aria-label": t("Map of {place}", { place }), children: [_jsxs("defs", { children: [_jsx(Patterns, {}), _jsx(GlassDefs, { prefix: "lm" }), _jsxs("radialGradient", { id: "lm-hostile-glow", children: [_jsx("stop", { offset: "0.75", "stop-color": "#c8321f", "stop-opacity": "0.3" }), _jsx("stop", { offset: "1", "stop-color": "#c8321f", "stop-opacity": "0" })] }), _jsx("clipPath", { id: "lm-open", children: _jsx("path", { d: floor, "clip-rule": "evenodd" }) }), !walled && (_jsx("mask", { id: "lm-fade", maskUnits: "userSpaceOnUse", x: 0, y: 0, width: width, height: height, children: _jsx("rect", { x: X(0) + size * 0.35, y: Y(0) + size * 0.35, width: map.columns * size - size * 0.7, height: map.rows * size - size * 0.7, fill: "#fff", filter: "url(#lm-soft)" }) })), standing.map((one, index) => (_jsx("clipPath", { id: `lm-token-${index}`, children: _jsx("circle", { cx: middle(one)[0], cy: middle(one)[1], r: size * (one.side ?? 1) * 0.43 }) }, index)))] }), _jsx("rect", { class: "lm-paper", width: width, height: height }), _jsx("g", { class: "lm-walls", children: squares.filter((square) => ["wall", "rock", "window"].includes(kindAt(map, square)) && nearRoom(square)).map((square) => (_jsxs(Fragment, { children: [_jsx("rect", { class: "lm-wall-under", x: X(square.column), y: Y(square.row), width: size, height: size }), _jsx("rect", { class: `lm-wall ${kindAt(map, square)}`, x: X(square.column), y: Y(square.row), width: size, height: size })] }, squareName(square)))) }), walled ? drawn : _jsx("g", { mask: "url(#lm-fade)", children: drawn }), reach.length > 0 && (_jsx("g", { class: "lm-out", "aria-hidden": "true", "clip-path": "url(#lm-open)", children: open.filter((square) => !reach.some((near) => near.column === square.column && near.row === square.row)).map((square) => (_jsx("rect", { x: X(square.column), y: Y(square.row), width: size, height: size }, squareName(square)))) })), _jsx("path", { class: "lm-outline", d: outline, filter: "url(#lm-ink)" }), squares.filter((square) => ["door", "open-door", "secret-door"].includes(kindAt(map, square))).map((square) => (_jsx(Door, { kind: kindAt(map, square), name: featureAt(square)?.name ?? "door", square: square, map: map, x: X(square.column), y: Y(square.row) }, squareName(square)))), map.exits.map((exit, index) => {
|
|
73
85
|
const square = squareOf(exit.square);
|
|
74
86
|
return square === undefined ? null : _jsx(Exit, { side: sides[index], to: exit.to, x: X(square.column) + size / 2, y: Y(square.row) + size / 2, letters: Math.max(13, 12 / scale) }, exit.square);
|
|
75
87
|
}), _jsxs("g", { class: "lm-coordinates", "font-size": letters, children: [Array.from({ length: map.columns }, (_, column) => _jsx("text", { x: X(column) + size / 2, y: top - 10, "text-anchor": "middle", children: columnName(column) }, `c${column}`)), Array.from({ length: map.rows }, (_, row) => _jsx("text", { x: left - 10, y: Y(row) + size / 2, "text-anchor": "end", "dominant-baseline": "middle", children: row + 1 }, `r${row}`))] }), _jsx("g", { class: "lm-tokens", children: standing.map((one, index) => {
|
|
@@ -87,7 +99,7 @@ export function PlaceMap({ map, place, acting, picking, choosing, bare = false,
|
|
|
87
99
|
: (_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
|
|
88
100
|
? _jsx("span", { class: "lm-where-far", children: t("from here") })
|
|
89
101
|
: one.distance !== undefined
|
|
90
|
-
? _jsx("span", { class: "lm-where-far", children: one.distance })
|
|
102
|
+
? _jsx("span", { class: "lm-where-far", children: shownText(one.distance) })
|
|
91
103
|
: self !== undefined && one !== self && (nextTo(one.at, self.at) || one.square === self.square) && (_jsx("span", { class: "lm-where-far", children: selfName === undefined ? t("next to you") : t("next to {name}", { name: selfName }) }))] }, index))) }))] }));
|
|
92
104
|
}
|
|
93
105
|
/** The one the distances are from before anyone else, when named: a negative number puts the first before the second. */
|
|
@@ -96,7 +108,7 @@ function measuredFirst(first, second, from) {
|
|
|
96
108
|
}
|
|
97
109
|
/** The map's key: the veil of the player's turn, named with more than one player character, the things of the legend, where the squares lead. */
|
|
98
110
|
function MapKey({ map, reach, self }) {
|
|
99
|
-
return (_jsxs("ul", { class: "lm-key", "aria-label": t("Legend"), children: [reach && (_jsxs("li", { children: [_jsxs("svg", { class: `lm-swatch lm-look-${map.ground}`, viewBox: "0 0 40 40", "aria-hidden": "true", children: [_jsx("rect", { class: "lm-floor-fill", width: 40, height: 40 }), _jsx("g", { class: "lm-out", children: _jsx("rect", { width: 40, height: 40 }) })] }), _jsx("span", { class: "lm-key-name", children: self === undefined ? t("out of your move this turn") : t("out of {name}'s move this turn", { name: self }) })] })), map.legend.filter((feature) => !["floor", "ground"].includes(feature.kind)).map((feature) => (_jsxs("li", { children: [_jsx(Swatch, { feature: feature, ground: map.ground }), _jsx("span", { class: "lm-key-name", children: featureName(feature) }), feature.blocks && !["wall", "rock"].includes(feature.kind) && _jsx("span", { class: "lm-key-note", children: t("blocks") }), feature.difficult && _jsx("span", { class: "lm-key-note", children: t("difficult") })] }, feature.symbol))), map.exits.map((exit) => (_jsxs("li", { class: "lm-key-exit", children: [_jsx("span", { class: "lm-key-square", children: exit.square }), _jsx("span", { children:
|
|
111
|
+
return (_jsxs("ul", { class: "lm-key", "aria-label": t("Legend"), children: [reach && (_jsxs("li", { children: [_jsxs("svg", { class: `lm-swatch lm-look-${map.ground}`, viewBox: "0 0 40 40", "aria-hidden": "true", children: [_jsx("rect", { class: "lm-floor-fill", width: 40, height: 40 }), _jsx("g", { class: "lm-out", children: _jsx("rect", { width: 40, height: 40 }) })] }), _jsx("span", { class: "lm-key-name", children: self === undefined ? t("out of your move this turn") : t("out of {name}'s move this turn", { name: self }) })] })), map.legend.filter((feature) => !["floor", "ground"].includes(feature.kind)).map((feature) => (_jsxs("li", { children: [_jsx(Swatch, { feature: feature, ground: map.ground }), _jsx("span", { class: "lm-key-name", children: featureName(feature) }), feature.blocks && !["wall", "rock"].includes(feature.kind) && _jsx("span", { class: "lm-key-note", children: t("blocks") }), feature.difficult && _jsx("span", { class: "lm-key-note", children: t("difficult") })] }, feature.symbol))), map.exits.map((exit) => (_jsxs("li", { class: "lm-key-exit", children: [_jsx("span", { class: "lm-key-square", children: exit.square }), _jsx("span", { children: `${pageDirection() === "rtl" ? "←" : "→"} ${exit.to ?? t("somewhere")}` })] }, exit.square)))] }));
|
|
100
112
|
}
|
|
101
113
|
/** How much the map is scaled on the screen, from its drawn width to its shown one: the letters around it keep a readable size on a phone. */
|
|
102
114
|
function useScale(svg) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// What the engine turned down, in the page's language (T-162): the server gives a refusal's code and values beside the engine's own words, which the master
|
|
2
|
+
// reads; the page says each code it knows in its words, and the engine's for one it does not know. npm's reasons stay npm's.
|
|
3
|
+
import { t } from "./text.js";
|
|
4
|
+
/** A refusal in the page's words by its code and values; the engine's words for a code the page does not know, or `otherwise` without any. */
|
|
5
|
+
export function refusalText(refused, otherwise) {
|
|
6
|
+
const values = refused.values ?? {};
|
|
7
|
+
const say = refused.code === undefined || !Object.hasOwn(phrases, refused.code) ? undefined : phrases[refused.code](values);
|
|
8
|
+
return say ?? refused.error ?? otherwise;
|
|
9
|
+
}
|
|
10
|
+
const phrases = {
|
|
11
|
+
"not-on-computer": (values) => t("There is no {name} on this computer: give its full path.", values),
|
|
12
|
+
"not-found": (values) => t("npm has no package {name}: check its name.", values),
|
|
13
|
+
"npm-failed": (values) => t("npm did not answer about {name}: {why}", values),
|
|
14
|
+
"not-ours": (values) => t("{name} is not a package for RPG Engine.", values),
|
|
15
|
+
"other-kind": (values) => t("{name} is a kind of package that is not added this way.", values),
|
|
16
|
+
"engine-too-old": (values) => t("{name} {version} needs a newer RPG Engine: update it in Installed.", values),
|
|
17
|
+
"package-too-old": (values) => t("{name} {version} was made for an older RPG Engine: look for a newer version of it.", values),
|
|
18
|
+
"install-failed": (values) => t("npm could not install {name}: {why}", values),
|
|
19
|
+
"taken-off": (values) => t("RPG Engine cannot use {name}, and took it off this computer again.", values),
|
|
20
|
+
"other-system": (values) => values.plays === "" ? t("{name} is for {system}, and this campaign has no game system yet.", values) : t("{name} is for {system}, and this campaign plays {plays}: it does not use it.", values),
|
|
21
|
+
"system-name": (values) => t("{name} has the name of the game system this campaign plays: it does not use it.", values),
|
|
22
|
+
"same-name": (values) => t("This campaign uses {other}, with the same name as {name}: take it out first.", values),
|
|
23
|
+
"code-broken": (values) => t("The code of {name} does not work: {why}", values),
|
|
24
|
+
"system-taken": (values) => t("There is already a game system called {system} on this computer: {name} would take its name.", values),
|
|
25
|
+
"system-unread": (values) => t("{name} was installed, but it does not read as a game system: uninstall it.", values),
|
|
26
|
+
"language-code": (values) => t("{name} says it is a language, but brings code: a language is texts only.", values),
|
|
27
|
+
"language-refused": (values) => t("{name} cannot be used, and was taken off this computer: {why}", values),
|
|
28
|
+
"language-kept": (values) => t("{name} cannot be used, and version {version} stays: {why}", values),
|
|
29
|
+
"not-used": (values) => t("This campaign does not use {name}.", values),
|
|
30
|
+
"system-played": (values) => t("This campaign plays {name}: it stays on this computer.", values),
|
|
31
|
+
"uninstall-failed": (values) => t("npm could not take {name} off this computer: {why}", values),
|
|
32
|
+
"not-here": (values) => t("{name} is not on this computer.", values),
|
|
33
|
+
"document": (values) => t("{name} is a document, not a package: ask the master to import it.", values),
|
|
34
|
+
"adventure-played": (values) => t("This campaign has {name} {version}, already in play: an adventure in play is not updated.", values),
|
|
35
|
+
"adventure-halfway": (values) => t("Adding {name} stopped halfway: add it again first.", values),
|
|
36
|
+
"adventure-names": (values) => t("{name} has pages with names this campaign already uses: {names}", values),
|
|
37
|
+
"adventure-in-story": (values) => t("{name} is part of the story now: it stays.", values),
|
|
38
|
+
"adventure-needs": (values) => t("{name} needs the extension {needs}: add it first.", values),
|
|
39
|
+
"adventure-needs-newer": (values) => t("{name} needs {needs} {version} or later, and this campaign has {has}: update it first.", values),
|
|
40
|
+
"export-played": () => t("The campaign has been played and has no save of its start: keep it as a save of the whole game instead."),
|
|
41
|
+
"archive-big": (values) => t("{name} unpacks to more than {size} MB, more than a package may.", values),
|
|
42
|
+
"archive-unread": (values) => t("{name} does not read: it is not a package's .zip or .tgz.", values),
|
|
43
|
+
"archive-link": (values) => t("{name} holds {entry}, which is not a plain file: it is refused whole.", values),
|
|
44
|
+
"archive-accents": (values) => t("{name} names files with accents in another encoding: make the zip again with 7-Zip.", values),
|
|
45
|
+
"not-adventure": (values) => t("{name} is not an adventure: it has no adventure.yaml at its top. A document is imported by the master.", values),
|
|
46
|
+
"adventure-file": (values) => t("{name} holds {file}, which an adventure may not hold: it is refused whole.", values),
|
|
47
|
+
"not-a-name": (values) => t("{name} is not the name of an npm package.", values),
|
|
48
|
+
"folder-characters": (values) => t("The folder {name} has characters npm cannot take: move it to another path.", values),
|
|
49
|
+
"not-a-book": (values) => t("{name} is no book RPG Engine reads: give a {kinds} file, or a folder of them.", values),
|
|
50
|
+
"books-in-campaign": (values) => t("{name} is inside a campaign: your books stay outside every campaign.", values),
|
|
51
|
+
"books-crowded": (values) => t("{name} holds more than {count} documents: give the folder with this game's books.", values),
|
|
52
|
+
"not-full-path": (values) => t("{name} is no full path: write it from its drive or its root.", values),
|
|
53
|
+
"engine-offline": () => t("npm cannot be reached: update RPG Engine once this computer is online."),
|
|
54
|
+
"engine-latest": (values) => t("RPG Engine {version} is the latest: there is nothing to update.", values),
|
|
55
|
+
"engine-installed": (values) => t("RPG Engine {version} is installed already: it comes with a new chat.", values),
|
|
56
|
+
"engine-link": (values) => t("This RPG Engine is a development link to {name}: update it there.", values),
|
|
57
|
+
"engine-elsewhere": (values) => t("This RPG Engine runs from {name}: update it the way it was installed.", values),
|
|
58
|
+
"engine-failed": (values) => t("npm could not update RPG Engine: {why}", values),
|
|
59
|
+
"file-big": (values) => t("The file is more than {size} MB: no package is that big.", values),
|
|
60
|
+
"file-kind": (values) => t("{name} is neither a .zip nor a .tgz.", values),
|
|
61
|
+
};
|
package/dist/dashboard/rolls.js
CHANGED
|
@@ -12,7 +12,7 @@ import { cardIcons, Icon } from "./icons.js";
|
|
|
12
12
|
import { notationModifier, strangerLabel } from "./labels.js";
|
|
13
13
|
import { rollWindow } from "./layout.js";
|
|
14
14
|
import { Token } from "./party.js";
|
|
15
|
-
import { capitalized, t } from "./text.js";
|
|
15
|
+
import { capitalized, pageLocale, t } from "./text.js";
|
|
16
16
|
// Where the browser remembers when the player last cleared the list of a campaign; how many older rolls each Load more shows.
|
|
17
17
|
const clearedKey = "rpg-engine.rolls-cleared";
|
|
18
18
|
const moreRolls = 10;
|
|
@@ -86,7 +86,7 @@ function RollRow({ roll, name, token, coins, fresh, greeted, several }) {
|
|
|
86
86
|
? _jsx("img", { class: "roll-robot", src: "/assets/favicon.svg", alt: "" })
|
|
87
87
|
: token === "die"
|
|
88
88
|
? (_jsx("span", { class: "token roll-die", "aria-hidden": "true", children: _jsx(Icon, { name: "dice" }) }))
|
|
89
|
-
: _jsx(Token, { member: token }), _jsxs("span", { class: "roll-who", children: [_jsx("span", { class: "visually-hidden", children: `${marked ? t("New.") + " " : ""}${free ? t("Your free roll, not logged:") : player ? (several ? t("The players' roll:") : t("Your roll:")) : t("The master's roll:")} ` }), name] }), roll.check && _jsx("span", { class: "roll-check", children: roll.check }), roll.toss !== undefined
|
|
89
|
+
: _jsx(Token, { member: token }), _jsxs("span", { class: "roll-who", children: [_jsx("span", { class: "visually-hidden", children: `${marked ? t("New.") + " " : ""}${free ? t("Your free roll, not logged:") : player ? (several ? t("The players' roll:") : t("Your roll:")) : t("The master's roll:")} ` }), name] }), roll.check && _jsx("span", { class: "roll-check", dir: "auto", children: roll.check }), roll.toss !== undefined
|
|
90
90
|
? _jsx(CoinFaces, { toss: roll.toss, className: "roll-total roll-coins", ...(coins === undefined ? {} : { look: coins }) })
|
|
91
91
|
: roll.says === undefined
|
|
92
92
|
? _jsx("span", { class: "roll-total num", children: roll.total })
|
|
@@ -189,7 +189,7 @@ function useMoreBelow(scroller) {
|
|
|
189
189
|
/** When a roll was made: the game's day and hour, and the real time, as "day 1, 18:00 in the game · rolled at 18:15". */
|
|
190
190
|
function rolledWhen(roll) {
|
|
191
191
|
const real = new Date(roll.at);
|
|
192
|
-
const time = Number.isNaN(real.getTime()) ? undefined : t("rolled at {time}", { time: real.toLocaleTimeString(
|
|
192
|
+
const time = Number.isNaN(real.getTime()) ? undefined : t("rolled at {time}", { time: real.toLocaleTimeString(pageLocale(), { hour: "2-digit", minute: "2-digit" }) });
|
|
193
193
|
return [roll.date === undefined ? undefined : t("{date} in the game", { date: gameDateLabel(roll.date) }), time].filter((part) => part !== undefined).join(" · ");
|
|
194
194
|
}
|
|
195
195
|
/** The look of the coins of a toss of the master's for no one of the party: their dice's material (D-526 (3)); undefined for the player's. */
|
|
@@ -32,7 +32,12 @@ export function SettingsView({ version, several = false }) {
|
|
|
32
32
|
// Only the last reading counts, as after quick changes.
|
|
33
33
|
const read = () => {
|
|
34
34
|
const reading = ++reads.current;
|
|
35
|
-
void readSettings().then((read) =>
|
|
35
|
+
void readSettings().then((read) => {
|
|
36
|
+
if (reading === reads.current) {
|
|
37
|
+
setSettings(read);
|
|
38
|
+
setProblem(undefined);
|
|
39
|
+
}
|
|
40
|
+
}, (error) => reading === reads.current && setProblem(error instanceof Error ? error.message : String(error)));
|
|
36
41
|
};
|
|
37
42
|
// Read again whenever the campaign changes, as after a change made here or by the master.
|
|
38
43
|
useEffect(read, [version]);
|
|
@@ -299,9 +304,10 @@ function gameStyleRows() {
|
|
|
299
304
|
const name = t("Game style");
|
|
300
305
|
if (!style.shows) {
|
|
301
306
|
const means = t("This game's style does not pass the page's check of legibility: the page keeps its own.");
|
|
302
|
-
return [{ name, about: t("the colours, faces and pictures of the game system"), options: [{ value: "page", label: t("The page's"), means }], value: "page", pick: () => undefined }];
|
|
307
|
+
return [{ key: "game-style", name, about: t("the colours, faces and pictures of the game system"), options: [{ value: "page", label: t("The page's"), means }], value: "page", pick: () => undefined }];
|
|
303
308
|
}
|
|
304
309
|
return [{
|
|
310
|
+
key: "game-style",
|
|
305
311
|
name,
|
|
306
312
|
about: style.name === undefined ? t("the colours, faces and pictures of the game system") : t("the colours, faces and pictures of {name}, from the game system", { name: style.name }),
|
|
307
313
|
options: [{ value: "game", label: t("The game's") }, { value: "page", label: t("The page's") }],
|
|
@@ -329,6 +335,7 @@ function PageSettings() {
|
|
|
329
335
|
const [conditions, setConditions] = useChoice(conditionsPref);
|
|
330
336
|
const rows = [
|
|
331
337
|
{
|
|
338
|
+
key: "theme",
|
|
332
339
|
name: t("Theme"),
|
|
333
340
|
about: t("the page's look"),
|
|
334
341
|
options: [{ value: "light", label: t("Light") }, { value: "dark", label: t("Dark") }],
|
|
@@ -337,6 +344,7 @@ function PageSettings() {
|
|
|
337
344
|
},
|
|
338
345
|
...gameStyleRows(),
|
|
339
346
|
{
|
|
347
|
+
key: "token-symbols",
|
|
340
348
|
name: t("Token symbols"),
|
|
341
349
|
about: t("a mark on each token: you, your companions, your foes"),
|
|
342
350
|
options: [{ value: "on", label: t("On") }, { value: "off", label: t("Off") }],
|
|
@@ -344,14 +352,16 @@ function PageSettings() {
|
|
|
344
352
|
pick: (value) => setSymbols(value === "on"),
|
|
345
353
|
},
|
|
346
354
|
{
|
|
355
|
+
key: "conditions",
|
|
347
356
|
name: t("Conditions on tokens"),
|
|
348
357
|
about: t("a mark on each token: what is on them, who is down"),
|
|
349
358
|
options: [{ value: "always", label: t("Always") }, { value: "hover", label: t("On hover") }, { value: "never", label: t("Never") }],
|
|
350
359
|
value: conditions,
|
|
351
360
|
pick: setConditions,
|
|
352
361
|
},
|
|
353
|
-
{ name: t("Dice sound"), about: t("the dice as they roll"), options: [{ value: "on", label: t("On") }, { value: "off", label: t("Off") }], value: sound ? "on" : "off", pick: (value) => setSound(value === "on") },
|
|
362
|
+
{ key: "dice-sound", name: t("Dice sound"), about: t("the dice as they roll"), options: [{ value: "on", label: t("On") }, { value: "off", label: t("Off") }], value: sound ? "on" : "off", pick: (value) => setSound(value === "on") },
|
|
354
363
|
{
|
|
364
|
+
key: "dice-set",
|
|
355
365
|
name: t("Dice set"),
|
|
356
366
|
about: t("what your dice are made of"),
|
|
357
367
|
options: diceSets.map((set) => ({ value: set.value, label: diceSetLabel(set.value) ?? set.label, picture: _jsx(SetSwatch, { value: set.value }) })),
|
|
@@ -361,6 +371,7 @@ function PageSettings() {
|
|
|
361
371
|
},
|
|
362
372
|
// Beside the dice, the coins: of the dice's material, the initial choice, which follows the set chosen, or of a metal (D-526 (1)).
|
|
363
373
|
{
|
|
374
|
+
key: "coins",
|
|
364
375
|
name: t("Coins"),
|
|
365
376
|
about: t("what your coins are made of"),
|
|
366
377
|
options: [
|
|
@@ -373,6 +384,7 @@ function PageSettings() {
|
|
|
373
384
|
},
|
|
374
385
|
// Under them, their design, heads and tails side by side, of the material chosen (D-526 (2)).
|
|
375
386
|
{
|
|
387
|
+
key: "coin-design",
|
|
376
388
|
name: t("Coin design"),
|
|
377
389
|
about: t("the pictures on your coins, heads first"),
|
|
378
390
|
options: coinDesigns.map((one) => ({ value: one.value, label: coinDesignLabel(one.value) ?? one.label, picture: _jsx(CoinPair, { design: one.value }) })),
|
|
@@ -381,6 +393,7 @@ function PageSettings() {
|
|
|
381
393
|
under: true,
|
|
382
394
|
},
|
|
383
395
|
{
|
|
396
|
+
key: "dice-edges",
|
|
384
397
|
name: t("Dice edges"),
|
|
385
398
|
about: t("how the dice's edges are cut"),
|
|
386
399
|
options: [{ value: "rounded", label: t("Rounded") }, { value: "sharp", label: t("Sharp") }],
|
|
@@ -388,6 +401,7 @@ function PageSettings() {
|
|
|
388
401
|
pick: setEdges,
|
|
389
402
|
},
|
|
390
403
|
{
|
|
404
|
+
key: "checks",
|
|
391
405
|
name: t("Checks"),
|
|
392
406
|
about: t("what the master asks you to roll"),
|
|
393
407
|
options: [
|
|
@@ -399,9 +413,9 @@ function PageSettings() {
|
|
|
399
413
|
},
|
|
400
414
|
];
|
|
401
415
|
return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: t("This page") }), _jsx("p", { class: "setting-about", children: t("Kept in this browser alone.") }), rows.map((row) => {
|
|
402
|
-
const id = `page-${
|
|
416
|
+
const id = `page-${row.key}`;
|
|
403
417
|
const chosen = row.options.find((option) => option.value === row.value);
|
|
404
|
-
return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: chosen?.means === undefined ? `${id}-about` : `${id}-about ${id}-means`, options: row.options, value: row.value, onPick: row.pick }), chosen?.means !== undefined && (_jsx("div", { class: "setting-after", children: _jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] }) }))] }, row.
|
|
418
|
+
return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: chosen?.means === undefined ? `${id}-about` : `${id}-about ${id}-means`, options: row.options, value: row.value, onPick: row.pick }), chosen?.means !== undefined && (_jsx("div", { class: "setting-after", children: _jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] }) }))] }, row.key));
|
|
405
419
|
})] }));
|
|
406
420
|
}
|
|
407
421
|
/**
|
package/dist/dashboard/sheet.js
CHANGED
|
@@ -7,7 +7,7 @@ import { CardHeader, useOpen } from "./card.js";
|
|
|
7
7
|
import { FixedColumns } from "./columns.js";
|
|
8
8
|
import { besideLabel, memberPlaceLabel } from "./game-words.js";
|
|
9
9
|
import { cardIcons, DieIcon, Icon } from "./icons.js";
|
|
10
|
-
import { fieldLabel, groupLabels, phraseLabel, readableIds, rollLabel, shownNotation, shownText } from "./labels.js";
|
|
10
|
+
import { fieldLabel, groupLabels, itemLabel, phraseLabel, readableIds, rollLabel, shownNotation, shownText } from "./labels.js";
|
|
11
11
|
import { arrangedGroups, groupLayout, orderedValues, widgetOf } from "./layout.js";
|
|
12
12
|
import { knowersOf, Markdown, plainLine } from "./markdown.js";
|
|
13
13
|
import { MoodFace, moodLabel } from "./mood.js";
|
|
@@ -118,7 +118,7 @@ function Group({ member, group, fields, version, onRoll, first }) {
|
|
|
118
118
|
const line = (value) => ({ value, label: label(value.field), fields, tip: tip(value), tabIndex: stop(value.field), onRoll: throwOf, answers: answersOf(value) });
|
|
119
119
|
// A card with the number the master asks stays open while it is asked.
|
|
120
120
|
const lit = values.some((value) => answersOf(value) !== undefined);
|
|
121
|
-
return (_jsxs(Card, { name: group.name, title: systemWord("groups", group.name) ?? systemWord("words", group.name), icon: group.icon ?? cardIcons.plain, layout: layout, preview: preview(group, label), onReach: explain, held: lit, first: first, children: [layout === "table" && values.length > 0 && (_jsx("div", { class: "rows", onKeyDown: onKeyDown, children: values.map((value) => _jsx(Row, { ...line(value) }, value.field)) })), layout === "table" && _jsx(ItemsTable, { group: group, fields: fields }), layout === "tiles" && (_jsx("div", { class: "tiles", onKeyDown: onKeyDown, children: values.map((value) => _jsx(Tile, { ...line(value) }, value.field)) })), layout === "rows" && (_jsx("div", { class: "rows", onKeyDown: onKeyDown, children: values.map((value) => _jsx(Row, { ...line(value) }, value.field)) }))] }));
|
|
121
|
+
return (_jsxs(Card, { name: group.name, title: systemWord("groups", group.name) ?? systemWord("words", group.name), icon: group.icon ?? cardIcons.plain, layout: layout, preview: preview(group, label, fields), onReach: explain, held: lit, first: first, children: [layout === "table" && values.length > 0 && (_jsx("div", { class: "rows", onKeyDown: onKeyDown, children: values.map((value) => _jsx(Row, { ...line(value) }, value.field)) })), layout === "table" && _jsx(ItemsTable, { group: group, fields: fields }), layout === "tiles" && (_jsx("div", { class: "tiles", onKeyDown: onKeyDown, children: values.map((value) => _jsx(Tile, { ...line(value) }, value.field)) })), layout === "rows" && (_jsx("div", { class: "rows", onKeyDown: onKeyDown, children: values.map((value) => _jsx(Row, { ...line(value) }, value.field)) }))] }));
|
|
122
122
|
}
|
|
123
123
|
/** A card of the sheet the player opens and closes (D-284): its icon and title on the left, what it holds while closed, the chevron on the right. */
|
|
124
124
|
export function Card({ name, title, icon, layout, preview, onReach, held, first, children }) {
|
|
@@ -211,7 +211,10 @@ function ItemsTable({ group, fields }) {
|
|
|
211
211
|
const labels = groupLabels(columns, fields);
|
|
212
212
|
const depths = items.map((item) => item.depth ?? 0);
|
|
213
213
|
const holds = (index) => (depths[index + 1] ?? 0) > depths[index];
|
|
214
|
-
|
|
214
|
+
// Two of the same thing in one place, as two ropes, are two lines: each its key by how many came before it.
|
|
215
|
+
const bases = items.map((item, index) => `${depths[index]} ${item.inside ?? ""} ${item.item}`);
|
|
216
|
+
const keys = bases.map((base, index) => `${base} ${bases.slice(0, index).filter((other) => other === base).length}`);
|
|
217
|
+
const key = (index) => keys[index];
|
|
215
218
|
const toggle = (index) => setClosed((before) => (before.has(key(index)) ? new Set([...before].filter((one) => one !== key(index))) : new Set([...before, key(index)])));
|
|
216
219
|
const shown = shownLines(depths, (index) => closed.has(key(index)));
|
|
217
220
|
// When something is equipped or holds other things, every name has its picture, golden on what is equipped; a container's chevron stands where the
|
|
@@ -282,11 +285,27 @@ function Changing({ text, children }) {
|
|
|
282
285
|
function sheetFields(member, sheet) {
|
|
283
286
|
return new Set([...member.counters, ...sheet.flatMap((group) => group.values)].map((value) => value.field));
|
|
284
287
|
}
|
|
285
|
-
/** What a closed group says of itself: its first values, or its items. */
|
|
286
|
-
function preview(group, label) {
|
|
288
|
+
/** What a closed group says of itself: its first values, or its items, in the words its open card writes them. */
|
|
289
|
+
function preview(group, label, fields) {
|
|
287
290
|
if (group.items !== undefined) {
|
|
288
291
|
// The group's own values first, as the money above the things carried: their text alone, as the card is narrow.
|
|
289
|
-
return [...group.values.map((value) =>
|
|
292
|
+
return [...group.values.map((value) => valueWords(value, fields)), ...group.items.map((item) => itemName(item.item))].join(" · ");
|
|
290
293
|
}
|
|
291
|
-
|
|
294
|
+
// A value named as the card is, as Features in Features, by its words alone.
|
|
295
|
+
const title = (systemWord("groups", group.name) ?? group.name).toLocaleLowerCase();
|
|
296
|
+
return group.values.slice(0, 4).map((value) => {
|
|
297
|
+
const name = label(value.field);
|
|
298
|
+
const words = valueWords(value, fields);
|
|
299
|
+
return name.toLocaleLowerCase() === title ? words : `${name} ${words}`;
|
|
300
|
+
}).join(" · ");
|
|
301
|
+
}
|
|
302
|
+
/** A value in a line of words, as its card writes it: a list's items by their names, money by its coins, any other its text. */
|
|
303
|
+
function valueWords(value, fields) {
|
|
304
|
+
if (widgetOf(value) === "list") {
|
|
305
|
+
return listText((value.items ?? []).map((item) => itemLabel(item, fields)));
|
|
306
|
+
}
|
|
307
|
+
if (value.coins !== undefined && value.coins.length > 0) {
|
|
308
|
+
return value.coins.map(({ coin, count }) => `${count} ${shownText(coin)}`).join(" ");
|
|
309
|
+
}
|
|
310
|
+
return shownText(besideLabel(value) ?? value.text, value.kind);
|
|
292
311
|
}
|
package/dist/dashboard/status.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
2
|
import { effectLabel } from "./game-words.js";
|
|
3
3
|
import { statusIcons } from "./icons.js";
|
|
4
|
+
import { textOf } from "./packages/widgets.js";
|
|
4
5
|
import { saysState } from "./person-panel.js";
|
|
5
6
|
import { conditionsPref, useChoice } from "./prefs.js";
|
|
6
|
-
import {
|
|
7
|
+
import { t } from "./text.js";
|
|
7
8
|
/**
|
|
8
9
|
* The state of someone of the party as the first widget on them that gives a word says it (D-514): its chip, the icon it shows or the widget's, its lead's
|
|
9
10
|
* tone; none where no widget on them gives one.
|
|
@@ -17,7 +18,8 @@ export function personState(widgets, name) {
|
|
|
17
18
|
const icon = shown.shows.icon ?? shown.widget.icon;
|
|
18
19
|
const tone = shown.shows.parts?.find((part) => "lead" in part && part.tone !== undefined);
|
|
19
20
|
return {
|
|
20
|
-
|
|
21
|
+
// As its chip says it, units and all (D-514).
|
|
22
|
+
word: textOf(shown.shows.chip),
|
|
21
23
|
...(icon === undefined ? {} : { icon }),
|
|
22
24
|
...(tone !== undefined && "lead" in tone && tone.tone !== undefined ? { tone: tone.tone } : {}),
|
|
23
25
|
...(shown.shows.dead === true ? { dead: true } : {}),
|
|
@@ -78,13 +80,25 @@ export function StatusPip({ status }) {
|
|
|
78
80
|
* drawn when its words already say it.
|
|
79
81
|
*/
|
|
80
82
|
export function StatusIcons({ status, said = [] }) {
|
|
81
|
-
const marks = statusMarks(status, true);
|
|
83
|
+
const marks = gatheredMarks(statusMarks(status, true));
|
|
82
84
|
return marks.length === 0 ? null : (_jsx("span", { class: "status-icons", children: marks.map((mark, index) => {
|
|
83
85
|
// A state the row already says in words, hidden from a screen reader.
|
|
84
86
|
const hidden = mark.kind === "state" && mark.tone !== undefined && said.includes(mark.tone);
|
|
85
|
-
return (
|
|
87
|
+
return (_jsxs("span", { class: ["status-icon", mark.kind, mark.tone ?? ""].filter((name) => name !== "").join(" "), ...(hidden ? { "aria-hidden": "true" } : { role: "img", "aria-label": mark.label, tabIndex: 0 }), "data-tip": mark.label, children: [_jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: mark.icon, class: mark.filled ? "filled" : undefined }) }), mark.count !== undefined && _jsx("span", { class: "status-count", "aria-hidden": "true", children: mark.count })] }, `${mark.label} ${index}`));
|
|
86
88
|
}) }));
|
|
87
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* The marks with the effects that have no drawing of their own gathered into one, its number beside it and their names in its tooltip, a line each, with its
|
|
92
|
+
* own end: two alike sparks tell nothing apart (Torch, Bless as ✦ 2); a condition or an effect with its own drawing stays alone.
|
|
93
|
+
*/
|
|
94
|
+
function gatheredMarks(marks) {
|
|
95
|
+
const plain = marks.filter((mark) => mark.kind !== "state" && mark.icon === statusIcons.condition);
|
|
96
|
+
if (plain.length < 2) {
|
|
97
|
+
return marks;
|
|
98
|
+
}
|
|
99
|
+
const gathered = { ...plain[0], label: plain.map((mark) => mark.label).join("\n"), count: plain.length };
|
|
100
|
+
return [...marks.filter((mark) => !plain.includes(mark)), gathered];
|
|
101
|
+
}
|
|
88
102
|
/** Someone's effects but the one the word of their state already says, as a widget's Down beside the condition Down (D-514). */
|
|
89
103
|
export function besideWord(effects, person) {
|
|
90
104
|
const said = person?.word.toLowerCase();
|
|
@@ -94,14 +108,6 @@ export function besideWord(effects, person) {
|
|
|
94
108
|
function toneState(tone) {
|
|
95
109
|
return tone === "good" ? "stable" : tone === "bad" ? "dying" : "down";
|
|
96
110
|
}
|
|
97
|
-
/** A widget's words as one string, its values as they are: a mark's tooltip and name. */
|
|
98
|
-
function wordOf(text) {
|
|
99
|
-
return typeof text === "string" ? text : text.text.replace(/\{(\w+)\}/g, (whole, name) => (name in text.values ? valueWord(text.values[name]) : whole));
|
|
100
|
-
}
|
|
101
|
-
/** A value of a widget's words in a word: a number as the page writes it. */
|
|
102
|
-
function valueWord(value) {
|
|
103
|
-
return typeof value === "number" ? numberText(value) : typeof value === "string" ? value : "number" in value ? numberText(value.number) : `${numberText(value.from)}–${numberText(value.to)}`;
|
|
104
|
-
}
|
|
105
111
|
/** The words of someone's state for a screen reader, as a token's name says them. */
|
|
106
112
|
export function statusWords(status) {
|
|
107
113
|
return statusMarks(status, true).map((mark) => mark.label);
|