rpg-engine 0.20.0 → 0.22.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/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 +3 -2
- package/dist/campaign/find-campaign.d.ts +2 -0
- package/dist/campaign/find-campaign.js +2 -0
- package/dist/campaign/host-files.js +4 -1
- package/dist/campaign/index.d.ts +3 -2
- package/dist/campaign/index.js +3 -2
- package/dist/campaign/port.d.ts +6 -0
- package/dist/campaign/port.js +24 -0
- package/dist/campaign/settings.d.ts +17 -0
- package/dist/campaign/settings.js +26 -3
- package/dist/cli/cli.js +15 -0
- package/dist/commands/book.d.ts +16 -35
- package/dist/commands/book.js +86 -62
- package/dist/commands/config/config.js +16 -2
- package/dist/commands/config/dashboard.d.ts +6 -2
- package/dist/commands/config/dashboard.js +45 -8
- package/dist/commands/config/shown.js +4 -0
- package/dist/commands/config/words.d.ts +3 -1
- package/dist/commands/config/words.js +29 -2
- package/dist/commands/image.d.ts +5 -0
- package/dist/commands/image.js +6 -3
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package/data.d.ts +35 -0
- package/dist/commands/package/data.js +144 -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 +67 -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 +1 -1
- package/dist/commands/scene/close.js +15 -8
- package/dist/commands/scene/scene.js +6 -1
- package/dist/commands/shared/books/adventures.d.ts +1 -4
- package/dist/commands/shared/books/adventures.js +3 -32
- package/dist/commands/shared/books/words.js +3 -2
- package/dist/commands/shared/campaign/book.d.ts +21 -8
- package/dist/commands/shared/campaign/book.js +65 -42
- package/dist/commands/shared/campaign/git.d.ts +25 -0
- package/dist/commands/shared/campaign/git.js +104 -0
- package/dist/commands/shared/campaign/saves.js +7 -3
- 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 +118 -43
- package/dist/commands/shared/packages/unpacked.d.ts +50 -0
- package/dist/commands/shared/packages/unpacked.js +146 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +8 -4
- package/dist/core/archive.d.ts +13 -0
- package/dist/core/archive.js +76 -0
- package/dist/core/context.d.ts +4 -0
- package/dist/core/context.js +1 -0
- package/dist/core/store.d.ts +5 -1
- package/dist/core/store.js +15 -2
- package/dist/core/version.d.ts +2 -0
- package/dist/core/version.js +5 -0
- package/dist/dashboard/api.js +24 -1
- package/dist/dashboard/app.js +7 -2
- package/dist/dashboard/guide/ar.md +11 -9
- package/dist/dashboard/guide/cs.md +11 -9
- package/dist/dashboard/guide/da.md +12 -10
- package/dist/dashboard/guide/de.md +13 -11
- package/dist/dashboard/guide/el.md +11 -9
- package/dist/dashboard/guide/en.md +10 -8
- package/dist/dashboard/guide/es.md +11 -9
- package/dist/dashboard/guide/fi.md +11 -9
- package/dist/dashboard/guide/fr.md +11 -9
- package/dist/dashboard/guide/he.md +11 -9
- package/dist/dashboard/guide/hi.md +11 -9
- package/dist/dashboard/guide/hu.md +11 -9
- package/dist/dashboard/guide/is.md +11 -9
- package/dist/dashboard/guide/it.md +11 -9
- package/dist/dashboard/guide/ja.md +12 -10
- package/dist/dashboard/guide/ko.md +11 -9
- package/dist/dashboard/guide/nb.md +12 -10
- package/dist/dashboard/guide/nl.md +11 -9
- package/dist/dashboard/guide/pl.md +11 -9
- package/dist/dashboard/guide/pt.md +11 -9
- package/dist/dashboard/guide/ro.md +11 -9
- package/dist/dashboard/guide/ru.md +12 -10
- package/dist/dashboard/guide/sv.md +11 -9
- package/dist/dashboard/guide/tr.md +11 -9
- package/dist/dashboard/guide/uk.md +12 -10
- package/dist/dashboard/guide/zh.md +11 -9
- package/dist/dashboard/i18n/ar.json +58 -5
- package/dist/dashboard/i18n/cs.json +58 -5
- package/dist/dashboard/i18n/da.json +58 -5
- package/dist/dashboard/i18n/de.json +58 -5
- package/dist/dashboard/i18n/el.json +58 -5
- package/dist/dashboard/i18n/es.json +58 -5
- package/dist/dashboard/i18n/fi.json +58 -5
- package/dist/dashboard/i18n/fr.json +58 -5
- package/dist/dashboard/i18n/he.json +58 -5
- package/dist/dashboard/i18n/hi.json +58 -5
- package/dist/dashboard/i18n/hu.json +58 -5
- package/dist/dashboard/i18n/is.json +58 -5
- package/dist/dashboard/i18n/it.json +58 -5
- package/dist/dashboard/i18n/ja.json +58 -5
- package/dist/dashboard/i18n/ko.json +58 -5
- package/dist/dashboard/i18n/nb.json +58 -5
- package/dist/dashboard/i18n/nl.json +58 -5
- package/dist/dashboard/i18n/pl.json +58 -5
- package/dist/dashboard/i18n/pt.json +58 -5
- package/dist/dashboard/i18n/ro.json +58 -5
- package/dist/dashboard/i18n/ru.json +58 -5
- package/dist/dashboard/i18n/sv.json +58 -5
- package/dist/dashboard/i18n/tr.json +58 -5
- package/dist/dashboard/i18n/uk.json +58 -5
- package/dist/dashboard/i18n/zh.json +58 -5
- package/dist/dashboard/journal/book.js +3 -2
- package/dist/dashboard/journal/journal.js +8 -5
- 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 +7 -0
- package/dist/dashboard/parts/picture.js +89 -0
- package/dist/dashboard/parts/refusals.js +8 -1
- package/dist/dashboard/parts/widgets.js +2 -1
- package/dist/dashboard/play/scene.js +8 -5
- package/dist/dashboard/settings/settings.js +55 -18
- package/dist/dashboard/sheet/party.js +5 -2
- package/dist/dashboard/sheet/sheet.js +2 -1
- package/dist/dashboard/shell/notices.js +2 -2
- package/dist/dashboard/shell/system-style.js +132 -15
- package/dist/dashboard/shell/tooltip.js +224 -0
- package/dist/dashboard/style.css +497 -193
- package/dist/dashboard/world/lore.js +4 -3
- package/dist/dashboard/world/place-card.js +2 -1
- package/dist/git/git.d.ts +12 -0
- package/dist/git/git.js +175 -0
- package/dist/git/ignore.d.ts +2 -0
- package/dist/git/ignore.js +16 -0
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +2 -0
- package/dist/importer/index.d.ts +1 -1
- package/dist/importer/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 +18 -6
- 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/bell-listener.d.ts +2 -1
- package/dist/server/bell-listener.js +10 -41
- package/dist/server/dashboard/engine.d.ts +18 -0
- package/dist/server/dashboard/engine.js +31 -0
- package/dist/server/dashboard/files.d.ts +11 -3
- package/dist/server/dashboard/files.js +66 -17
- package/dist/server/dashboard/index.d.ts +18 -2
- package/dist/server/dashboard/index.js +62 -23
- package/dist/server/dashboard/news.d.ts +3 -2
- package/dist/server/dashboard/news.js +19 -5
- package/dist/server/dashboard/pictures.d.ts +7 -0
- package/dist/server/dashboard/pictures.js +62 -0
- package/dist/server/dashboard/ports.d.ts +17 -2
- package/dist/server/dashboard/ports.js +60 -4
- package/dist/server/dashboard/writes.d.ts +5 -3
- package/dist/server/dashboard/writes.js +45 -14
- package/dist/server/mcp.d.ts +3 -2
- package/dist/server/mcp.js +55 -11
- package/dist/testing/index.js +1 -0
- package/dist/themes/css.d.ts +1 -1
- package/dist/themes/css.js +101 -2
- 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 +38 -0
- package/dist/themes/theme.js +192 -13
- package/instructions/core.md +4 -3
- package/instructions/dashboard-guide.md +2 -1
- 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/package.json +1 -1
- package/systems/free/instructions/outcomes-told.md +1 -1
package/dist/commands/book.js
CHANGED
|
@@ -2,101 +2,125 @@ import { z } from "zod";
|
|
|
2
2
|
import { requireCampaign } from "../campaign/index.js";
|
|
3
3
|
import { appendLogEntry } from "../core/log.js";
|
|
4
4
|
import { defineCommand } from "../core/registry.js";
|
|
5
|
-
import { campaignBook, chapterCraft, removeChapter,
|
|
5
|
+
import { campaignBook, chapterCraft, removeChapter, scenesText, storyScenes, untoldScenes, writeChapter } from "./shared/campaign/book.js";
|
|
6
6
|
import { firstInChat } from "./shared/campaign/parts.js";
|
|
7
7
|
import { newDatedLogEntry } from "./shared/time/time.js";
|
|
8
|
-
// How many
|
|
9
|
-
const
|
|
8
|
+
// How many scenes still untold a list shows, the first; the others are counted.
|
|
9
|
+
const listedScenes = 20;
|
|
10
10
|
// The longest chapter the book takes, in characters.
|
|
11
|
-
const chapterLength =
|
|
11
|
+
const chapterLength = 80_000;
|
|
12
12
|
export const book = defineCommand({
|
|
13
13
|
name: "book",
|
|
14
|
-
description: "The campaign's story told as a book, which the player reads in the dashboard's Journal: a novel
|
|
15
|
-
+ "
|
|
16
|
-
+ "with chapter alone, it reads one back, so that the voice holds from one to the next
|
|
14
|
+
description: "The campaign's story told as a book, which the player reads in the dashboard's Journal: chapters of a novel, never summaries, each telling the scenes closed since the last one, "
|
|
15
|
+
+ "ended where the story turns. With nothing, it lists the closed scenes no chapter tells yet, which is how a campaign begun without the book gets the story so far; "
|
|
16
|
+
+ "text writes the next chapter, of those scenes or of those through one; with chapter alone, it reads one back, so that the voice holds from one to the next, and with text it writes it again; "
|
|
17
|
+
+ "empty text takes the last out. The first call in a chat says how to write them.",
|
|
17
18
|
group: "game",
|
|
18
19
|
positionals: ["chapter"],
|
|
19
20
|
input: z.object({
|
|
20
|
-
chapter: z.coerce.number().int().positive().optional().describe("the chapter
|
|
21
|
-
title: z.string().optional().describe("the chapter's title, its scene's if left out"),
|
|
22
|
-
text: z.string().optional().describe("the chapter's prose, in markdown; empty to take
|
|
21
|
+
chapter: z.coerce.number().int().positive().optional().describe("the number of a chapter written, to read, write again or retitle; the next chapter if left out"),
|
|
22
|
+
title: z.string().optional().describe("the chapter's title, its first scene's if left out"),
|
|
23
|
+
text: z.string().optional().describe("the chapter's prose, in markdown; empty to take the last chapter out"),
|
|
24
|
+
through: z.coerce.number().int().positive().optional().describe("for the next chapter, the number of its last scene, when it tells only the first of the scenes still untold"),
|
|
23
25
|
}),
|
|
24
26
|
run(input, context) {
|
|
25
27
|
const root = requireCampaign(context.folder);
|
|
26
|
-
const scenes = sceneChapters(root);
|
|
27
28
|
const written = campaignBook(root);
|
|
29
|
+
const untold = untoldScenes(root, written);
|
|
28
30
|
const craft = firstInChat(context, "book") ? chapterCraft : undefined;
|
|
29
|
-
const
|
|
30
|
-
if (input.chapter
|
|
31
|
-
|
|
32
|
-
throw new Error("Give chapter, the number of the chapter to write: book alone lists those still to write. Nothing written.");
|
|
33
|
-
}
|
|
34
|
-
return { kind: "list", written: written.length, closed: scenes.filter((scene) => scene.to !== undefined).length, missing: scenes.filter(unwritten), craft };
|
|
31
|
+
const next = written.length + 1;
|
|
32
|
+
if (input.through !== undefined && input.chapter !== undefined && input.chapter !== next) {
|
|
33
|
+
throw new Error(`through is for the next chapter, ${next}: chapter ${input.chapter} keeps its scenes. Nothing written.`);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (input.text === undefined && input.title === undefined) {
|
|
39
|
-
return { kind: "read", scene, chapter: before, craft };
|
|
35
|
+
if (input.chapter === undefined && input.title === undefined && input.text === undefined) {
|
|
36
|
+
return { kind: "list", written: written.length, untold, craft };
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (before !== undefined) {
|
|
44
|
-
removeChapter(root, scene.number);
|
|
45
|
-
appendLogEntry(root, newDatedLogEntry(root, context, "book-chapter", "hidden", { chapter: scene.number, removed: true }));
|
|
46
|
-
}
|
|
47
|
-
return { kind: "removed", scene, had: before !== undefined };
|
|
38
|
+
if (input.chapter === undefined || input.chapter === next) {
|
|
39
|
+
return writeNext(root, context, next, chapterScenes(untold, input.through), input.title, input.text);
|
|
48
40
|
}
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
const before = written.find((chapter) => chapter.number === input.chapter);
|
|
42
|
+
if (before === undefined) {
|
|
43
|
+
throw new Error(`There is no chapter ${input.chapter}: the book has ${written.length}, and the next is ${next}. Nothing written.`);
|
|
51
44
|
}
|
|
52
|
-
if (text.
|
|
53
|
-
|
|
45
|
+
if (input.text === undefined && input.title === undefined) {
|
|
46
|
+
return { kind: "read", chapter: before, craft };
|
|
54
47
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
if (input.text !== undefined && input.text.trim() === "") {
|
|
49
|
+
if (before.number !== written.length) {
|
|
50
|
+
throw new Error(`Chapter ${before.number} has chapters after it: write it again, or take out the last first. Nothing written.`);
|
|
51
|
+
}
|
|
52
|
+
removeChapter(root, before.number);
|
|
53
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "book-chapter", "hidden", { chapter: before.number, removed: true }));
|
|
54
|
+
return { kind: "removed", number: before.number };
|
|
55
|
+
}
|
|
56
|
+
const scenes = storyScenes(root).slice(before.first - 1, before.last);
|
|
57
|
+
const text = proseOf(input.text ?? before.text);
|
|
58
|
+
const title = input.title?.trim() || before.title;
|
|
59
|
+
writeChapter(root, before.number, scenes, title, text);
|
|
60
|
+
return logged(root, context, { number: before.number, title, text, scenes, untold: untold.length });
|
|
60
61
|
},
|
|
61
62
|
format(result) {
|
|
62
63
|
const craft = "craft" in result && result.craft !== undefined ? `\n\n${result.craft}` : "";
|
|
63
64
|
if (result.kind === "list") {
|
|
64
|
-
if (result.
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
if (result.missing.length === 0) {
|
|
68
|
-
return `The book has every closed chapter, ${result.written}: write the next when its scene closes.${craft}`;
|
|
65
|
+
if (result.untold.length === 0) {
|
|
66
|
+
return `${result.written === 0 ? "The book has no chapter yet" : `The book has ${result.written} ${result.written === 1 ? "chapter" : "chapters"}`}, and no closed scene waits for one: `
|
|
67
|
+
+ `the next chapter comes when the story turns, at a scene's end.${craft}`;
|
|
69
68
|
}
|
|
70
|
-
const lines = result.
|
|
71
|
-
const more = result.
|
|
72
|
-
return `The book has ${result.written}
|
|
69
|
+
const lines = result.untold.slice(0, listedScenes).map(sceneLine);
|
|
70
|
+
const more = result.untold.length > listedScenes ? `\nAnd ${result.untold.length - listedScenes} more after them.` : "";
|
|
71
|
+
return `The book has ${result.written} ${result.written === 1 ? "chapter" : "chapters"}; ${scenesText(result.untold)} ${result.untold.length === 1 ? "waits" : "wait"} for the next. `
|
|
72
|
+
+ `Tell them in chapters, each ending where the story turns (through gives a chapter's last scene), each from its chats first, then its summary and the pages:\n${lines.join("\n")}${more}${craft}`;
|
|
73
73
|
}
|
|
74
74
|
if (result.kind === "read") {
|
|
75
|
-
return result.chapter
|
|
76
|
-
? `Chapter ${result.scene.number} is not written yet.\n${missingLine(result.scene)}${craft}`
|
|
77
|
-
: `Chapter ${result.scene.number} «${result.chapter.title}»:\n\n${result.chapter.text}${craft}`;
|
|
75
|
+
return `Chapter ${result.chapter.number} «${result.chapter.title}», ${scenesText([{ number: result.chapter.first }, { number: result.chapter.last }])}:\n\n${result.chapter.text}${craft}`;
|
|
78
76
|
}
|
|
79
77
|
if (result.kind === "removed") {
|
|
80
|
-
return
|
|
78
|
+
return `Chapter ${result.number} taken out of the book: its scenes wait for a chapter again.`;
|
|
81
79
|
}
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
return `Chapter ${result.scene.number} «${result.title}» written, ${result.words} words: the player reads it in the Journal, under Story.${left}`;
|
|
80
|
+
const left = result.untold === 0 ? "" : ` Still untold: ${result.untold} closed ${result.untold === 1 ? "scene" : "scenes"}, for the next chapter.`;
|
|
81
|
+
return `Chapter ${result.number} «${result.title}», ${scenesText(result.scenes)}, written, ${result.words} words: the player reads it in the Journal, under Story.${left}${craft}`;
|
|
85
82
|
},
|
|
86
83
|
});
|
|
87
|
-
/** The
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
throw new Error(`There is no chapter ${number}: the story has ${scenes.length}. book alone lists those still to write. Nothing written.`);
|
|
84
|
+
/** The next chapter, telling these scenes. */
|
|
85
|
+
function writeNext(root, context, number, scenes, title, text) {
|
|
86
|
+
if (text === undefined || text.trim() === "") {
|
|
87
|
+
throw new Error(`Chapter ${number} is not written yet: give its text, the prose of ${scenesText(scenes)}. Nothing written.`);
|
|
92
88
|
}
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
const prose = proseOf(text);
|
|
90
|
+
const named = title?.trim() || scenes[0].title;
|
|
91
|
+
writeChapter(root, number, scenes, named, prose);
|
|
92
|
+
return logged(root, context, { number, title: named, text: prose, scenes, untold: untoldScenes(root).length });
|
|
93
|
+
}
|
|
94
|
+
/** The scenes the next chapter tells: the untold ones, or those through one; stops the command when there are none. */
|
|
95
|
+
function chapterScenes(untold, through) {
|
|
96
|
+
if (untold.length === 0) {
|
|
97
|
+
throw new Error("No closed scene waits for a chapter: the next comes when the story turns, at a scene's end. Nothing written.");
|
|
98
|
+
}
|
|
99
|
+
if (through === undefined) {
|
|
100
|
+
return untold;
|
|
101
|
+
}
|
|
102
|
+
const last = untold.findIndex((scene) => scene.number === through);
|
|
103
|
+
if (last === -1) {
|
|
104
|
+
throw new Error(`Scene ${through} is not one still untold: give through between ${untold[0].number} and ${untold.at(-1)?.number}. Nothing written.`);
|
|
95
105
|
}
|
|
96
|
-
return
|
|
106
|
+
return untold.slice(0, last + 1);
|
|
107
|
+
}
|
|
108
|
+
/** A chapter's prose as the book keeps it; stops the command when it is too long. */
|
|
109
|
+
function proseOf(text) {
|
|
110
|
+
const prose = text.replace(/\r\n?/g, "\n").trim().normalize("NFC");
|
|
111
|
+
if (prose.length > chapterLength) {
|
|
112
|
+
throw new Error(`This chapter is ${prose.length} characters, the book takes ${chapterLength}: end it sooner, with through. Nothing written.`);
|
|
113
|
+
}
|
|
114
|
+
return prose;
|
|
115
|
+
}
|
|
116
|
+
/** A chapter written, in the log, with its length. */
|
|
117
|
+
function logged(root, context, chapter) {
|
|
118
|
+
const words = chapter.text.split(/\s+/).filter((word) => word !== "").length;
|
|
119
|
+
appendLogEntry(root, newDatedLogEntry(root, context, "book-chapter", "hidden", { chapter: chapter.number, title: chapter.title, scenes: chapter.scenes.map((scene) => scene.number), words }));
|
|
120
|
+
return { kind: "written", number: chapter.number, title: chapter.title, scenes: chapter.scenes, words, untold: chapter.untold };
|
|
97
121
|
}
|
|
98
|
-
/** A
|
|
99
|
-
function
|
|
122
|
+
/** A scene still untold: its title and game date, its summary, and when it ran in real time, for chats to read it. */
|
|
123
|
+
function sceneLine(scene) {
|
|
100
124
|
const date = scene.date === undefined ? "" : `, ${scene.date}`;
|
|
101
125
|
const summary = scene.summary === undefined ? "" : `: ${scene.summary}`;
|
|
102
126
|
const otherDay = scene.to !== undefined && scene.to.slice(0, 10) !== scene.from.slice(0, 10) ? ` of ${scene.to.slice(0, 10)}` : "";
|
|
@@ -10,6 +10,7 @@ import { declaredKind } from "../../pages/index.js";
|
|
|
10
10
|
import { campaignDataNames, rulesetSetting } from "../../systems/index.js";
|
|
11
11
|
import { readBetweenSessions, readCalendar, readCalendarStart } from "../../time/index.js";
|
|
12
12
|
import { checkLibraryRemovals, libraryAdditions, libraryRemovals, startLibraryReading } from "../shared/books/library.js";
|
|
13
|
+
import { gitProblem, isCampaignRepository } from "../shared/campaign/git.js";
|
|
13
14
|
import { campaignMode, campaignNote } from "../shared/campaign/mode.js";
|
|
14
15
|
import { campaignCoins } from "../shared/campaign/money.js";
|
|
15
16
|
import { askedBy, heldSystemSettings, offerRefusal, playedEngineSetting, unofferedLines, valuePart } from "../shared/campaign/offers.js";
|
|
@@ -63,7 +64,7 @@ export const config = defineCommand({
|
|
|
63
64
|
if (input.setting === "library" && (input.add !== undefined || input.remove !== undefined)) {
|
|
64
65
|
return changeLibrary(input, context);
|
|
65
66
|
}
|
|
66
|
-
const result = configure(input, context);
|
|
67
|
+
const result = withGitState(configure(input, context), input, context);
|
|
67
68
|
// A system installed in this chat, as in the setup, brings its code once the campaign plays it (D-513 (1)).
|
|
68
69
|
return input.setting === "system" && input.value !== undefined ? loadNewSystemCode(context).then(() => result) : result;
|
|
69
70
|
},
|
|
@@ -89,6 +90,19 @@ async function changeLibrary(input, context) {
|
|
|
89
90
|
startLibraryReading(context);
|
|
90
91
|
return result;
|
|
91
92
|
}
|
|
93
|
+
/** The setting of git with what the master cannot see otherwise (D-576): a folder that is no repository yet, and what went wrong the last time git ran. */
|
|
94
|
+
function withGitState(result, input, context) {
|
|
95
|
+
if (input.setting !== "git") {
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
const root = requireCampaign(context.folder);
|
|
99
|
+
const problem = gitProblem(root);
|
|
100
|
+
const lines = [
|
|
101
|
+
isCampaignRepository(root) ? "" : "This folder is not a git repository yet: nothing is committed until it is.",
|
|
102
|
+
problem === undefined ? "" : `The last ${problem.act} failed: ${problem.why}`,
|
|
103
|
+
].filter((line) => line !== "");
|
|
104
|
+
return lines.length === 0 ? result : { ...result, note: [result.note, ...lines].filter((line) => line !== "").join("\n") };
|
|
105
|
+
}
|
|
92
106
|
function configure(input, context) {
|
|
93
107
|
const root = requireCampaign(context.folder);
|
|
94
108
|
const listChange = input.add !== undefined || input.remove !== undefined;
|
|
@@ -246,7 +260,7 @@ function configure(input, context) {
|
|
|
246
260
|
part,
|
|
247
261
|
};
|
|
248
262
|
}
|
|
249
|
-
const ordersKept = "Kept until the player lifts it; the lines and veils still come first. An order for this scene only stays in the scene; when unsure, ask in one
|
|
263
|
+
const ordersKept = "Kept until the player lifts it; the lines and veils still come first. An order for this scene only stays in the scene; when unsure, ask in one [OOC: …].";
|
|
250
264
|
// The settings of free words the player may leave unset again, with the value none, and all those of how the master writes (D-395).
|
|
251
265
|
const freeSettingNames = ["author", "style", "calendar"];
|
|
252
266
|
/** A setting the game system adds, shown, or changed to one of its values (DAT-10); refused with them for any other. */
|
|
@@ -21,13 +21,13 @@ export interface PlayerSetting {
|
|
|
21
21
|
game?: string;
|
|
22
22
|
/**
|
|
23
23
|
* What the player should know of it on this computer, as whether pictures can be made here; fix when it says how to have what is missing; the values its
|
|
24
|
-
* {names} take, as a maker's own words; and
|
|
24
|
+
* {names} take, as a maker's own words; and the lines after it.
|
|
25
25
|
*/
|
|
26
26
|
note?: {
|
|
27
27
|
text: string;
|
|
28
28
|
fix?: true;
|
|
29
29
|
values?: Record<string, string>;
|
|
30
|
-
also?: string;
|
|
30
|
+
also?: string[];
|
|
31
31
|
};
|
|
32
32
|
/** A setting of the player's own words, as the author the master writes like, the longest its text may be (D-395); for a list, each item's (D-563). */
|
|
33
33
|
most?: number;
|
|
@@ -46,9 +46,13 @@ export declare function setupQuestions(root: string, context: Context, writtenWo
|
|
|
46
46
|
export declare function setupSettingNamed(root: string, name: string): PlayerSetting | undefined;
|
|
47
47
|
/** The player's settings as the dashboard shows them (D-341): with what this computer lacks, as pictures without Codex, asked again. */
|
|
48
48
|
export declare function shownPlayerSettings(root: string, context: Context): PlayerSetting[];
|
|
49
|
+
/** Every note the setting of git may have, which the dashboard writes in its language (D-394). */
|
|
50
|
+
export declare const gitNotes: string[];
|
|
49
51
|
/** The player's settings with their values, then those the game system adds (D-341). */
|
|
50
52
|
export declare function playerSettings(root: string, context: Context): PlayerSetting[];
|
|
51
53
|
/** One of the player's settings by its name, in any case, as the dashboard changes them (D-341); undefined for a setting of the master's or none. */
|
|
52
54
|
export declare function playerSettingNamed(root: string, context: Context, name: string): PlayerSetting | undefined;
|
|
55
|
+
/** Every question of git the setup may ask, which the dashboard writes in its language. */
|
|
56
|
+
export declare const gitQuestions: string[];
|
|
53
57
|
/** Every note the pictures' setting may have, which the dashboard writes in its language (D-394). */
|
|
54
58
|
export declare const picturesNotes: string[];
|
|
@@ -3,10 +3,11 @@ import { customLevel, customLevels, customSettings, lastChoices, listSettingName
|
|
|
3
3
|
import { comparableText } from "../../core/text.js";
|
|
4
4
|
import { claudeSays, codexClient, codexSays } from "../../helpers/index.js";
|
|
5
5
|
import { readBetweenSessions } from "../../time/index.js";
|
|
6
|
+
import { gitProblem, isCampaignRepository, isInLargerRepository } from "../shared/campaign/git.js";
|
|
6
7
|
import { heldSystemSettings, isLeading, offeredValues, playedEngineSetting } from "../shared/campaign/offers.js";
|
|
7
8
|
import { playedSettingValue } from "../shared/campaign/world.js";
|
|
8
9
|
import { customOf } from "./custom-levels.js";
|
|
9
|
-
import { betweenSessionsWays, playerSettingNames, playerWords, setupWords, wordsOf } from "./words.js";
|
|
10
|
+
import { betweenSessionsWays, gitSettingNames, playerSettingNames, playerWords, setupWords, wordsOf } from "./words.js";
|
|
10
11
|
/**
|
|
11
12
|
* The setup's questions as the dashboard asks them (D-370), each with its value or items, if answered, and its values with what each means: the player's
|
|
12
13
|
* settings of the setup, how the character and the companions come, the preparation and length of a world not written, those the game system adds, then the lines and veils.
|
|
@@ -39,7 +40,7 @@ export function setupQuestions(root, context, writtenWorld) {
|
|
|
39
40
|
const offered = suggestion !== undefined && (question.choices === undefined || question.choices.some((choice) => choice.value === suggestion));
|
|
40
41
|
const asked = { ...question, ...(question.choices === undefined ? {} : { choices: question.choices.filter((choice) => choice.value !== customLevel) }) };
|
|
41
42
|
const lastOne = offered && last[question.name] === suggestion ? { last: suggestion } : {};
|
|
42
|
-
const worded = Object.hasOwn(questionTexts, question.name) ? { question:
|
|
43
|
+
const worded = Object.hasOwn(questionTexts, question.name) ? { question: questionText(question.name, root) } : {};
|
|
43
44
|
return { ...(question.name === "mentor" ? mentorQuestion(asked, game ?? "") : unsetUnanswered(asked, settings)), ...worded, ...(offered ? { suggested: suggestion } : {}), ...lastOne };
|
|
44
45
|
});
|
|
45
46
|
}
|
|
@@ -66,7 +67,24 @@ export function setupSettingNamed(root, name) {
|
|
|
66
67
|
}
|
|
67
68
|
/** The player's settings as the dashboard shows them (D-341): with what this computer lacks, as pictures without Codex, asked again. */
|
|
68
69
|
export function shownPlayerSettings(root, context) {
|
|
69
|
-
return playerSettings(root, context).map((setting) =>
|
|
70
|
+
return playerSettings(root, context).map((setting) => {
|
|
71
|
+
if (setting.name === "pictures") {
|
|
72
|
+
return { ...setting, ...withOwnPicture(picturesReadyNote(context)) };
|
|
73
|
+
}
|
|
74
|
+
return setting.name === "git" ? { ...setting, ...gitNote(root) } : setting;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// What went wrong the last time git ran (D-576), told until it goes right.
|
|
78
|
+
const gitFailed = {
|
|
79
|
+
commit: "The last commit failed; the game goes on all the same. Ask the master to look at it. ({why})",
|
|
80
|
+
push: "The last push failed: the campaign is safe on this computer, only its copy online is behind. Ask the master to look at it. ({why})",
|
|
81
|
+
};
|
|
82
|
+
/** Every note the setting of git may have, which the dashboard writes in its language (D-394). */
|
|
83
|
+
export const gitNotes = Object.values(gitFailed);
|
|
84
|
+
/** What went wrong the last time git ran for the campaign; nothing when it went right. */
|
|
85
|
+
function gitNote(root) {
|
|
86
|
+
const problem = gitProblem(root);
|
|
87
|
+
return problem === undefined ? {} : { note: { text: gitFailed[problem.act], values: { why: problem.why } } };
|
|
70
88
|
}
|
|
71
89
|
/** The player's settings with their values, then those the game system adds (D-341). */
|
|
72
90
|
export function playerSettings(root, context) {
|
|
@@ -95,7 +113,8 @@ export function playerSettings(root, context) {
|
|
|
95
113
|
...(choices === undefined ? {} : { choices }),
|
|
96
114
|
...(words.most === undefined ? {} : { most: words.most }),
|
|
97
115
|
}];
|
|
98
|
-
}).flatMap((setting) => offeredSetting(root, context, setting)).map((setting) => (setting.name === "pictures-by" ? makersInChat(context, setting) : setting))
|
|
116
|
+
}).flatMap((setting) => offeredSetting(root, context, setting)).map((setting) => (setting.name === "pictures-by" ? makersInChat(context, setting) : setting))
|
|
117
|
+
.filter((setting) => !gitSettingNames.includes(setting.name) || isCampaignRepository(root)),
|
|
99
118
|
...own,
|
|
100
119
|
];
|
|
101
120
|
}
|
|
@@ -105,9 +124,21 @@ export function playerSettingNamed(root, context, name) {
|
|
|
105
124
|
}
|
|
106
125
|
// The setup's questions, in the order the player meets them on the dashboard: how well they know the game, how it plays, how it is rolled, who comes along,
|
|
107
126
|
// the world and how long it plays, then the limits.
|
|
108
|
-
const setupOrder = ["mentor", "difficulty", "lethality", "saves", "rigor", "dice", "master-rolls", "units", "character", "companions", "preparation", "length", "pictures", "pictures-by"];
|
|
127
|
+
const setupOrder = ["mentor", "difficulty", "lethality", "saves", "rigor", "dice", "master-rolls", "units", "character", "companions", "preparation", "length", "pictures", "pictures-by", "git"];
|
|
109
128
|
// The questions the setup's cards ask in place of a setting's name (D-572).
|
|
110
|
-
const questionTexts = {
|
|
129
|
+
const questionTexts = {
|
|
130
|
+
pictures: "Do you want pictures of places and of those you meet?",
|
|
131
|
+
"pictures-by": "Who makes them?",
|
|
132
|
+
git: "This campaign's folder is a git repository: what should the engine do with it?",
|
|
133
|
+
};
|
|
134
|
+
// The question of git where the repository holds more than the campaign: a push sends the player's other commits too (D-576).
|
|
135
|
+
const largerGitQuestion = "This campaign's folder is in a git repository that holds other folders too: what should the engine do with it? A push sends your commits on those folders as well.";
|
|
136
|
+
/** Every question of git the setup may ask, which the dashboard writes in its language. */
|
|
137
|
+
export const gitQuestions = [questionTexts.git, largerGitQuestion];
|
|
138
|
+
/** The question a setting's card asks in the setup. */
|
|
139
|
+
function questionText(name, root) {
|
|
140
|
+
return name === "git" && isInLargerRepository(root) ? largerGitQuestion : questionTexts[name];
|
|
141
|
+
}
|
|
111
142
|
// The mentor as the setup asks it (D-347): how well the player knows the game, each answer a way of the mentor, from the newest player's.
|
|
112
143
|
const mentorAnswers = { tutorial: "never played it", hints: "a little", off: "I know it" };
|
|
113
144
|
// What the setup asks only of a world not written (D-80, D-558): a written one has its own.
|
|
@@ -163,8 +194,10 @@ const toolAsked = "The master asks you in the chat which tool to use.";
|
|
|
163
194
|
// Where the maker the player chose made no picture, and the chat in use makes them (D-572): it refused one, with its own words, or it cannot.
|
|
164
195
|
const refusedNote = "{maker} refused the last picture: {why}. {by} makes them instead.";
|
|
165
196
|
const madeMeanwhile = "{by} makes them meanwhile.";
|
|
197
|
+
// Whoever makes them, the player may give a page a picture of their own (D-572 (3)).
|
|
198
|
+
const ownPicture = "You can also give a page you see a picture of your own: with its picture button, or dropped in the campaign's inbox folder for the master.";
|
|
166
199
|
/** Every note the pictures' setting may have, which the dashboard writes in its language (D-394). */
|
|
167
|
-
export const picturesNotes = [...Object.values(madeBy), madeWithTool, toolAsked, refusedNote, madeMeanwhile, ...[...Object.values(codexSays), ...Object.values(claudeSays)].map(notReadyText)];
|
|
200
|
+
export const picturesNotes = [...Object.values(madeBy), madeWithTool, toolAsked, refusedNote, madeMeanwhile, ownPicture, ...[...Object.values(codexSays), ...Object.values(claudeSays)].map(notReadyText)];
|
|
168
201
|
/**
|
|
169
202
|
* Whether this computer makes pictures, and with whose plan, in the player's words (D-308, D-390); why not and how to have them; where the maker the player
|
|
170
203
|
* chose made none and the chat in use makes them, why (D-572); nothing where no maker is asked.
|
|
@@ -181,7 +214,7 @@ function picturesReadyNote(context) {
|
|
|
181
214
|
if (instead !== undefined) {
|
|
182
215
|
return instead.refused === true
|
|
183
216
|
? { note: { text: refusedNote, values: { maker: instead.maker, why: instead.why.replace(/\.$/, ""), by: instead.by } } }
|
|
184
|
-
: { note: { text: notReadyText(instead), fix: true, values: { by: instead.by }, also: madeMeanwhile } };
|
|
217
|
+
: { note: { text: notReadyText(instead), fix: true, values: { by: instead.by }, also: [madeMeanwhile] } };
|
|
185
218
|
}
|
|
186
219
|
if (ready.tool !== undefined) {
|
|
187
220
|
return { note: { text: madeWithTool, values: { tool: ready.tool } } };
|
|
@@ -191,6 +224,10 @@ function picturesReadyNote(context) {
|
|
|
191
224
|
}
|
|
192
225
|
return { note: { text: madeBy[ready.maker === "Claude" || ready.maker === "Antigravity" ? ready.maker : "Codex"] } };
|
|
193
226
|
}
|
|
227
|
+
/** The pictures' note with the line that the player may give a picture of their own after it. */
|
|
228
|
+
function withOwnPicture(note) {
|
|
229
|
+
return note.note === undefined ? note : { note: { ...note.note, also: [...note.note.also ?? [], ownPicture] } };
|
|
230
|
+
}
|
|
194
231
|
/** How the player has pictures, or else why there are none. */
|
|
195
232
|
function notReadyText(said) {
|
|
196
233
|
return said.fix ?? `${said.why}.`;
|
|
@@ -37,6 +37,10 @@ export function shownValue(root, context, settings, name) {
|
|
|
37
37
|
voices: "auto (a subagent at key moments, as you choose, where the app has them)",
|
|
38
38
|
"master-rolls": "behind the screen (unset: roll hides your rolls for foes and NPCs)",
|
|
39
39
|
"between-sessions": "stops (unset: no game time passes between sessions)",
|
|
40
|
+
// Git, unset: off, the player's to choose where the campaign's folder is a repository (D-576).
|
|
41
|
+
git: "off (unset: the player's to choose where the campaign's folder is a git repository)",
|
|
42
|
+
"git-saves": "out (unset)",
|
|
43
|
+
"git-sessions": "out (unset)",
|
|
40
44
|
};
|
|
41
45
|
if (settings[name] === undefined && Object.hasOwn(own, name)) {
|
|
42
46
|
return own[name];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare const styleSettingNames: string[];
|
|
2
2
|
export declare const betweenSessionsWays: readonly ["stops", "1d per 7d", "1d per 1d"];
|
|
3
3
|
/** The settings the player changes on the dashboard (D-341): how the game plays for them; the master's own, as house rules, coins and precedents, stay in the chat. */
|
|
4
|
-
export declare const playerSettingNames: readonly ["difficulty", "custom-difficulty", "lethality", "saves", "rigor", "custom-rigor", "between-sessions", "mentor", "learned", "prose", "story", "author", "style", "dice", "master-rolls", "units", "voices", "pictures", "pictures-by", "effort", "lines", "veils", "orders", "language"];
|
|
4
|
+
export declare const playerSettingNames: readonly ["difficulty", "custom-difficulty", "lethality", "saves", "rigor", "custom-rigor", "between-sessions", "mentor", "learned", "prose", "story", "author", "style", "dice", "master-rolls", "units", "voices", "pictures", "pictures-by", "effort", "lines", "veils", "orders", "language", "git", "git-saves", "git-sessions"];
|
|
5
|
+
/** The settings of git (D-576), which count, and which the dashboard shows, only where the campaign's folder is a git repository. */
|
|
6
|
+
export declare const gitSettingNames: string[];
|
|
5
7
|
export declare const playerWords: Record<(typeof playerSettingNames)[number], PlayerWords>;
|
|
6
8
|
/**
|
|
7
9
|
* What a setting of the player's is to them, its values and what each means; what the master does when an item is added to a list or taken off it, or a text
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// What each player setting and setup question is, in the player's words
|
|
2
|
-
import { characterWays, companionWays, customLevel, diceWays, difficulties, efforts, lengths, lethalities, listLimits, masterRollWays, mentorWays, pictureMakers, pictureWays, preparations, proseWays, rigors, saveModes, storyWays, styleTextLengths, unitSystems, voiceWays, } from "../../campaign/index.js";
|
|
2
|
+
import { characterWays, companionWays, customLevel, diceWays, difficulties, efforts, gitIncludeWays, gitWays, lengths, lethalities, listLimits, masterRollWays, mentorWays, pictureMakers, pictureWays, preparations, proseWays, rigors, saveModes, storyWays, styleTextLengths, unitSystems, voiceWays, } from "../../campaign/index.js";
|
|
3
3
|
export const styleSettingNames = ["prose", "story", "author", "style"];
|
|
4
4
|
// The game time between sessions the dashboard offers (D-133): stopped, a day of the game for each real week, or as real time.
|
|
5
5
|
export const betweenSessionsWays = ["stops", "1d per 7d", "1d per 1d"];
|
|
@@ -29,7 +29,12 @@ export const playerSettingNames = [
|
|
|
29
29
|
"veils",
|
|
30
30
|
"orders",
|
|
31
31
|
"language",
|
|
32
|
+
"git",
|
|
33
|
+
"git-saves",
|
|
34
|
+
"git-sessions",
|
|
32
35
|
];
|
|
36
|
+
/** The settings of git (D-576), which count, and which the dashboard shows, only where the campaign's folder is a git repository. */
|
|
37
|
+
export const gitSettingNames = ["git", "git-saves", "git-sessions"];
|
|
33
38
|
// What each of the player's settings is, and what its values mean to the player, in their words rather than the master's.
|
|
34
39
|
export const playerWords = {
|
|
35
40
|
difficulty: {
|
|
@@ -77,7 +82,7 @@ export const playerWords = {
|
|
|
77
82
|
about: "how much the master teaches the game, out of the story",
|
|
78
83
|
values: mentorWays,
|
|
79
84
|
means: {
|
|
80
|
-
off: "only the story; ask in
|
|
85
|
+
off: "only the story; ask in [OOC: …] whenever you want",
|
|
81
86
|
hints: "a short note before big choices and when a rule slips by",
|
|
82
87
|
tutorial: "each rule explained the first time, the numbers shown, a short review after fights",
|
|
83
88
|
},
|
|
@@ -171,6 +176,28 @@ export const playerWords = {
|
|
|
171
176
|
most: listLimits.orders?.length,
|
|
172
177
|
},
|
|
173
178
|
language: { about: "the language the master plays in, and the page's too when it is translated" },
|
|
179
|
+
git: {
|
|
180
|
+
about: "what the engine does with git, as this campaign's folder is a git repository",
|
|
181
|
+
values: gitWays,
|
|
182
|
+
means: {
|
|
183
|
+
off: "nothing: you keep the repository yourself",
|
|
184
|
+
commit: "a commit at the start of each session, at each save and at each end of a scene",
|
|
185
|
+
push: "a commit at the start of each session, at each save and at each end of a scene, then a push",
|
|
186
|
+
},
|
|
187
|
+
unset: "off",
|
|
188
|
+
},
|
|
189
|
+
"git-saves": {
|
|
190
|
+
about: "whether the saves go into the repository",
|
|
191
|
+
values: gitIncludeWays,
|
|
192
|
+
means: { out: "the repository keeps the story without them", in: "each save's zip too, which makes the repository grow quickly" },
|
|
193
|
+
unset: "out",
|
|
194
|
+
},
|
|
195
|
+
"git-sessions": {
|
|
196
|
+
about: "whether your chats with the master go into the repository",
|
|
197
|
+
values: gitIncludeWays,
|
|
198
|
+
means: { out: "they stay on this computer", in: "everything you wrote to the master: keep the repository private" },
|
|
199
|
+
unset: "out",
|
|
200
|
+
},
|
|
174
201
|
};
|
|
175
202
|
// What the setup asks besides the player's settings (D-370): how the player character and the companions come, how far ahead a world is made and how long it
|
|
176
203
|
// plays, the campaign's name.
|
package/dist/commands/image.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { Context } from "../core/context.ts";
|
|
3
|
+
import { type ReadImage } from "../images/index.ts";
|
|
4
|
+
import { type Page, type World } from "../pages/index.ts";
|
|
2
5
|
interface ImageResult {
|
|
3
6
|
page: string;
|
|
4
7
|
/** The picture now in the campaign, from its folder; undefined when the page's own was removed. */
|
|
@@ -25,4 +28,6 @@ export declare const image: import("../core/registry.ts").Command<z.ZodObject<{
|
|
|
25
28
|
url: z.ZodOptional<z.ZodString>;
|
|
26
29
|
describe: z.ZodOptional<z.ZodString>;
|
|
27
30
|
}, z.core.$strip>, ImageResult>;
|
|
31
|
+
/** Writes a picture into the campaign's images folder and links it in the page, logging it; `from` is the file it was read from, if any. */
|
|
32
|
+
export declare function placeImage(root: string, context: Context, world: World, page: Page, picture: ReadImage, from?: string): ImageResult;
|
|
28
33
|
export {};
|
package/dist/commands/image.js
CHANGED
|
@@ -18,6 +18,7 @@ export const image = defineCommand({
|
|
|
18
18
|
description: "Give a page its picture: a portrait for a character, an image for a creature, an item or a place, as the dashboard will show it in a round token. "
|
|
19
19
|
+ "It copies the file into the campaign and links it in the page's image field; a page without one shows the picture of the page it derives from, such as a wolf's icon. "
|
|
20
20
|
+ "Use it when the player gives you a picture, or after you made one with your own tools: its file, or url with the https address your tool gives, which the engine downloads. "
|
|
21
|
+
+ "The player may drop pictures in the campaign's inbox folder: ask what each is for, give it, then delete it from the inbox. "
|
|
21
22
|
+ "For a place, a quest, a character or a creature of the campaign, describe instead of file has the picture made on this computer, as the campaign's pictures setting allows: "
|
|
22
23
|
+ "for the player character or a companion only when the player asks; for a creature once for each kind, whose copies show it. "
|
|
23
24
|
+ "Example: page Ettore, file C:\\Users\\me\\Pictures\\ettore.png.",
|
|
@@ -99,7 +100,7 @@ async function downloadedImage(root, context, world, page, url) {
|
|
|
99
100
|
return placeImage(root, context, world, page, imageOfBytes(bytes, "What the address gave"));
|
|
100
101
|
}
|
|
101
102
|
/** Writes a picture into the campaign's images folder and links it in the page, logging it; `from` is the file it was read from, if any. */
|
|
102
|
-
function placeImage(root, context, world, page, picture, from) {
|
|
103
|
+
export function placeImage(root, context, world, page, picture, from) {
|
|
103
104
|
if ("problem" in picture) {
|
|
104
105
|
throw new Error(`${picture.problem} Nothing changed.`);
|
|
105
106
|
}
|
|
@@ -114,6 +115,8 @@ function placeImage(root, context, world, page, picture, from) {
|
|
|
114
115
|
appendLogEntry(root, newDatedLogEntry(root, context, "image-set", "public", { page: page.name, image: shownPath(root, target) }));
|
|
115
116
|
return { page: page.name, image: shownPath(root, target), from: copied ? from : undefined, changed: true };
|
|
116
117
|
}
|
|
118
|
+
// Where nothing makes the picture, the player may give one of their own (D-572 (3)).
|
|
119
|
+
const playerGives = "ask the player for one of their own, given on the page in their dashboard or dropped in the campaign's inbox folder";
|
|
117
120
|
// How long a picture's download may take: a few megabytes come in seconds.
|
|
118
121
|
const longestDownload = 60 * 1000;
|
|
119
122
|
/** Why a page of the game system takes no picture, and how to give one: to a page of the campaign that derives from it, which a creature's scenes then bring in. */
|
|
@@ -154,7 +157,7 @@ function madePicture(root, context, world, page, seen) {
|
|
|
154
157
|
}
|
|
155
158
|
const ready = context.pictures?.ready(true) ?? { ready: false, why: "Nothing on this computer makes pictures" };
|
|
156
159
|
if (!ready.ready || context.pictures === undefined) {
|
|
157
|
-
throw new Error(`${ready.ready ? "Nothing on this computer makes pictures" : ready.why}. If your own tools make pictures, make one and give it with file; else go on without. Nothing changed.`);
|
|
160
|
+
throw new Error(`${ready.ready ? "Nothing on this computer makes pictures" : ready.why}. If your own tools make pictures, make one and give it with file; else ${playerGives}, or go on without. Nothing changed.`);
|
|
158
161
|
}
|
|
159
162
|
const unseen = [...readListSetting(root, "lines"), ...readListSetting(root, "veils")];
|
|
160
163
|
const { name, who } = kind === "place" || kind === "quest" ? { name: page.name } : isPartyMember(page) ? { name: page.name, who: portraitWho(root, context, world, page) } : metWho(root, world, page);
|
|
@@ -169,7 +172,7 @@ function madePicture(root, context, world, page, seen) {
|
|
|
169
172
|
const making = context.pictures.make(subject).then((made) => {
|
|
170
173
|
if ("refused" in made) {
|
|
171
174
|
appendLogEntry(root, newDatedLogEntry(root, context, "image-refused", "hidden", { page: page.name, why: made.refused }));
|
|
172
|
-
throw new Error(`No picture of ${page.name}: ${made.refused}.
|
|
175
|
+
throw new Error(`No picture of ${page.name}: ${made.refused}. Give one with file, or ${playerGives}, or go on without.`);
|
|
173
176
|
}
|
|
174
177
|
try {
|
|
175
178
|
const world = campaignWorld(root, context);
|
package/dist/commands/mode.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { type Mode } from "./shared/campaign/mode.ts";
|
|
|
3
3
|
import { type ResetPoint } from "./shared/campaign/saves.ts";
|
|
4
4
|
export declare const mode: import("../core/registry.ts").Command<z.ZodObject<{
|
|
5
5
|
to: z.ZodEnum<{
|
|
6
|
-
"session zero": "session zero";
|
|
7
6
|
setup: "setup";
|
|
7
|
+
"session zero": "session zero";
|
|
8
8
|
play: "play";
|
|
9
9
|
}>;
|
|
10
10
|
}, z.core.$strip>, {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type PackageEntry } from "../../core/archive.ts";
|
|
2
|
+
import type { Context } from "../../core/context.ts";
|
|
3
|
+
import type { PackageResult } from "./result.ts";
|
|
4
|
+
/** What a package of data alone is, by the file at its top. */
|
|
5
|
+
export type DataKind = "adventure" | "theme" | "language";
|
|
6
|
+
/** A package of data alone, read whole: what it is, what it was given as, and its files from its top. */
|
|
7
|
+
export interface DataPackage {
|
|
8
|
+
kind: DataKind;
|
|
9
|
+
label: string;
|
|
10
|
+
/** Where it came from, as a later update must: a GitHub repository's link, another link, a .zip's or a folder's path. */
|
|
11
|
+
source: string;
|
|
12
|
+
entries: PackageEntry[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether what was given to package install is a package of data alone: a .zip, an https link, or a folder with adventure.yaml, theme.yaml, or language.yaml
|
|
16
|
+
* and no package.json for RPG Engine, which npm installs; a document says it is imported instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isDataSpec(spec: string): boolean;
|
|
19
|
+
/** The package of data a .zip, a folder or an https link gives: a GitHub repository is read as the zip of its default branch, or of the branch or tag its link names. */
|
|
20
|
+
export declare function readDataSpec(spec: string, context: Context): Promise<DataPackage>;
|
|
21
|
+
/**
|
|
22
|
+
* A GitHub repository's link, as the catalog gives it, and the address of its zip: of its default branch, or of the branch or tag after /tree/, each part of
|
|
23
|
+
* the name written as an address writes it. Undefined for a link that is not a repository's.
|
|
24
|
+
*/
|
|
25
|
+
export declare function gitHubRepository(link: string): {
|
|
26
|
+
link: string;
|
|
27
|
+
zip: string;
|
|
28
|
+
} | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The package of data a .zip holds, at its top or inside one folder there, as GitHub zips a repository; it throws, saying why, when it is refused. Its names are
|
|
31
|
+
* read first: a theme's or a language's .zip that unpacks to more than they may is refused before any file is unpacked.
|
|
32
|
+
*/
|
|
33
|
+
export declare function zipDataPackage(bytes: Uint8Array, label: string, source: string): DataPackage;
|
|
34
|
+
/** Installs a package of data alone, as the file at its top says it is: an adventure in the campaign, a theme or a language for every campaign on this computer. */
|
|
35
|
+
export declare function installDataPackage(root: string, context: Context, data: DataPackage, from: string): Promise<PackageResult>;
|