rpg-engine 0.19.1 → 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/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) => {
|
|
@@ -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
|
}
|
|
@@ -1,52 +1,100 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
3
|
+
import { sectionAddress } from "../address.js";
|
|
4
|
+
import { readView } from "../api.js";
|
|
3
5
|
import { Icon } from "../parts/icons.js";
|
|
6
|
+
import { fieldLabel, phraseLabel, shownText } from "../parts/labels.js";
|
|
7
|
+
import { Markdown } from "../parts/markdown.js";
|
|
4
8
|
import { PlaceMap } from "../place/view.js";
|
|
5
9
|
import { t } from "../text.js";
|
|
6
10
|
import { actPeople, actSentence, actTitle, spokenBy, talkSentence, targetMode, verbLabel } from "./acts.js";
|
|
7
11
|
// How many characters a sentence may have, as the server takes them.
|
|
8
12
|
const mostWords = 500;
|
|
9
13
|
/**
|
|
10
|
-
* The
|
|
11
|
-
* sends and Escape closes
|
|
14
|
+
* The card of an action (D-495, D-573): a thing first, its page's text and its verbs; a verb chosen, on whom as chips and on the place's map,
|
|
15
|
+
* then the sentence in a field, which Enter sends and Escape closes. A card in the middle, wider with the map; a sheet from the foot on a phone.
|
|
12
16
|
*/
|
|
13
|
-
export function ActSheet({ start, self, place, scene, companions, reply, onSend, onClose }) {
|
|
17
|
+
export function ActSheet({ start, self, place, scene, companions, reply, asked, onSend, onClose }) {
|
|
14
18
|
const dialog = useRef(null);
|
|
15
19
|
const field = useRef(null);
|
|
16
20
|
const list = useRef(null);
|
|
17
|
-
const
|
|
21
|
+
const verbsBar = useRef(null);
|
|
22
|
+
const closer = useRef(null);
|
|
23
|
+
const thing = "verbs" in start;
|
|
24
|
+
// A thing opens on itself until a verb is chosen; talking goes straight to the words.
|
|
25
|
+
const [verb, setVerb] = useState();
|
|
26
|
+
const acting = !thing || verb !== undefined;
|
|
18
27
|
const mode = verb === undefined ? "none" : targetMode(verb);
|
|
19
|
-
const [target, setTarget] = useState(
|
|
28
|
+
const [target, setTarget] = useState();
|
|
20
29
|
const [square, setSquare] = useState("");
|
|
21
30
|
const map = place?.map;
|
|
31
|
+
// With a map at the place, on whom is chosen on it too, by a click.
|
|
32
|
+
const mapShown = map !== undefined && place !== undefined && mode !== "none";
|
|
22
33
|
const people = actPeople(place, scene, companions, self);
|
|
23
34
|
const shownTarget = target === undefined ? "none" : target === "square" ? (square.trim() === "" ? "none" : { square: square.trim().toUpperCase() }) : target;
|
|
24
35
|
// With more than one player character the sentence starts with who acts (D-480 (8)).
|
|
25
36
|
const composed = spokenBy("talk" in start ? talkSentence(start.talk) : actSentence(verb ?? "use", start.item, shownTarget), self);
|
|
26
37
|
const [text, setText] = useState(composed);
|
|
27
|
-
// What the page wrote last: changed by the player, the sentence is theirs and a new
|
|
38
|
+
// What the page wrote last: changed by the player, the sentence is theirs and a new target leaves it as it is; a new verb writes it again.
|
|
28
39
|
const written = useRef(composed);
|
|
40
|
+
const writtenFor = useRef(verb);
|
|
29
41
|
const [problem, setProblem] = useState();
|
|
30
42
|
const [sending, setSending] = useState(false);
|
|
31
|
-
|
|
32
|
-
const
|
|
43
|
+
// The text of the thing's page: undefined while it is read, empty for a page of data alone, null when the character knows no page of it.
|
|
44
|
+
const [about, setAbout] = useState();
|
|
45
|
+
// What the page says of the thing as data, as damage and weight (D-573).
|
|
46
|
+
const [data, setData] = useState([]);
|
|
47
|
+
const title = "talk" in start ? t("Talk to {name}", { name: start.talk }) : verb === undefined ? start.item : actTitle(verb, start.item);
|
|
33
48
|
useEffect(() => {
|
|
34
|
-
if (text === written.current) {
|
|
49
|
+
if (text === written.current || writtenFor.current !== verb) {
|
|
35
50
|
setText(composed);
|
|
36
51
|
}
|
|
37
52
|
written.current = composed;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
53
|
+
writtenFor.current = verb;
|
|
54
|
+
}, [composed, verb]);
|
|
55
|
+
// A modal dialog lies over everything on the page and closes with Escape by itself; a thing's page is read once, when it opens.
|
|
41
56
|
useEffect(() => {
|
|
42
57
|
dialog.current?.showModal();
|
|
58
|
+
if (!thing) {
|
|
59
|
+
focusEnd(field.current);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
(verbsBar.current?.querySelector("a, button") ?? closer.current)?.focus();
|
|
63
|
+
let live = true;
|
|
64
|
+
readView(start.page ?? start.item).then((page) => {
|
|
65
|
+
if (live) {
|
|
66
|
+
setAbout(page.kind === "page" ? page.text.trim() : null);
|
|
67
|
+
setData(page.kind === "page" ? page.sheet.flatMap((group) => group.values) : []);
|
|
68
|
+
}
|
|
69
|
+
}, () => live && setAbout(null));
|
|
70
|
+
return () => {
|
|
71
|
+
live = false;
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
// The focus goes where the player chooses next: on whom, for a verb that needs someone; else the sentence, the cursor at its end.
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (verb === undefined) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
43
79
|
if (mode === "asks") {
|
|
44
80
|
list.current?.querySelector("input[type=radio]")?.focus();
|
|
45
81
|
}
|
|
46
82
|
else {
|
|
47
83
|
focusEnd(field.current);
|
|
48
84
|
}
|
|
49
|
-
}, []);
|
|
85
|
+
}, [verb]);
|
|
86
|
+
const pick = (chosen) => {
|
|
87
|
+
setVerb(chosen);
|
|
88
|
+
setTarget(targetMode(chosen) === "lets" ? "none" : undefined);
|
|
89
|
+
setProblem(undefined);
|
|
90
|
+
};
|
|
91
|
+
// Back to the thing, the focus on the verb that was chosen.
|
|
92
|
+
const back = () => {
|
|
93
|
+
const was = verb;
|
|
94
|
+
setVerb(undefined);
|
|
95
|
+
setProblem(undefined);
|
|
96
|
+
requestAnimationFrame(() => verbsBar.current?.querySelector(`button[data-verb="${was ?? ""}"]`)?.focus());
|
|
97
|
+
};
|
|
50
98
|
const choose = (chosen) => {
|
|
51
99
|
setTarget(chosen);
|
|
52
100
|
setProblem(undefined);
|
|
@@ -80,11 +128,14 @@ export function ActSheet({ start, self, place, scene, companions, reply, onSend,
|
|
|
80
128
|
focusEnd(field.current);
|
|
81
129
|
}
|
|
82
130
|
};
|
|
131
|
+
const close = () => dialog.current?.close();
|
|
83
132
|
const personChosen = typeof target === "object" && "person" in target ? target.person : undefined;
|
|
84
133
|
const option = (key, chosen, label, kind = "") => (_jsxs("label", { class: ["act-who-one", kind].filter((name) => name !== "").join(" "), children: [_jsx("input", { type: "radio", name: "act-who", checked: sameTarget(target, chosen), onChange: () => choose(chosen), onKeyDown: toSentence }), label] }, key));
|
|
85
|
-
const full = choosing && map !== undefined;
|
|
86
134
|
const button = reply === "copy" ? t("Copy") : reply === "answer" ? t("Answer the master") : t("Tell the master");
|
|
87
|
-
|
|
135
|
+
const facts = thing ? start.facts ?? [] : [];
|
|
136
|
+
return (_jsxs("dialog", { ref: dialog, class: mapShown ? "map-sheet act-sheet wide" : "map-sheet act-sheet", "aria-labelledby": "act-sheet-title", "aria-describedby": !acting && facts.length > 0 ? "act-facts" : undefined, onClose: onClose, children: [_jsxs("header", { class: "map-sheet-head act-head", children: [thing && acting && (_jsx("button", { type: "button", class: "icon-button tip-right act-back", "aria-label": t("Back"), "data-tip": t("Back"), onClick: back, children: _jsx(Icon, { name: "fold" }) })), _jsxs("div", { class: "act-heading", children: [_jsx("h2", { id: "act-sheet-title", children: title }), !acting && facts.length > 0 && _jsx("p", { id: "act-facts", class: "act-facts", children: facts.join(" · ") })] }), _jsx("button", { ref: closer, type: "button", class: "icon-button tip-left", "aria-label": t("Close"), "data-tip": t("Close"), onClick: close, children: _jsx(Icon, { name: "close" }) })] }), thing && !acting && (_jsxs(_Fragment, { children: [data.length > 0 && (_jsx("dl", { class: "act-data", children: data.map((value) => (_jsxs("div", { children: [_jsx("dt", { children: phraseLabel(fieldLabel(value.field)) }), _jsx("dd", { children: shownText(value.text, value.kind) })] }, value.field))) })), about !== undefined && about !== "" && (about !== null || data.length === 0) && (_jsx("div", { class: "act-about", children: about === null ? _jsx("p", { class: "browse-none", children: t("Your character knows its name, and nothing more yet.") }) : _jsx(Markdown, { text: about }) })), (start.verbs.length > 0 || start.document === true) && (_jsxs("div", { ref: verbsBar, class: "act-buttons act-verbs", role: "group", "aria-label": t("What you do"), children: [start.document === true && (_jsx("a", { class: "map-sheet-go act-go", href: sectionAddress("world", "documents", start.page ?? start.item), onClick: close, children: t("Read it") })), start.verbs.map((one, index) => (_jsx("button", { type: "button", "data-verb": one, class: index === 0 && start.document !== true ? "map-sheet-go act-go" : "act-cancel", onClick: () => pick(one), children: verbLabel(one) }, one)))] }))] })), acting && mode !== "none" && (_jsxs("div", { class: "act-body", children: [_jsxs("fieldset", { ref: list, class: "act-who", children: [_jsx("legend", { class: "eyebrow", children: t("On whom") }), people.map((person, index) => option(`person ${index}`, { person: person.name }, _jsxs(_Fragment, { children: [_jsxs("span", { class: "act-who-name", children: [person.name, person.count !== undefined && _jsx("span", { class: "count", children: ` ×${person.count}` })] }), person.square !== undefined && _jsx("span", { class: "lm-key-square", children: person.square })] }), [person.role, person.hostile === true ? "hostile" : ""].filter((name) => name !== "").join(" "))), option("self", "self", _jsx("span", { class: "act-who-name", children: t("Myself") }), "plain"), option("none", "none", _jsx("span", { class: "act-who-name", children: t("No one in particular") }), "plain"), mapShown && option("square", "square", _jsx("span", { class: "act-who-name", children: t("A square…") }), "plain"), target === "square" && mapShown && (_jsx("input", { type: "text", class: "act-square", value: square, maxLength: 5, placeholder: "E4", "aria-label": t("The square, such as E4"), onInput: (event) => setSquare(event.currentTarget.value), onKeyDown: toSentence }))] }), mapShown && (_jsx(PlaceMap, { map: map, place: place.name, bare: true, self: self, choosing: { selected: personChosen, onChoose: (name) => choose(name === undefined ? "self" : { person: name }) }, ...(target === "square" ? { picking: { selected: square.trim().toUpperCase(), onSelect: setSquare } } : {}) }))] })), acting && (_jsxs("form", { class: "act-bar", onSubmit: (event) => void send(event), children: [reply === "answer" && (_jsxs("p", { id: "act-note", class: "act-note act-answer", children: [_jsx(Icon, { name: "bell" }), asked?.buttons === true
|
|
137
|
+
? t("These words answer the master instead of a roll or a button: {question}", { question: asked.question })
|
|
138
|
+
: t("These words answer the master's question: {question}", { question: asked?.question ?? "" })] })), _jsxs("label", { for: "act-words", class: "eyebrow act-words-label", children: [_jsx(Icon, { name: "chat" }), t("Your words to the master")] }), _jsx("textarea", { ref: field, id: "act-words", class: "act-words", value: text, rows: 2, maxLength: mostWords, "aria-describedby": reply === "tell" ? undefined : "act-note", onInput: (event) => setText(event.currentTarget.value), onKeyDown: keys }), reply === "copy" && (_jsxs("p", { id: "act-note", class: "act-note", children: [_jsx(Icon, { name: "info" }), t("This chat does not hear it by itself: copy it, then paste it in the chat.")] })), problem && _jsx("p", { class: "act-problem", role: "alert", children: problem }), _jsxs("div", { class: "act-buttons", children: [_jsx("button", { type: "button", class: "act-cancel", onClick: close, children: t("Cancel") }), _jsxs("button", { type: "submit", class: "map-sheet-go act-go", disabled: sending || text.trim() === "", children: [button, _jsx(Icon, { name: reply === "copy" ? "copy" : "send" })] })] })] }))] }));
|
|
88
139
|
}
|
|
89
140
|
/** Whether two choices of the list are the same. */
|
|
90
141
|
function sameTarget(target, other) {
|
package/dist/dashboard/api.js
CHANGED
|
@@ -318,10 +318,10 @@ export async function readActs() {
|
|
|
318
318
|
}
|
|
319
319
|
return await response.json();
|
|
320
320
|
}
|
|
321
|
-
/** Says a sentence to the master (D-495): its id, with how the sentences stand now; else what went wrong. */
|
|
322
|
-
export async function sayAct(text) {
|
|
321
|
+
/** Says a sentence to the master (D-495), with the thing of the sheet it starts from (T-218): its id, with how the sentences stand now; else what went wrong. */
|
|
322
|
+
export async function sayAct(text, item) {
|
|
323
323
|
try {
|
|
324
|
-
const response = await fetch("/api/act", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text }) });
|
|
324
|
+
const response = await fetch("/api/act", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(item === undefined ? { text } : { text, item }) });
|
|
325
325
|
const body = await response.json().catch(() => ({}));
|
|
326
326
|
return response.status === 202 && body.id !== undefined ? { id: body.id, shown: body } : { error: body.error ?? t("It did not reach the game: try again.") };
|
|
327
327
|
}
|
package/dist/dashboard/app.js
CHANGED
|
@@ -459,7 +459,7 @@ function App() {
|
|
|
459
459
|
const lead = playerNamed(shown.party, shown.foreground) ?? players[0];
|
|
460
460
|
const actor = member?.role === "pc" ? member : lead;
|
|
461
461
|
// The player's sentences to the master (D-495); read() sets the acts and the verbs it reads, by setters that never change.
|
|
462
|
-
const { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct } = useActs({
|
|
462
|
+
const { setActs, setActions, playerActs, acting, actsElsewhere, actPlace, reply, answering: answeringQuestion, strip, actProblem, sendAct, closeAct, withdraw, copyFromStrip, dismissAct } = useActs({
|
|
463
463
|
read,
|
|
464
464
|
live,
|
|
465
465
|
asked: shown.asked,
|
|
@@ -575,7 +575,7 @@ function App() {
|
|
|
575
575
|
}, onFree: (roll) => {
|
|
576
576
|
setFree((before) => withFree(shown.campaign, before, roll));
|
|
577
577
|
setFresh((before) => new Set([...before, roll.id]));
|
|
578
|
-
} }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: copyFromStrip, onDismiss: dismissAct })] }) }) }) }) }) }));
|
|
578
|
+
} }), acting !== undefined && (_jsx(ActSheet, { start: acting.start, self: several ? member?.name : undefined, place: actsElsewhere === undefined ? shown.place : actPlace?.who === actsElsewhere ? actPlace.place : undefined, scene: shown.openScene, companions: shown.party.filter((one) => one.role === "companion").map((one) => one.name), reply: reply, asked: answeringQuestion, onSend: sendAct, onClose: closeAct })), _jsx(ActStrip, { entries: strip, problem: actProblem, onWithdraw: (id) => void withdraw(id), onCopy: copyFromStrip, onDismiss: dismissAct })] }) }) }) }) }) }));
|
|
579
579
|
}
|
|
580
580
|
// The theme the player picked before, from the start (D-300).
|
|
581
581
|
restoreTheme();
|