rpg-engine 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/campaign/settings.d.ts +1 -0
- package/dist/campaign/settings.js +6 -5
- package/dist/command-line.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.d.ts +1 -1
- package/dist/commands/ask.js +66 -24
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +67 -21
- package/dist/commands/effect.js +42 -23
- package/dist/commands/find.js +1 -1
- package/dist/commands/game-adventures.js +2 -2
- package/dist/commands/game-catalog.d.ts +13 -0
- package/dist/commands/game-catalog.js +26 -2
- package/dist/commands/game-checks.js +23 -21
- package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
- package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
- package/dist/commands/game-effects.d.ts +12 -4
- package/dist/commands/game-effects.js +21 -13
- package/dist/commands/game-examples.d.ts +22 -0
- package/dist/commands/game-examples.js +72 -0
- package/dist/commands/game-extension-list.d.ts +31 -3
- package/dist/commands/game-extension-list.js +83 -7
- package/dist/commands/game-images.d.ts +1 -1
- package/dist/commands/game-images.js +3 -2
- package/dist/commands/game-library.d.ts +3 -0
- package/dist/commands/game-library.js +2 -2
- package/dist/commands/game-mode.js +1 -1
- package/dist/commands/game-package-code.d.ts +87 -0
- package/dist/commands/game-package-code.js +648 -0
- package/dist/commands/game-package-hooks.d.ts +37 -0
- package/dist/commands/game-package-hooks.js +116 -0
- package/dist/commands/game-recipes.js +2 -2
- package/dist/commands/game-reminders.d.ts +5 -2
- package/dist/commands/game-reminders.js +7 -4
- package/dist/commands/game-rules.d.ts +4 -1
- package/dist/commands/game-rules.js +7 -1
- package/dist/commands/game-upkeep.js +3 -3
- package/dist/commands/game-view-place.d.ts +8 -20
- package/dist/commands/game-view-place.js +16 -35
- package/dist/commands/game-widgets.d.ts +39 -10
- package/dist/commands/game-widgets.js +138 -35
- package/dist/commands/game-world.d.ts +17 -0
- package/dist/commands/game-world.js +70 -12
- package/dist/commands/image.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package.d.ts +8 -0
- package/dist/commands/package.js +81 -24
- package/dist/commands/progression.d.ts +2 -0
- package/dist/commands/progression.js +7 -2
- package/dist/commands/roll.d.ts +2 -0
- package/dist/commands/roll.js +50 -24
- package/dist/commands/rules.js +6 -4
- package/dist/commands/scene.d.ts +1 -1
- package/dist/commands/scene.js +13 -10
- package/dist/commands/sheet.js +10 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +14 -4
- package/dist/commands/trade.js +6 -4
- package/dist/commands/translate.js +2 -2
- package/dist/commands/travel.js +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/view.d.ts +8 -4
- package/dist/commands/view.js +7 -6
- package/dist/commands/worked-out.js +11 -5
- package/dist/commands/write.d.ts +8 -1
- package/dist/commands/write.js +84 -25
- package/dist/core/command-reference.js +3 -2
- package/dist/core/consents.d.ts +18 -0
- package/dist/core/consents.js +93 -0
- package/dist/core/context.d.ts +51 -29
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/{extensions/api.d.ts → core/package-api.d.ts} +134 -32
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +2 -0
- package/dist/core/text.d.ts +5 -0
- package/dist/core/text.js +12 -0
- package/dist/dashboard/acts.js +31 -24
- package/dist/dashboard/address.js +4 -1
- package/dist/dashboard/api.js +54 -0
- package/dist/dashboard/app.js +140 -96
- package/dist/dashboard/ask-card.js +76 -25
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +3 -3
- package/dist/dashboard/extension-widgets.js +104 -10
- package/dist/dashboard/i18n/ar.json +25 -29
- package/dist/dashboard/i18n/cs.json +25 -29
- package/dist/dashboard/i18n/da.json +25 -29
- package/dist/dashboard/i18n/de.json +25 -29
- package/dist/dashboard/i18n/el.json +25 -29
- package/dist/dashboard/i18n/es.json +25 -29
- package/dist/dashboard/i18n/fi.json +25 -29
- package/dist/dashboard/i18n/fr.json +25 -29
- package/dist/dashboard/i18n/he.json +25 -29
- package/dist/dashboard/i18n/hi.json +25 -29
- package/dist/dashboard/i18n/hu.json +25 -29
- package/dist/dashboard/i18n/is.json +25 -29
- package/dist/dashboard/i18n/it.json +25 -29
- package/dist/dashboard/i18n/ja.json +25 -29
- package/dist/dashboard/i18n/ko.json +25 -29
- package/dist/dashboard/i18n/nb.json +25 -29
- package/dist/dashboard/i18n/nl.json +25 -29
- package/dist/dashboard/i18n/pl.json +25 -29
- package/dist/dashboard/i18n/pt.json +25 -29
- package/dist/dashboard/i18n/ro.json +25 -29
- package/dist/dashboard/i18n/ru.json +25 -29
- package/dist/dashboard/i18n/sv.json +25 -29
- package/dist/dashboard/i18n/tr.json +25 -29
- package/dist/dashboard/i18n/uk.json +25 -29
- package/dist/dashboard/i18n/zh.json +25 -29
- package/dist/dashboard/icons.js +4 -1
- package/dist/dashboard/kit.js +35 -0
- package/dist/dashboard/labels.js +1 -0
- package/dist/dashboard/pack-card.js +7 -2
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +172 -23
- package/dist/dashboard/page-code.js +248 -0
- package/dist/dashboard/party.js +13 -14
- package/dist/dashboard/people.js +4 -0
- package/dist/dashboard/person-panel.js +110 -0
- package/dist/dashboard/place-map-view.js +11 -6
- package/dist/dashboard/scene.js +12 -9
- package/dist/dashboard/settings.js +55 -9
- package/dist/dashboard/sheet.js +21 -13
- package/dist/dashboard/status.js +69 -15
- package/dist/dashboard/style.css +592 -825
- package/dist/dashboard/top.js +75 -25
- package/dist/dashboard/turns.js +34 -13
- package/dist/dashboard/widgets.js +9 -2
- package/dist/dashboard-server.js +189 -10
- package/dist/dice/roll-dice.js +1 -1
- package/dist/effects/effect.d.ts +7 -4
- package/dist/effects/effect.js +12 -9
- package/dist/extensions/engine.d.ts +4 -0
- package/dist/extensions/engine.js +74 -0
- package/dist/extensions/extension.d.ts +25 -37
- package/dist/extensions/extension.js +26 -48
- package/dist/extensions/index.d.ts +3 -2
- package/dist/extensions/index.js +4 -1
- package/dist/extensions/packages.d.ts +6 -0
- package/dist/extensions/packages.js +100 -11
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +51 -14
- package/dist/page-words.d.ts +4 -0
- package/dist/page-words.js +4 -4
- package/dist/page.d.ts +218 -0
- package/dist/page.js +2 -0
- package/dist/pages/load.d.ts +7 -1
- package/dist/pages/load.js +10 -5
- package/dist/pages/page-file.js +1 -1
- package/dist/pages/stack-writes.js +5 -4
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +52 -26
- package/dist/systems/game-system.js +141 -42
- package/dist/systems/index.d.ts +3 -3
- package/dist/systems/index.js +3 -3
- package/dist/systems/system-code.d.ts +29 -88
- package/dist/systems/system-code.js +68 -23
- package/dist/systems/words.d.ts +2 -0
- package/dist/systems/words.js +11 -0
- package/dist/testing.d.ts +20 -5
- package/dist/testing.js +49 -14
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +2 -2
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +3 -3
- package/instructions/setup.md +1 -1
- package/package.json +10 -2
- package/systems/5e/LICENSE.md +13 -3
- package/systems/5e/dist/dying.js +83 -16
- package/systems/5e/dist/index.js +2 -2
- package/systems/5e/dist/page-style.js +634 -0
- package/systems/5e/dist/page.js +166 -0
- package/systems/5e/dist/shown.js +23 -0
- package/systems/5e/instructions/combat.md +1 -0
- package/systems/5e/package.json +4 -2
- package/systems/5e/system.yaml +37 -9
- package/systems/5e/versions/srd-5.1/system.yaml +2 -0
- package/systems/5e/words/ar.yaml +30 -0
- package/systems/5e/words/cs.yaml +30 -0
- package/systems/5e/words/da.yaml +30 -0
- package/systems/5e/words/de.yaml +30 -0
- package/systems/5e/words/el.yaml +30 -0
- package/systems/5e/words/es.yaml +30 -0
- package/systems/5e/words/fi.yaml +30 -0
- package/systems/5e/words/fr.yaml +30 -0
- package/systems/5e/words/he.yaml +30 -0
- package/systems/5e/words/hi.yaml +30 -0
- package/systems/5e/words/hu.yaml +30 -0
- package/systems/5e/words/is.yaml +30 -0
- package/systems/5e/words/it.yaml +30 -0
- package/systems/5e/words/ja.yaml +30 -0
- package/systems/5e/words/ko.yaml +30 -0
- package/systems/5e/words/nb.yaml +30 -0
- package/systems/5e/words/nl.yaml +30 -0
- package/systems/5e/words/pl.yaml +30 -0
- package/systems/5e/words/pt.yaml +30 -0
- package/systems/5e/words/ro.yaml +30 -0
- package/systems/5e/words/ru.yaml +30 -0
- package/systems/5e/words/sv.yaml +30 -0
- package/systems/5e/words/tr.yaml +30 -0
- package/systems/5e/words/uk.yaml +30 -0
- package/systems/5e/words/zh.yaml +30 -0
- package/dist/commands/game-extensions.d.ts +0 -34
- package/dist/commands/game-extensions.js +0 -407
- package/dist/commands/game-system-code.d.ts +0 -33
- package/dist/commands/game-system-code.js +0 -188
- package/dist/dashboard/death-save.js +0 -67
- package/dist/dashboard/dying.js +0 -46
- package/dist/dashboard/save-outcome.js +0 -42
- package/dist/dashboard/spend.js +0 -115
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type CardPage, type FigureSize } from "../page.ts";
|
|
3
|
+
export type { CardPage, FigureSize };
|
|
4
|
+
/**
|
|
5
|
+
* 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
|
|
6
|
+
* system.yaml may declare. It goes up with every addition a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
|
|
7
|
+
* 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.
|
|
8
|
+
*/
|
|
9
|
+
export declare const packageApi = 5;
|
|
10
|
+
/**
|
|
11
|
+
* 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
|
|
12
|
+
* npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ourSystems: readonly {
|
|
15
|
+
name: string;
|
|
16
|
+
package: string;
|
|
17
|
+
title: string;
|
|
18
|
+
}[];
|
|
19
|
+
/** The kinds of package whose API is read. */
|
|
20
|
+
export type ApiKind = "extension" | "system";
|
|
21
|
+
/** Whether this rpg-engine reads a package of this kind made for this version of the API: from the kind's first up to its own. */
|
|
22
|
+
export declare function readsApi(api: number | undefined, kind: ApiKind): boolean;
|
|
23
|
+
/** What a package made for a newer API asks of the player, said where it is refused. */
|
|
24
|
+
export declare const updateEngine = "rpg-engine must be updated first: ask the player to update it on the Packages page of their dashboard, or as they installed it, then open a new chat";
|
|
25
|
+
/** Why this rpg-engine does not read a package made for this API, with what to do; undefined when it reads it. */
|
|
26
|
+
export declare function apiProblem(api: number | undefined, kind: ApiKind): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The places of the dashboard a widget may stand in (D-502): a chip in the top, a card in the table's column beside the rolls, a card in a page; on each of
|
|
29
|
+
* the party (D-514), under their name on their sheet, in their row of the turns and as the word of their state; or only in the card of a question its
|
|
30
|
+
* package's code asks in (D-507), as the 5e's death save.
|
|
31
|
+
*/
|
|
32
|
+
export declare const widgetPlaces: readonly ["top", "side", "page", "person", "card"];
|
|
33
|
+
export type WidgetPlace = (typeof widgetPlaces)[number];
|
|
34
|
+
/** A widget as a package declares it (D-502): its name, which its code's hook has, its title, its icon, and where it stands, among the cards in order. */
|
|
35
|
+
export interface DeclaredWidget {
|
|
36
|
+
name: string;
|
|
37
|
+
title: string;
|
|
38
|
+
icon?: string;
|
|
39
|
+
place: WidgetPlace;
|
|
40
|
+
/** The page of a card that stands in one. */
|
|
41
|
+
page?: CardPage;
|
|
42
|
+
/** Its order among the cards of its place, the lowest first. */
|
|
43
|
+
order: number;
|
|
44
|
+
}
|
|
45
|
+
declare const widgetSchema: z.ZodObject<{
|
|
46
|
+
title: z.ZodString;
|
|
47
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
48
|
+
place: z.ZodEnum<{
|
|
49
|
+
page: "page";
|
|
50
|
+
top: "top";
|
|
51
|
+
side: "side";
|
|
52
|
+
person: "person";
|
|
53
|
+
card: "card";
|
|
54
|
+
}>;
|
|
55
|
+
page: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
world: "world";
|
|
57
|
+
scene: "scene";
|
|
58
|
+
sheet: "sheet";
|
|
59
|
+
journal: "journal";
|
|
60
|
+
}>>;
|
|
61
|
+
order: z.ZodOptional<z.ZodInt>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
/** The keys of extension.yaml and system.yaml that declare a package's icons, widgets and figures (D-502, D-510). */
|
|
64
|
+
export declare const packagePartsShape: {
|
|
65
|
+
icons: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
66
|
+
widgets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
67
|
+
title: z.ZodString;
|
|
68
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
69
|
+
place: z.ZodEnum<{
|
|
70
|
+
page: "page";
|
|
71
|
+
top: "top";
|
|
72
|
+
side: "side";
|
|
73
|
+
person: "person";
|
|
74
|
+
card: "card";
|
|
75
|
+
}>;
|
|
76
|
+
page: z.ZodOptional<z.ZodEnum<{
|
|
77
|
+
world: "world";
|
|
78
|
+
scene: "scene";
|
|
79
|
+
sheet: "sheet";
|
|
80
|
+
journal: "journal";
|
|
81
|
+
}>>;
|
|
82
|
+
order: z.ZodOptional<z.ZodInt>;
|
|
83
|
+
}, z.core.$strict>>>;
|
|
84
|
+
figures: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
85
|
+
width: z.ZodInt;
|
|
86
|
+
height: z.ZodInt;
|
|
87
|
+
mirror: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
+
}, z.core.$strict>>>;
|
|
89
|
+
};
|
|
90
|
+
/** A package's icons, widgets and figures, as its file declares them. */
|
|
91
|
+
export interface DeclaredParts {
|
|
92
|
+
icons?: Record<string, string>;
|
|
93
|
+
widgets?: Record<string, z.infer<typeof widgetSchema>>;
|
|
94
|
+
figures?: Record<string, FigureSize>;
|
|
95
|
+
}
|
|
96
|
+
/** The issues of a package's icons, widgets and figures beyond their shape: too many, or a widget's icon that is not among the icons. */
|
|
97
|
+
export declare function packagePartsIssues(declared: DeclaredParts, owner: "an extension" | "a game system"): {
|
|
98
|
+
path: string[];
|
|
99
|
+
message: string;
|
|
100
|
+
}[];
|
|
101
|
+
/** A package's widgets as the engine keeps them, in the order written, each with its order among the cards. */
|
|
102
|
+
export declare function declaredWidgets(widgets: DeclaredParts["widgets"]): DeclaredWidget[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// What every package for rpg-engine declares alike, an extension in extension.yaml and a game system in system.yaml (D-502, D-510, D-514): the version of the
|
|
2
|
+
// API it is made for, and its icons, widgets and figures, with the same limits.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { cardPages } from "../page.js";
|
|
5
|
+
/**
|
|
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 a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
|
|
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.
|
|
9
|
+
*/
|
|
10
|
+
export const packageApi = 5;
|
|
11
|
+
/**
|
|
12
|
+
* 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
|
|
13
|
+
* npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
|
|
14
|
+
*/
|
|
15
|
+
export const ourSystems = [
|
|
16
|
+
{ name: "5e", package: "@rpgengine/system-5e", title: "compatible with fifth edition, from the SRD" },
|
|
17
|
+
];
|
|
18
|
+
// The oldest API each kind is read at: a system's first is 5, the one contract.
|
|
19
|
+
const oldestApi = { extension: 1, system: 5 };
|
|
20
|
+
/** Whether this rpg-engine reads a package of this kind made for this version of the API: from the kind's first up to its own. */
|
|
21
|
+
export function readsApi(api, kind) {
|
|
22
|
+
return api !== undefined && Number.isInteger(api) && api >= oldestApi[kind] && api <= packageApi;
|
|
23
|
+
}
|
|
24
|
+
/** What a package made for a newer API asks of the player, said where it is refused. */
|
|
25
|
+
export const updateEngine = "rpg-engine must be updated first: ask the player to update it on the Packages page of their dashboard, or as they installed it, then open a new chat";
|
|
26
|
+
/** Why this rpg-engine does not read a package made for this API, with what to do; undefined when it reads it. */
|
|
27
|
+
export function apiProblem(api, kind) {
|
|
28
|
+
if (readsApi(api, kind)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const range = oldestApi[kind] === packageApi ? `${packageApi}` : `${oldestApi[kind]} to ${packageApi}`;
|
|
32
|
+
const reads = `this rpg-engine reads the API ${range} for ${kind === "system" ? "a game system" : "an extension"}`;
|
|
33
|
+
return api !== undefined && api > packageApi
|
|
34
|
+
? `it is made for the API ${api}, and ${reads}: ${updateEngine}`
|
|
35
|
+
: `it is made for ${api === undefined ? "no API, as its package.json does not name one in rpg-engine.api" : `the API ${api}`}, and ${reads}: install a newer version of it`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The places of the dashboard a widget may stand in (D-502): a chip in the top, a card in the table's column beside the rolls, a card in a page; on each of
|
|
39
|
+
* the party (D-514), under their name on their sheet, in their row of the turns and as the word of their state; or only in the card of a question its
|
|
40
|
+
* package's code asks in (D-507), as the 5e's death save.
|
|
41
|
+
*/
|
|
42
|
+
export const widgetPlaces = ["top", "side", "page", "person", "card"];
|
|
43
|
+
// How many icons, widgets and figures a package may declare, and the longest path of an icon.
|
|
44
|
+
const mostIcons = 40;
|
|
45
|
+
const mostWidgets = 8;
|
|
46
|
+
const mostFigures = 8;
|
|
47
|
+
const longestPath = 4000;
|
|
48
|
+
/** A name of an icon, a widget or a figure, as weather or sky-rain. */
|
|
49
|
+
const ownName = z.string().regex(/^[a-z][a-z0-9-]*$/, "use lowercase letters, digits and hyphens, as sky-rain");
|
|
50
|
+
const widgetSchema = z.object({
|
|
51
|
+
title: z.string().trim().min(1).max(40),
|
|
52
|
+
icon: ownName.optional(),
|
|
53
|
+
place: z.enum(widgetPlaces, { error: `a widget's place is ${widgetPlaces.join(", ")}` }),
|
|
54
|
+
page: z.enum(cardPages, { error: `a card's page is ${cardPages.join(", ")}` }).optional(),
|
|
55
|
+
order: z.int().min(-100).max(100).optional(),
|
|
56
|
+
}).strict().refine((widget) => (widget.place === "page") === (widget.page !== undefined), {
|
|
57
|
+
error: "a widget in place page names its page (scene, sheet, world or journal), and only one in a page does",
|
|
58
|
+
});
|
|
59
|
+
/** The keys of extension.yaml and system.yaml that declare a package's icons, widgets and figures (D-502, D-510). */
|
|
60
|
+
export const packagePartsShape = {
|
|
61
|
+
icons: z.record(ownName, z.string().max(longestPath).regex(/^[MmLlHhVvCcSsQqTtAaZz\d\s,.+-]+$/, "an icon is the path of an SVG, as M4 12h16")).optional(),
|
|
62
|
+
widgets: z.record(ownName, widgetSchema).optional(),
|
|
63
|
+
figures: z.record(ownName, z.object({ width: z.int().min(8).max(1280), height: z.int().min(8).max(800), mirror: z.boolean().optional() }).strict()).optional(),
|
|
64
|
+
};
|
|
65
|
+
/** The issues of a package's icons, widgets and figures beyond their shape: too many, or a widget's icon that is not among the icons. */
|
|
66
|
+
export function packagePartsIssues(declared, owner) {
|
|
67
|
+
const icons = Object.keys(declared.icons ?? {});
|
|
68
|
+
const widgets = Object.entries(declared.widgets ?? {});
|
|
69
|
+
const many = icons.length > mostIcons || widgets.length > mostWidgets || Object.keys(declared.figures ?? {}).length > mostFigures
|
|
70
|
+
? [{ path: [], message: `${owner} declares at most ${mostIcons} icons, ${mostWidgets} widgets and ${mostFigures} figures` }]
|
|
71
|
+
: [];
|
|
72
|
+
const strays = widgets.filter(([, widget]) => widget.icon !== undefined && !icons.includes(widget.icon)).map(([name, widget]) => ({
|
|
73
|
+
path: ["widgets", name, "icon"],
|
|
74
|
+
message: `the icon ${widget.icon ?? ""} is not among the icons: add it there`,
|
|
75
|
+
}));
|
|
76
|
+
return [...many, ...strays];
|
|
77
|
+
}
|
|
78
|
+
/** A package's widgets as the engine keeps them, in the order written, each with its order among the cards. */
|
|
79
|
+
export function declaredWidgets(widgets) {
|
|
80
|
+
return Object.entries(widgets ?? {}).map(([name, widget]) => ({ name, ...widget, order: widget.order ?? 0 }));
|
|
81
|
+
}
|
package/dist/core/registry.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface Command<Schema extends z.ZodObject = z.ZodObject, Result = unkn
|
|
|
16
16
|
positionals?: string[];
|
|
17
17
|
/** The command asks the player directly: it exists only where the surface can (Context.player), never on the command line. */
|
|
18
18
|
needsPlayer?: boolean;
|
|
19
|
+
/** The player may run it too, from an extension's code in the dashboard's page (D-510): only an extension's command says so. */
|
|
20
|
+
forPlayer?: boolean;
|
|
19
21
|
/** The command may wait for the player's answer, as an extension's that asks (D-505): the MCP server reports so meanwhile, and it runs everywhere. */
|
|
20
22
|
waitsForPlayer?: boolean;
|
|
21
23
|
/** The command may take minutes, as an installation: the MCP server reports its progress meanwhile, so that a host does not give up on it. */
|
package/dist/core/text.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export declare function firstSentence(text: string): string;
|
|
|
6
6
|
export declare function withArticle(noun: string): string;
|
|
7
7
|
/** The name in `names` that `name` writes, ignoring case, how accents are written and the spaces around it; undefined when none does. */
|
|
8
8
|
export declare function sameName(names: string[], name: string): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Whether two names are one, as names are compared, or one is the other's word in `words`, a table from names to their words in another language: Prone and
|
|
11
|
+
* Prono by {Prone: Prono}.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sameWord(one: string, other: string, words?: Record<string, string>): boolean;
|
|
9
14
|
/** The value a record holds under a name, as names are compared (INH-5); undefined when it holds none. */
|
|
10
15
|
export declare function valueNamed(record: Record<string, unknown>, name: string): unknown;
|
|
11
16
|
/** The page a link's target names: [[folder/Page.md]], and [[Page\|label]] as written in tables, name Page. */
|
package/dist/core/text.js
CHANGED
|
@@ -21,6 +21,18 @@ export function withArticle(noun) {
|
|
|
21
21
|
export function sameName(names, name) {
|
|
22
22
|
return names.find((candidate) => comparableText(candidate) === comparableText(name.trim()));
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether two names are one, as names are compared, or one is the other's word in `words`, a table from names to their words in another language: Prone and
|
|
26
|
+
* Prono by {Prone: Prono}.
|
|
27
|
+
*/
|
|
28
|
+
export function sameWord(one, other, words) {
|
|
29
|
+
const wordOf = (name) => {
|
|
30
|
+
const key = words === undefined ? undefined : sameName(Object.keys(words), name);
|
|
31
|
+
return key === undefined ? undefined : words?.[key];
|
|
32
|
+
};
|
|
33
|
+
const same = (first, second) => first !== undefined && comparableText(first.trim()) === comparableText(second.trim());
|
|
34
|
+
return same(one, other) || same(wordOf(one), other) || same(wordOf(other), one);
|
|
35
|
+
}
|
|
24
36
|
/** The value a record holds under a name, as names are compared (INH-5); undefined when it holds none. */
|
|
25
37
|
export function valueNamed(record, name) {
|
|
26
38
|
const key = sameName(Object.keys(record), name);
|
package/dist/dashboard/acts.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { strangerLabel } from "./labels.js";
|
|
2
2
|
import { t } from "./text.js";
|
|
3
|
-
|
|
3
|
+
// The system's own verbs, by name, as the overview gives them (D-514).
|
|
4
|
+
let systemVerbs = {};
|
|
5
|
+
/** Sets the game system's own verbs; none, the engine's alone. */
|
|
6
|
+
export function setSystemVerbs(verbs) {
|
|
7
|
+
systemVerbs = verbs ?? {};
|
|
8
|
+
}
|
|
9
|
+
/** Whether a verb asks for someone to act on, lets the player choose one, or goes straight to the sentence (D-495); a system's lets choose when it says on whom. */
|
|
4
10
|
export function targetMode(verb) {
|
|
5
|
-
return verb === "attack" ? "asks" : verb === "
|
|
11
|
+
return verb === "attack" ? "asks" : verb === "use" || ownVerb(verb)?.on !== undefined ? "lets" : "none";
|
|
6
12
|
}
|
|
7
13
|
/** The player's sentence as the page first writes it, which the player may change before it goes: a model of the page's language with the names as shown. */
|
|
8
14
|
export function actSentence(verb, item, target = "none") {
|
|
9
15
|
const on = typeof target === "object" && "person" in target ? target.person : undefined;
|
|
10
16
|
const at = typeof target === "object" && "square" in target ? target.square : undefined;
|
|
17
|
+
const own = ownVerb(verb);
|
|
18
|
+
if (own !== undefined) {
|
|
19
|
+
const chosen = on !== undefined ? own.on : at !== undefined ? own.at : target === "self" ? own.self : undefined;
|
|
20
|
+
return t(chosen ?? own.says, { item, ...(on === undefined ? {} : { target: on }), ...(at === undefined ? {} : { square: at }) });
|
|
21
|
+
}
|
|
11
22
|
switch (verb) {
|
|
12
23
|
case "attack":
|
|
13
24
|
return on !== undefined
|
|
@@ -17,14 +28,6 @@ export function actSentence(verb, item, target = "none") {
|
|
|
17
28
|
: target === "self"
|
|
18
29
|
? t("I attack myself with {item}.", { item })
|
|
19
30
|
: t("I attack with {item}.", { item });
|
|
20
|
-
case "cast":
|
|
21
|
-
return on !== undefined
|
|
22
|
-
? t("I cast {item} on {target}.", { target: on, item })
|
|
23
|
-
: at !== undefined
|
|
24
|
-
? t("I cast {item} at {square}.", { square: at, item })
|
|
25
|
-
: target === "self"
|
|
26
|
-
? t("I cast {item} on myself.", { item })
|
|
27
|
-
: t("I cast {item}.", { item });
|
|
28
31
|
case "use":
|
|
29
32
|
return on !== undefined
|
|
30
33
|
? t("I use {item} on {target}.", { target: on, item })
|
|
@@ -37,8 +40,8 @@ export function actSentence(verb, item, target = "none") {
|
|
|
37
40
|
return t("I equip {item}.", { item });
|
|
38
41
|
case "unequip":
|
|
39
42
|
return t("I put away {item}.", { item });
|
|
40
|
-
|
|
41
|
-
return t("I
|
|
43
|
+
default:
|
|
44
|
+
return t("I use {item}.", { item });
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
/** The start of what the player says to someone, the cursor after it. */
|
|
@@ -51,36 +54,36 @@ export function spokenBy(sentence, who) {
|
|
|
51
54
|
}
|
|
52
55
|
/** What a verb does with a thing, as a button's tooltip and the sheet's title say it: Attack with Mace. */
|
|
53
56
|
export function actTitle(verb, item) {
|
|
57
|
+
const own = ownVerb(verb);
|
|
58
|
+
if (own !== undefined) {
|
|
59
|
+
return t(own.title, { item });
|
|
60
|
+
}
|
|
54
61
|
switch (verb) {
|
|
55
62
|
case "attack":
|
|
56
63
|
return t("Attack with {item}", { item });
|
|
57
|
-
case "cast":
|
|
58
|
-
return t("Cast {item}", { item });
|
|
59
|
-
case "use":
|
|
60
|
-
return t("Use {item}", { item });
|
|
61
64
|
case "equip":
|
|
62
65
|
return t("Equip {item}", { item });
|
|
63
66
|
case "unequip":
|
|
64
67
|
return t("Put away {item}", { item });
|
|
65
|
-
|
|
66
|
-
return t("
|
|
68
|
+
default:
|
|
69
|
+
return t("Use {item}", { item });
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
/** A verb alone, for the choice among a thing's verbs. */
|
|
70
73
|
export function verbLabel(verb) {
|
|
74
|
+
const own = ownVerb(verb);
|
|
75
|
+
if (own !== undefined) {
|
|
76
|
+
return t(own.label);
|
|
77
|
+
}
|
|
71
78
|
switch (verb) {
|
|
72
79
|
case "attack":
|
|
73
80
|
return t("Attack");
|
|
74
|
-
case "cast":
|
|
75
|
-
return t("Cast");
|
|
76
|
-
case "use":
|
|
77
|
-
return t("Use");
|
|
78
81
|
case "equip":
|
|
79
82
|
return t("Equip");
|
|
80
83
|
case "unequip":
|
|
81
84
|
return t("Put away");
|
|
82
|
-
|
|
83
|
-
return t("
|
|
85
|
+
default:
|
|
86
|
+
return t("Use");
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
@@ -138,3 +141,7 @@ export function saidStates(said, shown, live) {
|
|
|
138
141
|
return state === undefined ? [] : [{ act, state }];
|
|
139
142
|
});
|
|
140
143
|
}
|
|
144
|
+
/** A verb the system declares, by its name; undefined for one of the engine's. */
|
|
145
|
+
function ownVerb(verb) {
|
|
146
|
+
return Object.hasOwn(systemVerbs, verb) ? systemVerbs[verb] : undefined;
|
|
147
|
+
}
|
|
@@ -6,11 +6,13 @@ import { t } from "./text.js";
|
|
|
6
6
|
export const sections = ["party", "scene", "journal", "world"];
|
|
7
7
|
/** The pages at the row's end, as icons, in the menu on a phone: the saves, played with, then what is read, as Help and the settings are, and the packages (D-356, D-409, D-475). */
|
|
8
8
|
export const menuPages = ["saves", "help", "settings", "packages", "about"];
|
|
9
|
+
/** A package's own page, as #/pkg/<package>/<name>, reached from its row in Packages and by its address (D-511). */
|
|
10
|
+
export const packagePages = "pkg";
|
|
9
11
|
/** The address a hash says, as #/party/Ettore; the sheet for none or one the page does not know. */
|
|
10
12
|
export function readAddress(hash) {
|
|
11
13
|
const [, written = "", ...rest] = hash.replace(/^#/, "").split("/");
|
|
12
14
|
const first = written === "combat" ? "scene" : written;
|
|
13
|
-
const section = [...sections, ...menuPages].find((candidate) => candidate === first) ?? "party";
|
|
15
|
+
const section = [...sections, ...menuPages, packagePages].find((candidate) => candidate === first) ?? "party";
|
|
14
16
|
const sheet = first === "party" || first === "character";
|
|
15
17
|
const known = section === first;
|
|
16
18
|
const tab = sheet || !known ? "" : decoded(rest[0] ?? "");
|
|
@@ -33,6 +35,7 @@ export function sectionLabel(section) {
|
|
|
33
35
|
settings: t("Settings"),
|
|
34
36
|
packages: t("Packages"),
|
|
35
37
|
about: t("About"),
|
|
38
|
+
pkg: t("Packages"),
|
|
36
39
|
};
|
|
37
40
|
return labels[section];
|
|
38
41
|
}
|
package/dist/dashboard/api.js
CHANGED
|
@@ -147,6 +147,32 @@ export async function changeSaves(change) {
|
|
|
147
147
|
return t("It did not reach the game: try again.");
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
/** 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
|
+
export async function readEngine() {
|
|
152
|
+
const response = await fetch("/api/engine");
|
|
153
|
+
const body = await response.json();
|
|
154
|
+
if (response.status === 400) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
if ("error" in body) {
|
|
158
|
+
throw new Error(body.error);
|
|
159
|
+
}
|
|
160
|
+
return body;
|
|
161
|
+
}
|
|
162
|
+
/** Installs npm's latest RPG Engine as it was installed: the chat and this page go on with the one they started with. */
|
|
163
|
+
export async function updateEngine() {
|
|
164
|
+
try {
|
|
165
|
+
const response = await fetch("/api/engine", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action: "update" }) });
|
|
166
|
+
const body = await response.json().catch(() => ({}));
|
|
167
|
+
if (response.status === 202 && body.version !== undefined) {
|
|
168
|
+
return { done: true, version: body.version, restart: body.restart === "app" ? "app" : "chat" };
|
|
169
|
+
}
|
|
170
|
+
return { done: false, error: body.error ?? t("It did not reach the game: try again."), ...(body.code === "busy" ? { code: body.code } : {}) };
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return { done: false, error: t("It did not reach the game: try again.") };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
150
176
|
/** The packages here, at once: without npm. */
|
|
151
177
|
export async function readPackages() {
|
|
152
178
|
const response = await fetch("/api/packages");
|
|
@@ -165,6 +191,25 @@ export async function readWidgets() {
|
|
|
165
191
|
}
|
|
166
192
|
return body.widgets;
|
|
167
193
|
}
|
|
194
|
+
/** 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
|
+
export async function readWidgetData(owner, widget, who) {
|
|
196
|
+
const query = new URLSearchParams({ package: owner, widget, ...(who === undefined ? {} : { who }) });
|
|
197
|
+
const response = await fetch(`/api/widget?${query.toString()}`);
|
|
198
|
+
const body = await response.json();
|
|
199
|
+
if (body.error !== undefined) {
|
|
200
|
+
throw new Error(body.error);
|
|
201
|
+
}
|
|
202
|
+
return body.shows;
|
|
203
|
+
}
|
|
204
|
+
/** The page modules of the campaign's system and extensions whose code runs (D-510, D-511), the system's first. */
|
|
205
|
+
export async function readModules() {
|
|
206
|
+
const response = await fetch("/api/modules");
|
|
207
|
+
const body = await response.json();
|
|
208
|
+
if ("error" in body) {
|
|
209
|
+
throw new Error(body.error);
|
|
210
|
+
}
|
|
211
|
+
return body.modules;
|
|
212
|
+
}
|
|
168
213
|
/** The catalog (D-486), as the server keeps it for ten minutes; `fresh` asks npm and GitHub again. */
|
|
169
214
|
export async function readCatalog(fresh) {
|
|
170
215
|
const response = await fetch(fresh ? "/api/catalog?fresh=true" : "/api/catalog");
|
|
@@ -321,3 +366,12 @@ export function explanations(lines) {
|
|
|
321
366
|
return colon < 0 ? [] : [[field, line.slice(colon + 2).split(", ")]];
|
|
322
367
|
}));
|
|
323
368
|
}
|
|
369
|
+
/** Runs a command of an extension marked for the player (D-510), as its page code asks: what it said; it throws what went wrong, as the engine says it. */
|
|
370
|
+
export async function runCommand(command, input = {}) {
|
|
371
|
+
const response = await fetch("/api/run", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ command, input }) });
|
|
372
|
+
const body = await response.json().catch(() => ({}));
|
|
373
|
+
if (!response.ok || body.error !== undefined) {
|
|
374
|
+
throw new Error(body.error ?? `${command} did not run (${response.status})`);
|
|
375
|
+
}
|
|
376
|
+
return body.text ?? "";
|
|
377
|
+
}
|