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
|
@@ -4,11 +4,11 @@ import { z } from "zod";
|
|
|
4
4
|
import { cardPages } from "./package-api.js";
|
|
5
5
|
/**
|
|
6
6
|
* The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
|
|
7
|
-
* system.yaml may declare. It goes up with every addition
|
|
7
|
+
* system.yaml may declare. It goes up with every addition an older engine would refuse or misread, and the engine reads a range (D-515, D-549): 2 added the widgets, 3 an extension's
|
|
8
8
|
* additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package, 6 the fields of
|
|
9
|
-
* knowledge of a game system (sheet-knowledge), 7 what a page carries and the pictures of the dashboard's states.
|
|
9
|
+
* knowledge of a game system (sheet-knowledge), 7 what a page carries and the pictures of the dashboard's states, 8 where a game system's oracle says yes.
|
|
10
10
|
*/
|
|
11
|
-
export const packageApi =
|
|
11
|
+
export const packageApi = 8;
|
|
12
12
|
/**
|
|
13
13
|
* Our game systems (D-513): the name a campaign gives each, which package install takes alone, its package, and what it is; the setup offers them even when
|
|
14
14
|
* npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** An error with a code and its values beside its message, for the dashboard to say in the page's language. */
|
|
2
|
+
export declare class Refusal extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly values: Record<string, string>;
|
|
5
|
+
constructor(message: string, code: string, values?: Record<string, string>);
|
|
6
|
+
}
|
|
7
|
+
/** What the dashboard sends of an error: its words, and its code and values when it is a refusal. */
|
|
8
|
+
export declare function refusalBody(error: unknown): {
|
|
9
|
+
error: string;
|
|
10
|
+
code?: string;
|
|
11
|
+
values?: Record<string, string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// A refusal the player may meet on the dashboard (T-162): the engine's words, which the master reads as they are, and a code with its values, which the page
|
|
2
|
+
// says in its own language. A code the page does not know shows the engine's words.
|
|
3
|
+
/** An error with a code and its values beside its message, for the dashboard to say in the page's language. */
|
|
4
|
+
export class Refusal extends Error {
|
|
5
|
+
code;
|
|
6
|
+
values;
|
|
7
|
+
constructor(message, code, values = {}) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.values = values;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** What the dashboard sends of an error: its words, and its code and values when it is a refusal. */
|
|
14
|
+
export function refusalBody(error) {
|
|
15
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16
|
+
return error instanceof Refusal ? { error: message, code: error.code, ...(Object.keys(error.values).length === 0 ? {} : { values: error.values }) } : { error: message };
|
|
17
|
+
}
|
package/dist/core/store.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ export declare class FileStore {
|
|
|
31
31
|
name: string;
|
|
32
32
|
isFolder: boolean;
|
|
33
33
|
}[];
|
|
34
|
+
/** Whether `path` is a link as it is now: a symbolic link or a junction, or a file with another name elsewhere, a hard link. */
|
|
35
|
+
isLink(path: string): boolean;
|
|
36
|
+
/** The links right inside `folder`, as they are now, by name, which entries leaves out; none when there is no such folder. */
|
|
37
|
+
links(folder: string): string[];
|
|
34
38
|
/** A file's bytes as they are now, as a save holds them; undefined when there is no file. */
|
|
35
39
|
bytes(path: string): Uint8Array | undefined;
|
|
36
40
|
/** The text of a file as it is now, for a command about to write it: in a call, the text the call reads; a session checks the disk (D-193). */
|
package/dist/core/store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The files as a command sees them (D-137, D-194): each read at most once in a call, kept as its text and as what it reads as, frozen; what the command writes
|
|
2
2
|
// updates what is kept. A command runs inside its store, and the modules reach it with files(): the MCP server will keep one for a whole session.
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
-
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { appendFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { fileOrder, filesIn } from "./files.js";
|
|
7
7
|
import { frozen } from "./frozen.js";
|
|
@@ -71,6 +71,15 @@ export class FileStore {
|
|
|
71
71
|
? readdirSync(folder, { withFileTypes: true }).filter((entry) => entry.isFile() || entry.isDirectory()).map((entry) => ({ name: entry.name, isFolder: entry.isDirectory() }))
|
|
72
72
|
: [];
|
|
73
73
|
}
|
|
74
|
+
/** Whether `path` is a link as it is now: a symbolic link or a junction, or a file with another name elsewhere, a hard link. */
|
|
75
|
+
isLink(path) {
|
|
76
|
+
const stats = lstatSync(path, { throwIfNoEntry: false });
|
|
77
|
+
return stats !== undefined && (stats.isSymbolicLink() || (stats.isFile() && stats.nlink > 1));
|
|
78
|
+
}
|
|
79
|
+
/** The links right inside `folder`, as they are now, by name, which entries leaves out; none when there is no such folder. */
|
|
80
|
+
links(folder) {
|
|
81
|
+
return existsSync(folder) && statSync(folder).isDirectory() ? readdirSync(folder, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink()).map((entry) => entry.name) : [];
|
|
82
|
+
}
|
|
74
83
|
/** A file's bytes as they are now, as a save holds them; undefined when there is no file. */
|
|
75
84
|
bytes(path) {
|
|
76
85
|
return existsSync(path) ? new Uint8Array(readFileSync(path)) : undefined;
|
|
@@ -100,6 +109,7 @@ export class FileStore {
|
|
|
100
109
|
}
|
|
101
110
|
/** Writes a file, with the folders it needs. */
|
|
102
111
|
write(path, text) {
|
|
112
|
+
refuseLinked(path);
|
|
103
113
|
mkdirSync(dirname(path), { recursive: true });
|
|
104
114
|
writeFileSync(path, text, "utf8");
|
|
105
115
|
this.changed(path, { text }, true);
|
|
@@ -107,6 +117,7 @@ export class FileStore {
|
|
|
107
117
|
}
|
|
108
118
|
/** Writes a file's bytes as they are, with the folders it needs, as a save gives them back: what the store kept of it is read again. */
|
|
109
119
|
writeBytes(path, bytes) {
|
|
120
|
+
refuseLinked(path);
|
|
110
121
|
mkdirSync(dirname(path), { recursive: true });
|
|
111
122
|
writeFileSync(path, bytes);
|
|
112
123
|
this.changed(path, undefined, true);
|
|
@@ -114,6 +125,7 @@ export class FileStore {
|
|
|
114
125
|
}
|
|
115
126
|
/** Adds text at the end of a file, as the log grows. */
|
|
116
127
|
append(path, text) {
|
|
128
|
+
refuseLinked(path);
|
|
117
129
|
const before = this.kept.get(resolve(path));
|
|
118
130
|
appendFileSync(path, text, "utf8");
|
|
119
131
|
// A file never read stays to be read: what is kept of it would be only its end.
|
|
@@ -251,3 +263,10 @@ function markWritten() {
|
|
|
251
263
|
call.wrote = true;
|
|
252
264
|
}
|
|
253
265
|
}
|
|
266
|
+
/** Throws for a file that is a link, a symbolic one or a hard link: what is written there would land in a file somewhere else. */
|
|
267
|
+
function refuseLinked(path) {
|
|
268
|
+
const stats = lstatSync(path, { throwIfNoEntry: false });
|
|
269
|
+
if (stats !== undefined && (stats.isSymbolicLink() || (stats.isFile() && stats.nlink > 1))) {
|
|
270
|
+
throw new Error(`${path} is a link to a file somewhere else, and what is written there would land in that file: replace it with a copy of its own. Nothing was written to it.`);
|
|
271
|
+
}
|
|
272
|
+
}
|
package/dist/dashboard/api.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refusalText } from "./refusals.js";
|
|
1
2
|
import { t } from "./text.js";
|
|
2
3
|
/** A picture's address, with when its file last changed, so that it comes again only when it changes. */
|
|
3
4
|
export function pictureAddress(picture) {
|
|
@@ -6,20 +7,11 @@ export function pictureAddress(picture) {
|
|
|
6
7
|
/** What view gives: the party, with the last rolls, as many as asked, and the place of the player character `focus` names (VIEW-12); or a page. */
|
|
7
8
|
export async function readView(page, rolls, focus) {
|
|
8
9
|
const query = new URLSearchParams({ ...(page === undefined ? {} : { page }), ...(rolls === undefined ? {} : { rolls: String(rolls) }), ...(focus === undefined ? {} : { focus }) });
|
|
9
|
-
|
|
10
|
-
const body = await response.json();
|
|
11
|
-
if ("error" in body) {
|
|
12
|
-
throw new Error(body.error);
|
|
13
|
-
}
|
|
14
|
-
return body;
|
|
10
|
+
return await readJson(query.size === 0 ? "/api/view" : `/api/view?${query}`);
|
|
15
11
|
}
|
|
16
12
|
/** The world map as the player character knows it (VIEW-7). */
|
|
17
13
|
export async function readMap() {
|
|
18
|
-
const
|
|
19
|
-
const body = await response.json();
|
|
20
|
-
if ("error" in body) {
|
|
21
|
-
throw new Error(body.error);
|
|
22
|
-
}
|
|
14
|
+
const body = await readJson("/api/view?map=true");
|
|
23
15
|
if (body.kind !== "map") {
|
|
24
16
|
throw new Error(t("There is no player character yet: the map starts with one."));
|
|
25
17
|
}
|
|
@@ -27,20 +19,12 @@ export async function readMap() {
|
|
|
27
19
|
}
|
|
28
20
|
/** The player's settings, with their values and what each means (D-341). */
|
|
29
21
|
export async function readSettings() {
|
|
30
|
-
const
|
|
31
|
-
const body = await response.json();
|
|
32
|
-
if ("error" in body) {
|
|
33
|
-
throw new Error(body.error);
|
|
34
|
-
}
|
|
22
|
+
const body = await readJson("/api/view?settings=true");
|
|
35
23
|
return body.kind === "settings" ? body.settings : [];
|
|
36
24
|
}
|
|
37
25
|
/** The campaign's setup: its mode and name, what the next mode needs, and the setup's questions (D-370). */
|
|
38
26
|
export async function readSetup() {
|
|
39
|
-
const
|
|
40
|
-
const body = await response.json();
|
|
41
|
-
if ("error" in body) {
|
|
42
|
-
throw new Error(body.error);
|
|
43
|
-
}
|
|
27
|
+
const body = await readJson("/api/view?setup=true");
|
|
44
28
|
if (body.kind !== "setup") {
|
|
45
29
|
throw new Error(t("The game gave no setup: reload the page."));
|
|
46
30
|
}
|
|
@@ -58,29 +42,17 @@ export async function sendSetupWord(word) {
|
|
|
58
42
|
}
|
|
59
43
|
/** The quests the character knows and the story by scenes (D-367); none before there is a player character. */
|
|
60
44
|
export async function readJournal() {
|
|
61
|
-
const
|
|
62
|
-
const body = await response.json();
|
|
63
|
-
if ("error" in body) {
|
|
64
|
-
throw new Error(body.error);
|
|
65
|
-
}
|
|
45
|
+
const body = await readJson("/api/view?journal=true");
|
|
66
46
|
return body.kind === "journal" ? body : undefined;
|
|
67
47
|
}
|
|
68
48
|
/** What the character knows, its documents and the calendar; none before there is a player character, or from a server older than the page. */
|
|
69
49
|
export async function readWorld() {
|
|
70
|
-
const
|
|
71
|
-
const body = await response.json();
|
|
72
|
-
if ("error" in body) {
|
|
73
|
-
throw new Error(body.error);
|
|
74
|
-
}
|
|
50
|
+
const body = await readJson("/api/view?world=true");
|
|
75
51
|
return body.kind === "world" ? body : undefined;
|
|
76
52
|
}
|
|
77
53
|
/** The player's notes, the last written first (D-371), and those shared that the master has not heard yet, which may be taken back (D-381). */
|
|
78
54
|
export async function readNotes() {
|
|
79
|
-
const
|
|
80
|
-
const body = await response.json().catch(() => ({ error: t("The notes did not come ({status}): reload the page.", { status: response.status }) }));
|
|
81
|
-
if ("error" in body) {
|
|
82
|
-
throw new Error(body.error);
|
|
83
|
-
}
|
|
55
|
+
const body = await readJson("/api/notes");
|
|
84
56
|
return { notes: body.notes, pending: body.pending ?? [] };
|
|
85
57
|
}
|
|
86
58
|
// The notes reach the game one after another, in the order they were written.
|
|
@@ -123,11 +95,7 @@ export async function readStory(who) {
|
|
|
123
95
|
}
|
|
124
96
|
/** The campaign's saves, newest first, and what the mode lets the player do with them (D-359). */
|
|
125
97
|
export async function readSaves() {
|
|
126
|
-
const
|
|
127
|
-
const body = await response.json();
|
|
128
|
-
if ("error" in body) {
|
|
129
|
-
throw new Error(body.error);
|
|
130
|
-
}
|
|
98
|
+
const body = await readJson("/api/view?saves=true");
|
|
131
99
|
if (body.kind !== "saves") {
|
|
132
100
|
throw new Error(t("The game gave no saves: reload the page."));
|
|
133
101
|
}
|
|
@@ -150,10 +118,10 @@ export async function changeSaves(change) {
|
|
|
150
118
|
/** RPG Engine and what npm has of it; undefined where the page is not served by the game's own server, which alone updates it. */
|
|
151
119
|
export async function readEngine() {
|
|
152
120
|
const response = await fetch("/api/engine");
|
|
153
|
-
const body = await response.json();
|
|
154
121
|
if (response.status === 400) {
|
|
155
122
|
return undefined;
|
|
156
123
|
}
|
|
124
|
+
const body = await response.json();
|
|
157
125
|
if ("error" in body) {
|
|
158
126
|
throw new Error(body.error);
|
|
159
127
|
}
|
|
@@ -167,7 +135,7 @@ export async function updateEngine() {
|
|
|
167
135
|
if (response.status === 202 && body.version !== undefined) {
|
|
168
136
|
return { done: true, version: body.version, restart: body.restart === "app" ? "app" : "chat" };
|
|
169
137
|
}
|
|
170
|
-
return { done: false, error: body
|
|
138
|
+
return { done: false, error: refusalText(body, t("It did not reach the game: try again.")), ...(body.code === "busy" ? { code: body.code } : {}) };
|
|
171
139
|
}
|
|
172
140
|
catch {
|
|
173
141
|
return { done: false, error: t("It did not reach the game: try again.") };
|
|
@@ -175,21 +143,11 @@ export async function updateEngine() {
|
|
|
175
143
|
}
|
|
176
144
|
/** The packages here, at once: without npm. */
|
|
177
145
|
export async function readPackages() {
|
|
178
|
-
|
|
179
|
-
const body = await response.json();
|
|
180
|
-
if ("error" in body) {
|
|
181
|
-
throw new Error(body.error);
|
|
182
|
-
}
|
|
183
|
-
return body;
|
|
146
|
+
return await readJson("/api/packages");
|
|
184
147
|
}
|
|
185
148
|
/** The widgets of the campaign's extensions (D-502), each where it stands and with what it shows now. */
|
|
186
149
|
export async function readWidgets() {
|
|
187
|
-
|
|
188
|
-
const body = await response.json();
|
|
189
|
-
if ("error" in body) {
|
|
190
|
-
throw new Error(body.error);
|
|
191
|
-
}
|
|
192
|
-
return body.widgets;
|
|
150
|
+
return (await readJson("/api/widgets")).widgets;
|
|
193
151
|
}
|
|
194
152
|
/** What a package's widget shows for a card or a page of its page code, for who (D-514): nothing when the package or the widget is not the campaign's. */
|
|
195
153
|
export async function readWidgetData(owner, widget, who) {
|
|
@@ -203,30 +161,15 @@ export async function readWidgetData(owner, widget, who) {
|
|
|
203
161
|
}
|
|
204
162
|
/** The theme of the campaign's game system (D-528): its CSS, icons and name; nothing when it names none, or refused when it does not pass its checks. */
|
|
205
163
|
export async function readGameTheme() {
|
|
206
|
-
|
|
207
|
-
const body = await response.json();
|
|
208
|
-
if ("error" in body) {
|
|
209
|
-
throw new Error(body.error);
|
|
210
|
-
}
|
|
211
|
-
return body;
|
|
164
|
+
return await readJson("/api/theme");
|
|
212
165
|
}
|
|
213
166
|
/** The page modules of the campaign's system and extensions whose code runs (D-510, D-511), the system's first. */
|
|
214
167
|
export async function readModules() {
|
|
215
|
-
|
|
216
|
-
const body = await response.json();
|
|
217
|
-
if ("error" in body) {
|
|
218
|
-
throw new Error(body.error);
|
|
219
|
-
}
|
|
220
|
-
return body.modules;
|
|
168
|
+
return (await readJson("/api/modules")).modules;
|
|
221
169
|
}
|
|
222
170
|
/** The catalog (D-486), as the server keeps it for ten minutes; `fresh` asks npm and GitHub again. */
|
|
223
171
|
export async function readCatalog(fresh) {
|
|
224
|
-
|
|
225
|
-
const body = await response.json();
|
|
226
|
-
if ("error" in body) {
|
|
227
|
-
throw new Error(body.error);
|
|
228
|
-
}
|
|
229
|
-
return body;
|
|
172
|
+
return await readJson(fresh ? "/api/catalog?fresh=true" : "/api/catalog");
|
|
230
173
|
}
|
|
231
174
|
/** Adds what the player wrote (D-485 (1)): a link, a GitHub repository's too, an npm name or a folder of this computer; the engine tells its kind. */
|
|
232
175
|
export async function addSource(source) {
|
|
@@ -247,7 +190,8 @@ async function packageWork(send) {
|
|
|
247
190
|
if (response.status === 202) {
|
|
248
191
|
return { done: true, ...(body.kind === undefined ? {} : { kind: body.kind }) };
|
|
249
192
|
}
|
|
250
|
-
|
|
193
|
+
const code = body.code === "declined" || body.code === "no-window" || body.code === "busy" ? body.code : undefined;
|
|
194
|
+
return { done: false, error: refusalText(body, t("It did not reach the game: try again.")), ...(code === undefined ? {} : { code }) };
|
|
251
195
|
}
|
|
252
196
|
catch {
|
|
253
197
|
return { done: false, error: t("It did not reach the game: try again.") };
|
|
@@ -255,12 +199,7 @@ async function packageWork(send) {
|
|
|
255
199
|
}
|
|
256
200
|
/** This computer's library, with what this campaign uses, at once. */
|
|
257
201
|
export async function readLibrary() {
|
|
258
|
-
|
|
259
|
-
const body = await response.json();
|
|
260
|
-
if ("error" in body) {
|
|
261
|
-
throw new Error(body.error);
|
|
262
|
-
}
|
|
263
|
-
return body;
|
|
202
|
+
return await readJson("/api/library");
|
|
264
203
|
}
|
|
265
204
|
/**
|
|
266
205
|
* Turns a folder or a book of this computer on in the campaign's library, adding it to the computer first with the player's yes in a window; off; or takes it
|
|
@@ -274,7 +213,7 @@ export async function exportCampaign(credits) {
|
|
|
274
213
|
try {
|
|
275
214
|
const response = await fetch("/api/export", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(credits) });
|
|
276
215
|
const body = await response.json().catch(() => ({}));
|
|
277
|
-
return body.file === undefined ? { error: body
|
|
216
|
+
return body.file === undefined ? { error: refusalText(body, t("It did not reach the game: try again.")) } : { download: `/api/export?file=${encodeURIComponent(body.file)}`, file: body.file };
|
|
278
217
|
}
|
|
279
218
|
catch {
|
|
280
219
|
return { error: t("It did not reach the game: try again.") };
|
|
@@ -384,3 +323,20 @@ export async function runCommand(command, input = {}) {
|
|
|
384
323
|
}
|
|
385
324
|
return body.text ?? "";
|
|
386
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* What the server answers at an address, as JSON: it throws what the server says went wrong, or, when the game cannot be reached or answers no JSON, says so
|
|
328
|
+
* in the page's words rather than the browser's.
|
|
329
|
+
*/
|
|
330
|
+
async function readJson(address) {
|
|
331
|
+
let body;
|
|
332
|
+
try {
|
|
333
|
+
body = await (await fetch(address)).json();
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
throw new Error(t("It did not reach the game: try again."));
|
|
337
|
+
}
|
|
338
|
+
if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
|
|
339
|
+
throw new Error(body.error);
|
|
340
|
+
}
|
|
341
|
+
return body;
|
|
342
|
+
}
|
package/dist/dashboard/app.js
CHANGED
|
@@ -40,7 +40,7 @@ import { SetupView, useSetup } from "./setup.js";
|
|
|
40
40
|
import { MemberSheet } from "./sheet.js";
|
|
41
41
|
import { gameStyleChanged, takeSystemStyle } from "./system-style.js";
|
|
42
42
|
import { PlayTable, tableBeside, TableTab, useTableAway } from "./table.js";
|
|
43
|
-
import { browserLanguage, pageDirection, setLanguage, setSystemWords, t } from "./text.js";
|
|
43
|
+
import { browserLanguage, pageDirection, pageLocale, setLanguage, setSystemWords, t } from "./text.js";
|
|
44
44
|
import { restoreTheme } from "./theme.js";
|
|
45
45
|
import { SetupCorner, Top } from "./top.js";
|
|
46
46
|
import { hasTurns, TurnsCard, turnWords } from "./turns.js";
|
|
@@ -176,7 +176,14 @@ function App() {
|
|
|
176
176
|
const page = member === undefined ? undefined : await readView(member.name);
|
|
177
177
|
// The page's words in the campaign's language (D-394), its file read once; its dates and screen readers follow the language too.
|
|
178
178
|
const language = (overview.kind === "overview" || overview.kind === "none" ? overview.language : undefined) ?? browserLanguage();
|
|
179
|
+
// A reading a newer one overtook sets no language: the newer one's stays, with its words.
|
|
180
|
+
if (number !== reading.current) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
179
183
|
await setLanguage(language);
|
|
184
|
+
if (number !== reading.current) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
180
187
|
setSystemWords(overview.kind === "overview" ? overview.words : undefined);
|
|
181
188
|
setSystemVerbs(overview.kind === "overview" ? overview.verbs : undefined);
|
|
182
189
|
if (number === reading.current) {
|
|
@@ -582,7 +589,7 @@ function App() {
|
|
|
582
589
|
const notices = [
|
|
583
590
|
...(shown.problem === undefined ? [] : [{ kind: "problem", text: shown.problem }]),
|
|
584
591
|
...(!live && shown.readAt !== undefined
|
|
585
|
-
? [{ kind: "away", text: t("Not connected: the sheet as of {time}. It comes back when the game does.", { time: shown.readAt.toLocaleTimeString(
|
|
592
|
+
? [{ kind: "away", text: t("Not connected: the sheet as of {time}. It comes back when the game does.", { time: shown.readAt.toLocaleTimeString(pageLocale(), { hour: "2-digit", minute: "2-digit" }) }) }]
|
|
586
593
|
: []),
|
|
587
594
|
...(shown.noCharacter && !inSetup ? [{ kind: "info", text: t("There is no player character yet: the sheet comes when the master writes one.") }] : []),
|
|
588
595
|
...gameNotices(shown.problems),
|
|
@@ -607,7 +614,7 @@ function App() {
|
|
|
607
614
|
return taken;
|
|
608
615
|
} }, shown.asked.id)), live && shown.pack === undefined && shown.asked && shown.asked.spend === undefined && !inCard(shown.asked) && (_jsx(AskedBanner, { asked: shown.asked, yourTurn: yourTurn && (asker === undefined || asker.name === turnOf?.name), who: asker, turnName: turnName, map: shown.place?.map, place: shown.place?.name, answered: answering === shown.asked.id, onAnswered: () => void read() })), inSetup
|
|
609
616
|
? _jsx(SetupView, { setup: setup })
|
|
610
|
-
: (_jsxs(_Fragment, { children: [live && yourTurn && address.section !== "scene" && shown.asked === undefined && shown.pack === undefined && (_jsxs("a", { class: "turn-notice", href: sectionAddress("scene"), children: [_jsx(Icon, { name: "combat" }),
|
|
617
|
+
: (_jsxs(_Fragment, { children: [live && yourTurn && address.section !== "scene" && shown.asked === undefined && shown.pack === undefined && (_jsxs("a", { class: "turn-notice", href: sectionAddress("scene"), children: [_jsx(Icon, { name: "combat" }), _jsxs("span", { children: [turnWords(turnName), shown.openScene?.round !== undefined && _jsx("span", { class: "turn-notice-round", children: ` · ${t("Round {round}", { round: shown.openScene.round })}` })] }), _jsx("span", { class: "turn-notice-go", children: t("Go to the scene") })] })), _jsx(Notices, { notices: importing }), !table && _jsx(QuestEndings, { version: shown.version, campaign: shown.campaign }), address.section === "party" && _jsx(PartyStrip, { party: shown.party, chosen: shown.chosen, scene: shown.openScene }), _jsxs("div", { class: "body", children: [_jsxs("main", { children: [address.section === "about" && _jsx(About, { product: productName, system: shown.system }), address.section === "help" && _jsx(Help, {}), !table && address.section === "scene" && _jsx(FollowedQuests, { version: shown.version, campaign: shown.campaign }), address.section === "scene" && (_jsx(SceneView, { place: shown.place, scene: shown.openScene, actor: actor, foreground: shown.foreground, several: several, party: shown.party, turnsBeside: table, onShowCard: (name) => {
|
|
611
618
|
handed.current = { who: name, turn: turnKey(shown.openScene) };
|
|
612
619
|
void read();
|
|
613
620
|
}, own: {
|
package/dist/dashboard/asked.js
CHANGED
|
@@ -297,8 +297,11 @@ export function AskedBanner({ asked, yourTurn, who, turnName, map, place, answer
|
|
|
297
297
|
setPicking(false);
|
|
298
298
|
setProblem(undefined);
|
|
299
299
|
try {
|
|
300
|
-
// A click that comes too late counts for nothing: the page reads what the master asks now.
|
|
301
|
-
await answer(asked.id, given)
|
|
300
|
+
// A click that comes too late counts for nothing: the page reads what the master asks now. One the game refuses can be given again.
|
|
301
|
+
if (!await answer(asked.id, given)) {
|
|
302
|
+
setSent(undefined);
|
|
303
|
+
setProblem(t("The answer did not reach the game: try again."));
|
|
304
|
+
}
|
|
302
305
|
}
|
|
303
306
|
catch {
|
|
304
307
|
setSent(undefined);
|
|
@@ -332,7 +335,7 @@ export function AskedBanner({ asked, yourTurn, who, turnName, map, place, answer
|
|
|
332
335
|
const shown = asked.labels.map((label, index) => answerButton(label, index, !roomy)).filter((button) => button !== null);
|
|
333
336
|
return (_jsxs("section", { ref: banner, class: classes, "aria-label": t("What the master asks"), children: [who === undefined ? _jsx("img", { class: "asked-robot", src: "/assets/favicon.svg", alt: "" }) : _jsx(AskedWho, { member: who }), _jsxs("p", { class: "asked-bar-question", children: [who !== undefined && (_jsxs(_Fragment, { children: [_jsx("b", { class: "asked-bar-name", children: who.name }), " · "] })), asked.question] }), shown.length > 0 && _jsx("div", { class: "asked-buttons", children: shown }), toggle] }));
|
|
334
337
|
}
|
|
335
|
-
return (_jsxs("section", { ref: banner, class: classes, "aria-labelledby": `asked-${asked.id}`, children: [toggle, who === undefined ? _jsx("img", { class: "asked-robot", src: "/assets/favicon.svg", alt: "" }) : _jsx(AskedWho, { member: who }), _jsxs("div", { class: "asked-body", children: [yourTurn ? _jsx("p", { class: "eyebrow asked-turn", children: turnWords(who?.name ?? turnName) }) : who !== undefined && _jsx("p", { class: "eyebrow asked-turn", children: t("For {name}", { name: who.name }) }), _jsx("h2", { class: "asked-title", children: asked.title }), _jsxs("p", { id: `asked-${asked.id}`, class: "asked-question", role: "alert", children: [who !== undefined && _jsx("span", { class: "visually-hidden", children: `${who.name}: ` }), asked.question] }), named.length > 0 && byHand && (_jsxs("p", { class: "asked-hand-note", children: [_jsx(Icon, { name: "hand" }), _jsx("span", { children: tParts("Roll {checks} yourself, on {sheet} or with the dice.", {
|
|
338
|
+
return (_jsxs("section", { ref: banner, class: classes, "aria-labelledby": `asked-${asked.id}`, children: [toggle, who === undefined ? _jsx("img", { class: "asked-robot", src: "/assets/favicon.svg", alt: "" }) : _jsx(AskedWho, { member: who }), _jsxs("div", { class: "asked-body", children: [yourTurn ? _jsx("p", { class: "eyebrow asked-turn", children: turnWords(who?.name ?? turnName) }) : who !== undefined && _jsx("p", { class: "eyebrow asked-turn", children: t("For {name}", { name: who.name }) }), _jsx("h2", { class: "asked-title", children: asked.title }), _jsxs("p", { id: `asked-${asked.id}`, class: "asked-question", dir: "auto", role: "alert", children: [who !== undefined && _jsx("span", { class: "visually-hidden", children: `${who.name}: ` }), asked.question] }), named.length > 0 && byHand && (_jsxs("p", { class: "asked-hand-note", children: [_jsx(Icon, { name: "hand" }), _jsx("span", { children: tParts("Roll {checks} yourself, on {sheet} or with the dice.", {
|
|
336
339
|
checks: named.map((check, index) => (_jsxs(Fragment, { children: [index > 0 && (index === named.length - 1 ? ` ${t("or")} ` : ", "), _jsxs("a", { class: "asked-hand-check", href: sheetAddress(asked.who ?? ""), onClick: () => showRow(asked.fields?.[asked.labels.findIndex((label) => checkOf(label, asked.title)?.check === check.check)]), children: [_jsx(NotationIcons, { notation: check.dice }), check.check] })] }, check.check))),
|
|
337
340
|
sheet: _jsx("a", { href: sheetAddress(asked.who ?? ""), children: who === undefined ? t("your sheet") : t("{name}'s sheet", { name: who.name }) }),
|
|
338
341
|
}).map((part, index) => _jsx(Fragment, { children: part }, index)) })] })), _jsxs("div", { class: "asked-buttons", children: [asked.square && map !== undefined && (_jsxs("button", { type: "button", class: sent === "square" ? "asked-check sent" : "asked-check", disabled: gone, onClick: () => setPicking(true), children: [_jsx(Icon, { name: "world" }), _jsx("span", { class: "asked-check-name", children: t("Choose on the map") })] })), asked.labels.map((label, index) => answerButton(label, index))] }), _jsxs("div", { class: "asked-foot", children: [_jsxs("form", { class: "asked-own", onSubmit: own, children: [_jsx("input", { type: "text", value: words, maxLength: mostWords, placeholder: t("Or write what you do…"), "aria-label": t("Or write what you do"), disabled: gone, onInput: (event) => setWords(event.currentTarget.value) }), _jsx("button", { type: "submit", class: "icon-button", "aria-label": t("Send"), "data-tip": t("Send"), disabled: gone || words.trim() === "", children: _jsx(Icon, { name: "send" }) })] }), roll && (_jsxs("label", { class: "asked-hand", children: [_jsx("input", { type: "checkbox", role: "switch", checked: byHand, onChange: (event) => setByHand(event.currentTarget.checked) }), _jsx(Icon, { name: "hand" }), t("By hand")] }))] }), problem && _jsx("p", { class: "asked-problem", role: "alert", children: problem })] }), picking && map !== undefined && _jsx(MapSheet, { map: map, place: place ?? "", question: asked.question, onPick: (square) => void reply({ square }), onClose: () => setPicking(false) })] }));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<svg class="robot" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"
|
|
2
|
-
<title>Robot game master</title>
|
|
1
|
+
<svg class="robot" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-hidden="true">
|
|
3
2
|
<g class="robot-head">
|
|
4
3
|
<g class="robot-antenna" fill="#DCAA32"><rect x="409" y="47" width="14" height="117" rx="7"/><circle cx="416" cy="45" r="19"/></g>
|
|
5
4
|
<g class="robot-ears" fill="#DCAA32"><rect x="74" y="154" width="64" height="91" rx="20"/><rect x="374" y="154" width="64" height="91" rx="20"/></g>
|
package/dist/dashboard/card.js
CHANGED
|
@@ -34,7 +34,7 @@ export function useMedia(query) {
|
|
|
34
34
|
* says what a click does; a card that stays open has no chevron and does not close.
|
|
35
35
|
*/
|
|
36
36
|
export function CardHeader({ icon, title, preview, note, open, onToggle, fixed }) {
|
|
37
|
-
return (_jsxs("summary", { class: fixed ? "fixed" : undefined, onClick: fixed ? (event) => event.preventDefault() : onToggle, children: [_jsx("svg", { class: "card-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: icon }) }), title, !open && preview !== undefined && _jsx("span", { class: "preview", "aria-hidden": "true", children: preview }), note !== undefined && _jsx("span", { class: "card-head-note", children: note }), !fixed && (_jsx("span", { class: "chevron-tip tip-left", "aria-hidden": "true", "data-tip": open ? t("Close") : t("Open"), children: _jsx("svg", { class: "chevron", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: chevronPath }) }) }))] }));
|
|
37
|
+
return (_jsxs("summary", { class: fixed ? "fixed" : undefined, onClick: fixed ? (event) => event.preventDefault() : onToggle, children: [_jsx("svg", { class: "card-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: icon }) }), title, !open && preview !== undefined && _jsx("span", { class: "preview", dir: "auto", "aria-hidden": "true", children: preview }), note !== undefined && _jsx("span", { class: "card-head-note", children: note }), !fixed && (_jsx("span", { class: "chevron-tip tip-left", "aria-hidden": "true", "data-tip": open ? t("Close") : t("Open"), children: _jsx("svg", { class: "chevron", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: chevronPath }) }) }))] }));
|
|
38
38
|
}
|
|
39
39
|
/** The header of a card that is always open (D-419): the look of a card's header, its icon, its title, a note at its end, and its own buttons after it; no toggle. */
|
|
40
40
|
export function CardHead({ icon, title, note, children }) {
|
|
@@ -7,7 +7,12 @@ import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
|
|
7
7
|
import { coinKind, faceNormals } from "./models.js";
|
|
8
8
|
/** Loads the dice's shapes and values, and the meshes of the edges given at once, the others when first asked. */
|
|
9
9
|
export async function loadDice(edges) {
|
|
10
|
-
const read = (file) => fetch(`/assets/dice/${file}`).then(async (response) =>
|
|
10
|
+
const read = (file) => fetch(`/assets/dice/${file}`).then(async (response) => {
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`/assets/dice/${file} did not come (${response.status}).`);
|
|
13
|
+
}
|
|
14
|
+
return await response.json();
|
|
15
|
+
});
|
|
11
16
|
const [dice, coin] = await Promise.all([read("dice.json"), read("coin.json")]);
|
|
12
17
|
const data = { ...dice, [coinKind]: coin };
|
|
13
18
|
const meshes = new Map();
|
|
@@ -47,7 +47,11 @@ const floorBounce = 0.25;
|
|
|
47
47
|
let loading;
|
|
48
48
|
/** Loads the physics, once: a throw needs it. */
|
|
49
49
|
export function loadPhysics() {
|
|
50
|
-
|
|
50
|
+
// One that failed is tried again the next time.
|
|
51
|
+
const loaded = loading ?? RAPIER.init().catch((error) => {
|
|
52
|
+
loading = undefined;
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
51
55
|
loading = loaded;
|
|
52
56
|
return loaded;
|
|
53
57
|
}
|
|
@@ -102,7 +102,11 @@ export function DiceTray({ requested, sheetThrow, party, campaign, onLanded, onS
|
|
|
102
102
|
/** The dice and their stage, loaded once; undefined when the browser cannot draw them, and then the plate comes alone. */
|
|
103
103
|
const loadRoller = () => {
|
|
104
104
|
const surface = canvas.current;
|
|
105
|
-
|
|
105
|
+
// A load that failed, as the game away for a moment, is tried again at the next throw.
|
|
106
|
+
roller.current ??= surface === null ? Promise.resolve(undefined) : import("./roller.js").then((module) => module.makeRoller(surface)).catch(() => {
|
|
107
|
+
roller.current = undefined;
|
|
108
|
+
return undefined;
|
|
109
|
+
});
|
|
106
110
|
return roller.current;
|
|
107
111
|
};
|
|
108
112
|
/** Throws these dice, each landing on its value, then shows the plate, and fades it all after a while; the plate alone when the dice cannot be thrown. */
|
package/dist/dashboard/footer.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
|
2
2
|
// The page's foot, under a line across the whole page as the head's: our copyright, the code on GitHub and the package on npm, a heart to support the project,
|
|
3
3
|
// and the game system with the credit its source asks for (PLAN, phase 2).
|
|
4
4
|
import { Icon } from "./icons.js";
|
|
5
|
-
import { systemTitleLabel } from "./labels.js";
|
|
5
|
+
import { systemNameLabel, systemTitleLabel } from "./labels.js";
|
|
6
6
|
import { t } from "./text.js";
|
|
7
7
|
/** Where the project lives, and how to support it. */
|
|
8
8
|
export const footLinks = {
|
|
@@ -13,5 +13,5 @@ export const footLinks = {
|
|
|
13
13
|
};
|
|
14
14
|
/** The foot of the page: who made it and where it lives, how to support it, and the game system's credits. */
|
|
15
15
|
export function PageFoot({ product, system }) {
|
|
16
|
-
return (_jsxs("footer", { class: "page-foot", children: [_jsxs("p", { class: "foot-own", children: [_jsxs("span", { children: ["© 2026 ", _jsx("a", { href: footLinks.author, target: "_blank", rel: "noreferrer", children: "Stefano Caronia" }), ` · ${product}`] }), _jsx("a", { href: footLinks.github, target: "_blank", rel: "noreferrer", "aria-label": t("{product} on GitHub", { product }), "data-tip": "GitHub", children: _jsx(Icon, { name: "github" }) }), _jsx("a", { href: footLinks.npm, target: "_blank", rel: "noreferrer", "aria-label": t("{product} on npm", { product }), "data-tip": "npm", children: _jsx(Icon, { name: "npm" }) }), _jsxs("a", { class: "foot-support", href: footLinks.support, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "heart" }), t("Support {product}", { product })] })] }), system && (_jsxs("p", { class: "foot-system", children: [_jsx("span", { children: `${system.name} · ${systemTitleLabel(system.title)}` }), system.attribution && (_jsxs("details", { children: [_jsx("summary", { children: t("Credits") }), _jsx("p", { children: system.attribution })] }))] }))] }));
|
|
16
|
+
return (_jsxs("footer", { class: "page-foot", children: [_jsxs("p", { class: "foot-own", children: [_jsxs("span", { children: ["© 2026 ", _jsx("a", { href: footLinks.author, target: "_blank", rel: "noreferrer", children: "Stefano Caronia" }), ` · ${product}`] }), _jsx("a", { href: footLinks.github, target: "_blank", rel: "noreferrer", "aria-label": t("{product} on GitHub", { product }), "data-tip": "GitHub", children: _jsx(Icon, { name: "github" }) }), _jsx("a", { href: footLinks.npm, target: "_blank", rel: "noreferrer", "aria-label": t("{product} on npm", { product }), "data-tip": "npm", children: _jsx(Icon, { name: "npm" }) }), _jsxs("a", { class: "foot-support", href: footLinks.support, target: "_blank", rel: "noreferrer", children: [_jsx(Icon, { name: "heart" }), t("Support {product}", { product })] })] }), system && (_jsxs("p", { class: "foot-system", children: [_jsx("span", { children: `${systemNameLabel(system.name)} · ${systemTitleLabel(system.title)}` }), system.attribution && (_jsxs("details", { children: [_jsx("summary", { children: t("Credits") }), _jsx("p", { children: system.attribution })] }))] }))] }));
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fieldLabel, phraseLabel } from "./labels.js";
|
|
2
|
-
import { isolated, listText, systemWord, systemWordAnyCase, t } from "./text.js";
|
|
1
|
+
import { fieldLabel, phraseLabel, strangerLabel } from "./labels.js";
|
|
2
|
+
import { isolated, listText, pageLocale, systemWord, systemWordAnyCase, t } from "./text.js";
|
|
3
3
|
/** A game date in the page's language: day 3, 06:00, or day 3; any other text as it is. */
|
|
4
4
|
export function gameDateLabel(date) {
|
|
5
5
|
const read = readDate(date);
|
|
@@ -31,7 +31,7 @@ export function calendarMonthLabel(month, year) {
|
|
|
31
31
|
at.setUTCFullYear(year);
|
|
32
32
|
}
|
|
33
33
|
const options = { month: "long", timeZone: "UTC", ...(year === undefined ? {} : { year: "numeric" }) };
|
|
34
|
-
return new Intl.DateTimeFormat(
|
|
34
|
+
return new Intl.DateTimeFormat(pageLocale(), options).format(at);
|
|
35
35
|
}
|
|
36
36
|
// The core's real months (TIM-8), which the page's language names on its own, as it bends them: 1 мая, 1. května.
|
|
37
37
|
const realMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
@@ -42,7 +42,7 @@ function realDayLabel(date, month) {
|
|
|
42
42
|
at.setUTCFullYear(date.year);
|
|
43
43
|
}
|
|
44
44
|
const options = { day: "numeric", month: "long", timeZone: "UTC", ...(date.year === undefined ? {} : { year: "numeric" }) };
|
|
45
|
-
return new Intl.DateTimeFormat(
|
|
45
|
+
return new Intl.DateTimeFormat(pageLocale(), options).format(at);
|
|
46
46
|
}
|
|
47
47
|
// A date within a phrase is put in it by its day and hour, which each language bends as the phrase needs: до дня 3, jusqu'au jour 3.
|
|
48
48
|
/** Until a game date, in the page's language: until day 3, 06:00. */
|
|
@@ -66,7 +66,9 @@ export function effectEndLabel(end) {
|
|
|
66
66
|
return untilDateLabel(end.date);
|
|
67
67
|
}
|
|
68
68
|
if ("round" in end) {
|
|
69
|
-
|
|
69
|
+
// A copy the character does not know by name, as creature B2, as the scene names it: Creatura B2.
|
|
70
|
+
const turn = /^creature \S+$/.test(end.turn) ? strangerLabel(end.turn) : nameLabel(end.turn);
|
|
71
|
+
return t("until {name}'s turn in round {round}", { name: turn, round: end.round });
|
|
70
72
|
}
|
|
71
73
|
return "scene" in end ? t("until the scene ends") : systemWord("words", `until ${end.occasion}`) ?? t("until {occasion}", { occasion: systemWord("words", end.occasion) ?? end.occasion });
|
|
72
74
|
}
|
|
@@ -127,7 +129,8 @@ export function memberPlaceLabel(place) {
|
|
|
127
129
|
}
|
|
128
130
|
/** A region's terrain in the page's language, as the game system says it: difficult terrain. */
|
|
129
131
|
export function terrainLabel(terrain) {
|
|
130
|
-
|
|
132
|
+
// The page's own word for difficult ground, where the game has none, as free play.
|
|
133
|
+
return systemWord("words", `${terrain} terrain`) ?? t("{terrain} terrain", { terrain: systemWord("words", terrain) ?? (terrain === "difficult" ? t("difficult") : terrain) });
|
|
131
134
|
}
|
|
132
135
|
/** A name of the story as the character knows it, in the page's language: someone, a creature, somewhere for those it does not know. */
|
|
133
136
|
export function nameLabel(name) {
|
|
@@ -136,32 +139,29 @@ export function nameLabel(name) {
|
|
|
136
139
|
}
|
|
137
140
|
/** A fact of the story in the page's language, as a sentence: Ettore: PF 14 → 12. */
|
|
138
141
|
export function factLabel(fact) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
})();
|
|
164
|
-
return told;
|
|
142
|
+
switch (fact.kind) {
|
|
143
|
+
case "counter":
|
|
144
|
+
// A stack goes by the name its entry gives it (STK-12), never a field's word.
|
|
145
|
+
return t("{who}: {field} {before} → {after}", { who: subjectLabel(fact.who), field: fact.stack === true ? fact.field : fieldLabel(fact.field), before: fact.before, after: fact.after });
|
|
146
|
+
case "time":
|
|
147
|
+
return fact.from === undefined
|
|
148
|
+
? storyStartLabel(fact.to)
|
|
149
|
+
: t("Time passes: {from} → {to}", { from: gameDateLabel(fact.from), to: gameDateLabel(fact.to) });
|
|
150
|
+
case "moved":
|
|
151
|
+
return fact.to === undefined
|
|
152
|
+
? t("{who} to the open", { who: listText(fact.who.map((name, index) => (index === 0 ? subjectLabel(name) : nameLabel(name)))) })
|
|
153
|
+
: t("{who} to {place}", { who: listText(fact.who.map((name, index) => (index === 0 ? subjectLabel(name) : nameLabel(name)))), place: nameLabel(fact.to) });
|
|
154
|
+
case "learned":
|
|
155
|
+
return t("{who} learned: {what}", { who: fact.who, what: listText(fact.what.map((link) => link.replace("#", " › "))) });
|
|
156
|
+
case "effect":
|
|
157
|
+
return t("{who}: {effect}", { who: subjectLabel(fact.who), effect: effectLabel(fact) });
|
|
158
|
+
case "effect-ended":
|
|
159
|
+
return t("{who}: {effect} ended", { who: subjectLabel(fact.who), effect: effectName(fact.effect) });
|
|
160
|
+
case "back":
|
|
161
|
+
return t("Back to save {save}: what came after it is gone", { save: fact.save });
|
|
162
|
+
case "quest":
|
|
163
|
+
return fact.status === "open" ? t("Quest taken: {quest}", { quest: fact.quest }) : fact.status === "done" ? t("Quest completed: {quest}", { quest: fact.quest }) : t("Quest failed: {quest}", { quest: fact.quest });
|
|
164
|
+
}
|
|
165
165
|
}
|
|
166
166
|
/** When the story starts: on day 1, 18:00. */
|
|
167
167
|
function storyStartLabel(date) {
|