rpg-engine 0.19.1 → 0.21.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/adventures/index.d.ts +1 -1
- package/dist/adventures/index.js +1 -1
- package/dist/adventures/source.d.ts +3 -0
- package/dist/adventures/source.js +11 -49
- package/dist/campaign/create-campaign.d.ts +1 -1
- package/dist/campaign/create-campaign.js +4 -3
- package/dist/campaign/find-campaign.d.ts +6 -0
- package/dist/campaign/find-campaign.js +7 -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 +32 -8
- 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 +36 -0
- package/dist/commands/book.js +129 -0
- package/dist/commands/chats.d.ts +38 -0
- package/dist/commands/chats.js +93 -0
- package/dist/commands/config/config.js +2 -2
- package/dist/commands/config/dashboard.d.ts +8 -1
- package/dist/commands/config/dashboard.js +70 -16
- package/dist/commands/config/words.d.ts +1 -1
- package/dist/commands/config/words.js +18 -5
- package/dist/commands/find.js +1 -1
- package/dist/commands/image.d.ts +14 -0
- package/dist/commands/image.js +100 -20
- package/dist/commands/index.js +4 -0
- package/dist/commands/init.js +3 -3
- package/dist/commands/package/data.d.ts +35 -0
- package/dist/commands/package/data.js +117 -0
- package/dist/commands/package/here.d.ts +7 -2
- package/dist/commands/package/here.js +23 -11
- package/dist/commands/package/install.js +14 -15
- package/dist/commands/package/language.d.ts +15 -0
- package/dist/commands/package/language.js +109 -0
- package/dist/commands/package/package.js +20 -10
- package/dist/commands/package/result.d.ts +19 -0
- package/dist/commands/package/theme.d.ts +13 -0
- package/dist/commands/package/theme.js +66 -0
- package/dist/commands/package/uninstall.d.ts +4 -1
- package/dist/commands/package/uninstall.js +29 -9
- package/dist/commands/scene/close.d.ts +2 -0
- package/dist/commands/scene/close.js +20 -2
- package/dist/commands/scene/result.d.ts +2 -0
- package/dist/commands/scene/scene.d.ts +2 -0
- package/dist/commands/shared/books/adventures.d.ts +0 -4
- package/dist/commands/shared/books/adventures.js +2 -31
- package/dist/commands/shared/books/words.js +3 -2
- package/dist/commands/shared/campaign/book.d.ts +42 -0
- package/dist/commands/shared/campaign/book.js +118 -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/campaign/world.js +2 -1
- package/dist/commands/shared/packages/catalog.d.ts +3 -3
- package/dist/commands/shared/packages/catalog.js +98 -42
- package/dist/commands/shared/packages/unpacked.d.ts +50 -0
- package/dist/commands/shared/packages/unpacked.js +146 -0
- 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/archive.d.ts +13 -0
- package/dist/core/archive.js +76 -0
- package/dist/core/consents.d.ts +2 -2
- package/dist/core/consents.js +3 -3
- package/dist/core/context.d.ts +40 -2
- package/dist/core/context.js +1 -0
- package/dist/core/download.js +1 -1
- package/dist/core/store.d.ts +5 -1
- package/dist/core/store.js +15 -2
- 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 +27 -4
- package/dist/dashboard/app.js +9 -4
- package/dist/dashboard/guide/ar.md +16 -15
- package/dist/dashboard/guide/cs.md +15 -14
- package/dist/dashboard/guide/da.md +17 -16
- package/dist/dashboard/guide/de.md +17 -16
- package/dist/dashboard/guide/el.md +17 -16
- package/dist/dashboard/guide/en.md +14 -13
- package/dist/dashboard/guide/es.md +15 -14
- package/dist/dashboard/guide/fi.md +15 -14
- package/dist/dashboard/guide/fr.md +20 -19
- package/dist/dashboard/guide/he.md +15 -14
- package/dist/dashboard/guide/hi.md +15 -14
- package/dist/dashboard/guide/hu.md +19 -18
- package/dist/dashboard/guide/is.md +15 -14
- package/dist/dashboard/guide/it.md +18 -17
- package/dist/dashboard/guide/ja.md +15 -14
- package/dist/dashboard/guide/ko.md +16 -15
- package/dist/dashboard/guide/nb.md +17 -16
- package/dist/dashboard/guide/nl.md +15 -14
- package/dist/dashboard/guide/pl.md +16 -15
- package/dist/dashboard/guide/pt.md +16 -15
- package/dist/dashboard/guide/ro.md +15 -14
- package/dist/dashboard/guide/ru.md +16 -15
- package/dist/dashboard/guide/sv.md +15 -14
- package/dist/dashboard/guide/tr.md +18 -17
- package/dist/dashboard/guide/uk.md +19 -18
- package/dist/dashboard/guide/zh.md +16 -15
- package/dist/dashboard/i18n/ar.json +63 -9
- package/dist/dashboard/i18n/cs.json +63 -9
- package/dist/dashboard/i18n/da.json +63 -9
- package/dist/dashboard/i18n/de.json +63 -9
- package/dist/dashboard/i18n/el.json +63 -9
- package/dist/dashboard/i18n/es.json +63 -9
- package/dist/dashboard/i18n/fi.json +63 -9
- package/dist/dashboard/i18n/fr.json +63 -9
- package/dist/dashboard/i18n/he.json +63 -9
- package/dist/dashboard/i18n/hi.json +63 -9
- package/dist/dashboard/i18n/hu.json +63 -9
- package/dist/dashboard/i18n/is.json +63 -9
- package/dist/dashboard/i18n/it.json +64 -10
- package/dist/dashboard/i18n/ja.json +63 -9
- package/dist/dashboard/i18n/ko.json +63 -9
- package/dist/dashboard/i18n/nb.json +63 -9
- package/dist/dashboard/i18n/nl.json +63 -9
- package/dist/dashboard/i18n/pl.json +63 -9
- package/dist/dashboard/i18n/pt.json +63 -9
- package/dist/dashboard/i18n/ro.json +63 -9
- package/dist/dashboard/i18n/ru.json +63 -9
- package/dist/dashboard/i18n/sv.json +63 -9
- package/dist/dashboard/i18n/tr.json +63 -9
- package/dist/dashboard/i18n/uk.json +63 -9
- package/dist/dashboard/i18n/zh.json +63 -9
- package/dist/dashboard/journal/book.js +107 -0
- package/dist/dashboard/journal/journal.js +16 -12
- package/dist/dashboard/kit.js +1 -1
- package/dist/dashboard/packages/catalog.js +31 -14
- package/dist/dashboard/packages/engine.js +46 -2
- package/dist/dashboard/packages/installed.js +13 -0
- package/dist/dashboard/packages/outcomes.js +21 -0
- package/dist/dashboard/packages/packages.js +41 -18
- package/dist/dashboard/packages/rows.js +3 -1
- package/dist/dashboard/parts/icons.js +3 -0
- package/dist/dashboard/parts/labels.js +6 -0
- package/dist/dashboard/parts/picture.js +89 -0
- package/dist/dashboard/parts/refusals.js +8 -1
- package/dist/dashboard/parts/widgets.js +3 -2
- package/dist/dashboard/place/view.js +1 -1
- package/dist/dashboard/play/scene.js +8 -5
- package/dist/dashboard/settings/settings.js +32 -16
- package/dist/dashboard/settings/setup.js +5 -3
- package/dist/dashboard/sheet/party.js +5 -2
- package/dist/dashboard/sheet/sheet.js +10 -6
- package/dist/dashboard/shell/notices.js +2 -2
- package/dist/dashboard/shell/system-style.js +45 -12
- package/dist/dashboard/shell/tooltip.js +223 -0
- package/dist/dashboard/style.css +775 -261
- package/dist/dashboard/world/calendar.js +1 -1
- package/dist/dashboard/world/lore.js +5 -4
- package/dist/dashboard/world/place-card.js +2 -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/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/languages/pack.d.ts +4 -1
- package/dist/languages/pack.js +16 -5
- package/dist/packages/engine.d.ts +7 -0
- package/dist/packages/engine.js +32 -1
- package/dist/packages/index.d.ts +1 -1
- package/dist/packages/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/engine.d.ts +18 -0
- package/dist/server/dashboard/engine.js +31 -0
- package/dist/server/dashboard/files.d.ts +8 -1
- package/dist/server/dashboard/files.js +30 -10
- package/dist/server/dashboard/index.d.ts +3 -0
- package/dist/server/dashboard/index.js +10 -1
- package/dist/server/dashboard/news.js +36 -5
- package/dist/server/dashboard/pictures.d.ts +7 -0
- package/dist/server/dashboard/pictures.js +62 -0
- package/dist/server/dashboard/writes.d.ts +5 -3
- package/dist/server/dashboard/writes.js +45 -14
- 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/dist/testing/index.js +1 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +4 -2
- package/dist/themes/installed.d.ts +14 -0
- package/dist/themes/installed.js +28 -0
- package/dist/themes/theme.d.ts +7 -0
- package/dist/themes/theme.js +22 -0
- package/instructions/core.md +3 -3
- package/instructions/dashboard-guide.md +1 -0
- package/instructions/mentor-hints.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/party.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/start.md +1 -1
- package/package.json +2 -2
- package/systems/free/instructions/outcomes-told.md +1 -1
|
@@ -8,8 +8,11 @@ import { comparableText } from "../../core/text.js";
|
|
|
8
8
|
import { dropConsent, installedExtensions, shortName } from "../../extensions/index.js";
|
|
9
9
|
import { isPackageName } from "../../packages/index.js";
|
|
10
10
|
import { listedExtensions } from "../shared/packages/extensions.js";
|
|
11
|
+
import { findUnpacked, unpackedName } from "../shared/packages/unpacked.js";
|
|
11
12
|
import { newDatedLogEntry } from "../shared/time/time.js";
|
|
12
13
|
import { installedExtensionFolder, languagesHere, systemsHere } from "./here.js";
|
|
14
|
+
import { dataLanguageUninstalled } from "./language.js";
|
|
15
|
+
import { themeUninstalled } from "./theme.js";
|
|
13
16
|
/** Takes an extension out of the campaign; it stays on this computer, for other campaigns. */
|
|
14
17
|
export function removed(root, context, name) {
|
|
15
18
|
const listed = listedExtensions(root);
|
|
@@ -23,20 +26,37 @@ export function removed(root, context, name) {
|
|
|
23
26
|
appendLogEntry(root, newDatedLogEntry(root, context, "package-removed", "public", { package: found }));
|
|
24
27
|
return { kind: "removed", name: shortName(found) };
|
|
25
28
|
}
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Takes a package off this computer with npm, and out of the campaign when it uses it (D-442); other campaigns that list it ask to install it again. A theme
|
|
31
|
+
* or a language of data alone goes by its folder, when no npm package has its name: theme:<id> and language:<code> name them alone.
|
|
32
|
+
*/
|
|
27
33
|
export async function uninstalled(root, context, name) {
|
|
28
34
|
const packages = context.packages;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
const npmName = name.startsWith("npm:") ? name.slice(4) : name;
|
|
36
|
+
const unpacked = findUnpacked(context, name);
|
|
37
|
+
const system = systemsHere(root, context).find((one) => one.package !== undefined && (one.package === npmName || comparableText(one.name) === comparableText(npmName)));
|
|
38
|
+
const other = system?.package
|
|
39
|
+
?? languagesHere(context).find((one) => one.unpacked !== true && (one.package === npmName || comparableText(one.code) === comparableText(npmName)))?.package;
|
|
34
40
|
const found = other === undefined
|
|
35
|
-
? installedExtensions(context.extensionFolders ?? []).find((one) => one.package ===
|
|
41
|
+
? installedExtensions(context.extensionFolders ?? []).find((one) => one.package === npmName || comparableText(shortName(one.package)) === comparableText(npmName))
|
|
36
42
|
: { package: other };
|
|
37
43
|
// A package that reads as nothing, as a system whose system.yaml is broken, is still npm's to take away by its folder, under its npm name.
|
|
38
|
-
const
|
|
39
|
-
|
|
44
|
+
const unread = found === undefined && packages !== undefined && isPackageName(npmName)
|
|
45
|
+
&& (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0);
|
|
46
|
+
const npm = unpacked !== undefined && /^(theme|language):/i.test(name) ? undefined : (found?.package ?? (unread ? npmName : undefined));
|
|
47
|
+
// A theme or a language of data alone goes only when no npm package has its name; when both have it, the player says which.
|
|
48
|
+
if (unpacked !== undefined && npm !== undefined) {
|
|
49
|
+
const npmAs = npm.startsWith("@") ? npm : `npm:${npm}`;
|
|
50
|
+
throw new Refusal(`${name} names two packages on this computer: ${npm} from npm, and the ${unpacked.kind} ${unpacked.kind === "theme" ? (unpacked.theme.theme?.name ?? unpacked.theme.id) : unpacked.pack.name}. `
|
|
51
|
+
+ `Say which: ${npmAs} for the one from npm, ${unpackedName(unpacked)} for the ${unpacked.kind}. Nothing changed.`, "ambiguous-name", { name, npm: npmAs, unpacked: unpackedName(unpacked) });
|
|
52
|
+
}
|
|
53
|
+
if (unpacked !== undefined) {
|
|
54
|
+
return unpacked.kind === "theme" ? themeUninstalled(root, context, unpacked.theme) : dataLanguageUninstalled(root, context, unpacked.pack);
|
|
55
|
+
}
|
|
56
|
+
if (system?.used === true) {
|
|
57
|
+
throw new Refusal(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`, "system-played", { name: system.name });
|
|
58
|
+
}
|
|
59
|
+
if (unread && packages !== undefined) {
|
|
40
60
|
const why = await packages.uninstall(npmName);
|
|
41
61
|
if (why !== undefined) {
|
|
42
62
|
throw new Refusal(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`, "uninstall-failed", { name: npmName, why });
|
|
@@ -5,6 +5,7 @@ import { readCounter } from "../../counters/index.js";
|
|
|
5
5
|
import { findPage, isPartyMember, linksIn, pagesWithName, parsePageReference } from "../../pages/index.js";
|
|
6
6
|
import { sceneTypes } from "../../scene/index.js";
|
|
7
7
|
import { formatGameDate } from "../../time/index.js";
|
|
8
|
+
import { chapterCraft, scenesPerChapter, scenesText, untoldScenes } from "../shared/campaign/book.js";
|
|
8
9
|
import { firstInChat } from "../shared/campaign/parts.js";
|
|
9
10
|
import { isTickedOpenQuest, tickedQuestNote } from "../shared/campaign/quests.js";
|
|
10
11
|
import { isPlayerDead, makeSave, saveText } from "../shared/campaign/saves.js";
|
|
@@ -49,7 +50,7 @@ export function close(root, world, summary, context) {
|
|
|
49
50
|
if (current === undefined) {
|
|
50
51
|
const titled = rawTitleAndType(raw);
|
|
51
52
|
appendLogEntry(root, newDatedLogEntry(root, context, "scene-closed", "public", { ...titled, closed, summary: summary.trim() }));
|
|
52
|
-
return { action: "close", copies: [], unreadable: problem?.message, ended, endless: [], quests, ...endOfSceneSave(root, context, world, titled.title) };
|
|
53
|
+
return { action: "close", copies: [], unreadable: problem?.message, ended, endless: [], quests, ...bookChapter(root, context), ...endOfSceneSave(root, context, world, titled.title) };
|
|
53
54
|
}
|
|
54
55
|
logCopies(root, context, current.title, current.copies);
|
|
55
56
|
const left = current.left?.filter((name) => pagesWithName(world, name).length > 0);
|
|
@@ -72,9 +73,15 @@ export function close(root, world, summary, context) {
|
|
|
72
73
|
...(fallen === "" ? {} : { fallen }),
|
|
73
74
|
...(peakEnded(current.type) && firstInChat(context, "after-peak") ? { afterPeak } : {}),
|
|
74
75
|
quests,
|
|
76
|
+
...bookChapter(root, context),
|
|
75
77
|
...saved,
|
|
76
78
|
};
|
|
77
79
|
}
|
|
80
|
+
/** The closed scenes that wait for the book's next chapter, for the master to write it where the story turns, with how to write it once in a chat (T-227). */
|
|
81
|
+
function bookChapter(root, context) {
|
|
82
|
+
const untold = untoldScenes(root).map((scene) => scene.number);
|
|
83
|
+
return untold.length === 0 ? {} : { untold, ...(firstInChat(context, "book") ? { craft: chapterCraft } : {}) };
|
|
84
|
+
}
|
|
78
85
|
/**
|
|
79
86
|
* The save at the end of a scene, named by its title (D-55, SAV-3): none while the player character is dead, since going back is what one is for. A save that
|
|
80
87
|
* cannot be written never stops the close, which is already done: it says why.
|
|
@@ -165,7 +172,7 @@ export function closedText(result) {
|
|
|
165
172
|
const advance = "Advance any time it took that you have not advanced yet; write on their pages what it changed for good, such as a fire put out or a door broken.";
|
|
166
173
|
const endless = result.endless.length === 0 ? "" : `\nStill there, with no end: ${result.endless.join(" · ")}. End those the scene ended, with effect end.`;
|
|
167
174
|
const ended = `${result.ended.length === 0 ? "" : `\nEnded with the scene: ${result.ended.join(" · ")}.`}${endless}`;
|
|
168
|
-
const quests = result.quests.map((line) => `\n${line}`).join("")
|
|
175
|
+
const quests = `${result.quests.map((line) => `\n${line}`).join("")}${chapterLine(result.untold, result.craft)}`;
|
|
169
176
|
if (result.unreadable !== undefined) {
|
|
170
177
|
return `The open scene could not be read (${result.unreadable}): closed it, without its copies. ${advance}${ended}${quests}${saved}`;
|
|
171
178
|
}
|
|
@@ -179,3 +186,14 @@ export function closedText(result) {
|
|
|
179
186
|
const peak = result.afterPeak === undefined ? "" : `\n${result.afterPeak}`;
|
|
180
187
|
return `Scene closed${rounds}: ${result.title}.${gone} ${advance}${ended}${left}${fallen}${rewards}${quests}${peak}${saved}`;
|
|
181
188
|
}
|
|
189
|
+
/** The scenes the book's next chapter waits for (T-227): written now where the story turns, and once they are many. */
|
|
190
|
+
function chapterLine(untold, craft) {
|
|
191
|
+
if (untold === undefined) {
|
|
192
|
+
return "";
|
|
193
|
+
}
|
|
194
|
+
const scenes = scenesText(untold.map((number) => ({ number })));
|
|
195
|
+
const when = untold.length >= scenesPerChapter
|
|
196
|
+
? "write it now with book."
|
|
197
|
+
: "if the story turned here (a goal reached or lost, a place left, a night passed), write it now with book, while the scenes are fresh; else at a later scene's end.";
|
|
198
|
+
return `\nThe book: ${scenes} ${untold.length === 1 ? "waits" : "wait"} for the next chapter; ${when}${craft === undefined ? "" : ` ${craft}`}`;
|
|
199
|
+
}
|
|
@@ -69,6 +69,8 @@ export type SceneResult = ({
|
|
|
69
69
|
fallen?: string;
|
|
70
70
|
afterPeak?: string;
|
|
71
71
|
quests: string[];
|
|
72
|
+
chapter?: number;
|
|
73
|
+
craft?: string;
|
|
72
74
|
} & Saved);
|
|
73
75
|
/** The order of turns, where the scene has one, and whether the turn is the player's character's. */
|
|
74
76
|
export interface Turns {
|
|
@@ -63,10 +63,6 @@ export interface AdventureExported {
|
|
|
63
63
|
/** The pages and layers written from the player's documents (source:), when no license was given: the zip keeps them to the player. */
|
|
64
64
|
sourced?: string[];
|
|
65
65
|
}
|
|
66
|
-
/** Whether what was given to package install is an adventure: a .zip, a link, or a folder with adventure.yaml; a document says it is imported instead. */
|
|
67
|
-
export declare function isAdventureSpec(spec: string): boolean;
|
|
68
|
-
/** The adventure a .zip, a folder or an https link gives (ADV-1): a GitHub repository is read as the zip of its branch. */
|
|
69
|
-
export declare function readAdventureSpec(spec: string, context: Context): Promise<AdventureFiles>;
|
|
70
66
|
/** The adventures the log says are installed and not taken out, in the order they came (ADV-6): they go back with a save. */
|
|
71
67
|
export declare function installedAdventures(root: string): InstalledAdventure[];
|
|
72
68
|
/** Installs an adventure in the campaign (ADV-2–ADV-5): checked whole, then written, or nothing at all; installed again, it finishes what stopped. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// The adventures of a campaign (D-476, D-483): installed from a package whole or not at all, taken out while the story has not touched them, and exported as
|
|
2
2
|
// they were at the start (ADV-1–ADV-7), with the campaign's layers over its game system as they are now (ADV-8).
|
|
3
|
-
import { basename, join, relative,
|
|
3
|
+
import { basename, join, relative, sep } from "node:path";
|
|
4
4
|
import { parse, parseDocument, stringify, visit } from "yaml";
|
|
5
|
-
import { adventureFolderName, adventureTarget,
|
|
5
|
+
import { adventureFolderName, adventureTarget, manifestLine, packAdventure } from "../../../adventures/index.js";
|
|
6
6
|
import { houseRulesFolderName, readSettings } from "../../../campaign/index.js";
|
|
7
7
|
import { appendLogEntry, readLog } from "../../../core/log.js";
|
|
8
8
|
import { Refusal } from "../../../core/refusal.js";
|
|
@@ -26,35 +26,6 @@ import { houseRules, systemRuleBook } from "./rules.js";
|
|
|
26
26
|
const changesMade = "Changes were made: the files under layers/ modify pages the game system adapted from that material.";
|
|
27
27
|
// The mark of an install under way, with its title and the days it moves dates by: while it is there, installing the same adventure finishes it (ADV-5).
|
|
28
28
|
const installMarkName = ".adventure-install.yaml";
|
|
29
|
-
// The documents a master imports, never a package: their pages are written by the master (D-483 (10)).
|
|
30
|
-
const documentPattern = /\.(pdf|docx?|odt|rtf|txt|md|epub)$/i;
|
|
31
|
-
/** Whether what was given to package install is an adventure: a .zip, a link, or a folder with adventure.yaml; a document says it is imported instead. */
|
|
32
|
-
export function isAdventureSpec(spec) {
|
|
33
|
-
if (documentPattern.test(spec)) {
|
|
34
|
-
throw new Refusal(`${spec} is a document, not a package: make an adventure from it with import; package install takes only what has adventure.yaml. Nothing changed.`, "document", { name: spec });
|
|
35
|
-
}
|
|
36
|
-
return /\.zip$/i.test(spec) || /^https:\/\//i.test(spec) || isAdventureFolder(resolve(spec));
|
|
37
|
-
}
|
|
38
|
-
/** The adventure a .zip, a folder or an https link gives (ADV-1): a GitHub repository is read as the zip of its branch. */
|
|
39
|
-
export async function readAdventureSpec(spec, context) {
|
|
40
|
-
if (/^https:\/\//i.test(spec)) {
|
|
41
|
-
if (context.download === undefined) {
|
|
42
|
-
throw new Error("Only the game's server and the command line download an adventure: give a .zip or a folder of this computer.");
|
|
43
|
-
}
|
|
44
|
-
const repository = /^https:\/\/github\.com\/([^/]+)\/([^/#?]+?)(?:\.git)?(?:\/tree\/([^#?]+))?\/?$/i.exec(spec);
|
|
45
|
-
const url = repository === null ? spec : `https://codeload.github.com/${repository[1]}/${repository[2]}/zip/${repository[3] === undefined ? "HEAD" : `refs/heads/${repository[3]}`}`;
|
|
46
|
-
return readAdventureZip(await context.download(url, largestAdventure, context.signal), spec);
|
|
47
|
-
}
|
|
48
|
-
const path = resolve(spec);
|
|
49
|
-
if (/\.zip$/i.test(spec)) {
|
|
50
|
-
const bytes = files().bytes(path);
|
|
51
|
-
if (bytes === undefined) {
|
|
52
|
-
throw new Refusal(`There is no file ${path}: give the path of the adventure's .zip. Nothing changed.`, "not-on-computer", { name: path });
|
|
53
|
-
}
|
|
54
|
-
return readAdventureZip(bytes, basename(path));
|
|
55
|
-
}
|
|
56
|
-
return readAdventureFolder(path);
|
|
57
|
-
}
|
|
58
29
|
/** The adventures the log says are installed and not taken out, in the order they came (ADV-6): they go back with a save. */
|
|
59
30
|
export function installedAdventures(root) {
|
|
60
31
|
return adventuresOfLog(readLog(root));
|
|
@@ -8,6 +8,7 @@ import { codeAndBase } from "../../../core/language.js";
|
|
|
8
8
|
import { files } from "../../../core/store.js";
|
|
9
9
|
import { languagePackFor, packPhrases } from "../../../languages/index.js";
|
|
10
10
|
import { layeredSystemWords, systemContentFolders, systemWords } from "../../../systems/index.js";
|
|
11
|
+
import { languageFolders } from "../packages/unpacked.js";
|
|
11
12
|
// How many phrases go in one request.
|
|
12
13
|
const batchSize = 130;
|
|
13
14
|
// How long a language whose translation stopped short waits before it is tried again, so that a writer that fails is not called at every reading.
|
|
@@ -51,7 +52,7 @@ export function pageTranslator(context, page, notify) {
|
|
|
51
52
|
return {
|
|
52
53
|
read: (language, system) => {
|
|
53
54
|
// A translation made by hand, installed as a package, comes before the one made on the fly (D-485 (3)).
|
|
54
|
-
const pack = languagePackFor(context
|
|
55
|
+
const pack = languagePackFor(languageFolders(context), language);
|
|
55
56
|
const own = { ...(context.home === undefined ? {} : readJson(join(context.home, "i18n", `${language}.json`))), ...(pack === undefined ? {} : packPhrases(pack)) };
|
|
56
57
|
const missing = Object.keys(reference()).filter((phrase) => !(phrase in own)).length;
|
|
57
58
|
const can = context.writer?.ready() === true && context.home !== undefined;
|
|
@@ -85,7 +86,7 @@ export function pagePhrase(context, language, phrase) {
|
|
|
85
86
|
}
|
|
86
87
|
const page = context.pageFolder;
|
|
87
88
|
const codes = codeAndBase(language);
|
|
88
|
-
const pack = languagePackFor(context
|
|
89
|
+
const pack = languagePackFor(languageFolders(context), language);
|
|
89
90
|
const shipped = [...codes, codes.at(-1) === "no" ? "nb" : ""].filter((candidate) => candidate !== "").map((candidate) => readJson(join(page, "i18n", `${candidate}.json`)));
|
|
90
91
|
const own = context.home === undefined ? {} : readJson(join(context.home, "i18n", `${language}.json`));
|
|
91
92
|
return [pack === undefined ? {} : packPhrases(pack), ...shipped, own].map((phrases) => phrases[phrase]).find((said) => typeof said === "string" && said !== "") ?? phrase;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** A scene of the story: its number, as the journal counts them, its title and summary, its game date, when it ran in real time, and the log line that opened it. */
|
|
2
|
+
export interface StoryScene {
|
|
3
|
+
number: number;
|
|
4
|
+
title: string;
|
|
5
|
+
summary?: string;
|
|
6
|
+
date?: string;
|
|
7
|
+
from: string;
|
|
8
|
+
/** When it closed; none while it is open. */
|
|
9
|
+
to?: string;
|
|
10
|
+
scene: string;
|
|
11
|
+
}
|
|
12
|
+
/** A chapter of the book as the player reads it. */
|
|
13
|
+
export interface BookChapter {
|
|
14
|
+
number: number;
|
|
15
|
+
title: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
/** A chapter with the scenes it tells, by their numbers, first and last. */
|
|
19
|
+
export interface WrittenChapter extends BookChapter {
|
|
20
|
+
first: number;
|
|
21
|
+
last: number;
|
|
22
|
+
}
|
|
23
|
+
/** How many closed scenes may wait for their chapter before the master is told to write it now. */
|
|
24
|
+
export declare const scenesPerChapter = 4;
|
|
25
|
+
/** How the master writes a chapter (T-227): told once in a chat, by the first scene that closes or the first call of book. */
|
|
26
|
+
export declare const chapterCraft: string;
|
|
27
|
+
/** The scenes of the story in order, by the public lines of the log, as the journal numbers them: a scene closed with no line that opened it is one too. */
|
|
28
|
+
export declare function storyScenes(root: string): StoryScene[];
|
|
29
|
+
/** The chapters of the book whose scenes are in the story as it stands, in order: each going on from the one before, the first from the first scene. */
|
|
30
|
+
export declare function campaignBook(root: string): WrittenChapter[];
|
|
31
|
+
/** The closed scenes no chapter tells yet, in order: those the next chapter is for. */
|
|
32
|
+
export declare function untoldScenes(root: string, book?: WrittenChapter[]): StoryScene[];
|
|
33
|
+
/** Writes a chapter telling these scenes, in place of the one with its number. */
|
|
34
|
+
export declare function writeChapter(root: string, number: number, scenes: StoryScene[], title: string, text: string): void;
|
|
35
|
+
/** Takes a chapter out of the book; nothing when it has none. */
|
|
36
|
+
export declare function removeChapter(root: string, number: number): void;
|
|
37
|
+
/** What status says of a book left behind, by a chat closed or a computer turned off: the scenes waiting too long for their chapter, once the book has begun. */
|
|
38
|
+
export declare function bookBehind(root: string): string | undefined;
|
|
39
|
+
/** Scenes by their numbers, as «scene 4» or «scenes 4–7». */
|
|
40
|
+
export declare function scenesText(scenes: {
|
|
41
|
+
number: number;
|
|
42
|
+
}[]): string;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// The campaign's story told as a book (T-227): chapters of prose written by the master into book/, out of the saves, each telling the closed scenes since the one
|
|
2
|
+
// before, ended where the story turns. A chapter holds its scenes by the log lines that opened them: one whose scenes a load undid, or that a reset took away, is
|
|
3
|
+
// left out, with those after it, until the master writes it again.
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { parse, stringify } from "yaml";
|
|
6
|
+
import { bookFolderName } from "../../../campaign/index.js";
|
|
7
|
+
import { readLog } from "../../../core/log.js";
|
|
8
|
+
import { files } from "../../../core/store.js";
|
|
9
|
+
/** How many closed scenes may wait for their chapter before the master is told to write it now. */
|
|
10
|
+
export const scenesPerChapter = 4;
|
|
11
|
+
/** How the master writes a chapter (T-227): told once in a chat, by the first scene that closes or the first call of book. */
|
|
12
|
+
export const chapterCraft = "How to write a chapter: as a chapter of a novel, never a summary or a report. In the campaign's language, third person with an outside narrator, in the prose style the player chose: "
|
|
13
|
+
+ "its voice binds the book, its limits on length and its endings in play do not. A chapter tells the scenes closed since the last one, ended where the story turns: a goal reached or lost, a place left, a night passed. "
|
|
14
|
+
+ "Pick up where the last chapter left off (book with its number reads it back), without retelling it. "
|
|
15
|
+
+ "Tell it in scenes: places, gestures, silences, and people's words as dialogue where they mattered; summary only for roads and time passing. "
|
|
16
|
+
+ "The player character does and says only what the player played: their words may be put better, never a deed, a line or a choice of yours added. "
|
|
17
|
+
+ "Only what the player saw and learned: no secret, no hidden roll, nothing you planned, no conclusion they did not reach. No game words: no rolls, points, turns, nor a condition by its game name. "
|
|
18
|
+
+ "As long as its scenes deserve, from about 1500 words to 4000: a short scene a page of it, a great one most of it; end on an image or a line, never on a question to the player. "
|
|
19
|
+
+ "Paragraphs apart by a blank line, *italics* where a voice or a thought needs them, *** alone on a line for a break within the chapter.";
|
|
20
|
+
/** The scenes of the story in order, by the public lines of the log, as the journal numbers them: a scene closed with no line that opened it is one too. */
|
|
21
|
+
export function storyScenes(root) {
|
|
22
|
+
const scenes = [];
|
|
23
|
+
let open;
|
|
24
|
+
for (const entry of readLog(root).filter((line) => line.visibility === "public")) {
|
|
25
|
+
if (entry.type !== "scene-opened" && entry.type !== "scene-closed") {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const known = entry.type === "scene-opened" ? undefined : open;
|
|
29
|
+
const scene = known ?? {
|
|
30
|
+
number: scenes.length + 1,
|
|
31
|
+
title: String(entry.data.title ?? ""),
|
|
32
|
+
...(entry.date === undefined ? {} : { date: entry.date }),
|
|
33
|
+
from: entry.at,
|
|
34
|
+
scene: entry.id,
|
|
35
|
+
};
|
|
36
|
+
if (known === undefined) {
|
|
37
|
+
scenes.push(scene);
|
|
38
|
+
}
|
|
39
|
+
if (entry.type === "scene-opened") {
|
|
40
|
+
open = scene;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const summary = typeof entry.data.summary === "string" ? entry.data.summary.trim() : "";
|
|
44
|
+
Object.assign(scene, { to: entry.at }, summary === "" ? {} : { summary });
|
|
45
|
+
open = undefined;
|
|
46
|
+
}
|
|
47
|
+
return scenes;
|
|
48
|
+
}
|
|
49
|
+
/** The chapters of the book whose scenes are in the story as it stands, in order: each going on from the one before, the first from the first scene. */
|
|
50
|
+
export function campaignBook(root) {
|
|
51
|
+
const scenes = storyScenes(root);
|
|
52
|
+
const book = [];
|
|
53
|
+
for (const chapter of writtenChapters(root).sort((one, other) => one.number - other.number)) {
|
|
54
|
+
const told = scenes.slice(chapter.first - 1, chapter.last);
|
|
55
|
+
const follows = chapter.number === book.length + 1 && chapter.first === (book.at(-1)?.last ?? 0) + 1;
|
|
56
|
+
if (!follows || told.length !== chapter.scenes.length || told.some((scene, index) => scene.scene !== chapter.scenes[index] || scene.to === undefined)) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
book.push({ number: chapter.number, title: chapter.title, text: chapter.text, first: chapter.first, last: chapter.last });
|
|
60
|
+
}
|
|
61
|
+
return book;
|
|
62
|
+
}
|
|
63
|
+
/** The closed scenes no chapter tells yet, in order: those the next chapter is for. */
|
|
64
|
+
export function untoldScenes(root, book = campaignBook(root)) {
|
|
65
|
+
const told = book.at(-1)?.last ?? 0;
|
|
66
|
+
return storyScenes(root).filter((scene) => scene.number > told && scene.to !== undefined);
|
|
67
|
+
}
|
|
68
|
+
/** Writes a chapter telling these scenes, in place of the one with its number. */
|
|
69
|
+
export function writeChapter(root, number, scenes, title, text) {
|
|
70
|
+
const head = stringify({ chapter: number, title, scenes: scenes.map((scene) => scene.scene) }, { lineWidth: 0 });
|
|
71
|
+
files().write(chapterPath(root, number), `---\n${head}---\n\n${text}\n`);
|
|
72
|
+
}
|
|
73
|
+
/** Takes a chapter out of the book; nothing when it has none. */
|
|
74
|
+
export function removeChapter(root, number) {
|
|
75
|
+
const path = chapterPath(root, number);
|
|
76
|
+
if (files().exists(path)) {
|
|
77
|
+
files().remove(path);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** What status says of a book left behind, by a chat closed or a computer turned off: the scenes waiting too long for their chapter, once the book has begun. */
|
|
81
|
+
export function bookBehind(root) {
|
|
82
|
+
const book = campaignBook(root);
|
|
83
|
+
const untold = untoldScenes(root, book);
|
|
84
|
+
return book.length === 0 || untold.length < scenesPerChapter ? undefined : `The book is behind: ${scenesText(untold)} wait for their chapter. Write it with book before the story goes on; book lists them with their chats.`;
|
|
85
|
+
}
|
|
86
|
+
/** Scenes by their numbers, as «scene 4» or «scenes 4–7». */
|
|
87
|
+
export function scenesText(scenes) {
|
|
88
|
+
const first = scenes[0]?.number;
|
|
89
|
+
const last = scenes.at(-1)?.number;
|
|
90
|
+
return first === last ? `scene ${first}` : `scenes ${first}–${last}`;
|
|
91
|
+
}
|
|
92
|
+
function chapterPath(root, number) {
|
|
93
|
+
return join(root, bookFolderName, `${String(number).padStart(3, "0")}.md`);
|
|
94
|
+
}
|
|
95
|
+
/** The chapters written in the book folder, each with the scenes it tells, after the scenes before it; a file that does not read as one is left out. */
|
|
96
|
+
function writtenChapters(root) {
|
|
97
|
+
const read = files().files(join(root, bookFolderName), (name) => /^\d+\.md$/.test(name)).flatMap((path) => {
|
|
98
|
+
const parts = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(files().text(path) ?? "");
|
|
99
|
+
try {
|
|
100
|
+
const head = parts === null ? undefined : parse(parts[1]);
|
|
101
|
+
const scenes = Array.isArray(head?.scenes) ? head.scenes.filter((scene) => typeof scene === "string") : [];
|
|
102
|
+
if (parts === null || head === null || head === undefined || typeof head.chapter !== "number" || scenes.length === 0) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
return [{ number: head.chapter, title: typeof head.title === "string" ? head.title : "", text: parts[2].trim(), scenes }];
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
}).sort((one, other) => one.number - other.number);
|
|
111
|
+
// Each chapter goes on from the scenes of those before it.
|
|
112
|
+
let told = 0;
|
|
113
|
+
return read.map((chapter) => {
|
|
114
|
+
const first = told + 1;
|
|
115
|
+
told += chapter.scenes.length;
|
|
116
|
+
return { ...chapter, first, last: told };
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Chat, type UndoneStretch } from "../../../chats/index.ts";
|
|
2
|
+
import type { Context } from "../../../core/context.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The stretches of real time the loads undid, by the log as it stands: each from when its save was made to when it was loaded. A load the save undid in
|
|
5
|
+
* its turn is no longer in the log, and the later load's stretch holds it. A load logged before its save's time was written starts at the line before it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function undoneStretches(root: string): UndoneStretch[];
|
|
8
|
+
/** Copies the campaign's chats from the hosts into its sessions folder, where the context knows the hosts' folders. */
|
|
9
|
+
export declare function copyChats(root: string, context: Context): void;
|
|
10
|
+
/** The campaign's chats as it keeps them, a few minutes behind the chat going on, which is the master's own. */
|
|
11
|
+
export declare function campaignChats(root: string): Chat[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The campaign's chats as text (T-225): copied from the AI hosts into its sessions folder, with what a load undid marked, as the log says.
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { sessionsFolderName } from "../../../campaign/index.js";
|
|
4
|
+
import { keepChats, keptChats } from "../../../chats/index.js";
|
|
5
|
+
import { readLog } from "../../../core/log.js";
|
|
6
|
+
/**
|
|
7
|
+
* The stretches of real time the loads undid, by the log as it stands: each from when its save was made to when it was loaded. A load the save undid in
|
|
8
|
+
* its turn is no longer in the log, and the later load's stretch holds it. A load logged before its save's time was written starts at the line before it.
|
|
9
|
+
*/
|
|
10
|
+
export function undoneStretches(root) {
|
|
11
|
+
const log = readLog(root);
|
|
12
|
+
return log.flatMap((entry, index) => {
|
|
13
|
+
if (entry.type !== "save-loaded") {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const data = entry.data;
|
|
17
|
+
return [{ from: typeof data.made === "string" ? data.made : log[index - 1]?.at ?? entry.at, to: entry.at, save: Number(data.save) }];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Copies the campaign's chats from the hosts into its sessions folder, where the context knows the hosts' folders. */
|
|
21
|
+
export function copyChats(root, context) {
|
|
22
|
+
if (context.chatFolders !== undefined) {
|
|
23
|
+
keepChats(root, join(root, sessionsFolderName), context.chatFolders, context.platform, undoneStretches(root));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The campaign's chats as it keeps them, a few minutes behind the chat going on, which is the master's own. */
|
|
27
|
+
export function campaignChats(root) {
|
|
28
|
+
return keptChats(join(root, sessionsFolderName));
|
|
29
|
+
}
|
|
@@ -17,7 +17,13 @@ export function picturesNote(root, context, world, place) {
|
|
|
17
17
|
// Asked once in a chat, not at every status and scene (T-64).
|
|
18
18
|
const ready = context.told === undefined || firstInChat(context, "pictures-ask") ? context.pictures?.ready() : undefined;
|
|
19
19
|
return ready?.ready === true
|
|
20
|
-
? `Pictures:
|
|
20
|
+
? `Pictures: ${ready.tool !== undefined
|
|
21
|
+
? `you can make the pictures of places, quests and those met with ${ready.tool}`
|
|
22
|
+
: ready.askTool === true
|
|
23
|
+
? "you can make the pictures of places, quests and those met with the image tool the player names"
|
|
24
|
+
: ready.maker === "Antigravity"
|
|
25
|
+
? "you can make the pictures of places, quests and those met with your own image tool"
|
|
26
|
+
: `this computer can make the pictures of places, quests and those met with the player's ${ready.maker === "Claude" ? "Claude Code" : "Codex"}`}, which spends their plan: ask them once whether they want one for each new place, quest and one met, only those they ask for, or none; then config pictures (new elements, on request or none).`
|
|
21
27
|
: undefined;
|
|
22
28
|
}
|
|
23
29
|
if (setting !== "new elements" || place === undefined || place.type !== "place" || shownImage(root, context, world, place) !== undefined) {
|
|
@@ -28,6 +28,8 @@ const settingLabels = {
|
|
|
28
28
|
character: "character (made with the player; made by the master, from a few words; the player's own, one they bring)",
|
|
29
29
|
companions: `companions (${companionWays.join(", ")})`,
|
|
30
30
|
"calendar-start": "calendar-start (when the story starts: day 1 to count only the days, or a day of the world, such as 14 April 1491)",
|
|
31
|
+
pictures: "pictures (of places, quests and those met: none; on request; new elements, one for each)",
|
|
32
|
+
"pictures-by": "pictures-by (who makes them: chat, your app by its own means; codex; elevenlabs; other, a tool the player names, written by its name; suggest chat)",
|
|
31
33
|
lines: 'lines ("none" is an answer)',
|
|
32
34
|
veils: 'veils ("none" is an answer)',
|
|
33
35
|
};
|
|
@@ -144,7 +146,7 @@ function setupMissingNames(root, context, world) {
|
|
|
144
146
|
* the settings still missing, when the game offers them (T-134), said once with the whole checklist; empty when there are none.
|
|
145
147
|
*/
|
|
146
148
|
function lastChoicesNote(root, context, world) {
|
|
147
|
-
const last = lastChoices(context.home);
|
|
149
|
+
const last = lastChoices(context.home, root);
|
|
148
150
|
const chosen = setupMissingNames(root, context, world).flatMap((name) => {
|
|
149
151
|
const value = last[name];
|
|
150
152
|
const offered = offeredValues(root, context, name);
|
|
@@ -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, inboxFolderName, 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 && name.toLowerCase() !== inboxFolderName;
|
|
270
278
|
}
|
|
271
279
|
function joinBytes(first, second) {
|
|
272
280
|
const joined = new Uint8Array((first?.length ?? 0) + second.length);
|
|
@@ -10,6 +10,7 @@ import { layerFolder, layersFolderName, loadWorld, playerCharacters, searchSyste
|
|
|
10
10
|
import { engineSettingValue, findCampaignSystem, findSystem, layeredSystemWords, readableSystems, rulesetSetting, systemContentFolders, systemWords, withSettings, } from "../../../systems/index.js";
|
|
11
11
|
import { homeSystemWords } from "../books/words.js";
|
|
12
12
|
import { campaignExtensions, extensionSources, layeredParts } from "../packages/extensions.js";
|
|
13
|
+
import { languageFolders } from "../packages/unpacked.js";
|
|
13
14
|
/** The world of the campaign in `root`, with the pages of its game system when campaign.yaml names one that is installed (SYS-1, SYS-3). */
|
|
14
15
|
export function campaignWorld(root, context) {
|
|
15
16
|
// The same world until one of its pages, campaign.yaml or the system's pages translated on this computer change, or a folder of the packages is read again
|
|
@@ -48,7 +49,7 @@ export function ownTranslationFolder(context, system, language) {
|
|
|
48
49
|
*/
|
|
49
50
|
export function systemWordsOf(root, system, language, context) {
|
|
50
51
|
// A language package's words come first, then the system's own, then those translated on the fly (D-485 (3)).
|
|
51
|
-
const pack = languagePackFor(context
|
|
52
|
+
const pack = languagePackFor(languageFolders(context), language);
|
|
52
53
|
const packed = pack === undefined ? undefined : packSystemFolder(pack, system.name);
|
|
53
54
|
const own = (packed === undefined ? undefined : systemWords(packed, language)) ?? layeredSystemWords(systemContentFolders(system), language) ?? homeSystemWords(context.home, system, language);
|
|
54
55
|
const added = campaignExtensions(root, context).extensions.reduce((fields, extension) => ({ ...fields, ...extensionFieldWords(extension, language) }), {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "../../../core/context.ts";
|
|
2
2
|
/** The kinds of packages the catalog lists. */
|
|
3
|
-
export type CatalogKind = "system" | "adventure" | "extension" | "language";
|
|
3
|
+
export type CatalogKind = "system" | "adventure" | "extension" | "language" | "theme";
|
|
4
4
|
/** A package one may add, as the page lists it (D-486 (3)). */
|
|
5
5
|
export interface CatalogEntry {
|
|
6
6
|
kind: CatalogKind;
|
|
@@ -13,7 +13,7 @@ export interface CatalogEntry {
|
|
|
13
13
|
code: boolean;
|
|
14
14
|
/** What the player adds it by: an npm name or a GitHub link. */
|
|
15
15
|
source: string;
|
|
16
|
-
/** The version here, when it is installed. */
|
|
16
|
+
/** The version here, when it is installed; empty for a theme installed without one. */
|
|
17
17
|
installed?: string;
|
|
18
18
|
update: boolean;
|
|
19
19
|
/** Its latest version, when it needs a newer rpg-engine than this one, which version offers the newest it reads (D-515 (2)): with the first engine that reads it. */
|
|
@@ -23,7 +23,7 @@ export interface CatalogEntry {
|
|
|
23
23
|
};
|
|
24
24
|
/** The game system an extension is made for, as its package.json says (D-548). */
|
|
25
25
|
system?: string;
|
|
26
|
-
/** An adventure's levels, length and language, as its adventure.yaml says. */
|
|
26
|
+
/** An adventure's levels, length and language, as its adventure.yaml says; a language's code. */
|
|
27
27
|
levels?: string;
|
|
28
28
|
length?: string;
|
|
29
29
|
language?: string;
|