rpg-engine 0.16.0 → 0.17.1

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.
Files changed (116) hide show
  1. package/dist/adventures/source.d.ts +3 -1
  2. package/dist/adventures/source.js +31 -1
  3. package/dist/campaign/find-campaign.js +8 -4
  4. package/dist/commands/import/import.js +23 -1
  5. package/dist/commands/package/package.js +43 -9
  6. package/dist/commands/package/result.d.ts +3 -4
  7. package/dist/commands/save.d.ts +1 -1
  8. package/dist/commands/shared/books/adventure-layers.d.ts +89 -0
  9. package/dist/commands/shared/books/adventure-layers.js +201 -0
  10. package/dist/commands/shared/books/adventures.d.ts +25 -8
  11. package/dist/commands/shared/books/adventures.js +60 -22
  12. package/dist/commands/shared/characters/thoughts.d.ts +7 -4
  13. package/dist/commands/shared/characters/thoughts.js +15 -5
  14. package/dist/commands/shared/scene/scene.js +3 -1
  15. package/dist/commands/shared/sheet/sheet.d.ts +2 -0
  16. package/dist/commands/show.d.ts +6 -0
  17. package/dist/commands/show.js +16 -2
  18. package/dist/commands/thoughts.d.ts +1 -0
  19. package/dist/commands/thoughts.js +23 -15
  20. package/dist/commands/view/layers.d.ts +36 -0
  21. package/dist/commands/view/layers.js +53 -0
  22. package/dist/commands/view/memory.js +12 -6
  23. package/dist/commands/view/page.js +4 -1
  24. package/dist/commands/view/result.d.ts +8 -1
  25. package/dist/commands/view/view.d.ts +3 -0
  26. package/dist/commands/view/view.js +5 -2
  27. package/dist/commands/write/inheritance.js +1 -5
  28. package/dist/commands/write/layer.d.ts +11 -3
  29. package/dist/commands/write/layer.js +27 -7
  30. package/dist/commands/write/write.d.ts +1 -0
  31. package/dist/commands/write/write.js +6 -2
  32. package/dist/core/length.d.ts +4 -1
  33. package/dist/core/length.js +13 -2
  34. package/dist/core/text.d.ts +2 -0
  35. package/dist/core/text.js +4 -0
  36. package/dist/dashboard/api.js +18 -0
  37. package/dist/dashboard/app.js +5 -1
  38. package/dist/dashboard/guide/ar.md +3 -1
  39. package/dist/dashboard/guide/cs.md +5 -3
  40. package/dist/dashboard/guide/da.md +5 -3
  41. package/dist/dashboard/guide/de.md +3 -1
  42. package/dist/dashboard/guide/el.md +5 -3
  43. package/dist/dashboard/guide/en.md +2 -0
  44. package/dist/dashboard/guide/es.md +5 -3
  45. package/dist/dashboard/guide/fi.md +5 -3
  46. package/dist/dashboard/guide/fr.md +5 -3
  47. package/dist/dashboard/guide/he.md +4 -2
  48. package/dist/dashboard/guide/hi.md +5 -3
  49. package/dist/dashboard/guide/hu.md +5 -3
  50. package/dist/dashboard/guide/is.md +5 -3
  51. package/dist/dashboard/guide/it.md +3 -1
  52. package/dist/dashboard/guide/ja.md +3 -1
  53. package/dist/dashboard/guide/ko.md +3 -1
  54. package/dist/dashboard/guide/nb.md +5 -3
  55. package/dist/dashboard/guide/nl.md +4 -2
  56. package/dist/dashboard/guide/pl.md +5 -3
  57. package/dist/dashboard/guide/pt.md +4 -2
  58. package/dist/dashboard/guide/ro.md +5 -3
  59. package/dist/dashboard/guide/ru.md +4 -2
  60. package/dist/dashboard/guide/sv.md +5 -3
  61. package/dist/dashboard/guide/tr.md +4 -2
  62. package/dist/dashboard/guide/uk.md +5 -3
  63. package/dist/dashboard/guide/zh.md +4 -2
  64. package/dist/dashboard/i18n/ar.json +25 -0
  65. package/dist/dashboard/i18n/cs.json +25 -0
  66. package/dist/dashboard/i18n/da.json +25 -0
  67. package/dist/dashboard/i18n/de.json +25 -0
  68. package/dist/dashboard/i18n/el.json +25 -0
  69. package/dist/dashboard/i18n/es.json +25 -0
  70. package/dist/dashboard/i18n/fi.json +25 -0
  71. package/dist/dashboard/i18n/fr.json +25 -0
  72. package/dist/dashboard/i18n/he.json +25 -0
  73. package/dist/dashboard/i18n/hi.json +25 -0
  74. package/dist/dashboard/i18n/hu.json +25 -0
  75. package/dist/dashboard/i18n/is.json +25 -0
  76. package/dist/dashboard/i18n/it.json +25 -0
  77. package/dist/dashboard/i18n/ja.json +25 -0
  78. package/dist/dashboard/i18n/ko.json +25 -0
  79. package/dist/dashboard/i18n/nb.json +25 -0
  80. package/dist/dashboard/i18n/nl.json +25 -0
  81. package/dist/dashboard/i18n/pl.json +25 -0
  82. package/dist/dashboard/i18n/pt.json +25 -0
  83. package/dist/dashboard/i18n/ro.json +25 -0
  84. package/dist/dashboard/i18n/ru.json +25 -0
  85. package/dist/dashboard/i18n/sv.json +25 -0
  86. package/dist/dashboard/i18n/tr.json +25 -0
  87. package/dist/dashboard/i18n/uk.json +25 -0
  88. package/dist/dashboard/i18n/zh.json +25 -0
  89. package/dist/dashboard/packages/changes.js +111 -0
  90. package/dist/dashboard/packages/installed.js +2 -2
  91. package/dist/dashboard/packages/packages.js +12 -7
  92. package/dist/dashboard/parts/changed.js +37 -0
  93. package/dist/dashboard/parts/refusals.js +4 -0
  94. package/dist/dashboard/parts/widgets.js +3 -1
  95. package/dist/dashboard/play/choices.js +3 -2
  96. package/dist/dashboard/sheet/sheet.js +10 -7
  97. package/dist/dashboard/shell/shown.js +1 -0
  98. package/dist/dashboard/style.css +214 -1
  99. package/dist/dashboard/world/lore.js +5 -1
  100. package/dist/pages/index.d.ts +3 -3
  101. package/dist/pages/index.js +3 -3
  102. package/dist/pages/layers.d.ts +5 -3
  103. package/dist/pages/layers.js +15 -7
  104. package/dist/pages/load.d.ts +2 -0
  105. package/dist/pages/load.js +16 -3
  106. package/dist/pages/markdown.d.ts +5 -1
  107. package/dist/pages/markdown.js +13 -1
  108. package/dist/pages/write-layer.d.ts +5 -0
  109. package/dist/pages/write-layer.js +59 -5
  110. package/dist/server/dashboard/choices.d.ts +2 -0
  111. package/dist/server/dashboard/choices.js +4 -2
  112. package/dist/server/dashboard/index.js +5 -1
  113. package/dist/server/dashboard/writes.d.ts +7 -0
  114. package/dist/server/dashboard/writes.js +39 -0
  115. package/instructions/voices.md +1 -1
  116. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { type AdventureFiles, type AdventureManifest } from "../../../adventures/index.ts";
