rpg-engine 0.19.0 → 0.20.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 +9 -6
- package/dist/campaign/create-campaign.js +2 -2
- package/dist/campaign/find-campaign.d.ts +4 -0
- package/dist/campaign/find-campaign.js +5 -1
- package/dist/campaign/host-files.js +22 -0
- package/dist/campaign/index.d.ts +2 -2
- package/dist/campaign/index.js +2 -2
- package/dist/campaign/last-choices.d.ts +10 -4
- package/dist/campaign/last-choices.js +43 -17
- package/dist/campaign/settings.d.ts +10 -2
- package/dist/campaign/settings.js +30 -6
- package/dist/chats/chat.d.ts +33 -0
- package/dist/chats/chat.js +50 -0
- package/dist/chats/claude-code.d.ts +5 -0
- package/dist/chats/claude-code.js +39 -0
- package/dist/chats/codex.d.ts +3 -0
- package/dist/chats/codex.js +42 -0
- package/dist/chats/index.d.ts +5 -0
- package/dist/chats/index.js +12 -0
- package/dist/chats/keep.d.ts +10 -0
- package/dist/chats/keep.js +50 -0
- package/dist/chats/read.d.ts +8 -0
- package/dist/chats/read.js +46 -0
- package/dist/cli/cli.js +6 -1
- package/dist/cli/command-line.js +3 -2
- package/dist/commands/book.d.ts +55 -0
- package/dist/commands/book.js +105 -0
- package/dist/commands/chats.d.ts +38 -0
- package/dist/commands/chats.js +93 -0
- package/dist/commands/config/config.js +1 -1
- package/dist/commands/config/dashboard.d.ts +8 -1
- package/dist/commands/config/dashboard.js +63 -15
- package/dist/commands/config/words.d.ts +1 -1
- package/dist/commands/config/words.js +17 -4
- package/dist/commands/find.js +1 -1
- package/dist/commands/image.d.ts +9 -0
- package/dist/commands/image.js +95 -18
- package/dist/commands/index.js +4 -0
- package/dist/commands/init.js +3 -3
- package/dist/commands/scene/close.d.ts +2 -0
- package/dist/commands/scene/close.js +13 -2
- package/dist/commands/scene/result.d.ts +2 -0
- package/dist/commands/scene/scene.d.ts +2 -0
- package/dist/commands/shared/campaign/book.d.ts +29 -0
- package/dist/commands/shared/campaign/book.js +95 -0
- package/dist/commands/shared/campaign/chats.d.ts +11 -0
- package/dist/commands/shared/campaign/chats.js +29 -0
- package/dist/commands/shared/campaign/images.js +7 -1
- package/dist/commands/shared/campaign/mode.js +3 -1
- package/dist/commands/shared/campaign/saves.js +13 -5
- package/dist/commands/shared/sheet/sheet.d.ts +7 -0
- package/dist/commands/shared/sheet/sheet.js +27 -0
- package/dist/commands/shared/time/dawn.d.ts +1 -1
- package/dist/commands/shared/time/dawn.js +19 -7
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +4 -0
- package/dist/commands/view/page.js +4 -3
- package/dist/commands/view/result.d.ts +2 -0
- package/dist/commands/view/view.d.ts +1 -0
- package/dist/commands/view/view.js +4 -0
- package/dist/core/consents.d.ts +2 -2
- package/dist/core/consents.js +3 -3
- package/dist/core/context.d.ts +38 -2
- package/dist/core/download.js +1 -1
- package/dist/dashboard/acts/names.js +10 -5
- package/dist/dashboard/acts/sending.js +5 -2
- package/dist/dashboard/acts/sheet.js +66 -15
- package/dist/dashboard/api.js +3 -3
- package/dist/dashboard/app.js +2 -2
- package/dist/dashboard/guide/ar.md +11 -10
- package/dist/dashboard/guide/cs.md +10 -9
- package/dist/dashboard/guide/da.md +12 -11
- package/dist/dashboard/guide/de.md +12 -11
- package/dist/dashboard/guide/el.md +12 -11
- package/dist/dashboard/guide/en.md +9 -8
- package/dist/dashboard/guide/es.md +10 -9
- package/dist/dashboard/guide/fi.md +10 -9
- package/dist/dashboard/guide/fr.md +16 -15
- package/dist/dashboard/guide/he.md +11 -10
- package/dist/dashboard/guide/hi.md +10 -9
- package/dist/dashboard/guide/hu.md +14 -13
- package/dist/dashboard/guide/is.md +10 -9
- package/dist/dashboard/guide/it.md +13 -12
- package/dist/dashboard/guide/ja.md +10 -9
- package/dist/dashboard/guide/ko.md +11 -10
- package/dist/dashboard/guide/nb.md +12 -11
- package/dist/dashboard/guide/nl.md +10 -9
- package/dist/dashboard/guide/pl.md +11 -10
- package/dist/dashboard/guide/pt.md +12 -11
- package/dist/dashboard/guide/ro.md +10 -9
- package/dist/dashboard/guide/ru.md +12 -11
- package/dist/dashboard/guide/sv.md +10 -9
- package/dist/dashboard/guide/tr.md +13 -12
- package/dist/dashboard/guide/uk.md +13 -12
- package/dist/dashboard/guide/zh.md +11 -10
- package/dist/dashboard/i18n/ar.json +31 -5
- package/dist/dashboard/i18n/cs.json +31 -5
- package/dist/dashboard/i18n/da.json +31 -5
- package/dist/dashboard/i18n/de.json +31 -5
- package/dist/dashboard/i18n/el.json +31 -5
- package/dist/dashboard/i18n/es.json +31 -5
- package/dist/dashboard/i18n/fi.json +31 -5
- package/dist/dashboard/i18n/fr.json +31 -5
- package/dist/dashboard/i18n/he.json +31 -5
- package/dist/dashboard/i18n/hi.json +31 -5
- package/dist/dashboard/i18n/hu.json +31 -5
- package/dist/dashboard/i18n/is.json +31 -5
- package/dist/dashboard/i18n/it.json +32 -6
- package/dist/dashboard/i18n/ja.json +31 -5
- package/dist/dashboard/i18n/ko.json +31 -5
- package/dist/dashboard/i18n/nb.json +31 -5
- package/dist/dashboard/i18n/nl.json +31 -5
- package/dist/dashboard/i18n/pl.json +31 -5
- package/dist/dashboard/i18n/pt.json +31 -5
- package/dist/dashboard/i18n/ro.json +31 -5
- package/dist/dashboard/i18n/ru.json +31 -5
- package/dist/dashboard/i18n/sv.json +31 -5
- package/dist/dashboard/i18n/tr.json +31 -5
- package/dist/dashboard/i18n/uk.json +31 -5
- package/dist/dashboard/i18n/zh.json +31 -5
- package/dist/dashboard/journal/book.js +106 -0
- package/dist/dashboard/journal/journal.js +9 -8
- package/dist/dashboard/parts/labels.js +6 -0
- package/dist/dashboard/parts/widgets.js +1 -1
- package/dist/dashboard/place/view.js +1 -1
- package/dist/dashboard/settings/settings.js +10 -4
- package/dist/dashboard/settings/setup.js +5 -3
- package/dist/dashboard/sheet/sheet.js +8 -5
- package/dist/dashboard/style.css +459 -96
- package/dist/dashboard/world/calendar.js +1 -1
- package/dist/dashboard/world/lore.js +1 -1
- package/dist/helpers/briefs.d.ts +5 -0
- package/dist/helpers/briefs.js +8 -0
- package/dist/helpers/chosen.d.ts +8 -2
- package/dist/helpers/chosen.js +110 -6
- package/dist/helpers/codex.js +2 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/index.js +2 -2
- package/dist/images/images.d.ts +2 -0
- package/dist/images/images.js +16 -2
- package/dist/images/index.d.ts +1 -1
- package/dist/images/index.js +1 -1
- package/dist/server/approver.d.ts +6 -0
- package/dist/server/approver.js +28 -0
- package/dist/server/chats.d.ts +3 -0
- package/dist/server/chats.js +27 -0
- package/dist/server/dashboard/news.js +36 -5
- package/dist/server/mcp.js +37 -6
- package/dist/server/player-acts.d.ts +7 -2
- package/dist/server/player-acts.js +10 -3
- package/instructions/start.md +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The saves of a campaign as commands use them (D-54, D-55): which files a save holds, a save made at the end of a scene or when asked, and given back.
|
|
2
2
|
import { join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { campaignFileName, hostFileNames, readSettings } from "../../../campaign/index.js";
|
|
3
|
+
import { bookFolderName, campaignFileName, hostFileNames, readSettings, sessionsFolderName } from "../../../campaign/index.js";
|
|
4
4
|
import { filesIn } from "../../../core/files.js";
|
|
5
5
|
import { appendLogEntry, logFileName, logLine, readLog } from "../../../core/log.js";
|
|
6
6
|
import { files, isInside } from "../../../core/store.js";
|
|
@@ -118,7 +118,14 @@ export function loadSave(root, context, save) {
|
|
|
118
118
|
for (const other of later) {
|
|
119
119
|
step(join(folder, other.file), () => files().remove(join(folder, other.file)));
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
// When the save was made: what was said in the chats from then to now did not happen (T-225).
|
|
122
|
+
const made = files().modified(join(folder, save.file));
|
|
123
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "save-loaded", "public", {
|
|
124
|
+
save: save.number,
|
|
125
|
+
label: save.label,
|
|
126
|
+
made: made === undefined ? undefined : new Date(made).toISOString(),
|
|
127
|
+
removed: later.length === 0 ? undefined : later.map((other) => other.number),
|
|
128
|
+
}));
|
|
122
129
|
files().remove(join(folder, loadingMarkName));
|
|
123
130
|
files().writeBytes(join(folder, newChatMarkName), new TextEncoder().encode(saveText(save)));
|
|
124
131
|
return { removed: later, copy };
|
|
@@ -255,8 +262,8 @@ function gameFileBytes(root) {
|
|
|
255
262
|
return Object.fromEntries(gameFiles(root).map((path) => [relative(root, path).split(sep).join("/"), files().bytes(path) ?? new Uint8Array()]));
|
|
256
263
|
}
|
|
257
264
|
/**
|
|
258
|
-
* The files a save holds (SAV-2), as the disk has them, not as a session last saw them: every file of the campaign but those of the AI hosts, the exports,
|
|
259
|
-
* under a name with a dot at its top, as .saves, .git, .obsidian.
|
|
265
|
+
* The files a save holds (SAV-2), as the disk has them, not as a session last saw them: every file of the campaign but those of the AI hosts, the exports, the
|
|
266
|
+
* chats, which a load must never take back (T-225), and those under a name with a dot at its top, as .saves, .git, .obsidian.
|
|
260
267
|
*/
|
|
261
268
|
function gameFiles(root) {
|
|
262
269
|
return files().entries(root).filter((entry) => isGameName(entry.name)).flatMap((entry) => {
|
|
@@ -266,7 +273,8 @@ function gameFiles(root) {
|
|
|
266
273
|
}
|
|
267
274
|
/** Whether a name at the top of a campaign is the game's: not the host's, in any case, as Windows reads them, and not starting with a dot. */
|
|
268
275
|
function isGameName(name) {
|
|
269
|
-
return !name.startsWith(".") && !hostNames.has(name.toLowerCase()) && name.toLowerCase() !== exportsFolderName
|
|
276
|
+
return !name.startsWith(".") && !hostNames.has(name.toLowerCase()) && name.toLowerCase() !== exportsFolderName && name.toLowerCase() !== sessionsFolderName
|
|
277
|
+
&& name.toLowerCase() !== bookFolderName;
|
|
270
278
|
}
|
|
271
279
|
function joinBytes(first, second) {
|
|
272
280
|
const joined = new Uint8Array((first?.length ?? 0) + second.length);
|
|
@@ -114,6 +114,8 @@ export interface SheetItem {
|
|
|
114
114
|
bonds?: string[];
|
|
115
115
|
/** Its page, or one it derives from, is a page of the game system the campaign changed with a layer (SYS-11): the view says so. */
|
|
116
116
|
layered?: true;
|
|
117
|
+
/** It is a document, as a letter, read again among the World's documents (D-573). */
|
|
118
|
+
document?: true;
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
119
121
|
* The sheet of a player character or a companion as data, a group for each that has a value, as the character reads it, effects and formulas included (DAT-2).
|
|
@@ -136,6 +138,11 @@ export declare function sheetHeadline(world: World, system: GameSystem | undefin
|
|
|
136
138
|
* by str. None for a page that derives from no creature.
|
|
137
139
|
*/
|
|
138
140
|
export declare function statBlock(world: World, system: GameSystem | undefined, page: Page): SheetGroupData[];
|
|
141
|
+
/**
|
|
142
|
+
* What a thing's page says of it as data, for its card on the dashboard (D-573): the fields the system declares, of its own and of the pages it derives from,
|
|
143
|
+
* as damage and weight; never the formulas it gives who holds it, as an attack, nor a bonus of 0. None for a page that is not an item.
|
|
144
|
+
*/
|
|
145
|
+
export declare function thingBlock(world: World, system: GameSystem | undefined, page: Page): SheetGroupData[];
|
|
139
146
|
/** "Abilities: str 14 (+2) · dex 12 (+1)…": the sheet as the chat gives it, a line for each group. */
|
|
140
147
|
export declare function sheetText(groups: SheetGroupData[]): string[];
|
|
141
148
|
/** The sheet of a player character or a companion as the chat gives it (DAT-2): sheetData as text. */
|
|
@@ -187,6 +187,27 @@ export function statBlock(world, system, page) {
|
|
|
187
187
|
});
|
|
188
188
|
return values.length === 0 ? [] : [{ name: creature.name, values }];
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* What a thing's page says of it as data, for its card on the dashboard (D-573): the fields the system declares, of its own and of the pages it derives from,
|
|
192
|
+
* as damage and weight; never the formulas it gives who holds it, as an attack, nor a bonus of 0. None for a page that is not an item.
|
|
193
|
+
*/
|
|
194
|
+
export function thingBlock(world, system, page) {
|
|
195
|
+
if (system === undefined || page.type !== "item") {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const fields = effectiveFields(world, page);
|
|
199
|
+
const given = new Set(Object.values(system.itemFormulas).flat().map(comparableText));
|
|
200
|
+
const names = [...new Set([...baseChain(world, page)].reverse().concat(page).flatMap((holder) => Object.keys(holder.fields)))];
|
|
201
|
+
const values = names.flatMap((field) => {
|
|
202
|
+
const value = valueNamed(fields, field);
|
|
203
|
+
const kind = declaredKind(world, field);
|
|
204
|
+
if (kind === undefined || isStandardField(page.type, field) || given.has(comparableText(field)) || isEmptyField(value) || (kind === "bonus" && Number(value) === 0)) {
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
return [sheetValue(world, fields, field, value)];
|
|
208
|
+
});
|
|
209
|
+
return values.length === 0 ? [] : [{ name: page.name, values }];
|
|
210
|
+
}
|
|
190
211
|
/** "Abilities: str 14 (+2) · dex 12 (+1)…": the sheet as the chat gives it, a line for each group. */
|
|
191
212
|
export function sheetText(groups) {
|
|
192
213
|
return groups.map((group) => {
|
|
@@ -416,6 +437,11 @@ function groupEntries(world, system, group, fields) {
|
|
|
416
437
|
* What a holder carries, as rows of the sheet (D-431): a stack with its count (STK-1), an item with a story of its own, 1, and below it what it holds, one level deeper, and
|
|
417
438
|
* text as written; marked when equipped. Pages that are elsewhere, or not items, are left out.
|
|
418
439
|
*/
|
|
440
|
+
/** Whether a thing is a document, as a letter: an item with a document field. */
|
|
441
|
+
function isDocument(page) {
|
|
442
|
+
const value = page.fields.document;
|
|
443
|
+
return page.type === "item" && typeof value === "string" && value.trim() !== "";
|
|
444
|
+
}
|
|
419
445
|
function carriedRows(world, holder, marks, depth = 0, seen = new Set()) {
|
|
420
446
|
const field = containerFieldOf(holder.type);
|
|
421
447
|
const stacks = stacksOf(world, holder);
|
|
@@ -429,6 +455,7 @@ function carriedRows(world, holder, marks, depth = 0, seen = new Set()) {
|
|
|
429
455
|
...(depth === 0 ? {} : { depth, inside: holder.name }),
|
|
430
456
|
...(page !== undefined && marks.equipped.includes(page) ? { equipped: true } : {}),
|
|
431
457
|
...(bonds === undefined ? {} : { bonds }),
|
|
458
|
+
...(page !== undefined && isDocument(page) ? { document: true } : {}),
|
|
432
459
|
};
|
|
433
460
|
};
|
|
434
461
|
return (field === undefined ? [] : textsIn(holder.fields[field])).flatMap((entry) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type World } from "../../../pages/index.ts";
|
|
2
2
|
import type { GameSystem, Recipe } from "../../../systems/index.ts";
|
|
3
3
|
import { type GameDate } from "../../../time/index.ts";
|
|
4
4
|
/** The type of the log's line that says a recipe gave a page something (RST-1). */
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// What comes back at dawn (D-571, RST-2): when time passes through the system's dawn, what the party carries below its maximum, which its text brings back, and
|
|
2
2
|
// who of the party had no rest of a night in its time, which the master gives if they slept. The engine gives nothing by itself.
|
|
3
3
|
import { readLog } from "../../../core/log.js";
|
|
4
|
-
import { comparableText } from "../../../core/text.js";
|
|
4
|
+
import { comparableText, valueNamed } from "../../../core/text.js";
|
|
5
|
+
import { readCounter } from "../../../counters/index.js";
|
|
6
|
+
import { isInParty } from "../../../pages/index.js";
|
|
5
7
|
import { formatGameDate, minutesBetween, readDuration, readGameDate } from "../../../time/index.js";
|
|
6
|
-
import {
|
|
8
|
+
import { effectiveFields } from "../sheet/effect-layer.js";
|
|
9
|
+
import { carriedCounters, recipeTargets } from "./recipes.js";
|
|
7
10
|
/** The type of the log's line that says a recipe gave a page something (RST-1). */
|
|
8
11
|
export const recipeAppliedType = "recipe-applied";
|
|
9
12
|
/** The lines of a dawn this passing of time went through, the last when it went through more; none without one, or when nothing is to say. */
|
|
@@ -12,9 +15,10 @@ export function dawnLines(root, world, system, from, to) {
|
|
|
12
15
|
if (system === undefined || dawn === undefined) {
|
|
13
16
|
return [];
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
// Dawn comes for the whole living party, wherever each one is.
|
|
19
|
+
const members = world.pages.filter(isInParty);
|
|
16
20
|
const carried = members.flatMap((member) => carriedCounters(world, member).map((counter) => `${counter} (${member.name})`));
|
|
17
|
-
const unrested = system.recipes.filter((recipe) => recipe.oncePer !== undefined && recipe.lasts !== undefined).flatMap((recipe) => unrestedLine(root, recipe, members, to));
|
|
21
|
+
const unrested = system.recipes.filter((recipe) => recipe.oncePer !== undefined && recipe.lasts !== undefined).flatMap((recipe) => unrestedLine(root, world, recipe, members, to));
|
|
18
22
|
const counters = carried.length === 0 ? "" : ` Below their maximum, what the party carries: ${carried.join(" · ")}; what comes back at dawn, its text says: give it with change.`;
|
|
19
23
|
return counters === "" && unrested.length === 0 ? [] : [`Dawn came at ${formatGameDate(dawn)}.${counters}`, ...unrested];
|
|
20
24
|
}
|
|
@@ -29,12 +33,20 @@ function lastDawn(from, to, minute) {
|
|
|
29
33
|
const dawn = { day, minute };
|
|
30
34
|
return day >= 1 && minutesBetween(from, dawn) > 0 ? dawn : undefined;
|
|
31
35
|
}
|
|
32
|
-
/** "No long rest in the last 24h: …", for those of the party who had none in its time (RST-1); none when
|
|
33
|
-
function unrestedLine(root, recipe, members, now) {
|
|
36
|
+
/** "No long rest in the last 24h: …", for those of the party it would give something to who had none in its time (RST-1); none when no one is left. */
|
|
37
|
+
function unrestedLine(root, world, recipe, members, now) {
|
|
34
38
|
const every = readDuration(recipe.oncePer ?? "") ?? 0;
|
|
35
|
-
const missing = members.flatMap((member) => {
|
|
39
|
+
const missing = members.filter((member) => gainsFrom(world, recipe, member)).flatMap((member) => {
|
|
36
40
|
const last = lastApplied(root, recipe, member.name);
|
|
37
41
|
return last === undefined ? [`${member.name} (none yet)`] : minutesBetween(last, now) >= every ? [`${member.name} (last at ${formatGameDate(last)})`] : [];
|
|
38
42
|
});
|
|
39
43
|
return missing.length === 0 ? [] : [`No ${recipe.name} in the last ${recipe.oncePer}: ${missing.join(", ")}. If they slept, give it with change and the recipe ${recipe.name}.`];
|
|
40
44
|
}
|
|
45
|
+
/** Whether a recipe would change something on a page now: a counter it brings back that is not there yet. */
|
|
46
|
+
function gainsFrom(world, recipe, page) {
|
|
47
|
+
const fields = effectiveFields(world, page);
|
|
48
|
+
return recipeTargets(world, recipe, page).some(({ field, target }) => {
|
|
49
|
+
const counter = readCounter(valueNamed(fields, field));
|
|
50
|
+
return counter !== undefined && counter.value !== (target === "max" ? counter.max : target);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -46,6 +46,7 @@ export declare const status: import("../core/registry.ts").Command<z.ZodObject<{
|
|
|
46
46
|
journey: string | undefined;
|
|
47
47
|
lastScenes: string[];
|
|
48
48
|
sceneCounts: string;
|
|
49
|
+
book: string | undefined;
|
|
49
50
|
openQuests: string[];
|
|
50
51
|
now: string | undefined;
|
|
51
52
|
betweenSessions: string | undefined;
|
package/dist/commands/status.js
CHANGED
|
@@ -8,6 +8,7 @@ import { sceneTypes } from "../scene/index.js";
|
|
|
8
8
|
import { rulesetSetting } from "../systems/index.js";
|
|
9
9
|
import { choicesNotes } from "./choices.js";
|
|
10
10
|
import { importLine } from "./import/import.js";
|
|
11
|
+
import { bookBehind } from "./shared/campaign/book.js";
|
|
11
12
|
import { allStateChecks, markStateChecksTold } from "./shared/campaign/checks.js";
|
|
12
13
|
import { picturesNote } from "./shared/campaign/images.js";
|
|
13
14
|
import { campaignMode, campaignNote } from "./shared/campaign/mode.js";
|
|
@@ -176,6 +177,8 @@ export const status = defineCommand({
|
|
|
176
177
|
journey: journeyText(world, roadsOf(world), readJourney(root), measuresOf(root, system)),
|
|
177
178
|
lastScenes: closed.slice(0, shownNames).map((scene) => `${scene.title} (${scene.type}): ${scene.summary}`),
|
|
178
179
|
sceneCounts: sceneCounts(closed),
|
|
180
|
+
// The book's chapters left behind, once it has begun (T-227).
|
|
181
|
+
book: bookBehind(root),
|
|
179
182
|
openQuests: openQuests(world, now),
|
|
180
183
|
now: now === undefined ? undefined : datedText(root, context, now),
|
|
181
184
|
// In play, the game time to let pass when the last move is an hour old or more and the time runs between sessions (D-133).
|
|
@@ -244,6 +247,7 @@ export const status = defineCommand({
|
|
|
244
247
|
result.journey === undefined ? "" : `Journey: ${result.journey}`,
|
|
245
248
|
result.lastScenes.length === 0 ? "" : `Last scenes: ${result.lastScenes.join(" · ")}`,
|
|
246
249
|
result.sceneCounts === "" ? "" : `Scenes so far: ${result.sceneCounts}`,
|
|
250
|
+
result.book ?? "",
|
|
247
251
|
dueLine(result.dueEvents),
|
|
248
252
|
namesLine("Open quests", result.openQuests, "find text open, type quest"),
|
|
249
253
|
namesLine("Planned events", result.plannedEvents, "find text planned, type event"),
|
|
@@ -11,14 +11,15 @@ import { knownSecretsApart, knownText, knowsPage, pageKnownBy, playerStory } fro
|
|
|
11
11
|
import { measuresOf } from "../shared/places/roads.js";
|
|
12
12
|
import { lineExperience } from "../shared/sheet/counters.js";
|
|
13
13
|
import { effectiveFields } from "../shared/sheet/effect-layer.js";
|
|
14
|
-
import { counterOf, experienceNeed, experienceProgress, sheetData, sheetHeadline, statBlock } from "../shared/sheet/sheet.js";
|
|
14
|
+
import { counterOf, experienceNeed, experienceProgress, sheetData, sheetHeadline, statBlock, thingBlock } from "../shared/sheet/sheet.js";
|
|
15
15
|
import { hasSheet } from "../shared/sheet/system-fields.js";
|
|
16
16
|
import { isLayered } from "./layers.js";
|
|
17
17
|
/** A page as the one whose view it is knows it (VIEW-3): its text, and the whole sheet when it is theirs or of their party. */
|
|
18
18
|
export function shownPage(root, context, world, knowledge, page, party) {
|
|
19
19
|
const system = campaignSystem(root, context);
|
|
20
|
-
// A companion who keeps no sheet shows the stat block of the creature it derives from (D-275).
|
|
21
|
-
const
|
|
20
|
+
// A companion who keeps no sheet shows the stat block of the creature it derives from (D-275); a thing, what its page says of it as data (D-573).
|
|
21
|
+
const groups = !party ? thingBlock(world, system, page) : hasSheet(world, page) ? sheetData(world, system, page) : statBlock(world, system, page);
|
|
22
|
+
const sheet = withItemImages(root, context, world, withCoins(speedInUnits(groups, system, measuresOf(root, system)), campaignCoins(root, context).coins, system));
|
|
22
23
|
const language = readSettings(root).language;
|
|
23
24
|
const headline = party ? sheetHeadline(world, system, page, system === undefined || language === undefined ? undefined : systemWordsOf(root, system, language, context)) : undefined;
|
|
24
25
|
const cards = party && hasSheet(world, page) ? system?.sheetCards : undefined;
|
|
@@ -4,6 +4,7 @@ import type { ActVerb, SheetVerb, SystemWords } from "../../systems/index.ts";
|
|
|
4
4
|
import type { CalendarDay } from "../../time/index.ts";
|
|
5
5
|
import type { PlayerSetting } from "../config/dashboard.ts";
|
|
6
6
|
import type { ShownImport } from "../import/import.ts";
|
|
7
|
+
import type { BookChapter } from "../shared/campaign/book.ts";
|
|
7
8
|
import type { Mode } from "../shared/campaign/mode.ts";
|
|
8
9
|
import type { ResetPoint, SaveMode } from "../shared/campaign/saves.ts";
|
|
9
10
|
import type { MoodMoment } from "../shared/characters/moods.ts";
|
|
@@ -152,6 +153,7 @@ export type ViewResult = {
|
|
|
152
153
|
quests: ShownQuest[];
|
|
153
154
|
chapters: ShownChapter[];
|
|
154
155
|
thoughts: ShownThought[];
|
|
156
|
+
book: BookChapter[];
|
|
155
157
|
}
|
|
156
158
|
/** The World section but the map (VIEW-11): the pages the character knows, each as it knows it, the documents it has or read, and the calendar. */
|
|
157
159
|
| {
|
|
@@ -109,6 +109,7 @@ export declare const view: import("../../core/registry.ts").Command<z.ZodObject<
|
|
|
109
109
|
quests: import("./journal.ts").ShownQuest[];
|
|
110
110
|
chapters: import("./journal.ts").ShownChapter[];
|
|
111
111
|
thoughts: import("./journal.ts").ShownThought[];
|
|
112
|
+
book: import("../shared/campaign/book.ts").BookChapter[];
|
|
112
113
|
} | {
|
|
113
114
|
kind: "world";
|
|
114
115
|
known: import("./world.ts").KnownEntry[];
|
|
@@ -11,6 +11,7 @@ import { offeredPages } from "../choices.js";
|
|
|
11
11
|
import { setupQuestions, shownPlayerSettings } from "../config/dashboard.js";
|
|
12
12
|
import { importShown } from "../import/import.js";
|
|
13
13
|
import { translatingTexts, wantTexts } from "../shared/books/system-texts.js";
|
|
14
|
+
import { campaignBook } from "../shared/campaign/book.js";
|
|
14
15
|
import { shownImage } from "../shared/campaign/images.js";
|
|
15
16
|
import { blockingMode, campaignMode, modes } from "../shared/campaign/mode.js";
|
|
16
17
|
import { campaignCoins } from "../shared/campaign/money.js";
|
|
@@ -142,6 +143,8 @@ export const view = defineCommand({
|
|
|
142
143
|
...shownJournal(root, world, knowledge, present, (entry) => storyFact(world, entry, lineNamed(entry)), known, (name) => placeLook(root, context, world, knowledge, name)),
|
|
143
144
|
// The diaries the player reads, the last line first: never a hidden line, as another character's (DIA-4).
|
|
144
145
|
thoughts: thoughtsIn(root, world).filter((one) => !one.hidden).reverse().map((one) => ({ who: known(one.page.name) ?? "someone", ...(one.date === undefined ? {} : { date: one.date }), text: one.text })),
|
|
146
|
+
// The story told as a book, the chapters of the scenes the story holds as it stands (T-227).
|
|
147
|
+
book: campaignBook(root),
|
|
145
148
|
};
|
|
146
149
|
}
|
|
147
150
|
if (input.map === true && [input.page, input.diary, input.rolls].some((given) => given !== undefined)) {
|
|
@@ -304,6 +307,7 @@ export const view = defineCommand({
|
|
|
304
307
|
...(result.quests.length === 0 ? ["No quests yet."] : result.quests.map(questText)),
|
|
305
308
|
...result.chapters.map((chapter) => `${chapter.title ?? "Between scenes"}${chapter.date === undefined ? "" : `, ${chapter.date}`}${chapter.summary === undefined ? "" : `: ${chapter.summary}`}`),
|
|
306
309
|
...result.thoughts.map((thought) => `${thought.who}'s diary${thought.date === undefined ? "" : `, ${thought.date}`}: ${thought.text}`),
|
|
310
|
+
...(result.book.length === 0 ? [] : [`The book: ${result.book.length} ${result.book.length === 1 ? "chapter" : "chapters"} written; book reads one.`]),
|
|
307
311
|
].join("\n");
|
|
308
312
|
case "world":
|
|
309
313
|
return [
|
package/dist/core/consents.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export declare const ourScope = "@rpgengine/";
|
|
|
7
7
|
export declare function packageCodeMayRun(folder: string): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* The fingerprint of a package's files as installed, and of its dependencies' as npm resolved them: every file but those npm or git keep beside them, by its
|
|
10
|
-
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or
|
|
11
|
-
* at each load of the package's code.
|
|
10
|
+
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or times changed (ctime too,
|
|
11
|
+
* since npm installs every file with one fixed mtime): it is asked at each load of the package's code.
|
|
12
12
|
*/
|
|
13
13
|
export declare function packageFingerprint(folder: string): string;
|
|
14
14
|
/** Records the player's yes to a package installed in a folder of npm's packages: its version and its files as they are now. */
|
package/dist/core/consents.js
CHANGED
|
@@ -29,14 +29,14 @@ export function packageCodeMayRun(folder) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* The fingerprint of a package's files as installed, and of its dependencies' as npm resolved them: every file but those npm or git keep beside them, by its
|
|
32
|
-
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or
|
|
33
|
-
* at each load of the package's code.
|
|
32
|
+
* path and its bytes, so that a dependency another install changed asks the yes again. Worked out again only when a file's size or times changed (ctime too,
|
|
33
|
+
* since npm installs every file with one fixed mtime): it is asked at each load of the package's code.
|
|
34
34
|
*/
|
|
35
35
|
export function packageFingerprint(folder) {
|
|
36
36
|
const paths = withDependencies(folder).flatMap(packageFiles);
|
|
37
37
|
const signature = paths.map((path) => {
|
|
38
38
|
const stat = statSync(path);
|
|
39
|
-
return `${path}|${stat.size}|${stat.mtimeMs}`;
|
|
39
|
+
return `${path}|${stat.size}|${stat.mtimeMs}|${stat.ctimeMs}`;
|
|
40
40
|
}).join("\n");
|
|
41
41
|
const known = fingerprints.get(folder);
|
|
42
42
|
if (known?.signature === signature) {
|
package/dist/core/context.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ export interface Context {
|
|
|
73
73
|
};
|
|
74
74
|
/** What makes pictures from words on this computer (D-308), as Codex with the player's login; missing where none can, as in tests. */
|
|
75
75
|
pictures?: PictureMaker;
|
|
76
|
+
/** Lines for the master's next call, as of a picture that came after its call answered (D-572); MCP only. */
|
|
77
|
+
later?: LaterLines;
|
|
76
78
|
/** What writes text from a brief on this computer, outside the chat, as Codex or Claude Code with the player's login (D-406); missing where none can. */
|
|
77
79
|
writer?: TextWriter;
|
|
78
80
|
/** A game system's pages translated on this computer as a player first reads them, where the system has no translation of its own (D-539); missing elsewhere. */
|
|
@@ -96,6 +98,19 @@ export interface Context {
|
|
|
96
98
|
pageFolder?: string;
|
|
97
99
|
/** Codex and Claude Code on this computer, installed and signed in with the player's yes (D-424); missing outside the MCP server, as in tests. */
|
|
98
100
|
helpers?: Helpers;
|
|
101
|
+
/** Where the AI hosts keep their chats on this computer, which the MCP server copies into the campaign (T-225); missing elsewhere, as in tests. */
|
|
102
|
+
chatFolders?: ChatFolders;
|
|
103
|
+
}
|
|
104
|
+
/** The folders where Claude Code and Codex keep their chats, each in its own way (T-225). */
|
|
105
|
+
export interface ChatFolders {
|
|
106
|
+
claudeCode: string;
|
|
107
|
+
codex: string;
|
|
108
|
+
}
|
|
109
|
+
/** Lines for the master at the head of their next call: added as they come, taken by the call, given back by one whose answer never goes. */
|
|
110
|
+
export interface LaterLines {
|
|
111
|
+
add(line: string): void;
|
|
112
|
+
take(): string[];
|
|
113
|
+
giveBack(lines: string[]): void;
|
|
99
114
|
}
|
|
100
115
|
/** A game system's pages a player reads, translated into the campaign's language in the background where they lack it (D-539). */
|
|
101
116
|
export interface SystemTexts {
|
|
@@ -239,16 +254,31 @@ export interface DocumentReader {
|
|
|
239
254
|
}
|
|
240
255
|
/**
|
|
241
256
|
* Whether pictures can be made here, or why not, in words the master can tell the player, and in the player's own with the steps to have them, one a line,
|
|
242
|
-
* numbered, with the commands between backticks (D-341).
|
|
257
|
+
* numbered, with the commands between backticks (D-341). Ready, who makes them, as Codex, Claude or Antigravity, and the master's own image tool it names, as
|
|
258
|
+
* ElevenLabs, or that the player is to name it (D-572).
|
|
243
259
|
*/
|
|
244
260
|
export type PicturesReady = {
|
|
245
261
|
ready: true;
|
|
246
|
-
maker?:
|
|
262
|
+
maker?: string;
|
|
263
|
+
tool?: string;
|
|
264
|
+
askTool?: true;
|
|
265
|
+
instead?: PictureFallback;
|
|
247
266
|
} | {
|
|
248
267
|
ready: false;
|
|
249
268
|
why: string;
|
|
250
269
|
fix?: string;
|
|
251
270
|
};
|
|
271
|
+
/**
|
|
272
|
+
* Why the maker the player chose made no picture and the chat in use makes it (D-572): its name, who makes it in its place, its reason, how the player has
|
|
273
|
+
* it, and whether it refused a picture.
|
|
274
|
+
*/
|
|
275
|
+
export interface PictureFallback {
|
|
276
|
+
maker: string;
|
|
277
|
+
by: string;
|
|
278
|
+
why: string;
|
|
279
|
+
fix?: string;
|
|
280
|
+
refused?: true;
|
|
281
|
+
}
|
|
252
282
|
/**
|
|
253
283
|
* What a picture shows (D-308, D-388, D-408): a place as the party sees it arriving, a quest as the character knows it, or the portrait of one of the party as
|
|
254
284
|
* the player sees them; never what the table keeps out.
|
|
@@ -265,14 +295,20 @@ export interface PictureSubject {
|
|
|
265
295
|
export interface MadePicture {
|
|
266
296
|
file: string;
|
|
267
297
|
done(): void;
|
|
298
|
+
/** Made by the chat in use in place of the maker the player chose, and why (D-572). */
|
|
299
|
+
instead?: PictureFallback;
|
|
268
300
|
}
|
|
269
301
|
/** What makes a picture from a brief: whether it can, and the picture, or why none came. */
|
|
270
302
|
export interface PictureMaker {
|
|
271
303
|
/** Asked once; with again, a no a minute old or more is asked once more, as after the player logs in. */
|
|
272
304
|
ready(again?: boolean): PicturesReady;
|
|
305
|
+
/** A picture, or why none came; onlyThis when the next may come, as after a safety check or a timeout (D-572). */
|
|
273
306
|
make(subject: PictureSubject): Promise<MadePicture | {
|
|
274
307
|
refused: string;
|
|
308
|
+
onlyThis?: true;
|
|
275
309
|
}>;
|
|
310
|
+
/** Where the chat makes the picture itself with its own tool (D-390), as Antigravity: the brief it follows; the engine then starts nothing. */
|
|
311
|
+
brief?(subject: PictureSubject): string | undefined;
|
|
276
312
|
}
|
|
277
313
|
/** The player's own words in place of a button, as the dashboard's page lets them write (ASK-10). */
|
|
278
314
|
export interface Said {
|
package/dist/core/download.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function downloadBytes(url, most, signal) {
|
|
|
30
30
|
throw new Error(`${url} stopped half way (${error instanceof Error ? error.message : String(error)}): check the address, or download it and give the file.`);
|
|
31
31
|
}
|
|
32
32
|
if (size > most) {
|
|
33
|
-
throw new Error(`${url} is more than ${most / 1024 / 1024} MB, more than
|
|
33
|
+
throw new Error(`${url} is more than ${most / 1024 / 1024} MB, more than may be taken from it.`);
|
|
34
34
|
}
|
|
35
35
|
const bytes = new Uint8Array(size);
|
|
36
36
|
let at = 0;
|
|
@@ -3,18 +3,23 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
|
|
|
3
3
|
import { createContext } from "preact";
|
|
4
4
|
import { useContext } from "preact/hooks";
|
|
5
5
|
import { t } from "../text.js";
|
|
6
|
-
import {
|
|
6
|
+
import { verbLabel } from "./acts.js";
|
|
7
7
|
/** The player's actions where the page has them: none for a system that names none, and the page is as it was. */
|
|
8
8
|
export const PlayerActsContext = createContext(undefined);
|
|
9
9
|
/** The player's actions, when the page has them. */
|
|
10
10
|
export function usePlayerActs() {
|
|
11
11
|
return useContext(PlayerActsContext);
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A thing's name that opens its card (D-495): what it is, then its verbs; with none, only what it is. Its tooltip names its verbs; `page`, the thing's page
|
|
15
|
+
* when the name shown is another; `facts`, what the sheet says of it; `said`, what a screen reader hears after it.
|
|
16
|
+
*/
|
|
17
|
+
export function ActName({ verbs, item, page, facts, document, said = "", children }) {
|
|
15
18
|
const acts = usePlayerActs();
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
// The click opens the card: the tooltip names what can be done there, a screen reader the thing and what the sheet says of it.
|
|
20
|
+
const title = verbs.length === 0 ? undefined : verbs.map(verbLabel).join(" · ");
|
|
21
|
+
const start = { verbs, item, ...(page === undefined ? {} : { page }), ...(facts === undefined ? {} : { facts }), ...(document === undefined ? {} : { document }) };
|
|
22
|
+
return (_jsxs("button", { type: "button", class: verbs.length === 0 ? "act reads" : "act", "data-tip": title, "aria-label": `${item}${said}`, onClick: (event) => acts?.start(start, event.currentTarget), children: [children, verbs.length > 0 && _jsx("span", { class: "act-mark", "aria-hidden": "true", children: "\u203A" })] }));
|
|
18
23
|
}
|
|
19
24
|
/** Someone's name that starts talking to them (D-495), where the page has the player's actions; else the name as it is. */
|
|
20
25
|
export function TalkName({ name, children }) {
|
|
@@ -55,6 +55,7 @@ export function useActs({ read, live, asked, foreground, version, players, membe
|
|
|
55
55
|
// With a question of the master's open, the sentence answers it (ASK-10); else it rings the master, or, in a chat that hears nothing by itself, is copied.
|
|
56
56
|
const question = asked !== undefined && asked.spend === undefined && asked.forced !== true ? asked : undefined;
|
|
57
57
|
const reply = question !== undefined ? "answer" : acts?.bell === true ? "tell" : "copy";
|
|
58
|
+
const answering = question === undefined ? undefined : { question: question.question, buttons: question.labels.length > 0 };
|
|
58
59
|
const sendAct = async (text) => {
|
|
59
60
|
setActProblem(undefined);
|
|
60
61
|
if (reply === "answer" && question !== undefined) {
|
|
@@ -65,7 +66,9 @@ export function useActs({ read, live, asked, foreground, version, players, membe
|
|
|
65
66
|
if (reply === "copy") {
|
|
66
67
|
return await copyAct(text) ? undefined : t("Copy did not work: select the words and copy them yourself.");
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
// The thing it starts from, for the master to hear what the character already knows of it (T-218).
|
|
70
|
+
const item = acting !== undefined && "verbs" in acting.start ? acting.start.page ?? acting.start.item : undefined;
|
|
71
|
+
const result = await sayAct(text, item);
|
|
69
72
|
if ("error" in result) {
|
|
70
73
|
return result.error;
|
|
71
74
|
}
|
|
@@ -106,5 +109,5 @@ export function useActs({ read, live, asked, foreground, version, players, membe
|
|
|
106
109
|
requestAnimationFrame(() => opener?.isConnected === true && opener.focus());
|
|
107
110
|
};
|
|
108
111
|
const playerActs = actions === undefined || players.length === 0 ? undefined : { actions, start: (start, opener) => setActing({ start, opener }) };
|
|
109
|
-
return { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct };
|
|
112
|
+
return { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, answering, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct };
|
|
110
113
|
}
|