rpg-engine 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/campaign/settings.d.ts +1 -0
- package/dist/campaign/settings.js +6 -5
- package/dist/command-line.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.d.ts +37 -2
- package/dist/commands/ask.js +106 -35
- package/dist/commands/change.js +28 -17
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +69 -21
- package/dist/commands/effect.js +42 -23
- package/dist/commands/find.js +1 -1
- package/dist/commands/game-adventures.js +2 -2
- package/dist/commands/game-catalog.d.ts +13 -0
- package/dist/commands/game-catalog.js +26 -2
- package/dist/commands/game-checks.js +23 -21
- package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
- package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
- package/dist/commands/game-effects.d.ts +12 -4
- package/dist/commands/game-effects.js +21 -13
- package/dist/commands/game-examples.d.ts +22 -0
- package/dist/commands/game-examples.js +72 -0
- package/dist/commands/game-extension-list.d.ts +31 -3
- package/dist/commands/game-extension-list.js +94 -6
- package/dist/commands/game-images.d.ts +1 -1
- package/dist/commands/game-images.js +3 -2
- package/dist/commands/game-library.d.ts +3 -0
- package/dist/commands/game-library.js +2 -2
- package/dist/commands/game-mode.js +1 -1
- package/dist/commands/game-package-code.d.ts +87 -0
- package/dist/commands/game-package-code.js +648 -0
- package/dist/commands/game-package-hooks.d.ts +37 -0
- package/dist/commands/game-package-hooks.js +116 -0
- package/dist/commands/game-recipes.js +2 -2
- package/dist/commands/game-reminders.d.ts +5 -2
- package/dist/commands/game-reminders.js +7 -4
- package/dist/commands/game-rules.d.ts +4 -1
- package/dist/commands/game-rules.js +7 -1
- package/dist/commands/game-upkeep.js +3 -3
- package/dist/commands/game-view-place.d.ts +8 -20
- package/dist/commands/game-view-place.js +16 -35
- package/dist/commands/game-widgets.d.ts +42 -8
- package/dist/commands/game-widgets.js +182 -31
- package/dist/commands/game-world.d.ts +32 -3
- package/dist/commands/game-world.js +113 -24
- package/dist/commands/image.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package.d.ts +15 -1
- package/dist/commands/package.js +96 -24
- package/dist/commands/progression.d.ts +2 -0
- package/dist/commands/progression.js +7 -2
- package/dist/commands/roll.d.ts +2 -0
- package/dist/commands/roll.js +50 -24
- package/dist/commands/rules.js +6 -4
- package/dist/commands/scene.d.ts +2 -2
- package/dist/commands/scene.js +13 -10
- package/dist/commands/sheet.js +10 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +14 -4
- package/dist/commands/trade.js +6 -4
- package/dist/commands/translate.js +2 -2
- package/dist/commands/travel.js +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/view.d.ts +12 -4
- package/dist/commands/view.js +11 -8
- package/dist/commands/worked-out.js +11 -5
- package/dist/commands/write.d.ts +8 -1
- package/dist/commands/write.js +84 -25
- package/dist/core/command-reference.js +3 -2
- package/dist/core/consents.d.ts +18 -0
- package/dist/core/consents.js +93 -0
- package/dist/core/context.d.ts +68 -27
- package/dist/core/context.js +3 -1
- package/dist/core/examples.d.ts +25 -0
- package/dist/core/examples.js +19 -0
- package/dist/core/files.d.ts +2 -0
- package/dist/core/files.js +10 -1
- package/dist/core/package-api.d.ts +388 -0
- package/dist/core/package-declarations.d.ts +102 -0
- package/dist/core/package-declarations.js +81 -0
- package/dist/core/registry.d.ts +4 -0
- package/dist/core/text.d.ts +5 -0
- package/dist/core/text.js +12 -0
- package/dist/dashboard/acts.js +31 -24
- package/dist/dashboard/address.js +4 -1
- package/dist/dashboard/api.js +65 -3
- package/dist/dashboard/app.js +222 -98
- package/dist/dashboard/ask-card.js +169 -0
- package/dist/dashboard/asked-dice.js +57 -0
- package/dist/dashboard/dice/tray.js +6 -4
- package/dist/dashboard/extension-widgets.js +136 -16
- package/dist/dashboard/faces.js +6 -4
- package/dist/dashboard/help.js +10 -3
- package/dist/dashboard/i18n/ar.json +34 -29
- package/dist/dashboard/i18n/cs.json +34 -29
- package/dist/dashboard/i18n/da.json +34 -29
- package/dist/dashboard/i18n/de.json +34 -29
- package/dist/dashboard/i18n/el.json +34 -29
- package/dist/dashboard/i18n/es.json +34 -29
- package/dist/dashboard/i18n/fi.json +34 -29
- package/dist/dashboard/i18n/fr.json +34 -29
- package/dist/dashboard/i18n/he.json +34 -29
- package/dist/dashboard/i18n/hi.json +34 -29
- package/dist/dashboard/i18n/hu.json +34 -29
- package/dist/dashboard/i18n/is.json +34 -29
- package/dist/dashboard/i18n/it.json +34 -29
- package/dist/dashboard/i18n/ja.json +34 -29
- package/dist/dashboard/i18n/ko.json +34 -29
- package/dist/dashboard/i18n/nb.json +34 -29
- package/dist/dashboard/i18n/nl.json +34 -29
- package/dist/dashboard/i18n/pl.json +34 -29
- package/dist/dashboard/i18n/pt.json +34 -29
- package/dist/dashboard/i18n/ro.json +34 -29
- package/dist/dashboard/i18n/ru.json +34 -29
- package/dist/dashboard/i18n/sv.json +34 -29
- package/dist/dashboard/i18n/tr.json +34 -29
- package/dist/dashboard/i18n/uk.json +34 -29
- package/dist/dashboard/i18n/zh.json +34 -29
- package/dist/dashboard/icons.js +4 -1
- package/dist/dashboard/kit.js +35 -0
- package/dist/dashboard/labels.js +1 -0
- package/dist/dashboard/pack-card.js +97 -0
- package/dist/dashboard/package-page.js +50 -0
- package/dist/dashboard/packages.js +180 -24
- package/dist/dashboard/page-code.js +248 -0
- package/dist/dashboard/party.js +13 -14
- package/dist/dashboard/people.js +4 -0
- package/dist/dashboard/person-panel.js +110 -0
- package/dist/dashboard/place-map-view.js +11 -6
- package/dist/dashboard/rolls.js +2 -2
- package/dist/dashboard/scene.js +12 -9
- package/dist/dashboard/settings.js +55 -9
- package/dist/dashboard/sheet.js +21 -13
- package/dist/dashboard/status.js +69 -15
- package/dist/dashboard/style.css +859 -574
- package/dist/dashboard/top.js +75 -25
- package/dist/dashboard/turns.js +34 -13
- package/dist/dashboard/widgets.js +9 -2
- package/dist/dashboard-server.js +246 -11
- package/dist/dice/roll-dice.js +1 -1
- package/dist/effects/effect.d.ts +7 -4
- package/dist/effects/effect.js +12 -9
- package/dist/extensions/engine.d.ts +4 -0
- package/dist/extensions/engine.js +74 -0
- package/dist/extensions/extension.d.ts +28 -33
- package/dist/extensions/extension.js +37 -46
- package/dist/extensions/index.d.ts +4 -3
- package/dist/extensions/index.js +5 -2
- package/dist/extensions/packages.d.ts +14 -0
- package/dist/extensions/packages.js +148 -12
- package/dist/extensions/words.d.ts +2 -1
- package/dist/extensions/words.js +5 -4
- package/dist/index.d.ts +1 -3
- package/dist/mcp-server.js +52 -15
- package/dist/page-words.d.ts +4 -0
- package/dist/page-words.js +4 -4
- package/dist/page.d.ts +218 -0
- package/dist/page.js +2 -0
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/load.d.ts +7 -1
- package/dist/pages/load.js +10 -5
- package/dist/pages/page-file.js +1 -1
- package/dist/pages/stack-writes.js +5 -4
- package/dist/pages/standard-fields.d.ts +2 -0
- package/dist/pages/standard-fields.js +8 -1
- package/dist/pages/world.d.ts +8 -0
- package/dist/pages/world.js +9 -2
- package/dist/systems/game-system.d.ts +61 -30
- package/dist/systems/game-system.js +159 -50
- package/dist/systems/index.d.ts +3 -3
- package/dist/systems/index.js +3 -3
- package/dist/systems/system-code.d.ts +29 -88
- package/dist/systems/system-code.js +68 -23
- package/dist/systems/words.d.ts +2 -0
- package/dist/systems/words.js +11 -0
- package/dist/testing.d.ts +76 -0
- package/dist/testing.js +197 -0
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/dashboard.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/setup.md +1 -1
- package/package.json +15 -2
- package/systems/5e/LICENSE.md +13 -3
- package/systems/5e/dist/dying.js +83 -16
- package/systems/5e/dist/index.js +2 -2
- package/systems/5e/dist/page-style.js +634 -0
- package/systems/5e/dist/page.js +166 -0
- package/systems/5e/dist/shown.js +23 -0
- package/systems/5e/instructions/combat.md +1 -0
- package/systems/5e/package.json +4 -2
- package/systems/5e/system.yaml +35 -7
- package/systems/5e/versions/srd-5.1/system.yaml +2 -0
- package/systems/5e/words/ar.yaml +30 -0
- package/systems/5e/words/cs.yaml +30 -0
- package/systems/5e/words/da.yaml +30 -0
- package/systems/5e/words/de.yaml +30 -0
- package/systems/5e/words/el.yaml +30 -0
- package/systems/5e/words/es.yaml +30 -0
- package/systems/5e/words/fi.yaml +30 -0
- package/systems/5e/words/fr.yaml +30 -0
- package/systems/5e/words/he.yaml +30 -0
- package/systems/5e/words/hi.yaml +30 -0
- package/systems/5e/words/hu.yaml +30 -0
- package/systems/5e/words/is.yaml +30 -0
- package/systems/5e/words/it.yaml +30 -0
- package/systems/5e/words/ja.yaml +30 -0
- package/systems/5e/words/ko.yaml +30 -0
- package/systems/5e/words/nb.yaml +30 -0
- package/systems/5e/words/nl.yaml +30 -0
- package/systems/5e/words/pl.yaml +30 -0
- package/systems/5e/words/pt.yaml +30 -0
- package/systems/5e/words/ro.yaml +30 -0
- package/systems/5e/words/ru.yaml +30 -0
- package/systems/5e/words/sv.yaml +30 -0
- package/systems/5e/words/tr.yaml +30 -0
- package/systems/5e/words/uk.yaml +30 -0
- package/systems/5e/words/zh.yaml +30 -0
- package/dist/commands/game-extensions.d.ts +0 -34
- package/dist/commands/game-extensions.js +0 -182
- package/dist/commands/game-system-code.d.ts +0 -25
- package/dist/commands/game-system-code.js +0 -172
- package/dist/dashboard/death-save.js +0 -67
- package/dist/dashboard/dying.js +0 -46
- package/dist/dashboard/save-outcome.js +0 -42
- package/dist/dashboard/spend.js +0 -115
- package/dist/extensions/api.d.ts +0 -155
- /package/dist/{extensions/api.js → core/package-api.js} +0 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/** What a package's code gets when it loads: zod, to describe its commands' input with the same library the engine checks them with. */
|
|
3
|
+
export interface PackageKit {
|
|
4
|
+
z: typeof z;
|
|
5
|
+
}
|
|
6
|
+
/** The default export of a package's code: given the kit, what it gives rpg-engine. */
|
|
7
|
+
export type PackageEntry = (kit: PackageKit) => PackageCode;
|
|
8
|
+
/**
|
|
9
|
+
* What a package's code gives rpg-engine, each part optional, the same for every kind of package (D-511, D-514). The hooks after the engine's own writes,
|
|
10
|
+
* counterChanged, turnStarted, rolled and effectAdded, are called for the campaign's game system first, then for its extensions in order, each giving lines for
|
|
11
|
+
* the command's output; they are called at once, never waiting.
|
|
12
|
+
*/
|
|
13
|
+
export interface PackageCode {
|
|
14
|
+
/** Its commands, which the command line and the MCP server give the master beside the core's (D-63). */
|
|
15
|
+
commands?: PackageCommand<any>[];
|
|
16
|
+
/** After advance or travel moved the game date: lines for their output, such as the weather of a new morning (D-436). */
|
|
17
|
+
timePassed?(passage: TimePassage, game: Game): string[] | Promise<string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* What each widget its extension.yaml or system.yaml declares shows now, by the widget's name there (D-502): called as the dashboard reads the game, it only
|
|
20
|
+
* reads; nothing shows for undefined. Read as the card of a question, it is given the card's key, the attempt to show (D-507), and whose roll it is; for a card or a page of
|
|
21
|
+
* its page code that names it, the character the card shows, as who (D-514); in place person, each of the party in turn, as who.
|
|
22
|
+
*/
|
|
23
|
+
widgets?: Record<string, (game: GameView, asked?: {
|
|
24
|
+
key?: string;
|
|
25
|
+
who?: string;
|
|
26
|
+
}) => Widget | undefined | Promise<Widget | undefined>>;
|
|
27
|
+
/** After change, or a rest's dice, wrote a counter of a page. Writes made through the game call no hook. */
|
|
28
|
+
counterChanged?(change: CounterChange, game: Game): string[];
|
|
29
|
+
/** As someone's turn starts in a scene. */
|
|
30
|
+
turnStarted?(turn: {
|
|
31
|
+
who: string;
|
|
32
|
+
}, game: Game): string[];
|
|
33
|
+
/** After a roll for someone was logged, never a hidden one. */
|
|
34
|
+
rolled?(roll: Rolled & {
|
|
35
|
+
who: string;
|
|
36
|
+
}, game: Game): string[];
|
|
37
|
+
/** After an effect was added to a page, never to a copy. */
|
|
38
|
+
effectAdded?(added: {
|
|
39
|
+
page: string;
|
|
40
|
+
effect: string;
|
|
41
|
+
}, game: Game): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Before the core's ask shows its buttons: how the dashboard asks this roll (D-507), as game.ask words it, such as in the card of one of its widgets and with
|
|
44
|
+
* no button to turn it down; undefined to ask as always. The first package that gives one words the roll. It only reads.
|
|
45
|
+
*/
|
|
46
|
+
asking?(question: AskingQuestion, game: GameView): Asking | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What the core's ask asks, as asking gets it: whose roll, the checks' names and their dice, in order; for the dice of a rest, the recipe, the checks being the
|
|
50
|
+
* counters of dice and the notations a die of each, as 1d8.
|
|
51
|
+
*/
|
|
52
|
+
export interface AskingQuestion {
|
|
53
|
+
who: string;
|
|
54
|
+
checks: string[];
|
|
55
|
+
notations: string[];
|
|
56
|
+
recipe?: string;
|
|
57
|
+
}
|
|
58
|
+
/** A command of a package: its name is the package's, or starts with it and a hyphen, as weather or weather-set (D-63). */
|
|
59
|
+
export interface PackageCommand<Input extends z.ZodObject = z.ZodObject> {
|
|
60
|
+
name: string;
|
|
61
|
+
/** Written for an AI: what it does (the first sentence), when to use it, an example. */
|
|
62
|
+
description: string;
|
|
63
|
+
input: Input;
|
|
64
|
+
/** It changes nothing: hosts may run it without asking. */
|
|
65
|
+
readOnly?: boolean;
|
|
66
|
+
/** Fields the command line takes as positional arguments, in order: weather-set 2. */
|
|
67
|
+
positionals?: string[];
|
|
68
|
+
/** The player may run it too, from the package's code in the dashboard's page, with run (D-510); the master hears it at their next call. */
|
|
69
|
+
player?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* It may ask the player with game.ask (D-505): through MCP the host is told it waits for the player, so that it does not give up. Unlike the core's ask it
|
|
72
|
+
* stays on the command line and where nothing shows buttons, where ask gives the question in words.
|
|
73
|
+
*/
|
|
74
|
+
needsPlayer?: boolean;
|
|
75
|
+
/** The text the master reads; an error thrown says what went wrong and how to fix it. */
|
|
76
|
+
run(input: z.infer<Input>, game: Game): string | Promise<string>;
|
|
77
|
+
}
|
|
78
|
+
/** A moment of the story: its game date as written, day 3, 06:00; the day and the minute of the day; the day of the calendar, when the story starts on one. */
|
|
79
|
+
export interface GameMoment {
|
|
80
|
+
date: string;
|
|
81
|
+
day: number;
|
|
82
|
+
minute?: number;
|
|
83
|
+
calendar?: CalendarDay;
|
|
84
|
+
}
|
|
85
|
+
/** A day of the world's calendar (TIM-8). */
|
|
86
|
+
export interface CalendarDay {
|
|
87
|
+
day: number;
|
|
88
|
+
month: string;
|
|
89
|
+
season?: string;
|
|
90
|
+
year?: number;
|
|
91
|
+
}
|
|
92
|
+
/** The time an advance or a travel let pass. */
|
|
93
|
+
export interface TimePassage {
|
|
94
|
+
from: GameMoment;
|
|
95
|
+
to: GameMoment;
|
|
96
|
+
}
|
|
97
|
+
/** A counter a command changed on a page: before and after, its maximum, and what damage took of it past what shields it. */
|
|
98
|
+
export interface CounterChange {
|
|
99
|
+
page: string;
|
|
100
|
+
field: string;
|
|
101
|
+
before: number;
|
|
102
|
+
after: number;
|
|
103
|
+
max?: number;
|
|
104
|
+
lost: number;
|
|
105
|
+
}
|
|
106
|
+
/** The campaign as a widget reads it (D-502): what the code's commands reach, without the dice, the log, asking or writing. */
|
|
107
|
+
export interface GameView {
|
|
108
|
+
/** Now, in the game; undefined before the game has a date. */
|
|
109
|
+
now(): GameMoment | undefined;
|
|
110
|
+
/** The day of the calendar a game day falls on; undefined when the story counts only the days. */
|
|
111
|
+
calendarDay(day: number): CalendarDay | undefined;
|
|
112
|
+
/** The units of measure the campaign tells the story in. */
|
|
113
|
+
units(): "metric" | "imperial";
|
|
114
|
+
/**
|
|
115
|
+
* Where the party is: the first living player character's places, in the order of the pages, the nearest first, and what holds there by the places'
|
|
116
|
+
* environment, such as biome: desert; and its living members, in the order of the pages (D-505).
|
|
117
|
+
*/
|
|
118
|
+
party(): {
|
|
119
|
+
places: string[];
|
|
120
|
+
environment: Record<string, string>;
|
|
121
|
+
members: {
|
|
122
|
+
name: string;
|
|
123
|
+
pc: boolean;
|
|
124
|
+
}[];
|
|
125
|
+
} | undefined;
|
|
126
|
+
/** A page by its name or alias (D-505); undefined when no page, or more than one, has it. */
|
|
127
|
+
page(name: string): GamePage | undefined;
|
|
128
|
+
/** The open scene: its title, when it opened, and in a fight its round and whose turn it is (D-505); undefined when none is open. */
|
|
129
|
+
scene(): {
|
|
130
|
+
title: string;
|
|
131
|
+
opened?: string;
|
|
132
|
+
round?: number;
|
|
133
|
+
turn?: string;
|
|
134
|
+
} | undefined;
|
|
135
|
+
/** A setting of the campaign, as mentor; undefined when it has none. */
|
|
136
|
+
setting(name: string): string | undefined;
|
|
137
|
+
/** Whether two names are the same, as the engine compares them: case and accents aside. */
|
|
138
|
+
sameName(one: string, other: string): boolean;
|
|
139
|
+
/** The package's own state, kept in the campaign. */
|
|
140
|
+
state: {
|
|
141
|
+
read(): unknown;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** A page as a package's code reads it (D-505), with what its effects give and what the game system works out, as show gives it. */
|
|
145
|
+
export interface GamePage {
|
|
146
|
+
name: string;
|
|
147
|
+
/** The player's character. */
|
|
148
|
+
pc: boolean;
|
|
149
|
+
/** The player's character or a companion. */
|
|
150
|
+
party: boolean;
|
|
151
|
+
/** A field: a number, text, or a list as text; a counter as written, such as 3/5; undefined when the page has none. */
|
|
152
|
+
value(field: string): number | string | string[] | undefined;
|
|
153
|
+
/** A counter, with its maximum when it has one. */
|
|
154
|
+
counter(field: string): {
|
|
155
|
+
value: number;
|
|
156
|
+
max?: number;
|
|
157
|
+
} | undefined;
|
|
158
|
+
/** Whether an effect is on it, such as a condition. */
|
|
159
|
+
has(effect: string): boolean;
|
|
160
|
+
/** A formula of the game system worked out on it, as has(skills, stealth) * proficiency; undefined when it has no value. It throws when it does not read. */
|
|
161
|
+
formula(text: string): number | undefined;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The campaign as a package's code reaches it: only through these (D-428, D-436, D-505, D-511): the fields and the effects of any page, its own state and the
|
|
165
|
+
* log. Each write has its line in the log, public or hidden as the engine shows that page.
|
|
166
|
+
*/
|
|
167
|
+
export interface Game extends GameView {
|
|
168
|
+
/**
|
|
169
|
+
* Rolls with the engine's dice, as 1d6 or 4d6kh3: the total, each die's face and each die as thrown, and the roll as one line. With by, a roll in the log for
|
|
170
|
+
* who (D-505): in view for the party, behind the screen for anyone else as the master-rolls setting says (D-287); with values, the faces of the player's
|
|
171
|
+
* physical dice, in view.
|
|
172
|
+
*/
|
|
173
|
+
roll(notation: string, by?: RollFor): Rolled;
|
|
174
|
+
/**
|
|
175
|
+
* Sets fields on a page, any field, numbers or text, as write --set does, with its checks: a number on a counter keeps its maximum. It throws what write
|
|
176
|
+
* refuses, and for a name no page alone has, by name or alias. A counter the rules watch, such as hit points, is changed with change.
|
|
177
|
+
*/
|
|
178
|
+
set(page: string, values: Record<string, number | string>, why: string): void;
|
|
179
|
+
/**
|
|
180
|
+
* Changes a counter or money on a page as the change command does, the way to change one the rules watch, such as hit points: by an amount, to a value, or
|
|
181
|
+
* spent, within its limits; its text, with the hooks' lines. Called from a command it calls the hooks of the campaign's packages after the change; from
|
|
182
|
+
* inside a hook, none, so that no change sets off another.
|
|
183
|
+
*/
|
|
184
|
+
change(page: string, field: string, amount: {
|
|
185
|
+
by?: number | string;
|
|
186
|
+
to?: number | string;
|
|
187
|
+
spend?: number | string;
|
|
188
|
+
}, why: string): string;
|
|
189
|
+
/** Adds an effect without end; the engine's notes on what it breaks of what one keeps, or undefined when the page has it already. */
|
|
190
|
+
addEffect(page: string, name: string, why: string): string[] | undefined;
|
|
191
|
+
/** Ends an effect; whether the page had it. */
|
|
192
|
+
endEffect(page: string, name: string, why: string): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Asks the player for a roll of their character, with the buttons of ask (D-505): the roll, logged as theirs; declined, when they change their mind; said, their
|
|
195
|
+
* own words in place of a button; in words, the question to ask them in the chat where no buttons show: with physical dice they tell the faces,
|
|
196
|
+
* else once they go ahead the code rolls them with roll and who, as the core's ask leaves to the master's roll.
|
|
197
|
+
*/
|
|
198
|
+
ask(asked: AskedRoll): Promise<Asked>;
|
|
199
|
+
state: {
|
|
200
|
+
read(): unknown;
|
|
201
|
+
write(value: unknown): void;
|
|
202
|
+
};
|
|
203
|
+
/** A line in the campaign's log: public when the player may see it, hidden when only the master may. */
|
|
204
|
+
log(text: string, visibility?: "public" | "hidden"): void;
|
|
205
|
+
}
|
|
206
|
+
/** Whom a roll is for (D-505): who rolls, why, as the master reads it, what the player sees it as, and the faces of physical dice. */
|
|
207
|
+
export interface RollFor {
|
|
208
|
+
who: string;
|
|
209
|
+
why: string;
|
|
210
|
+
check?: string;
|
|
211
|
+
values?: number[];
|
|
212
|
+
/** What the faces mean, which the player sees in place of the total when a sum means nothing, as "4 pins, no 1": in the package's words, translated. */
|
|
213
|
+
says?: (faces: number[]) => WidgetText;
|
|
214
|
+
/** How each die turned out, by its face in order, for the page to colour it: a 1 that resets a lock is bad (D-507). */
|
|
215
|
+
tones?: (faces: number[]) => (DieTone | undefined)[];
|
|
216
|
+
}
|
|
217
|
+
/** The colour of the moment of a card of a question (D-517), by the dashboard's token: danger, an ally's green, gold, muted. */
|
|
218
|
+
export type CardTint = "low" | "ally" | "gold" | "muted";
|
|
219
|
+
/** How a die, or a part of a card, turned out for the one who rolls: good or bad, as the page colours it. */
|
|
220
|
+
export type DieTone = "good" | "bad";
|
|
221
|
+
/** The words of a button: its name, or its name with a note under it, as "Reroll" and "3 left"; the package's words, translated. */
|
|
222
|
+
export type ButtonWords = WidgetText | {
|
|
223
|
+
label: WidgetText;
|
|
224
|
+
note: WidgetText;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* A roll asked of the player (D-505): the question, the master's words or the package's own, translated by its words; the check's name and its dice; and how
|
|
228
|
+
* the dashboard asks it.
|
|
229
|
+
*/
|
|
230
|
+
export interface AskedRoll extends Asking {
|
|
231
|
+
who?: string;
|
|
232
|
+
question: WidgetText;
|
|
233
|
+
check: string;
|
|
234
|
+
notation: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* How the dashboard asks a roll, in a package's words (D-507): the roll's button; the button that turns it down, renamed, in place of the core's change of mind,
|
|
238
|
+
* or none when the roll is forced; the rule under the buttons; the card of one of its widgets; and what the faces mean, as for a roll with by.
|
|
239
|
+
*/
|
|
240
|
+
export interface Asking {
|
|
241
|
+
/** The roll's button, in place of the core's "Roll: check (dice)". */
|
|
242
|
+
roll?: ButtonWords;
|
|
243
|
+
/** The button that turns it down, renamed; false for none, when the roll is forced, as a death save (D-507). */
|
|
244
|
+
decline?: ButtonWords | false;
|
|
245
|
+
/** The rule under the buttons, in a line, as "A 1 resets the lock". */
|
|
246
|
+
rule?: WidgetText;
|
|
247
|
+
/**
|
|
248
|
+
* The card the dashboard asks it in (D-507): one of the package's widgets, by its name in extension.yaml or system.yaml, and which attempt it is, the same for
|
|
249
|
+
* each question of it, as a reroll after the roll. The page shows the widget as it is before the dice and as it is after; the code writes its state first.
|
|
250
|
+
*/
|
|
251
|
+
card?: {
|
|
252
|
+
widget: string;
|
|
253
|
+
key: string;
|
|
254
|
+
};
|
|
255
|
+
says?: (faces: number[]) => WidgetText;
|
|
256
|
+
tones?: (faces: number[]) => (DieTone | undefined)[];
|
|
257
|
+
}
|
|
258
|
+
/** A roll made: its dice as written, each die as thrown, as the lower of two kept highest dropped; with by, the id of its line in the log and whether it was hidden. */
|
|
259
|
+
export interface Rolled {
|
|
260
|
+
notation: string;
|
|
261
|
+
total: number;
|
|
262
|
+
faces: number[];
|
|
263
|
+
dice: {
|
|
264
|
+
sides: number | "F";
|
|
265
|
+
value: number;
|
|
266
|
+
dropped?: boolean;
|
|
267
|
+
}[];
|
|
268
|
+
text: string;
|
|
269
|
+
id?: string;
|
|
270
|
+
hidden?: boolean;
|
|
271
|
+
}
|
|
272
|
+
/** What the player answered when asked for a roll (D-505). */
|
|
273
|
+
export type Asked = {
|
|
274
|
+
rolled: {
|
|
275
|
+
id: string;
|
|
276
|
+
total: number;
|
|
277
|
+
faces: number[];
|
|
278
|
+
text: string;
|
|
279
|
+
};
|
|
280
|
+
} | {
|
|
281
|
+
declined: true;
|
|
282
|
+
} | {
|
|
283
|
+
said: string;
|
|
284
|
+
} | {
|
|
285
|
+
inWords: string;
|
|
286
|
+
physical: boolean;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* What a widget shows now (D-502), in the dashboard's own parts: in the top, its icon and its chip, what it says whole in the chip's tip; in a card, under the
|
|
290
|
+
* widget's title, its note and its parts. The server checks it, and keeps it short.
|
|
291
|
+
*/
|
|
292
|
+
export interface Widget {
|
|
293
|
+
/** What only its page code draws (D-510), as the pins of a lock: JSON, kept short, which goes only to the page, never to the master. */
|
|
294
|
+
data?: unknown;
|
|
295
|
+
/** The figure of its page code that draws the whole inside of its card of a roll, the dashboard keeping the question and the field for words (D-510). */
|
|
296
|
+
body?: string;
|
|
297
|
+
/** One of the package's icons, in place of the widget's own; in place person, the mark of their state on their token. */
|
|
298
|
+
icon?: string;
|
|
299
|
+
/** The few words of a chip in the top, as 10–15 °C; in place person, the word of their state, as Dying, tinted by its lead's tone. */
|
|
300
|
+
chip?: WidgetText;
|
|
301
|
+
/** In place person, dead by the package's rules though not yet marked so (D-516): drawn as the dead are, greyed, with the skull. */
|
|
302
|
+
dead?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* In the card of a question, the colour of its moment, as the 5e's death save in the red of danger (D-517): one of the dashboard's tokens, low for danger,
|
|
305
|
+
* ally, gold or muted; the card then has a frame of that tint, without the robot. None, as the lock's card: the question's own frame (D-509).
|
|
306
|
+
*/
|
|
307
|
+
tint?: CardTint;
|
|
308
|
+
/** What it says whole, in a sentence: the chip's tip, and its name for a screen reader. */
|
|
309
|
+
says?: WidgetText;
|
|
310
|
+
/** A note at the end of a card's head. */
|
|
311
|
+
note?: WidgetText;
|
|
312
|
+
parts?: WidgetPart[];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Words of the package, written in its language: translated whole by its words/<code>.yaml, as "Light fog this morning"; or a phrase whose {names} are values
|
|
316
|
+
* the page writes in its own language, as {text: "From {low} to {high}", values: {low: 10, high: 15}}.
|
|
317
|
+
*/
|
|
318
|
+
export type WidgetText = string | {
|
|
319
|
+
text: string;
|
|
320
|
+
values: Record<string, WidgetValue>;
|
|
321
|
+
};
|
|
322
|
+
/** A value the page writes: a number; a word, translated; a number with its unit, as 12 km; a range, as 10–15 °C. */
|
|
323
|
+
export type WidgetValue = number | string | {
|
|
324
|
+
number: number;
|
|
325
|
+
unit?: string;
|
|
326
|
+
} | {
|
|
327
|
+
from: number;
|
|
328
|
+
to: number;
|
|
329
|
+
unit?: string;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* A count, as pips, a bar, or steps of a progress (D-507): its value lit; after them, those held but not yet sure, those marked, as a die that failed, and
|
|
333
|
+
* those the roll asked may light; in an ask's card, where it stands, and whether it is good or bad to have.
|
|
334
|
+
*/
|
|
335
|
+
export interface Track {
|
|
336
|
+
label: WidgetText;
|
|
337
|
+
value: number;
|
|
338
|
+
max: number;
|
|
339
|
+
look?: "pips" | "bar" | "steps";
|
|
340
|
+
held?: number;
|
|
341
|
+
marked?: number;
|
|
342
|
+
coming?: number;
|
|
343
|
+
stage?: "start" | "center" | "end";
|
|
344
|
+
tone?: DieTone;
|
|
345
|
+
/** The figure of the package's page code that draws it, in place of the dashboard's pips (D-510); its label and value still say it in words. */
|
|
346
|
+
figure?: string;
|
|
347
|
+
/** The counter of the sheet it counts, which leaves the line of values under the name while a widget in place person shows it (D-514). */
|
|
348
|
+
field?: string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* A part of a widget's card: one thing large, with its icon and its value; text; facts, as chips; values, each in a box under its label; a count as pips or a
|
|
352
|
+
* bar; rows of a label, a value and a note; a table; a picture of the package's images/.
|
|
353
|
+
*/
|
|
354
|
+
export type WidgetPart = {
|
|
355
|
+
lead: WidgetText;
|
|
356
|
+
icon?: string;
|
|
357
|
+
value?: WidgetValue;
|
|
358
|
+
tone?: DieTone;
|
|
359
|
+
figure?: string;
|
|
360
|
+
} | {
|
|
361
|
+
who: string;
|
|
362
|
+
does?: WidgetText;
|
|
363
|
+
} | {
|
|
364
|
+
text: WidgetText;
|
|
365
|
+
} | {
|
|
366
|
+
facts: WidgetText[];
|
|
367
|
+
} | {
|
|
368
|
+
values: {
|
|
369
|
+
label: WidgetText;
|
|
370
|
+
value: WidgetValue;
|
|
371
|
+
}[];
|
|
372
|
+
} | {
|
|
373
|
+
track: Track;
|
|
374
|
+
} | {
|
|
375
|
+
rows: {
|
|
376
|
+
label: WidgetText;
|
|
377
|
+
value?: WidgetValue;
|
|
378
|
+
note?: WidgetText;
|
|
379
|
+
}[];
|
|
380
|
+
} | {
|
|
381
|
+
table: {
|
|
382
|
+
head: WidgetText[];
|
|
383
|
+
rows: WidgetValue[][];
|
|
384
|
+
};
|
|
385
|
+
} | {
|
|
386
|
+
image: string;
|
|
387
|
+
alt: WidgetText;
|
|
388
|
+
};
|
|
@@ -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,10 @@ 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;
|
|
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. */
|
|
22
|
+
waitsForPlayer?: boolean;
|
|
19
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. */
|
|
20
24
|
slow?: boolean;
|
|
21
25
|
run(input: z.infer<Schema>, context: Context): Result | Promise<Result>;
|
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);
|