2
2
  import type { Context } from "../../../core/context.ts";
3
3
  import { type LogEntry } from "../../../core/log.ts";
4
+ import { type LayeredPage, type LayerLeftOut, type LayersInstalled } from "./adventure-layers.ts";
4
5
  /** An adventure the campaign has installed and not taken out (ADV-6). */
5
6
  export interface InstalledAdventure {
6
7
  title: string;
@@ -9,6 +10,8 @@ export interface InstalledAdventure {
9
10
  since?: string;
10
11
  /** The files it wrote, from the campaign's folder. */
11
12
  files: string[];
13
+ /** The layers it brought over the pages of the game system (ADV-8), by their file, each with the print of its text as it wrote it. */
14
+ layers: Record<string, string>;
12
15
  /** The days its dates were moved by. */
13
16
  shift: number;
14
17
  /** The line of the log that installed it. */
@@ -34,20 +37,30 @@ export interface AdventureInstalled {
34
37
  name: string;
35
38
  placed: boolean;
36
39
  };
40
+ /** What its layers over the pages of the game system did (ADV-8): the pages they change, and the layers left out. */
41
+ layers: LayersInstalled;
37
42
  }
38
- /** What an export wrote (ADV-7). */
43
+ /** What taking an adventure out did (ADV-6, ADV-8): the pages of the game system its layers change no more, and those whose layer, changed since, stays the campaign's. */
44
+ export interface AdventureRemoved {
45
+ title: string;
46
+ layers: LayeredPage[];
47
+ layersKept: string[];
48
+ }
49
+ /** What an export wrote (ADV-7, ADV-8). */
39
50
  export interface AdventureExported {
40
51
  file: string;
41
52
  from: string;
42
53
  pages: number;
43
- /** The player characters, the adventures installed, and the pages of the game system the campaign's layers change (SYS-11), which an adventure does not carry. */
54
+ /** The pages of the game system whose layers it carries, as the campaign has them now, each with its type. */
55
+ layers: LayeredPage[];
56
+ /** The player characters, the adventures installed, and the campaign's layers that stay out, each with why. */
44
57
  leftOut: {
45
58
  characters: string[];
46
59
  adventures: string[];
47
- layers: string[];
60
+ layers: LayerLeftOut[];
48
61
  };
49
62
  opening?: string;
50
- /** The pages written from the player's documents (source:), when no license was given: the zip keeps them to the player. */
63
+ /** The pages and layers written from the player's documents (source:), when no license was given: the zip keeps them to the player. */
51
64
  sourced?: string[];
52
65
  }
53
66
  /** Whether what was given to package install is an adventure: a .zip, a link, or a folder with adventure.yaml; a document says it is imported instead. */
@@ -58,13 +71,17 @@ export declare function readAdventureSpec(spec: string, context: Context): Promi
58
71
  export declare function installedAdventures(root: string): InstalledAdventure[];
59
72
  /** Installs an adventure in the campaign (ADV-2–ADV-5): checked whole, then written, or nothing at all; installed again, it finishes what stopped. */
60
73
  export declare function installAdventure(root: string, context: Context, adventure: AdventureFiles, from: string): AdventureInstalled;
61
- /** Takes an adventure out (ADV-6), with the files it wrote, while no line of the log after it names one of its pages; else it throws, saying it stays. */
62
- export declare function removeAdventure(root: string, context: Context, adventure: InstalledAdventure): void;
63
- /** The first line of the log after an adventure came in that names one of its pages (ADV-6): it can no longer be taken out; undefined while none does. */
74
+ /**
75
+ * Takes an adventure out (ADV-6), with the files it wrote and the layers still as it wrote them (ADV-8), while no line of the log after it names one of its pages;
76
+ * else it throws, saying it stays.
77
+ */
78
+ export declare function removeAdventure(root: string, context: Context, adventure: InstalledAdventure): AdventureRemoved;
79
+ /** The first line of the log after an adventure came in that names one of its pages (ADV-6), never of the system's its layers change: it can no longer be taken out; undefined while none does. */
64
80
  export declare function storyTouching(root: string, adventure: InstalledAdventure): LogEntry | undefined;
65
81
  /**
66
82
  * Exports the campaign's world as an adventure (ADV-7), as it was at its start: the save before session zero, else that of the start, else the world now while no
67
- * scene was ever opened; without the player characters and the adventures it installed. Written in exports/, by the campaign's name.
83
+ * scene was ever opened; without the player characters and the adventures it installed. Its layers over the game system go as they are now (ADV-8), whatever the
84
+ * save held. Written in exports/, by the campaign's name.
68
85
  */
69
86
  export declare function exportAdventure(root: string, context: Context, credits: {
70
87
  author?: string;
@@ -1,5 +1,5 @@
1
1
  // The adventures of a campaign (D-476, D-483): installed from a package whole or not at all, taken out while the story has not touched them, and exported as
2
- // they were at the start (ADV-1–ADV-7).
2
+ // they were at the start (ADV-1–ADV-7), with the campaign's layers over its game system as they are now (ADV-8).
3
3
  import { basename, join, relative, resolve, sep } from "node:path";
4
4
  import { parse, parseDocument, stringify, visit } from "yaml";
5
5
  import { adventureFolderName, adventureTarget, isAdventureFolder, largestAdventure, manifestLine, packAdventure, readAdventureFolder, readAdventureZip } from "../../../adventures/index.js";
@@ -11,7 +11,7 @@ import { comparableText, linkTargetName } from "../../../core/text.js";
11
11
  import { isNewerVersion } from "../../../core/version.js";
12
12
  import { shortName } from "../../../extensions/index.js";
13
13
  import { findImage, imageFileName, largestImage } from "../../../images/index.js";
14
- import { layersFolderName, locate, pageNamed, pageNamedQuietly, readFields, splitPageFile, textsIn, worldFolderName } from "../../../pages/index.js";
14
+ import { locate, pageNamed, pageNamedQuietly, readFields, splitPageFile, textsIn, worldFolderName } from "../../../pages/index.js";
15
15
  import { readRuleBook, ruleSections } from "../../../rules/index.js";
16
16
  import { unpackFiles } from "../../../saves/index.js";
17
17
  import { formatGameDate, readGameDate } from "../../../time/index.js";
@@ -20,7 +20,10 @@ import { campaignSaves, exportsFolderName, resetSave, savesFolderName, savesWhy
20
20
  import { campaignSystem, campaignWorld } from "../campaign/world.js";
21
21
  import { listedExtensions } from "../packages/extensions.js";
22
22
  import { newDatedLogEntry, readPresent } from "../time/time.js";
23
+ import { changedPages, checkLayersNotCopied, layerPrints, layersToExport, layersToRemove, logLayerCounters, planLayers } from "./adventure-layers.js";
23
24
  import { houseRules, systemRuleBook } from "./rules.js";
25
+ // What the system's attribution adds when the adventure carries layers over its pages: an open licence asks to say that the material was changed (ADV-8).
26
+ const changesMade = "Changes were made: the files under layers/ modify pages the game system adapted from that material.";
24
27
  // The mark of an install under way, with its title and the days it moves dates by: while it is there, installing the same adventure finishes it (ADV-5).
25
28
  const installMarkName = ".adventure-install.yaml";
26
29
  // The documents a master imports, never a package: their pages are written by the master (D-483 (10)).
@@ -67,7 +70,11 @@ export function installAdventure(root, context, adventure, from) {
67
70
  version: there.version,
68
71
  });
69
72
  }
70
- return { ...describe(root, context, adventure, there.shift, [], []), already: true };
73
+ // An install that stopped after its line was written left only its mark behind.
74
+ if (comparableText(installMark(root)?.title ?? "") === comparableText(manifest.title)) {
75
+ files().remove(join(root, installMarkName));
76
+ }
77
+ return { ...describe(root, context, adventure, there.shift, [], []), already: true, layers: { changed: [], kept: [], stray: [] } };
71
78
  }
72
79
  const stopped = installMark(root);
73
80
  if (stopped !== undefined && comparableText(stopped.title) !== comparableText(manifest.title)) {
@@ -77,35 +84,61 @@ export function installAdventure(root, context, adventure, from) {
77
84
  }
78
85
  checkNeeds(root, context, manifest);
79
86
  const shift = stopped?.shift ?? Math.max(0, (readPresent(root).date?.day ?? 1) - 1);
87
+ const world = campaignWorld(root, context);
80
88
  const plan = planInstall(root, context, adventure, shift);
89
+ const layers = planLayers(root, world, adventure);
81
90
  if (plan.problems.length > 0) {
82
91
  const listed = plan.problems.slice(0, 10).join("; ");
83
92
  const more = plan.problems.length > 10 ? `; and ${plan.problems.length - 10} more` : "";
84
93
  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
94
  + "and install it again. Nothing changed.", "adventure-names", { name: manifest.title, names: `${listed}${more}` });
86
95
  }
96
+ if (layers.problems.length > 0) {
97
+ const listed = layers.problems.join("; ");
98
+ throw new Refusal(`${manifest.title} cannot be installed: ${listed}. A layer changes neither the name nor the type of a page of the game system, nor a field no page inherits, nor gives uses to an item `
99
+ + "counted in stacks, and a page has one layer: fix its layers, in its folder or its .zip, and install it again. Nothing changed.", "adventure-layers", { name: manifest.title, layers: listed });
100
+ }
101
+ // The copies read the fields a layer gives, never its text (INH-10).
102
+ checkLayersNotCopied(root, world, manifest.title, "installed", layers.changed.filter((one) => one.fields.length > 0).map((one) => one.page));
87
103
  const mark = join(root, installMarkName);
88
104
  files().write(mark, stringify({ title: manifest.title, shift, from }));
89
- for (const write of plan.writes) {
105
+ for (const write of [...plan.writes, ...layers.writes]) {
90
106
  files().writeBytes(join(root, ...write.path.split("/")), write.bytes);
91
107
  }
92
- appendLogEntry(root, newDatedLogEntry(root, context, "adventure-installed", "public", { title: manifest.title, version: manifest.version, from, shift, files: plan.paths }));
108
+ // Before the adventure's own line: a line after it is the story going on (ADV-6).
109
+ logLayerCounters(root, context, world, layers.changed.map((one) => one.page));
110
+ const brought = Object.keys(layers.prints).length === 0 ? {} : { layers: layers.prints };
111
+ appendLogEntry(root, newDatedLogEntry(root, context, "adventure-installed", "public", { title: manifest.title, version: manifest.version, from, shift, files: plan.paths, ...brought }));
93
112
  files().remove(mark);
94
- return { ...describe(root, context, adventure, shift, plan.shadows, plan.covers), already: false };
113
+ return {
114
+ ...describe(root, context, adventure, shift, plan.shadows, plan.covers),
115
+ already: false,
116
+ layers: { changed: changedPages(layers.changed.map((one) => one.page)), kept: layers.kept, stray: layers.stray },
117
+ };
95
118
  }
96
- /** Takes an adventure out (ADV-6), with the files it wrote, while no line of the log after it names one of its pages; else it throws, saying it stays. */
119
+ /**
120
+ * Takes an adventure out (ADV-6), with the files it wrote and the layers still as it wrote them (ADV-8), while no line of the log after it names one of its pages;
121
+ * else it throws, saying it stays.
122
+ */
97
123
  export function removeAdventure(root, context, adventure) {
98
124
  const touching = storyTouching(root, adventure);
99
125
  if (touching !== undefined) {
100
126
  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 });
101
127
  }
