rpg-engine 0.9.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adventures/placement.js +4 -0
- package/dist/adventures/source.js +6 -5
- package/dist/campaign/find-campaign.js +18 -0
- package/dist/campaign/host-files.js +8 -6
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +2 -0
- package/dist/campaign/settings.js +12 -5
- package/dist/commands/advance.js +1 -1
- package/dist/commands/ask.js +1 -1
- package/dist/commands/config.js +21 -32
- package/dist/commands/import/import.js +1 -1
- package/dist/commands/instructions.js +1 -1
- package/dist/commands/mode.js +1 -1
- package/dist/commands/mood.js +2 -3
- package/dist/commands/move.js +1 -1
- package/dist/commands/package.d.ts +3 -3
- package/dist/commands/package.js +74 -37
- package/dist/commands/reveal.js +1 -1
- package/dist/commands/roll/roll.js +6 -12
- package/dist/commands/rules.js +0 -1
- package/dist/commands/scene.js +6 -8
- package/dist/commands/shared/adventures.js +21 -12
- package/dist/commands/shared/images.js +3 -1
- package/dist/commands/shared/knowledge.d.ts +8 -0
- package/dist/commands/shared/knowledge.js +41 -18
- package/dist/commands/shared/library.js +13 -5
- package/dist/commands/shared/mode.d.ts +7 -4
- package/dist/commands/shared/mode.js +28 -15
- package/dist/commands/shared/packages/catalog.d.ts +2 -0
- package/dist/commands/shared/packages/catalog.js +1 -0
- package/dist/commands/shared/packages/code.js +13 -2
- package/dist/commands/shared/page-words.d.ts +2 -0
- package/dist/commands/shared/page-words.js +13 -0
- package/dist/commands/shared/sheet.d.ts +3 -2
- package/dist/commands/shared/sheet.js +8 -5
- package/dist/commands/show.js +1 -1
- package/dist/commands/status.js +9 -5
- package/dist/commands/view/place.d.ts +2 -0
- package/dist/commands/view/place.js +17 -5
- package/dist/commands/write/write.js +4 -3
- package/dist/core/archive-paths.js +1 -1
- package/dist/core/context.d.ts +2 -0
- package/dist/core/package-api.d.ts +1 -1
- package/dist/core/package-declarations.d.ts +3 -3
- package/dist/core/package-declarations.js +3 -3
- package/dist/core/refusal.d.ts +12 -0
- package/dist/core/refusal.js +17 -0
- package/dist/core/store.d.ts +4 -0
- package/dist/core/store.js +20 -1
- package/dist/dashboard/api.js +37 -81
- package/dist/dashboard/app.js +10 -3
- package/dist/dashboard/asked.js +6 -3
- package/dist/dashboard/assets/master.svg +1 -2
- package/dist/dashboard/card.js +1 -1
- package/dist/dashboard/dice/load.js +6 -1
- package/dist/dashboard/dice/throw.js +5 -1
- package/dist/dashboard/dice/tray.js +5 -1
- package/dist/dashboard/footer.js +2 -2
- package/dist/dashboard/game-words.js +32 -32
- package/dist/dashboard/guide/ar.md +17 -17
- package/dist/dashboard/guide/cs.md +17 -17
- package/dist/dashboard/guide/da.md +16 -16
- package/dist/dashboard/guide/de.md +15 -15
- package/dist/dashboard/guide/el.md +19 -19
- package/dist/dashboard/guide/en.md +4 -4
- package/dist/dashboard/guide/es.md +17 -17
- package/dist/dashboard/guide/fi.md +19 -19
- package/dist/dashboard/guide/fr.md +16 -16
- package/dist/dashboard/guide/he.md +16 -16
- package/dist/dashboard/guide/hi.md +20 -20
- package/dist/dashboard/guide/hu.md +18 -18
- package/dist/dashboard/guide/is.md +16 -16
- package/dist/dashboard/guide/it.md +7 -7
- package/dist/dashboard/guide/ja.md +17 -17
- package/dist/dashboard/guide/ko.md +22 -22
- package/dist/dashboard/guide/nb.md +17 -17
- package/dist/dashboard/guide/nl.md +19 -19
- package/dist/dashboard/guide/pl.md +18 -18
- package/dist/dashboard/guide/pt.md +13 -13
- package/dist/dashboard/guide/ro.md +19 -19
- package/dist/dashboard/guide/ru.md +17 -17
- package/dist/dashboard/guide/sv.md +16 -16
- package/dist/dashboard/guide/tr.md +21 -21
- package/dist/dashboard/guide/uk.md +16 -16
- package/dist/dashboard/guide/zh.md +20 -20
- package/dist/dashboard/help/blocks.js +6 -0
- package/dist/dashboard/help/help.js +15 -3
- package/dist/dashboard/help/markdown.js +2 -1
- package/dist/dashboard/i18n/ar.json +54 -1
- package/dist/dashboard/i18n/cs.json +54 -1
- package/dist/dashboard/i18n/da.json +54 -1
- package/dist/dashboard/i18n/de.json +54 -1
- package/dist/dashboard/i18n/el.json +54 -1
- package/dist/dashboard/i18n/es.json +54 -1
- package/dist/dashboard/i18n/fi.json +54 -1
- package/dist/dashboard/i18n/fr.json +54 -1
- package/dist/dashboard/i18n/he.json +54 -1
- package/dist/dashboard/i18n/hi.json +54 -1
- package/dist/dashboard/i18n/hu.json +54 -1
- package/dist/dashboard/i18n/is.json +54 -1
- package/dist/dashboard/i18n/it.json +57 -4
- package/dist/dashboard/i18n/ja.json +54 -1
- package/dist/dashboard/i18n/ko.json +54 -1
- package/dist/dashboard/i18n/nb.json +54 -1
- package/dist/dashboard/i18n/nl.json +54 -1
- package/dist/dashboard/i18n/pl.json +54 -1
- package/dist/dashboard/i18n/pt.json +54 -1
- package/dist/dashboard/i18n/ro.json +54 -1
- package/dist/dashboard/i18n/ru.json +54 -1
- package/dist/dashboard/i18n/sv.json +54 -1
- package/dist/dashboard/i18n/tr.json +54 -1
- package/dist/dashboard/i18n/uk.json +54 -1
- package/dist/dashboard/i18n/zh.json +54 -1
- package/dist/dashboard/icons.js +2 -2
- package/dist/dashboard/journal.js +9 -4
- package/dist/dashboard/labels.js +5 -4
- package/dist/dashboard/language-choice.js +3 -3
- package/dist/dashboard/markdown.js +11 -4
- package/dist/dashboard/notes.js +4 -2
- package/dist/dashboard/notices.js +2 -2
- package/dist/dashboard/packages/ask-card.js +1 -1
- package/dist/dashboard/packages/packages.js +14 -10
- package/dist/dashboard/packages/page-code.js +11 -3
- package/dist/dashboard/packages/widgets.js +5 -5
- package/dist/dashboard/pages.js +3 -3
- package/dist/dashboard/place/map-sheet.js +4 -3
- package/dist/dashboard/place/map-view.js +17 -5
- package/dist/dashboard/refusals.js +61 -0
- package/dist/dashboard/rolls.js +3 -3
- package/dist/dashboard/settings.js +19 -5
- package/dist/dashboard/sheet.js +26 -7
- package/dist/dashboard/status.js +19 -13
- package/dist/dashboard/style.css +113 -16
- package/dist/dashboard/text.js +6 -2
- package/dist/dashboard/top.js +7 -9
- package/dist/dashboard/turns.js +7 -2
- package/dist/dashboard/world/lore.js +16 -15
- package/dist/dashboard/world/map.js +43 -1
- package/dist/dashboard/world/world.js +50 -15
- package/dist/dice/index.d.ts +1 -1
- package/dist/dice/oracle.d.ts +5 -3
- package/dist/dice/oracle.js +7 -6
- package/dist/extensions/extension.js +4 -1
- package/dist/helpers/codex.js +1 -1
- package/dist/packages/npm.js +17 -4
- package/dist/packages/tarball.js +8 -4
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/markdown.d.ts +2 -0
- package/dist/pages/markdown.js +21 -0
- package/dist/pages/world.js +4 -0
- package/dist/server/dashboard/index.js +8 -4
- package/dist/server/dashboard/writes.js +22 -13
- package/dist/server/mcp.d.ts +3 -1
- package/dist/server/mcp.js +20 -5
- package/dist/systems/game-system.d.ts +2 -0
- package/dist/systems/game-system.js +2 -0
- package/dist/systems/system-code.js +5 -0
- package/instructions/adventure.md +1 -1
- package/instructions/combat.md +1 -1
- package/instructions/core.md +2 -2
- package/instructions/import.md +1 -0
- package/instructions/session-zero.md +1 -1
- package/instructions/session.md +1 -1
- package/instructions/setup.md +1 -1
- package/package.json +2 -2
- package/systems/free/instructions/outcomes-rolled.md +1 -1
- package/systems/free/instructions/outcomes-tossed.md +1 -1
- package/systems/free/instructions/play.md +1 -2
package/dist/commands/package.js
CHANGED
|
@@ -6,7 +6,8 @@ import { engineSystemsFolder } from "../core/context.js";
|
|
|
6
6
|
import { neutralExamples } from "../core/examples.js";
|
|
7
7
|
import { installedFromFolder } from "../core/files.js";
|
|
8
8
|
import { appendLogEntry } from "../core/log.js";
|
|
9
|
-
import { apiProblem, ourSystems, readsApi } from "../core/package-declarations.js";
|
|
9
|
+
import { apiProblem, ourSystems, packageApi, readsApi } from "../core/package-declarations.js";
|
|
10
|
+
import { Refusal } from "../core/refusal.js";
|
|
10
11
|
import { defineCommand } from "../core/registry.js";
|
|
11
12
|
import { files, FileStore, isInside, withFiles } from "../core/store.js";
|
|
12
13
|
import { comparableText } from "../core/text.js";
|
|
@@ -14,7 +15,7 @@ import { isNewerVersion } from "../core/version.js";
|
|
|
14
15
|
import { dropConsent, findExtension, installedExtensions, readExtension, recordConsent, shortName } from "../extensions/index.js";
|
|
15
16
|
import { installedLanguages, languagePackProblems, readLanguagePack } from "../languages/index.js";
|
|
16
17
|
import { isLocalSpec, isPackageName, issuesPage, isTarball, isVerified, verifiedScope } from "../packages/index.js";
|
|
17
|
-
import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder } from "../systems/index.js";
|
|
18
|
+
import { findSystem, readableSystems, systemFolders, systemHasCode, systemInFolder, systemWords } from "../systems/index.js";
|
|
18
19
|
import { exportAdventure, installAdventure, installedAdventures, isAdventureSpec, readAdventureSpec, removeAdventure, storyTouching } from "./shared/adventures.js";
|
|
19
20
|
import { campaignExamples } from "./shared/examples.js";
|
|
20
21
|
import { campaignMode } from "./shared/mode.js";
|
|
@@ -23,11 +24,9 @@ import { listedExtensions, runsCode } from "./shared/packages/extensions.js";
|
|
|
23
24
|
import { newDatedLogEntry } from "./shared/time.js";
|
|
24
25
|
import { campaignWorld } from "./shared/world.js";
|
|
25
26
|
/** The player's yes to a package not ours, not given (D-478): they said no or closed the question, or no window could be shown here. */
|
|
26
|
-
export class YesRefused extends
|
|
27
|
-
code
|
|
28
|
-
|
|
29
|
-
super(message);
|
|
30
|
-
this.code = code;
|
|
27
|
+
export class YesRefused extends Refusal {
|
|
28
|
+
constructor(message, code, values = {}) {
|
|
29
|
+
super(message, code, values);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
export const packageCommand = defineCommand({
|
|
@@ -285,7 +284,12 @@ async function installed(root, context, name) {
|
|
|
285
284
|
const other = second !== undefined && "failed" in tried && tried.missing === true ? await packages.describe(second) : undefined;
|
|
286
285
|
const [asked, described] = second !== undefined && other !== undefined && !("failed" in other && other.missing === true) ? [second, other] : [first, tried];
|
|
287
286
|
if ("failed" in described) {
|
|
288
|
-
|
|
287
|
+
const message = `${described.failed}. Nothing changed${asked === name ? "" : `: ${name} alone means ${asked}, one of RPG Engine's; another's is named with its scope, or as npm:${name} without one`}.`;
|
|
288
|
+
throw isLocalSpec(asked)
|
|
289
|
+
? new Refusal(message, "not-on-computer", { name })
|
|
290
|
+
: described.missing === true
|
|
291
|
+
? new Refusal(message, "not-found", { name })
|
|
292
|
+
: new Refusal(message, "npm-failed", { name, why: described.failed });
|
|
289
293
|
}
|
|
290
294
|
// npm is given the version described, which the player's yes was for: by its name alone, npm would keep the exact version it saved before.
|
|
291
295
|
const spec = isLocalSpec(asked) ? asked : `${described.name}@${described.version}`;
|
|
@@ -296,13 +300,15 @@ async function installed(root, context, name) {
|
|
|
296
300
|
return await languageInstalled(root, context, spec, described);
|
|
297
301
|
}
|
|
298
302
|
if (described.kind !== "extension") {
|
|
299
|
-
throw
|
|
300
|
-
? `${described.name} is not a package for RPG Engine: its package.json does not say "rpg-engine": {"kind": "extension"}, or {"kind": "system"} for a game system. Nothing changed
|
|
301
|
-
: `${described.name} is a package of kind ${described.kind}: for now extensions, game systems and adventures are installed this way. Nothing changed
|
|
303
|
+
throw described.kind === undefined
|
|
304
|
+
? new Refusal(`${described.name} is not a package for RPG Engine: its package.json does not say "rpg-engine": {"kind": "extension"}, or {"kind": "system"} for a game system. Nothing changed.`, "not-ours", { name: described.name })
|
|
305
|
+
: new Refusal(`${described.name} is a package of kind ${described.kind}: for now extensions, game systems and adventures are installed this way. Nothing changed.`, "other-kind", {
|
|
306
|
+
name: described.name,
|
|
307
|
+
});
|
|
302
308
|
}
|
|
303
309
|
const unread = apiProblem(described.api, "extension");
|
|
304
310
|
if (unread !== undefined) {
|
|
305
|
-
throw
|
|
311
|
+
throw apiRefusal(described, unread);
|
|
306
312
|
}
|
|
307
313
|
const local = isLocalSpec(spec);
|
|
308
314
|
const before = usable(context, described.name);
|
|
@@ -318,7 +324,7 @@ async function installed(root, context, name) {
|
|
|
318
324
|
if (reinstall) {
|
|
319
325
|
const why = await packages.install(spec);
|
|
320
326
|
if (why !== undefined) {
|
|
321
|
-
throw new
|
|
327
|
+
throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed in the campaign.`, "install-failed", { name: described.name, why });
|
|
322
328
|
}
|
|
323
329
|
// npm wrote there: what the call read of those folders is read again, and the code anew.
|
|
324
330
|
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
@@ -336,7 +342,10 @@ async function installed(root, context, name) {
|
|
|
336
342
|
: "unread" in installed
|
|
337
343
|
? `its extension does not read: ${installed.unread}`
|
|
338
344
|
: "no extension of that name is where npm put it";
|
|
339
|
-
throw new
|
|
345
|
+
throw new Refusal(`npm installed ${described.name}, but ${why}: RPG Engine cannot use it, and took it off this computer again. Nothing changed in the campaign.`, "taken-off", {
|
|
346
|
+
name: described.name,
|
|
347
|
+
why,
|
|
348
|
+
});
|
|
340
349
|
}
|
|
341
350
|
// The player's yes holds for this version and these files, on this computer: its code runs on the server and in the page (D-478, D-510).
|
|
342
351
|
if (!isVerified(described.name, local) && !extension.linked) {
|
|
@@ -344,20 +353,24 @@ async function installed(root, context, name) {
|
|
|
344
353
|
}
|
|
345
354
|
const system = readTextSetting(root, "system");
|
|
346
355
|
if (extension.needs.system !== undefined && comparableText(extension.needs.system) !== comparableText(system ?? "")) {
|
|
347
|
-
throw new
|
|
356
|
+
throw new Refusal(`${extension.name} is installed on this computer, but it is for the game system ${extension.needs.system}, and the campaign plays ${system ?? "none"}: the campaign does not use it.`, "other-system", { name: extension.name, system: extension.needs.system, plays: system ?? "" });
|
|
348
357
|
}
|
|
349
358
|
// Its state, widgets and pictures go by its name, which the system's would share (D-514).
|
|
350
359
|
if (comparableText(extension.name) === comparableText(system ?? "")) {
|
|
351
|
-
throw new
|
|
360
|
+
throw new Refusal(`${extension.name} is installed on this computer, but it has the name of the game system the campaign plays: the campaign does not use it. Nothing changed in the campaign.`, "system-name", { name: extension.name });
|
|
352
361
|
}
|
|
353
362
|
const others = Object.keys(listedExtensions(root)).filter((other) => other !== extension.package && shortName(other) === extension.name);
|
|
354
363
|
if (others.length > 0) {
|
|
355
|
-
throw new
|
|
364
|
+
throw new Refusal(`The campaign uses ${others[0]}, with the same name, ${extension.name}: take it away with package remove ${others[0]} first. Nothing changed in the campaign.`, "same-name", {
|
|
365
|
+
name: extension.name,
|
|
366
|
+
other: others[0],
|
|
367
|
+
});
|
|
356
368
|
}
|
|
357
369
|
// Its code is checked before the campaign lists it: a package that would not work is never added.
|
|
358
370
|
const commands = runsCode(extension)
|
|
359
371
|
? await packageCommandNames(extension, context).catch((error) => {
|
|
360
|
-
|
|
372
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
373
|
+
throw new Refusal(`The code of ${extension.package} cannot be used: ${why}. Nothing changed in the campaign.`, "code-broken", { name: extension.package, why });
|
|
361
374
|
})
|
|
362
375
|
: [];
|
|
363
376
|
const listedBefore = listedExtensions(root);
|
|
@@ -389,18 +402,18 @@ async function systemInstalled(root, context, spec, name, described) {
|
|
|
389
402
|
const named = shortName(described.name).replace(/^system-/, "");
|
|
390
403
|
const unread = apiProblem(described.api, "system");
|
|
391
404
|
if (unread !== undefined) {
|
|
392
|
-
throw
|
|
405
|
+
throw apiRefusal(described, unread);
|
|
393
406
|
}
|
|
394
407
|
const taken = systemsHere(root, context).find((one) => comparableText(one.name) === comparableText(named) && one.package !== described.name);
|
|
395
408
|
if (taken !== undefined) {
|
|
396
|
-
throw new
|
|
409
|
+
throw new Refusal(`There is already a game system named ${taken.name} on this computer${taken.package === undefined ? ", the engine's own" : `, from ${taken.package}`}: ${described.name} would take its name. Nothing changed.`, "system-taken", { name: described.name, system: taken.name });
|
|
397
410
|
}
|
|
398
411
|
if (!isVerified(described.name, local)) {
|
|
399
412
|
await playerYes(context, local ? name : `${described.name} ${described.version}`, described.name, local, local ? ` (${described.name} ${described.version})` : "");
|
|
400
413
|
}
|
|
401
414
|
const why = await context.packages.install(spec);
|
|
402
415
|
if (why !== undefined) {
|
|
403
|
-
throw new
|
|
416
|
+
throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
|
|
404
417
|
}
|
|
405
418
|
[...context.systemFolders, ...(context.extensionFolders ?? [])].forEach((folder) => files().refresh(folder));
|
|
406
419
|
const installed = installedExtensionFolder(context, described.name);
|
|
@@ -410,7 +423,9 @@ async function systemInstalled(root, context, spec, name, described) {
|
|
|
410
423
|
}
|
|
411
424
|
const system = systemsHere(root, context).find((one) => one.package === described.name);
|
|
412
425
|
if (system === undefined) {
|
|
413
|
-
throw new
|
|
426
|
+
throw new Refusal(`${described.name} was installed, but ${unreadSystemWhy(installed, described.name)}. Uninstall it with package uninstall ${described.name}.`, "system-unread", {
|
|
427
|
+
name: described.name,
|
|
428
|
+
});
|
|
414
429
|
}
|
|
415
430
|
appendLogEntry(root, newDatedLogEntry(root, context, "package-installed", "public", { package: described.name, version: described.version, verified: system.verified, kind: "system" }));
|
|
416
431
|
const plays = readTextSetting(root, "system");
|
|
@@ -435,6 +450,7 @@ function codeText(loaded) {
|
|
|
435
450
|
/** The game systems on this computer, those shipped with the engine first, with the package each came in when npm installed it (D-485). */
|
|
436
451
|
function systemsHere(root, context) {
|
|
437
452
|
const plays = readTextSetting(root, "system") ?? "";
|
|
453
|
+
const language = readTextSetting(root, "language");
|
|
438
454
|
const folders = systemFolders(context.systemFolders);
|
|
439
455
|
return readableSystems(context.systemFolders).map((system) => {
|
|
440
456
|
const manifest = packageOf(folders.find((one) => one.name === system.name)?.folder ?? system.folder);
|
|
@@ -443,7 +459,7 @@ function systemsHere(root, context) {
|
|
|
443
459
|
const linked = installedFromFolder(system.folder);
|
|
444
460
|
return {
|
|
445
461
|
name: system.name,
|
|
446
|
-
title: system.title,
|
|
462
|
+
title: language === undefined ? system.title : titleIn(system.folder, system.title, language),
|
|
447
463
|
...(manifest === undefined ? {} : { version: manifest.version }),
|
|
448
464
|
...(manifest === undefined || shipped ? {} : { package: manifest.name }),
|
|
449
465
|
verified: shipped || (manifest !== undefined && isVerified(manifest.name, linked)),
|
|
@@ -454,6 +470,15 @@ function systemsHere(root, context) {
|
|
|
454
470
|
};
|
|
455
471
|
});
|
|
456
472
|
}
|
|
473
|
+
/** A system's title in the campaign's language, as its own words give it; as it is where they do not, or do not read. */
|
|
474
|
+
function titleIn(folder, title, language) {
|
|
475
|
+
try {
|
|
476
|
+
return systemWords(folder, language)?.words[title] ?? title;
|
|
477
|
+
}
|
|
478
|
+
catch {
|
|
479
|
+
return title;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
457
482
|
/** Where the package in this folder takes reports of its problems, as its package.json says; nothing when it says none or has none that reads. */
|
|
458
483
|
function issuesOf(folder) {
|
|
459
484
|
try {
|
|
@@ -480,13 +505,15 @@ function packageOf(folder) {
|
|
|
480
505
|
*/
|
|
481
506
|
async function languageInstalled(root, context, spec, described) {
|
|
482
507
|
if (described.code === true || described.dependencies === true) {
|
|
483
|
-
throw new
|
|
508
|
+
throw new Refusal(`${described.name} says it is a language, and brings code or needs other packages: a language package is texts only. Nothing changed.`, "language-code", {
|
|
509
|
+
name: described.name,
|
|
510
|
+
});
|
|
484
511
|
}
|
|
485
512
|
const before = installedLanguages(context.extensionFolders ?? []);
|
|
486
513
|
const packages = context.packages;
|
|
487
514
|
const why = await packages.install(spec);
|
|
488
515
|
if (why !== undefined) {
|
|
489
|
-
throw new
|
|
516
|
+
throw new Refusal(`${described.name} could not be installed: ${why}. Nothing changed.`, "install-failed", { name: described.name, why });
|
|
490
517
|
}
|
|
491
518
|
(context.extensionFolders ?? []).forEach((folder) => files().refresh(folder));
|
|
492
519
|
const folder = installedExtensionFolder(context, described.name);
|
|
@@ -506,7 +533,9 @@ async function languageInstalled(root, context, spec, described) {
|
|
|
506
533
|
const earlier = before.find((one) => one.package === described.name);
|
|
507
534
|
const back = earlier === undefined || isLocalSpec(spec) ? undefined : await packages.install(`${earlier.package}@${earlier.version}`).then((why) => (why === undefined ? earlier.version : undefined));
|
|
508
535
|
(context.extensionFolders ?? []).forEach((one) => files().refresh(one));
|
|
509
|
-
|
|
536
|
+
const why = checked.problems.join("; ");
|
|
537
|
+
const message = `${described.name} cannot be used: ${why}. ${back === undefined ? "It was taken off this computer." : `Version ${back} stays.`}`;
|
|
538
|
+
throw back === undefined ? new Refusal(message, "language-refused", { name: described.name, why }) : new Refusal(message, "language-kept", { name: described.name, why, version: back });
|
|
510
539
|
}
|
|
511
540
|
// One language, one package: the one before for the same code goes (D-485 (3)).
|
|
512
541
|
const replaced = before.find((one) => one.code.toLowerCase() === pack.code.toLowerCase() && one.package !== described.name);
|
|
@@ -576,7 +605,7 @@ function pagePhrases(context) {
|
|
|
576
605
|
async function playerYes(context, name, pack, local, holds = "", replaces = "") {
|
|
577
606
|
// A no in a window holds for the package npm describes, however it was written, until the server starts again (D-510).
|
|
578
607
|
if (context.declined?.has(pack) === true) {
|
|
579
|
-
throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined");
|
|
608
|
+
throw new YesRefused(`The player said no to ${pack} in this session: it is not asked again until the game's server starts again. Nothing changed.`, "declined", { name: pack });
|
|
580
609
|
}
|
|
581
610
|
// Said in plain words, the fixed text before the name its author chose; and where the request comes from (D-510). The package's own words cut short, so
|
|
582
611
|
// that a window, which shows so much at most, never loses the warning to them.
|
|
@@ -585,8 +614,8 @@ async function playerYes(context, name, pack, local, holds = "", replaces = "")
|
|
|
585
614
|
const from = context.actor === "player" ? "the dashboard" : context.host === undefined ? "the command line" : "the chat";
|
|
586
615
|
const can = "Its code runs on this computer with your permissions, and in the dashboard, where it can see the whole campaign, its secrets included, and press buttons and speak to the master for you.";
|
|
587
616
|
const warning = local
|
|
588
|
-
? `Not verified by RPG Engine: ${name}${holds}, ${isTarball(name) ? "a file" : "a folder"} of this computer, asked from ${from}. ${can} RPG Engine takes no responsibility for it.${replaces}`
|
|
589
|
-
: `Not verified by RPG Engine: ${name}, asked from ${from}. ${can}
|
|
617
|
+
? `Not verified by RPG Engine: ${name}${holds}, ${isTarball(name) ? "a file" : "a folder"} of this computer, asked from ${from}. ${can} RPG Engine takes no responsibility for it: install it only if you trust who made it.${replaces}`
|
|
618
|
+
: `Not verified by RPG Engine: ${name}, from npm, asked from ${from}. ${can} RPG Engine takes no responsibility for it: install it only if you trust who made it.`;
|
|
590
619
|
const question = `Install ${name}? ${warning}`;
|
|
591
620
|
const title = "A package not ours";
|
|
592
621
|
const answer = context.player === undefined ? "unavailable" : await context.player.choose(question, title, ["Install it, at my risk", "Do not install it"], context.signal);
|
|
@@ -594,11 +623,11 @@ async function playerYes(context, name, pack, local, holds = "", replaces = "")
|
|
|
594
623
|
return;
|
|
595
624
|
}
|
|
596
625
|
if (answer === 1 || (typeof answer === "object" && answer !== null)) {
|
|
597
|
-
throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined");
|
|
626
|
+
throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
|
|
598
627
|
}
|
|
599
628
|
// Closed without an answer is no yes, never a reason to ask again some other way.
|
|
600
629
|
if (answer === undefined) {
|
|
601
|
-
throw new YesRefused(`The player closed the question without a yes to ${name}. Nothing changed: ask again only if they bring it up.`, "declined");
|
|
630
|
+
throw new YesRefused(`The player closed the question without a yes to ${name}. Nothing changed: ask again only if they bring it up.`, "declined", { name });
|
|
602
631
|
}
|
|
603
632
|
const window = context.confirm === undefined ? "none" : await context.confirm.ask(title, question, context.signal);
|
|
604
633
|
if (window === "yes") {
|
|
@@ -606,11 +635,19 @@ async function playerYes(context, name, pack, local, holds = "", replaces = "")
|
|
|
606
635
|
}
|
|
607
636
|
if (window === "no") {
|
|
608
637
|
context.declined?.add(pack);
|
|
609
|
-
throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined");
|
|
638
|
+
throw new YesRefused(`The player did not want ${name}. Nothing changed.`, "declined", { name });
|
|
610
639
|
}
|
|
611
640
|
throw new YesRefused(`${warning} Only the player can say yes to it, in the host's form or in a window of their computer, and neither can be shown here (no desktop, as over SSH; `
|
|
612
641
|
+ `on Linux zenity or kdialog shows it): install it where one can be. Nothing changed.`, "no-window");
|
|
613
642
|
}
|
|
643
|
+
/** A package made for an API this engine does not read: one newer than the engine, which an update of the engine reads, or one older, which a newer version of it fixes. */
|
|
644
|
+
function apiRefusal(described, unread) {
|
|
645
|
+
const newer = described.api !== undefined && described.api > packageApi;
|
|
646
|
+
return new Refusal(`${described.name} ${described.version} cannot be used, because ${unread}. Nothing changed.`, newer ? "engine-too-old" : "package-too-old", {
|
|
647
|
+
name: described.name,
|
|
648
|
+
version: described.version,
|
|
649
|
+
});
|
|
650
|
+
}
|
|
614
651
|
/** The installed extension of this package, when it reads; undefined when it is missing or broken. */
|
|
615
652
|
function usable(context, name) {
|
|
616
653
|
try {
|
|
@@ -672,7 +709,7 @@ function removed(root, context, name) {
|
|
|
672
709
|
const found = Object.keys(listed).find((candidate) => candidate === name || comparableText(shortName(candidate)) === comparableText(name));
|
|
673
710
|
if (found === undefined) {
|
|
674
711
|
const names = Object.keys(listed).map(shortName);
|
|
675
|
-
throw new
|
|
712
|
+
throw new Refusal(`The campaign does not use ${name}${names.length === 0 ? ": it uses no package" : `; it uses ${names.join(", ")}`}. Nothing changed.`, "not-used", { name });
|
|
676
713
|
}
|
|
677
714
|
const rest = Object.fromEntries(Object.entries(listed).filter(([candidate]) => candidate !== found));
|
|
678
715
|
changeExtensions(root, rest);
|
|
@@ -684,7 +721,7 @@ async function uninstalled(root, context, name) {
|
|
|
684
721
|
const packages = context.packages;
|
|
685
722
|
const system = systemsHere(root, context).find((one) => one.package !== undefined && (one.package === name || comparableText(one.name) === comparableText(name)));
|
|
686
723
|
if (system?.used === true) {
|
|
687
|
-
throw new
|
|
724
|
+
throw new Refusal(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`, "system-played", { name: system.name });
|
|
688
725
|
}
|
|
689
726
|
const other = system?.package ?? languagesHere(context).find((one) => one.package === name || comparableText(one.code) === comparableText(name))?.package;
|
|
690
727
|
const found = other === undefined
|
|
@@ -695,13 +732,13 @@ async function uninstalled(root, context, name) {
|
|
|
695
732
|
if (found === undefined && packages !== undefined && isPackageName(npmName) && (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0)) {
|
|
696
733
|
const why = await packages.uninstall(npmName);
|
|
697
734
|
if (why !== undefined) {
|
|
698
|
-
throw new
|
|
735
|
+
throw new Refusal(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`, "uninstall-failed", { name: npmName, why });
|
|
699
736
|
}
|
|
700
737
|
return { kind: "uninstalled", name: npmName, wasUsed: false, extension: false };
|
|
701
738
|
}
|
|
702
739
|
if (found === undefined) {
|
|
703
740
|
const here = installedExtensions(context.extensionFolders ?? []).map((one) => shortName(one.package));
|
|
704
|
-
throw new
|
|
741
|
+
throw new Refusal(`${name} is not on this computer${here.length === 0 ? ": no package is" : `; these are: ${here.join(", ")}`}. Nothing changed.`, "not-here", { name });
|
|
705
742
|
}
|
|
706
743
|
if (packages === undefined) {
|
|
707
744
|
throw new Error("Packages are uninstalled only by the game's server or the command line, which reach npm.");
|
|
@@ -709,7 +746,7 @@ async function uninstalled(root, context, name) {
|
|
|
709
746
|
const folder = installedExtensionFolder(context, found.package);
|
|
710
747
|
const why = await packages.uninstall(found.package);
|
|
711
748
|
if (why !== undefined) {
|
|
712
|
-
throw new
|
|
749
|
+
throw new Refusal(`${found.package} could not be uninstalled: ${why}. Nothing changed.`, "uninstall-failed", { name: found.package, why });
|
|
713
750
|
}
|
|
714
751
|
// Off this computer, its yes goes with it: installed again, it is asked again.
|
|
715
752
|
if (folder !== undefined) {
|
package/dist/commands/reveal.js
CHANGED
|
@@ -13,7 +13,7 @@ import { campaignWorld } from "./shared/world.js";
|
|
|
13
13
|
export const reveal = defineCommand({
|
|
14
14
|
name: "reveal",
|
|
15
15
|
description: "Record what characters learn: a secret, as Page#Secret, or a whole page they did not know. "
|
|
16
|
-
+ "
|
|
16
|
+
+ "It adds the links to their knows and answers without the text: read a secret with show before you tell it. "
|
|
17
17
|
+ "Example: page [Coppa#Veleno, Varro], to [Ettore, Bruna].",
|
|
18
18
|
group: "game",
|
|
19
19
|
positionals: ["page"],
|
|
@@ -28,14 +28,8 @@ export const roll = defineCommand({
|
|
|
28
28
|
name: "roll",
|
|
29
29
|
description: "Roll dice and log the roll. "
|
|
30
30
|
+ "Give why and, if it belongs to someone, who; for a roll the player sees, check names it for them, while why stays yours. "
|
|
31
|
-
+ "
|
|
32
|
-
+ "
|
|
33
|
-
+ "keep stores the dice rolled for later, as a power of foresight does, rolled by the player for the player character, by you for a companion; "
|
|
34
|
-
+ "use takes one of those instead of the die and logs which roll it replaced. "
|
|
35
|
-
+ "Instead of a notation, table rolls on a random table of a page and gives its row, for you to tell; oracle answers a yes/no question with its odds; "
|
|
36
|
-
+ "toss tosses one to three coins, each heads or tails, in any game. "
|
|
37
|
-
+ "On the player's dashboard a shown roll goes in its list of rolls; tray true throws it in the dice tray too, landing on its faces, false keeps it in the list alone; "
|
|
38
|
-
+ "left out, coins fly and dice do not. "
|
|
31
|
+
+ "With physical dice, pass the player's faces as values. hidden when the player must not see the result; left out, master-rolls decides for who is outside the party. "
|
|
32
|
+
+ "Instead of a notation: table, oracle or toss, in any game; keep stores dice for later, use spends one. "
|
|
39
33
|
+ 'Example: notation {{roll}}, why "notice the trap", who Lena; table "Colli di Vallerana#Incontri", why "a night on the hills"; oracle likely, why "is the ferryman awake?"; '
|
|
40
34
|
+ 'toss 2, why "does the rope hold?", who Lena.',
|
|
41
35
|
group: "game",
|
|
@@ -207,7 +201,7 @@ function answerRoll(input, root, context) {
|
|
|
207
201
|
}
|
|
208
202
|
const physical = input.values !== undefined;
|
|
209
203
|
const source = input.values ? { values: input.values } : { random: context.random };
|
|
210
|
-
const answer = input.table !== undefined ? tableAnswer(root, context, input.table, source) : input.toss !== undefined ? tossAnswer(input.toss, source) : oracleAnswer(input.oracle ?? "", source);
|
|
204
|
+
const answer = input.table !== undefined ? tableAnswer(root, context, input.table, source) : input.toss !== undefined ? tossAnswer(input.toss, source) : oracleAnswer(input.oracle ?? "", source, campaignSystem(root, context)?.oracleYes);
|
|
211
205
|
// A table or the oracle is the master's own roll, behind the screen as master-rolls says, but for a party member's (D-287); a secret's table is never shown.
|
|
212
206
|
const masters = input.who === undefined || !ofTheParty(root, context, input.who);
|
|
213
207
|
const screened = answer.secret || (input.hidden === undefined && !physical && masters && screenUp(root));
|
|
@@ -225,10 +219,10 @@ function tableAnswer(root, context, table, source) {
|
|
|
225
219
|
const rolled = rollPageTable(root, context, table, source);
|
|
226
220
|
return { secret: rolled.secret, notation: rolled.die, total: rolled.result, text: rolled.text, dice: rolled.roll.dice, data: { table: rolled.table, row: rolled.row.label } };
|
|
227
221
|
}
|
|
228
|
-
/** The oracle's answer, with its odds and the answer for the log. */
|
|
229
|
-
function oracleAnswer(odds, source) {
|
|
222
|
+
/** The oracle's answer, read where the game system says a d100 says yes, with its odds and the answer for the log. */
|
|
223
|
+
function oracleAnswer(odds, source, yesOn) {
|
|
230
224
|
try {
|
|
231
|
-
const asked = askOracle(odds, source);
|
|
225
|
+
const asked = askOracle(odds, source, yesOn);
|
|
232
226
|
return { secret: false, notation: "d100", total: asked.roll.total, text: asked.text, dice: asked.roll.dice, data: { oracle: asked.odds, odds: asked.chance, answer: `${asked.extreme ? "extreme " : ""}${asked.yes ? "yes" : "no"}` } };
|
|
233
227
|
}
|
|
234
228
|
catch (error) {
|
package/dist/commands/rules.js
CHANGED
|
@@ -18,7 +18,6 @@ const namedSections = 8;
|
|
|
18
18
|
export const rules = defineCommand({
|
|
19
19
|
name: "rules",
|
|
20
20
|
description: "Find the exact text of a rule: the campaign's house rules first, then the game system's rules, then the table's precedents. "
|
|
21
|
-
+ "Use it whenever you are unsure how a rule works, before you rule and say what is at stake, and when the player questions a ruling. "
|
|
22
21
|
+ "Give the book's words, such as grappled, cover or falling; a heading, or headings joined by ›, reads that section. "
|
|
23
22
|
+ "It searches the player's own books too, after the system, each excerpt with its book and page: Book › p. 194 reads that page.",
|
|
24
23
|
group: "game",
|
package/dist/commands/scene.js
CHANGED
|
@@ -50,14 +50,12 @@ const mostCopies = 50;
|
|
|
50
50
|
export const scene = defineCommand({
|
|
51
51
|
name: "scene",
|
|
52
52
|
description: "Open, run and close a scene of the story. "
|
|
53
|
-
+ "
|
|
54
|
-
+ "
|
|
55
|
-
+ "
|
|
56
|
-
+ "
|
|
57
|
-
+ "
|
|
58
|
-
+ "
|
|
59
|
-
+ "seen, at open or add, gives what the character sees of those it does not know by name; the player's dashboard calls them so until the character learns the name. "
|
|
60
|
-
+ "close ends the scene with a summary: the player may read the title and summary. Change a copy's counters with change, as for a page. "
|
|
53
|
+
+ "Creatures come as numbered copies, such as Annegato 1: a copy holds only what changes, the rest is read from the creature. "
|
|
54
|
+
+ "At open, whoever of the party is elsewhere moves to the scene's place, except in a travel scene. "
|
|
55
|
+
+ "order sets who takes turns, after rolling for it if the game does; next passes the turn; use marks what one uses of a turn: the engine counts the uses the game declares and refuses one too many. "
|
|
56
|
+
+ "now is the line the player's dashboard shows: give it at open too, and change it as the scene turns. "
|
|
57
|
+
+ "hostile marks who attacks the party, calm takes the mark off; seen gives what the character sees of those it does not know by name; the player's dashboard shows both. "
|
|
58
|
+
+ "close ends the scene with a summary the player may read. Change a copy's counters with change, as for a page. "
|
|
61
59
|
+ 'Example: action open, title "Scontro all\'ossario", type combat, creatures {"Annegato": 2}.',
|
|
62
60
|
group: "game",
|
|
63
61
|
positionals: ["action"],
|
|
@@ -5,6 +5,7 @@ import { parse, parseDocument, stringify, visit } from "yaml";
|
|
|
5
5
|
import { adventureFolderName, adventureTarget, isAdventureFolder, largestAdventure, manifestLine, packAdventure, readAdventureFolder, readAdventureZip } from "../../adventures/index.js";
|
|
6
6
|
import { houseRulesFolderName, readSettings } from "../../campaign/index.js";
|
|
7
7
|
import { appendLogEntry, readLog } from "../../core/log.js";
|
|
8
|
+
import { Refusal } from "../../core/refusal.js";
|
|
8
9
|
import { files } from "../../core/store.js";
|
|
9
10
|
import { comparableText, linkTargetName } from "../../core/text.js";
|
|
10
11
|
import { isNewerVersion } from "../../core/version.js";
|
|
@@ -27,7 +28,7 @@ const documentPattern = /\.(pdf|docx?|odt|rtf|txt|md|epub)$/i;
|
|
|
27
28
|
/** 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. */
|
|
28
29
|
export function isAdventureSpec(spec) {
|
|
29
30
|
if (documentPattern.test(spec)) {
|
|
30
|
-
throw new
|
|
31
|
+
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 });
|
|
31
32
|
}
|
|
32
33
|
return /\.zip$/i.test(spec) || /^https:\/\//i.test(spec) || isAdventureFolder(resolve(spec));
|
|
33
34
|
}
|
|
@@ -45,7 +46,7 @@ export async function readAdventureSpec(spec, context) {
|
|
|
45
46
|
if (/\.zip$/i.test(spec)) {
|
|
46
47
|
const bytes = files().bytes(path);
|
|
47
48
|
if (bytes === undefined) {
|
|
48
|
-
throw new
|
|
49
|
+
throw new Refusal(`There is no file ${path}: give the path of the adventure's .zip. Nothing changed.`, "not-on-computer", { name: path });
|
|
49
50
|
}
|
|
50
51
|
return readAdventureZip(bytes, basename(path));
|
|
51
52
|
}
|
|
@@ -61,13 +62,18 @@ export function installAdventure(root, context, adventure, from) {
|
|
|
61
62
|
const there = installedAdventures(root).find((one) => comparableText(one.title) === comparableText(manifest.title));
|
|
62
63
|
if (there !== undefined) {
|
|
63
64
|
if (there.version !== manifest.version) {
|
|
64
|
-
throw new
|
|
65
|
+
throw new Refusal(`The campaign has ${manifest.title} ${there.version}: a played adventure is not updated. Nothing changed.`, "adventure-played", {
|
|
66
|
+
name: manifest.title,
|
|
67
|
+
version: there.version,
|
|
68
|
+
});
|
|
65
69
|
}
|
|
66
70
|
return { ...describe(root, context, adventure, there.shift, [], []), already: true };
|
|
67
71
|
}
|
|
68
72
|
const stopped = installMark(root);
|
|
69
73
|
if (stopped !== undefined && comparableText(stopped.title) !== comparableText(manifest.title)) {
|
|
70
|
-
throw new
|
|
74
|
+
throw new Refusal(`The install of ${stopped.title} stopped halfway: finish it first with package install ${stopped.from}. Nothing changed.`, "adventure-halfway", {
|
|
75
|
+
name: stopped.title,
|
|
76
|
+
});
|
|
71
77
|
}
|
|
72
78
|
checkNeeds(root, context, manifest);
|
|
73
79
|
const shift = stopped?.shift ?? Math.max(0, (readPresent(root).date?.day ?? 1) - 1);
|
|
@@ -75,8 +81,8 @@ export function installAdventure(root, context, adventure, from) {
|
|
|
75
81
|
if (plan.problems.length > 0) {
|
|
76
82
|
const listed = plan.problems.slice(0, 10).join("; ");
|
|
77
83
|
const more = plan.problems.length > 10 ? `; and ${plan.problems.length - 10} more` : "";
|
|
78
|
-
throw new
|
|
79
|
-
+ "and install it again. Nothing changed.");
|
|
84
|
+
throw new Refusal(`${manifest.title} cannot be installed: ${listed}${more}. Rename the adventure's pages in its folder, or the campaign's with rename if the player has not met them, `
|
|
85
|
+
+ "and install it again. Nothing changed.", "adventure-names", { name: manifest.title, names: `${listed}${more}` });
|
|
80
86
|
}
|
|
81
87
|
const mark = join(root, installMarkName);
|
|
82
88
|
files().write(mark, stringify({ title: manifest.title, shift, from }));
|
|
@@ -91,7 +97,7 @@ export function installAdventure(root, context, adventure, from) {
|
|
|
91
97
|
export function removeAdventure(root, context, adventure) {
|
|
92
98
|
const touching = storyTouching(root, adventure);
|
|
93
99
|
if (touching !== undefined) {
|
|
94
|
-
throw new
|
|
100
|
+
throw new Refusal(`${adventure.title} is part of the story now: the log names its pages${touching.date === undefined ? "" : ` on ${touching.date}`}. It stays; nothing changed.`, "adventure-in-story", { name: adventure.title });
|
|
95
101
|
}
|
|
96
102
|
// A file already gone, by hand or by a remove that stopped, is no reason to stop.
|
|
97
103
|
for (const path of adventure.files.map((one) => join(root, ...one.split("/"))).filter((one) => files().exists(one))) {
|
|
@@ -147,7 +153,7 @@ export function exportAdventure(root, context, credits) {
|
|
|
147
153
|
...(start === undefined ? {} : { start }),
|
|
148
154
|
...(opening === undefined ? {} : { opening: basename(opening.path, ".md") }),
|
|
149
155
|
};
|
|
150
|
-
const file = join(root, exportsFolderName, `${settings.name.replace(/[\\/:*?"
|
|
156
|
+
const file = join(root, exportsFolderName, `${settings.name.replace(/[\\/:*?"<>|\u0000-\u001f]/g, "").trim()}.adventure.zip`);
|
|
151
157
|
files().writeBytes(file, packAdventure(manifest, kept));
|
|
152
158
|
const adventures = adventuresOfLog(log).map((adventure) => adventure.title);
|
|
153
159
|
return {
|
|
@@ -194,16 +200,19 @@ function adventuresOfLog(log) {
|
|
|
194
200
|
function checkNeeds(root, context, manifest) {
|
|
195
201
|
const settings = readSettings(root);
|
|
196
202
|
if (manifest.needs.system !== undefined && comparableText(manifest.needs.system) !== comparableText(settings.system ?? "")) {
|
|
197
|
-
throw new
|
|
203
|
+
throw new Refusal(`${manifest.title} is for the game system ${manifest.needs.system}, and the campaign plays ${settings.system ?? "none yet"}: it cannot be installed here. Nothing changed.`, "other-system", { name: manifest.title, system: manifest.needs.system, plays: settings.system ?? "" });
|
|
198
204
|
}
|
|
199
205
|
const listed = listedExtensions(root);
|
|
200
206
|
for (const [name, lowest] of Object.entries(manifest.needs.extensions)) {
|
|
201
207
|
const found = Object.keys(listed).find((one) => one === name || comparableText(shortName(one)) === comparableText(shortName(name)));
|
|
202
208
|
if (found === undefined) {
|
|
203
|
-
throw new
|
|
209
|
+
throw new Refusal(`${manifest.title} needs the extension ${name}: install it with package install ${shortName(name)} first. Nothing changed.`, "adventure-needs", {
|
|
210
|
+
name: manifest.title,
|
|
211
|
+
needs: shortName(name),
|
|
212
|
+
});
|
|
204
213
|
}
|
|
205
214
|
if (isNewerVersion(lowest, listed[found])) {
|
|
206
|
-
throw new
|
|
215
|
+
throw new Refusal(`${manifest.title} needs ${name} ${lowest} or later, and the campaign has ${listed[found]}: install the newer with package install ${shortName(name)}. Nothing changed.`, "adventure-needs-newer", { name: manifest.title, needs: shortName(name), version: lowest, has: listed[found] });
|
|
207
216
|
}
|
|
208
217
|
}
|
|
209
218
|
if (manifest.levels !== undefined && campaignSystem(root, context)?.progression?.level === undefined) {
|
|
@@ -320,7 +329,7 @@ function startingFiles(root, context) {
|
|
|
320
329
|
}
|
|
321
330
|
const played = readLog(root).some((entry) => entry.type === "scene-opened") || campaignMode(root, campaignWorld(root, context)) === "play";
|
|
322
331
|
if (played) {
|
|
323
|
-
throw new
|
|
332
|
+
throw new Refusal("The campaign has been played, and has no save of its start: what it is now goes on as a save of the whole game, not as an adventure. Nothing was written.", "export-played");
|
|
324
333
|
}
|
|
325
334
|
const held = {};
|
|
326
335
|
const log = files().bytes(join(root, "log.jsonl"));
|
|
@@ -5,6 +5,7 @@ import { files } from "../../core/store.js";
|
|
|
5
5
|
import { findImage, imageFileName } from "../../images/index.js";
|
|
6
6
|
import { baseChain, isPartyMember, ownField } from "../../pages/index.js";
|
|
7
7
|
import { systemContentFolders } from "../../systems/index.js";
|
|
8
|
+
import { firstInChat } from "./parts.js";
|
|
8
9
|
import { campaignSystem } from "./world.js";
|
|
9
10
|
/**
|
|
10
11
|
* What the master hears of the places' pictures (D-308, PIC-4): where pictures can be made and the player has not chosen, to ask them once; with new elements, that
|
|
@@ -13,7 +14,8 @@ import { campaignSystem } from "./world.js";
|
|
|
13
14
|
export function picturesNote(root, context, world, place) {
|
|
14
15
|
const setting = readSettings(root).pictures;
|
|
15
16
|
if (setting === undefined) {
|
|
16
|
-
|
|
17
|
+
// Asked once in a chat, not at every status and scene (T-64).
|
|
18
|
+
const ready = context.told === undefined || firstInChat(context, "pictures-ask") ? context.pictures?.ready() : undefined;
|
|
17
19
|
return ready?.ready === true
|
|
18
20
|
? `Pictures: 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).`
|
|
19
21
|
: undefined;
|
|
@@ -38,6 +38,14 @@ export declare function knowsPage(knowledge: Knowledge, page: Page): boolean;
|
|
|
38
38
|
* without a name is never known; comments are left out (LNK-2).
|
|
39
39
|
*/
|
|
40
40
|
export declare function knownText(world: World, knowledge: Knowledge, page: Page): string;
|
|
41
|
+
/**
|
|
42
|
+
* A text as the character may read it (VIEW-3): a link to a page it does not know, or to none, written as its words, so that no name tells the page exists; a link
|
|
43
|
+
* to a secret it has not discovered too, so that the secret's name tells nothing, and to a section that tells it nothing but its title, as one over a secret; a
|
|
44
|
+
* secret written so that the engine does not read it as one, left out.
|
|
45
|
+
*/
|
|
46
|
+
export declare function inKnownWords(world: World, knowledge: Knowledge, text: string): string;
|
|
47
|
+
/** Whether the character may read where a link points (VIEW-3): a page it knows, and of it a secret it discovered or a section that tells it more than its title. */
|
|
48
|
+
export declare function readsLink(world: World, knowledge: Knowledge, link: Link): boolean;
|
|
41
49
|
/** The secrets a page's text shows (VIEW-3) that only some of the player characters discovered, when more than one is played, each by its name and with who (VIEW-12). */
|
|
42
50
|
export declare function knownSecretsApart(world: World, knowledge: Knowledge, page: Page): {
|
|
43
51
|
secret: string;
|