128
+ const world = campaignWorld(root, context);
129
+ const others = installedAdventures(root).filter((one) => one.entry !== adventure.entry).map((one) => one.layers);
130
+ const layers = layersToRemove(root, world, adventure.layers, others);
131
+ // The copies read the fields a layer gives, never its text (INH-10).
132
+ checkLayersNotCopied(root, world, adventure.title, "taken out", layers.changed.filter((page) => (page.layer?.fields.length ?? 0) > 0));
102
133
  // A file already gone, by hand or by a remove that stopped, is no reason to stop.
103
- for (const path of adventure.files.map((one) => join(root, ...one.split("/"))).filter((one) => files().exists(one))) {
134
+ for (const path of [...adventure.files, ...layers.paths].map((one) => join(root, ...one.split("/"))).filter((one) => files().exists(one))) {
104
135
  files().remove(path);
105
136
  }
137
+ logLayerCounters(root, context, world, layers.changed);
106
138
  appendLogEntry(root, newDatedLogEntry(root, context, "adventure-removed", "public", { title: adventure.title }));
139
+ return { title: adventure.title, layers: changedPages(layers.changed), layersKept: layers.kept };
107
140
  }
108
- /** The first line of the log after an adventure came in that names one of its pages (ADV-6): it can no longer be taken out; undefined while none does. */
141
+ /** The first line of the log after an adventure came in that names one of its pages (ADV-6), never of the system's its layers change: it can no longer be taken out; undefined while none does. */
109
142
  export function storyTouching(root, adventure) {
110
143
  const log = readLog(root);
111
144
  const names = new Set(adventure.files.filter((path) => path.startsWith(`${worldFolderName}/`)).flatMap((path) => pageNames(root, path)).map(comparableText));
@@ -114,7 +147,8 @@ export function storyTouching(root, adventure) {
114
147
  }
115
148
  /**
116
149
  * Exports the campaign's world as an adventure (ADV-7), as it was at its start: the save before session zero, else that of the start, else the world now while no
117
- * scene was ever opened; without the player characters and the adventures it installed. Written in exports/, by the campaign's name.
150
+ * scene was ever opened; without the player characters and the adventures it installed. Its layers over the game system go as they are now (ADV-8), whatever the
151
+ * save held. Written in exports/, by the campaign's name.
118
152
  */
119
153
  export function exportAdventure(root, context, credits) {
120
154
  const { held, from } = startingFiles(root, context);
@@ -136,10 +170,16 @@ export function exportAdventure(root, context, credits) {
136
170
  const opening = pages.find((page) => !installed.has(page.path) && textsIn(page.fields.tags).some((tag) => comparableText(tag) === "opening"));
137
171
  const start = opening === undefined ? undefined : textsIn(opening.fields.start)[0]?.replace(/^\[\[|\]\]$/g, "");
138
172
  const system = campaignSystem(root, context);
139
- // The system is needed, with its credits, only where a page uses it (D-489 (6)); pages from the player's documents keep it to the player unless they say otherwise.
140
- const usesSystem = settings.system !== undefined && systemUsed(kept, campaignWorld(root, context), system?.fields ?? {});
141
- const sourced = pages.filter((page) => kept[page.path] !== undefined && page.fields.source !== undefined).map((page) => basename(page.path, ".md"));
173
+ const world = campaignWorld(root, context);
174
+ const none = { carried: {}, pages: [], sourced: [], leftOut: [] };
175
+ const layers = settings.system === undefined ? none : layersToExport(root, world, system?.name ?? settings.system, installedAdventures(root).map((adventure) => adventure.layers));
176
+ const layered = layers.pages.length > 0;
177
+ // The system is needed, with its credits, only where a page uses it (D-489 (6)), and always with layers over its pages (ADV-8); pages from the player's documents
178
+ // keep it to the player unless they say otherwise.
179
+ const usesSystem = settings.system !== undefined && (layered || systemUsed(kept, world, system?.fields ?? {}));
180
+ const sourced = [...pages.filter((page) => kept[page.path] !== undefined && page.fields.source !== undefined).map((page) => basename(page.path, ".md")), ...layers.sourced];
142
181
  const license = credits.license ?? (sourced.length > 0 ? "personal use only" : undefined);
182
+ const attribution = system?.attribution === undefined || !usesSystem ? undefined : layered ? `${system.attribution.trim()} ${changesMade}` : system.attribution;
143
183
  const manifest = {
144
184
  title: manifestLine(settings.name, "title"),
145
185
  about: manifestLine(settings.premise ?? settings.name, "about"),
@@ -147,24 +187,21 @@ export function exportAdventure(root, context, credits) {
147
187
  version: "1.0.0",
148
188
  ...(credits.author === undefined ? {} : { author: credits.author }),
149
189
  ...(license === undefined ? {} : { license }),
150
- ...(system?.attribution === undefined || !usesSystem ? {} : { attribution: system.attribution }),
190
+ ...(attribution === undefined ? {} : { attribution }),
151
191
  needs: { ...(usesSystem ? { system: settings.system } : {}), extensions: listedExtensions(root) },
152
192
  content: [],
153
193
  ...(start === undefined ? {} : { start }),
154
194
  ...(opening === undefined ? {} : { opening: basename(opening.path, ".md") }),
155
195
  };
156
196
  const file = join(root, exportsFolderName, `${settings.name.replace(/[\\/:*?"<>|\u0000-\u001f]/g, "").trim()}.adventure.zip`);
157
- files().writeBytes(file, packAdventure(manifest, kept));
197
+ files().writeBytes(file, packAdventure(manifest, { ...kept, ...layers.carried }));
158
198
  const adventures = adventuresOfLog(log).map((adventure) => adventure.title);
159
199
  return {
160
200
  file,
161
201
  from,
162
202
  pages: Object.keys(kept).filter((path) => path.startsWith(`${worldFolderName}/`)).length,
163
- leftOut: {
164
- characters: players.map((page) => basename(page.path, ".md")),
165
- adventures,
166
- layers: Object.keys(held).filter((path) => path.startsWith(`${layersFolderName}/`) && path.endsWith(".md")).map((path) => basename(path, ".md")),
167
- },
203
+ layers: layers.pages,
204
+ leftOut: { characters: players.map((page) => basename(page.path, ".md")), adventures, layers: layers.leftOut },
168
205
  ...(sourced.length > 0 && credits.license === undefined ? { sourced } : {}),
169
206
  ...(opening === undefined ? {} : { opening: basename(opening.path, ".md") }),
170
207
  };
@@ -188,8 +225,9 @@ function adventuresOfLog(log) {
188
225
  const data = entry.data;
189
226
  const title = String(data.title ?? "");
190
227
  if (entry.type === "adventure-installed") {
191
- const shift = Number(entry.data.shift ?? 0);
192
- found.push({ title, version: String(data.version ?? ""), ...(entry.date === undefined ? {} : { since: entry.date }), files: textsIn(data.files), shift, entry: entry.id });
228
+ const { shift, layers } = entry.data;
229
+ const since = entry.date === undefined ? {} : { since: entry.date };
230
+ found.push({ title, version: String(data.version ?? ""), ...since, files: textsIn(data.files), layers: layerPrints(layers), shift: Number(shift ?? 0), entry: entry.id });
193
231
  }
194
232
  else if (entry.type === "adventure-removed") {
195
233
  const removed = found.findIndex((one) => comparableText(one.title) === comparableText(title));
@@ -4,15 +4,18 @@ import { type Page, type World } from "../../../pages/index.ts";
4
4
  export declare const thoughtsType = "thoughts";
5
5
  /** How long a line of a diary may be, in characters (DIA-1). */
6
6
  export declare const thoughtsLength = 200;
7
- /** How many of their last lines a companion reads in view as (DIA-3). */
7
+ /** How many of their last lines a character reads in view as, and the master in show (DIA-3). */
8
8
  export declare const thoughtsShown = 3;
9
- /** What a companion writes of themselves, as the character agent and the master read it (DIA-3). */
10
- export declare const thoughtsRule = "how you took what happened, whom you trust or fear now, what you mean to do; never what happened (Lived keeps it), and nothing you hide from the others";
11
- /** A line of a diary: whose, its game date, its text. */
9
+ /** What a character writes of themselves, as the character agent and the master read it (DIA-3): a companion's the player reads too, another's no one but them. */
10
+ export declare function thoughtsRule(companion: boolean): string;
11
+ /** Whether a page keeps a diary (DIA-1): a character of the campaign, not the player's. */
12
+ export declare function keepsDiary(page: Page): boolean;
13
+ /** A line of a diary: whose, its game date, its text, and whether it is hidden from the player, as another character's than a companion (DIA-4). */
12
14
  export interface Thought {
13
15
  page: Page;
14
16
  date?: string;
15
17
  text: string;
18
+ hidden: boolean;
16
19
  }
17
20
  /** The lines of the diaries, oldest first (DIA-1); of one character when `page` is given. Lines of a page no longer there are left out. */
18
21
  export declare function thoughtsIn(root: string, world: World, page?: Page): Thought[];
@@ -1,5 +1,5 @@
1
1
  import { readLog } from "../../../core/log.js";
2
- import { isInParty, pagesWithNameOrAlias, parsePageReference } from "../../../pages/index.js";
2
+ import { isInParty, isPlayerCharacter, pagesWithNameOrAlias, parsePageReference } from "../../../pages/index.js";
3
3
  import { readOpenScene } from "../scene/scene.js";
4
4
  import { textList } from "./knowledge.js";
5
5
  import { agentVoices } from "./voices.js";
@@ -7,10 +7,18 @@ import { agentVoices } from "./voices.js";
7
7
  export const thoughtsType = "thoughts";
8
8
  /** How long a line of a diary may be, in characters (DIA-1). */
9
9
  export const thoughtsLength = 200;
10
- /** How many of their last lines a companion reads in view as (DIA-3). */
10
+ /** How many of their last lines a character reads in view as, and the master in show (DIA-3). */
11
11
  export const thoughtsShown = 3;
12
- /** What a companion writes of themselves, as the character agent and the master read it (DIA-3). */
13
- export const thoughtsRule = "how you took what happened, whom you trust or fear now, what you mean to do; never what happened (Lived keeps it), and nothing you hide from the others";
12
+ /** What a character writes of themselves, as the character agent and the master read it (DIA-3): a companion's the player reads too, another's no one but them. */
13
+ export function thoughtsRule(companion) {
14
+ return companion
15
+ ? "how you took what happened, whom you trust or fear now, what you mean to do; never what happened (Lived keeps it), and nothing you hide from the others"
16
+ : "how you took what happened, whom you trust or fear now, what you mean to do, even what you would show no one: no one reads it but you; never what happened (Lived keeps it), nor a secret or a plan your page already holds";
17
+ }
18
+ /** Whether a page keeps a diary (DIA-1): a character of the campaign, not the player's. */
19
+ export function keepsDiary(page) {
20
+ return page.type === "character" && page.system === undefined && !isPlayerCharacter(page);
21
+ }
14
22
  /** The lines of the diaries, oldest first (DIA-1); of one character when `page` is given. Lines of a page no longer there are left out. */
15
23
  export function thoughtsIn(root, world, page) {
16
24
  return readLog(root).flatMap((entry) => {
@@ -48,7 +56,9 @@ function diaryDue(root, world) {
48
56
  /** A line of the log as a line of a diary, or nothing when it is not one, or its page is gone. */
49
57
  function thoughtOf(world, entry) {
50
58
  const page = entry.type === thoughtsType && typeof entry.data.page === "string" ? pageOf(world, entry.data.page) : undefined;
51
- return page === undefined || typeof entry.data.text !== "string" ? undefined : { page, ...(entry.date === undefined ? {} : { date: entry.date }), text: entry.data.text };
59
+ return page === undefined || typeof entry.data.text !== "string"
60
+ ? undefined
61
+ : { page, ...(entry.date === undefined ? {} : { date: entry.date }), text: entry.data.text, hidden: entry.visibility !== "public" };
52
62
  }
53
63
  function pageOf(world, name) {
54
64
  return pagesWithNameOrAlias(world, parsePageReference(name).name)[0];
@@ -2,6 +2,7 @@
2
2
  import { z } from "zod";
3
3
  import { changeStateAt, readStateValues } from "../../../campaign/index.js";
4
4
  import { readLog } from "../../../core/log.js";
5
+ import { Refusal } from "../../../core/refusal.js";
5
6
  import { sameName } from "../../../core/text.js";
6
7
  import { baseChain, findPage, isEmptyField, isInParty, kindMessage, locate, pagesWithName, parsePageReference, readOnlyMessage, systemFirstFix, systemLabel, systemPageNamed } from "../../../pages/index.js";
7
8
  import { readScene } from "../../../scene/index.js";
@@ -101,7 +102,8 @@ export function checkNotCopied(world, open, page) {
101
102
  }
102
103
  const copies = open.scene === undefined ? [] : copiesReadingFrom(world, open.scene, page);
103
104
  if (copies.length > 0) {
104
- throw new Error(`${page.name} has copies in the open scene, which read from it what they do not change: ${copies.join(", ")}. Change a copy; to change ${page.name} for all, close the scene first. Nothing changed.`);
105
+ // A refusal with a code, by which an adventure's install tells it and says its own: these words name the copies and their numbers, the master's.
106
+ throw new Refusal(`${page.name} has copies in the open scene, which read from it what they do not change: ${copies.join(", ")}. Change a copy; to change ${page.name} for all, close the scene first. Nothing changed.`, "copies-in-scene", { page: page.name });
105
107
  }
106
108
  }
107
109
  /** Refuses to change a page of the game system (SYS-6): the same call goes to one of its copies in the open scene; with none, how one enters the story. */
@@ -112,6 +112,8 @@ export interface SheetItem {
112
112
  equipped?: boolean;
113
113
  /** The lists of bonds it is in, as attuned (BND-1). */
114
114
  bonds?: string[];
115
+ /** Its page, or one it derives from, is a page of the game system the campaign changed with a layer (SYS-11): the view says so. */
116
+ layered?: true;
115
117
  }
116
118
  /**
117
119
  * The sheet of a player character or a companion as data, a group for each that has a value, as the character reads it, effects and formulas included (DAT-2).
@@ -32,6 +32,7 @@ export declare const show: import("../core/registry.ts").Command<z.ZodObject<{
32
32
  featureOf?: undefined;
33
33
  inherited?: undefined;
34
34
  text?: undefined;
35
+ diary?: undefined;
35
36
  linkedFrom?: undefined;
36
37
  problems?: undefined;
37
38
  loot?: undefined;
@@ -67,6 +68,7 @@ export declare const show: import("../core/registry.ts").Command<z.ZodObject<{
67
68
  featureOf?: undefined;
68
69
  inherited?: undefined;
69
70
  text?: undefined;
71
+ diary?: undefined;
70
72
  linkedFrom?: undefined;
71
73
  problems?: undefined;
72
74
  loot?: undefined;
@@ -109,6 +111,10 @@ export declare const show: import("../core/registry.ts").Command<z.ZodObject<{
109
111
  parts: string[];
110
112
  }[];
111
113
  text: string;
114
+ diary: {
115
+ hidden: boolean;
116
+ lines: string[];
117
+ };
112
118
  linkedFrom: {
113
119
  page: string;
114
120
  places: string[];
@@ -6,6 +6,7 @@ import { backlinks, baseChain, findPage, formatFields, inheritedByBase, inherite
6
6
  import { featureParts } from "../progression/index.js";
7
7
  import { firstInChat } from "./shared/campaign/parts.js";
8
8
  import { campaignSystem, campaignWorld, missingSystemHint } from "./shared/campaign/world.js";
9
+ import { keepsDiary, thoughtsIn, thoughtsShown } from "./shared/characters/thoughts.js";
9
10
  import { skippedPagesNote } from "./shared/notes.js";
10
11
  import { surroundings, surroundingsText } from "./shared/places/environment.js";
11
12
  import { holdsItems, isFallen, lootAdvice } from "./shared/scene/loot.js";
@@ -22,6 +23,7 @@ export const show = defineCommand({
22
23
  description: "Show a page of the world, or one of its sections or secrets, with what it inherits from the pages it derives from. "
23
24
  + "It also says where the thing is and which pages link to it. "
24
25
  + "The player character and the companions show their sheet in groups, such as Abilities; Page#Group shows one group with how each number is made. "
26
+ + "A character's page ends with the last lines of their diary, when they keep one. "
25
27
  + 'Example: page "Old lighthouse#Cellar".',
26
28
  group: "game",
27
29
  readOnly: true,
@@ -113,6 +115,8 @@ export const show = defineCommand({
113
115
  : [],
114
116
  // A system's page in the campaign's language where it has it, whole (D-542); a section as the system writes it.
115
117
  text: group === undefined ? (part?.text ?? page.translated ?? page.body) : "",
118
+ // The master reads a character's diary here, a hidden line too (DIA-3).
119
+ diary: reference.section === undefined && !isCopy && keepsDiary(page) ? diaryOf(root, world, page) : { hidden: false, lines: [] },
116
120
  linkedFrom: isCopy ? [] : backlinks(world, page).map((link) => ({ page: link.page.name, places: link.places })),
117
121
  problems: world.problems,
118
122
  loot: reference.section === undefined ? (lootNote(world, system, page, chain) ?? fallenCopiesNote(root, world, system, page)) : undefined,
@@ -171,9 +175,10 @@ export const show = defineCommand({
171
175
  const inheritedText = onSheet.size > 0
172
176
  ? result.inherited.filter((group) => group.parts.length > 0).map((group) => `From ${group.from}: ${group.parts.join(", ")}. show ${result.page}#${group.parts[0]} gives one.`)
173
177
  : result.inherited.filter((group) => group.text !== "").map((group) => `Text inherited from ${group.from}:\n\n${group.text}`);
178
+ const diary = result.diary.lines.length > 0 ? `Diary, in their words, the last lines${result.diary.hidden ? " (hidden from the player)" : ""}:\n${result.diary.lines.map((line) => `- ${line}`).join("\n")}` : "";
174
179
  const links = result.linkedFrom.length > 0 ? `Linked from:\n${result.linkedFrom.map((link) => `- ${link.page}: ${link.places.join(", ")}`).join("\n")}` : "";
175
180
  const notes = [result.loot ?? "", result.knows ?? ""].filter((note) => note !== "").join("\n");
176
- return [header, sheet, fields, worked, ...inheritedFields, result.text, ...inheritedText, links, skippedPagesNote(result.problems), notes].filter((block) => block !== "").join("\n\n");
181
+ return [header, sheet, fields, worked, ...inheritedFields, result.text, ...inheritedText, diary, links, skippedPagesNote(result.problems), notes].filter((block) => block !== "").join("\n\n");
177
182
  },
178
183
  });
179
184
  /** "The campaign changes it with its layer layers/5e/…: hp; the section Bite.": what a layer changed on a page of the game system (SYS-11). */
@@ -189,7 +194,16 @@ function layerLine(page) {
189
194
  ].filter((part) => part !== "");
190
195
  const ignored = layer.ignored.length === 0 ? "" : ` It also writes ${layer.ignored.join(", ")}, which a layer cannot change: validate says why.`;
191
196
  const what = changed.length === 0 ? "nothing yet" : changed.join("; ");
192
- return `The campaign changes it with its layer ${layer.path}: ${what}. write ${page.name} with layer and unset, or with empty text, gives back the system's.${ignored}`;
197
+ return `The campaign changes it with its layer ${layer.path}: ${what}. write ${page.name} with layer and unset, or with empty text, gives back the system's; with reset, all of it.${ignored}`;
198
+ }
199
+ /**
200
+ * "day 1, 18:00 · I will watch him.": a character's last lines of their diary (DIA-3), and whether all of them are hidden from the player; where only some are,
201
+ * each of those says so.
202
+ */
203
+ function diaryOf(root, world, page) {
204
+ const last = thoughtsIn(root, world, page).slice(-thoughtsShown);
205
+ const hidden = last.length > 0 && last.every((one) => one.hidden);
206
+ return { hidden, lines: last.map((one) => [one.date ?? "", one.hidden && !hidden ? "hidden from the player" : "", one.text].filter((part) => part !== "").join(" · ")) };
193
207
  }
194
208
  /** What show says once in a chat, as play's rule on what the character knows left the instructions for it (D-530). */
195
209
  const knowsNote = "When the player asks what their character knows, remembers or has seen, answer from view, never from show, which holds what they have not found out.";
@@ -3,6 +3,7 @@ interface ThoughtsResult {
3
3
  who: string;
4
4
  date?: string;
5
5
  text: string;
6
+ hidden: boolean;
6
7
  }
7
8
  export declare const thoughts: import("../core/registry.ts").Command<z.ZodObject<{
8
9
  page: z.ZodString;
@@ -2,25 +2,27 @@ 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 { isInParty, pageNamed } from "../pages/index.js";
5
+ import { isPlayerCharacter, pageNamed } from "../pages/index.js";
6
6
  import { campaignWorld } from "./shared/campaign/world.js";
7
7
  import { thoughtsLength, thoughtsType } from "./shared/characters/thoughts.js";
8
8
  import { newDatedLogEntry } from "./shared/time/time.js";
9
9
  export const thoughts = defineCommand({
10
10
  name: "thoughts",
11
- description: "Write a few lines in a companion's diary, when an output says it is due or after a moment that changed them, in their voice: "
12
- + "how they took what happened, whom they trust or fear now, what they mean to do; never what happened, which the log keeps, and nothing they hide from the others. "
13
- + "From their agent, its Writes line as it is. The player reads it on the dashboard, and view as gives them their last lines back. "
11
+ description: "Write a few lines in a character's diary, in their voice: a companion's when an output says it is due, or any character's of the campaign after a moment that changed them. "
12
+ + "How they took what happened, whom they trust or fear now, what they mean to do; never what happened, which the log keeps. "
13
+ + "A companion's the player reads on the dashboard: nothing they hide from the others. Another's only you read: what they hide too, never a secret or a plan their page already holds. "
14
+ + "A plan the story must keep goes on their page, as a secret: the diary gives back only its last lines. "
15
+ + "From their agent, its Writes line as it is. view as gives them their last lines back, and show gives them to you. "
14
16
  + 'Example: Mira "I no longer trust Corrado, since he lied to Agata. I will watch him."',
15
17
  group: "game",
16
18
  positionals: ["page", "text"],
17
19
  input: z.object({
18
- page: z.string().describe("the companion's page"),
20
+ page: z.string().describe("the character's page: a companion, or another character of the campaign, never the player's"),
19
21
  text: z.string().describe(`their lines, at most ${thoughtsLength} characters`),
20
22
  }),
21
23
  run(input, context) {
22
24
  const root = requireCampaign(context.folder);
23
- const page = companionPage(campaignWorld(root, context), input.page.trim());
25
+ const page = diaryPage(campaignWorld(root, context), input.page.trim());
24
26
  const text = input.text.trim().replace(/\s*\n\s*/g, " ").normalize("NFC");
25
27
  // Characters as a reader counts them: an emoji is one.
26
28
  const length = [...text].length;
@@ -30,24 +32,30 @@ export const thoughts = defineCommand({
30
32
  if (length > thoughtsLength) {
31
33
  throw new Error(`These lines are ${length} characters, the diary takes ${thoughtsLength}: keep how ${page.name} feels and what they mean to do, leave out what happened. Nothing written.`);
32
34
  }
33
- const entry = newDatedLogEntry(root, context, thoughtsType, "public", { page: page.name, text });
35
+ // A companion's diary the player reads; another character's only the master (DIA-1, DIA-4).
36
+ const hidden = page.fields.role !== "companion";
37
+ const entry = newDatedLogEntry(root, context, thoughtsType, hidden ? "hidden" : "public", { page: page.name, text });
34
38
  appendLogEntry(root, entry);
35
- return { who: page.name, ...(entry.date === undefined ? {} : { date: entry.date }), text };
39
+ return { who: page.name, ...(entry.date === undefined ? {} : { date: entry.date }), text, hidden };
36
40
  },
37
41
  format(result) {
38
- return `${result.who}'s diary${result.date === undefined ? "" : `, ${result.date}`}: ${result.text}`;
42
+ const when = [result.date ?? "", result.hidden ? "hidden from the player" : ""].filter((part) => part !== "").join(", ");
43
+ return `${result.who}'s diary${when === "" ? "" : `, ${when}`}: ${result.text}`;
39
44
  },
40
45
  });
41
- /** The companion whose diary it is (DIA-1); stops the command for any other page. */
42
- function companionPage(world, name) {
46
+ /** The character whose diary it is (DIA-1): a living character of the campaign, not the player's; stops the command for any other page. */
47
+ function diaryPage(world, name) {
43
48
  const page = pageNamed(world, name);
44
49
  if (page === undefined) {
45
- throw new Error(`There is no page ${name}: give a companion's name, or look for it with find. Nothing written.`);
50
+ throw new Error(`There is no page ${name}: give a character's name, or look for it with find. Nothing written.`);
46
51
  }
47
- if (page.type !== "character" || page.fields.role !== "companion" || page.system !== undefined) {
48
- throw new Error(`${page.name} is not a companion of the party: only companions keep a diary. Nothing written.`);
52
+ if (page.type !== "character" || page.system !== undefined) {
53
+ throw new Error(`${page.name} is not a character of the campaign: only they keep a diary. Nothing written.`);
49
54
  }
50
- if (!isInParty(page)) {
55
+ if (isPlayerCharacter(page)) {
56
+ throw new Error(`${page.name} is the player's character: their thoughts are the player's to tell. Nothing written.`);
57
+ }
58
+ if (page.fields.status === "dead") {
51
59
  throw new Error(`${page.name} is dead: the dead keep no diary. Nothing written.`);
52
60
  }
53
61
  return page;
@@ -0,0 +1,36 @@
1
+ import { type Page, type World } from "../../pages/index.ts";
2
+ import type { GameSystem } from "../../systems/index.ts";
3
+ import { type Knowledge } from "../shared/characters/knowledge.ts";
4
+ import type { Measures } from "../shared/places/roads.ts";
5
+ /** A page of the game system the campaign changed with a layer (SYS-11), as the dashboard lists it. */
6
+ export interface ShownLayer {
7
+ /** The page's name, by which its layer is taken off. */
8
+ name: string;
9
+ /** Its name in the campaign's language, when the system's translation gives one (D-542). */
10
+ title?: string;
11
+ /** Its type, of a page the player may read. */
12
+ type?: string;
13
+ /** The fields the layer changes: each as the system gives it, none for one the layer adds, and as the campaign has it, its measures in the story's units; none of a page the player may not read. */
14
+ fields: {
15
+ field: string;
16
+ system?: string;
17
+ campaign: string;
18
+ }[];
19
+ /** The sections the layer writes, by name: never a secret, and none of a page the player may not read. */
20
+ sections: string[];
21
+ /** Whether the layer writes the introduction, of a page the player may read. */
22
+ introduction?: true;
23
+ }
24
+ /**
25
+ * The pages of the game system with a layer of the campaign, by name (SYS-11). One the player may read (VIEW-2) with what the layer changes and the system's
26
+ * value of every field; any other, as a creature the character does not know, by its name alone, never a value nor what changed: a layer is a house rule of
27
+ * the campaign, not a fact of the story (D-565).
28
+ */
29
+ export declare function shownLayers(world: World, knowledge: Knowledge, system: GameSystem | undefined, measures: Measures): ShownLayer[];
30
+ /** The page of the game system with a layer, by its name, as the view lists it and the player takes the layer off; undefined for any other. */
31
+ export declare function listedLayer(world: World, name: string): Page | undefined;
32
+ /**
33
+ * Whether what a page shows comes from a page of the game system the campaign changed with a layer (SYS-11): itself, or one it derives from; with `known`, only
34
+ * a base the viewer knows, so that the mark never tells of a creature that is the master's (D-254).
35
+ */
36
+ export declare function isLayered(world: World, page: Page, known?: (base: Page) => boolean): boolean;
@@ -0,0 +1,53 @@
1
+ // The pages of the game system the campaign changed with a layer (SYS-11), as the player may see them: what changed, and what the system gave
2
+ import { lengthsInUnits } from "../../core/length.js";
3
+ import { comparableText, sameName, valueNamed, valueText } from "../../core/text.js";
4
+ import { baseChain, partContent, poundsInKilograms, systemOriginal } from "../../pages/index.js";
5
+ import { inKnownWords, knowsPage } from "../shared/characters/knowledge.js";
6
+ /**
7
+ * The pages of the game system with a layer of the campaign, by name (SYS-11). One the player may read (VIEW-2) with what the layer changes and the system's
8
+ * value of every field; any other, as a creature the character does not know, by its name alone, never a value nor what changed: a layer is a house rule of
9
+ * the campaign, not a fact of the story (D-565).
10
+ */
11
+ export function shownLayers(world, knowledge, system, measures) {
12
+ const pound = measures.units === "metric" ? system?.pound : undefined;
13
+ const weightField = system?.load?.field;
14
+ // Measures in the story's units, as the sheet tells them (D-328, LOAD-2); a layer never holds aliases (INH-8), so no name is told in other units.
15
+ const text = (field, value) => {
16
+ const known = inKnownWords(world, knowledge, valueText(value));
17
+ return pound !== undefined && weightField !== undefined && comparableText(field) === comparableText(weightField)
18
+ ? poundsInKilograms(known, pound)
19
+ : lengthsInUnits(known, measures.units, measures.imperial);
20
+ };
21
+ return layeredPages(world).map((page) => {
22
+ const named = { name: page.name, ...(page.title === undefined ? {} : { title: page.title }) };
23
+ if (!knowsPage(knowledge, page)) {
24
+ return { ...named, fields: [], sections: [] };
25
+ }
26
+ const original = systemOriginal(page).fields;
27
+ return {
28
+ ...named,
29
+ ...(page.type === undefined ? {} : { type: page.type }),
30
+ fields: (page.layer?.fields ?? []).map((field) => {
31
+ const given = valueNamed(original, field);
32
+ return { field: sameName(Object.keys(original), field) ?? field, ...(given === undefined ? {} : { system: text(field, given) }), campaign: text(field, valueNamed(page.fields, field)) };
33
+ }),
34
+ sections: (page.layer?.sections ?? []).filter((section) => partContent(page.body, section)?.secret === false),
35
+ ...(page.layer?.introduction === true ? { introduction: true } : {}),
36
+ };
37
+ }).sort((one, other) => one.name.localeCompare(other.name));
38
+ }
39
+ /** The page of the game system with a layer, by its name, as the view lists it and the player takes the layer off; undefined for any other. */
40
+ export function listedLayer(world, name) {
41
+ return layeredPages(world).find((page) => comparableText(page.name) === comparableText(name));
42
+ }
43
+ /**
44
+ * Whether what a page shows comes from a page of the game system the campaign changed with a layer (SYS-11): itself, or one it derives from; with `known`, only
45
+ * a base the viewer knows, so that the mark never tells of a creature that is the master's (D-254).
46
+ */
47
+ export function isLayered(world, page, known = () => true) {
48
+ return [page, ...baseChain(world, page).filter(known)].some((one) => one.layer !== undefined);
49
+ }
50
+ /** The pages of the game system the campaign changed with a layer. */
51
+ function layeredPages(world) {
52
+ return (world.system?.pages ?? []).filter((page) => page.layer !== undefined);
53
+ }