rpg-engine 0.4.0 → 0.4.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.
@@ -38,6 +38,7 @@ export declare const change: import("../core/registry.ts").Command<z.ZodObject<{
38
38
  /** What the change may break that someone keeps alive, and what shields the counter it lowered (EFF-14, DAT-14). */
39
39
  reminders: string[];
40
40
  } | {
41
+ hiddenRoll?: HiddenDice | undefined;
41
42
  rolled: string;
42
43
  problems: string[];
43
44
  page: string;
@@ -57,6 +58,12 @@ export declare const change: import("../core/registry.ts").Command<z.ZodObject<{
57
58
  /** What the change may break that someone keeps alive, and what shields the counter it lowered (EFF-14, DAT-14). */
58
59
  reminders: string[];
59
60
  }>;
61
+ /** The dice in by, hidden: the roll's id, the fingerprint the player may ask for, and whether master-rolls hid them. */
62
+ interface HiddenDice {
63
+ id: string;
64
+ fingerprint: string;
65
+ screened: boolean;
66
+ }
60
67
  /** What a step did to a counter or to money. */
61
68
  interface StepOutcome {
62
69
  page: string;
@@ -13,6 +13,7 @@ import { checkEffectsReadable, saveEffects } from "./game-effects.js";
13
13
  import { fireEvents, nowDueNote } from "./game-events.js";
14
14
  import { experienceOf, newLevelNotes } from "./game-experience.js";
15
15
  import { spendableDice, spendDice } from "./game-hit-dice.js";
16
+ import { screenNote, screenUp, sealHiddenRoll } from "./game-master-rolls.js";
16
17
  import { campaignCoins } from "./game-money.js";
17
18
  import { logRecipeApplied, tooSoonNote } from "./game-recipe-pace.js";
18
19
  import { effectsAtRecipe, notBroughtBack, partyPages, recipeChoices, recipeNamed, recipeTargets } from "./game-recipes.js";
@@ -43,7 +44,7 @@ export const change = defineCommand({
43
44
  input: z.object({
44
45
  page: z.string().optional().describe("page that holds the counter or the money; with a recipe, left out for the player character and the companions with them"),
45
46
  field: z.string().optional().describe("the counter or the money, such as hp, or the kind of a stack, such as Torch; none with a recipe"),
46
- by: z.union([wholeNumber, z.string()]).optional().describe("how much to add, or to take away when negative, or coins; stops at a limit (damage, healing); on the command line write --by=-7. Dice are rolled here, as the player sees: by -(2d6+3) takes away 2d6+3, by -2d6 a die alone, as the game's rules have them rolled"),
47
+ by: z.union([wholeNumber, z.string()]).optional().describe("how much to add, or to take away when negative, or coins; stops at a limit (damage, healing); on the command line write --by=-7. Dice are rolled here: by -(2d6+3) takes away 2d6+3, by -2d6 a die alone, as the game's rules have them rolled; taking away from the party, the master's roll, hidden or shown as master-rolls says"),
47
48
  spend: z.union([wholeNumber, z.string()]).optional().describe("how much is paid or used up, or coins; refused when there is not enough"),
48
49
  to: z.union([z.number().int(), z.string()]).optional().describe("the new value, even outside the limits: a number, max, current/max such as 15/15 (the maximum changes too), or coins; on the command line write --to=-3"),
49
50
  why: z.string().optional().describe("what the change is for"),
@@ -63,16 +64,15 @@ export const change = defineCommand({
63
64
  if (input.page === undefined || input.field === undefined) {
64
65
  throw new Error('Give the page and the field, such as page Bruna, field hp, by -7; or a recipe of the game system, such as recipe "long rest".');
65
66
  }
66
- // Dice in by are rolled first and logged once the change is made, as a roll the player sees (D-459): one call for a roll and its damage.
67
+ // Dice in by are rolled first and logged once the change is made (D-459): one call for a roll and its damage.
67
68
  const roll = diceBy(input.by, context);
69
+ const hiding = roll === undefined ? undefined : diceHiding(root, world, input.page, roll.taking);
68
70
  const { hitCounter, ...result } = changeField(root, context, world, { ...input, page: input.page, field: input.field, ...(roll === undefined ? {} : { by: roll.by }) });
69
- if (roll !== undefined) {
70
- appendLogEntry(root, newDatedLogEntry(root, context, "roll", "public", { ...roll.data, why: input.why ?? `${input.field} of ${input.page}` }));
71
- }
71
+ const hiddenRoll = roll === undefined ? undefined : logDiceBy(root, context, { ...roll.data, why: input.why ?? `${input.field} of ${input.page}` }, hiding);
72
72
  // The game system's code follows the change, after the roll that made it (D-448): as the 5e's dying point.
73
73
  const lines = hitCounter === undefined ? [] : allSaid(systemCounterChanged(root, context, hitCounter));
74
74
  const told = lines.length === 0 ? result : { ...result, reminders: [...result.reminders, ...lines] };
75
- return roll === undefined ? told : { ...told, rolled: roll.data.result };
75
+ return roll === undefined ? told : { ...told, rolled: roll.data.result, ...(hiddenRoll === undefined ? {} : { hiddenRoll }) };
76
76
  },
77
77
  format(result) {
78
78
  if ("recipe" in result) {
@@ -83,7 +83,7 @@ export const change = defineCommand({
83
83
  const summary = result.changed ? `${result.page}: ${result.field} ${result.before} → ${after}${note}.` : `Nothing changed: ${result.field} on ${result.page} is ${after}${note}.`;
84
84
  // A rule's text, of several lines, comes after the lines of the change.
85
85
  const notes = stepNotes(result);
86
- const lines = [...("rolled" in result && result.rolled !== undefined ? [`Rolled ${result.rolled}.`] : []), summary, ...notes.filter((line) => !line.includes("\n"))];
86
+ const lines = [...("rolled" in result && result.rolled !== undefined ? [rolledText(result.rolled, result.hiddenRoll)] : []), summary, ...notes.filter((line) => !line.includes("\n"))];
87
87
  return [lines.join("\n"), ...notes.filter((line) => line.includes("\n")), skippedPagesNote(result.problems)].filter((block) => block !== "").join("\n\n");
88
88
  },
89
89
  });
@@ -151,7 +151,33 @@ function diceBy(by, context) {
151
151
  }
152
152
  const rolled = rollDice(notation, { random: context.random });
153
153
  const total = Math.max(0, rolled.total);
154
- return { by: text.startsWith("-") ? -total : total, data: { notation, total: rolled.total, result: rolled.text, physical: false, dice: rolled.dice } };
154
+ return { by: text.startsWith("-") ? -total : total, taking: text.startsWith("-"), data: { notation, total: rolled.total, result: rolled.text, physical: false, dice: rolled.dice } };
155
+ }
156
+ /**
157
+ * Why the dice in by are hidden, or undefined when shown (D-287): with their change, on a page that does not concern the player, whatever master-rolls says;
158
+ * behind the screen, taking away from the player character or a companion, as a foe's or a trap's do. Healing them, or dice on a copy in the scene, are shown.
159
+ */
160
+ function diceHiding(root, world, name, taking) {
161
+ const holder = holderNamed(root, world, name);
162
+ if (holder.kind === "copy") {
163
+ return undefined;
164
+ }
165
+ if (holder.visibility === "hidden") {
166
+ return "secret";
167
+ }
168
+ return taking && screenUp(root) && isPartyMember(holder.page) ? "screen" : undefined;
169
+ }
170
+ /** Logs the roll of the dice in by, sealed when hidden as roll seals one; what the master is told of it when hidden. */
171
+ function logDiceBy(root, context, data, hiding) {
172
+ const entry = newDatedLogEntry(root, context, "roll", hiding === undefined ? "public" : "hidden", data);
173
+ const fingerprint = hiding === undefined ? undefined : sealHiddenRoll(entry, data.result, context);
174
+ appendLogEntry(root, entry);
175
+ return fingerprint === undefined ? undefined : { id: entry.id, fingerprint, screened: hiding === "screen" };
176
+ }
177
+ /** "Rolled 2d6+3 = 11 [5, 3] + 3.", or the hidden roll as roll tells it, only for the master. */
178
+ function rolledText(rolled, hidden) {
179
+ const screen = hidden?.screened === true ? `. ${screenNote}` : "";
180
+ return hidden === undefined ? `Rolled ${rolled}.` : `Hidden roll ${hidden.id}, only for the master: ${rolled}${screen}\nIts fingerprint, only if the player asks for it: ${hidden.fingerprint}`;
155
181
  }
156
182
  /** Whether a text reads as dice, such as 2d6+3: coins and names of fields do not. */
157
183
  function isDiceNotation(text) {
@@ -1,5 +1,7 @@
1
1
  import type { Context } from "../core/context.ts";
2
2
  import type { LogEntry } from "../core/log.ts";
3
+ /** What the master is told of a roll the setting hid. */
4
+ export declare const screenNote = "Behind the screen, as master-rolls says: tell only the outcome, in the story.";
3
5
  /**
4
6
  * Whether the master-rolls setting hides a roll of who: one for anyone the party does not hold, by name or alias, as a foe's copy in the scene or a name of
5
7
  * no page; never a roll of no one, as an oracle's.
@@ -5,6 +5,8 @@ import { createProof, fingerprint } from "../dice/index.js";
5
5
  import { isPartyMember, pagesWithNameOrAlias } from "../pages/index.js";
6
6
  import { readOpenScene } from "./game-scene.js";
7
7
  import { campaignWorld } from "./game-world.js";
8
+ /** What the master is told of a roll the setting hid. */
9
+ export const screenNote = "Behind the screen, as master-rolls says: tell only the outcome, in the story.";
8
10
  /**
9
11
  * Whether the master-rolls setting hides a roll of who: one for anyone the party does not hold, by name or alias, as a foe's copy in the scene or a name of
10
12
  * no page; never a roll of no one, as an oracle's.
@@ -8,7 +8,7 @@ import { readCounter } from "../counters/index.js";
8
8
  import { askOracle, DiceError, rollDice, sha256 } from "../dice/index.js";
9
9
  import { declaredKind, findPage, pagesWithName, writePage } from "../pages/index.js";
10
10
  import { effectiveFields, effectsOf } from "./effect-layer.js";
11
- import { behindTheScreen, namesNoOne, ofTheParty, screenUp, sealHiddenRoll } from "./game-master-rolls.js";
11
+ import { behindTheScreen, namesNoOne, ofTheParty, screenNote, screenUp, sealHiddenRoll } from "./game-master-rolls.js";
12
12
  import { copyPage, readOpenScene } from "./game-scene.js";
13
13
  import { systemRolled } from "./game-system-code.js";
14
14
  import { rollPageTable } from "./game-tables.js";
@@ -114,7 +114,7 @@ export const roll = defineCommand({
114
114
  }
115
115
  const note = [output.kept, output.note].filter((line) => line !== undefined).map((line) => `\n${line}`).join("");
116
116
  if (output.hidden) {
117
- const screen = output.screened === true ? ". Behind the screen, as master-rolls says: tell only the outcome, in the story." : "";
117
+ const screen = output.screened === true ? `. ${screenNote}` : "";
118
118
  const stranger = output.stranger === true
119
119
  ? `\n${output.who} names no page nor copy in the scene: hidden as a stranger's. If ${output.who} is of the party, roll --reveal ${output.id}, and give who as their page's name.`
120
120
  : "";
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "عودة إلى الوقوف بـ {value}",
164
164
  "Backstory": "الخلفية",
165
165
  "Before session zero": "قبل الجلسة صفر",
166
- "Behind the screen": "خلف الشاشة",
166
+ "Behind the screen": "خلف شاشة مدير اللعبة",
167
167
  "below {value}": "أقل من {value}",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "أفضل في {better} وأسوأ في {worse}: يلغي أحدهما الآخر",
169
169
  "Between scenes": "بين المشاهد",
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "Ανάκτηση με {value}",
164
164
  "Backstory": "Παρελθόν",
165
165
  "Before session zero": "Πριν από τη συνεδρία μηδέν",
166
- "Behind the screen": "Πίσω από την οθόνη",
166
+ "Behind the screen": "Πίσω από την οθόνη του αφηγητή",
167
167
  "below {value}": "κάτω από {value}",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "Καλύτερα για {better}, χειρότερα για {worse}: αλληλοεξουδετερώνονται",
169
169
  "Between scenes": "Ανάμεσα στις σκηνές",
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "חזרה לעמידה עם {value}",
164
164
  "Backstory": "רקע",
165
165
  "Before session zero": "לפני סשן אפס",
166
- "Behind the screen": "מאחורי המסך",
166
+ "Behind the screen": "מאחורי מסך המנחה",
167
167
  "below {value}": "מתחת ל-{value}",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "טוב יותר עבור {better} וגרוע יותר עבור {worse}: מבטלים זה את זה",
169
169
  "Between scenes": "בין סצנות",
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "{value} के साथ वापस खड़े",
164
164
  "Backstory": "बैकस्टोरी",
165
165
  "Before session zero": "सेशन ज़ीरो से पहले",
166
- "Behind the screen": "स्क्रीन के पीछे",
166
+ "Behind the screen": "गेम मास्टर की स्क्रीन के पीछे",
167
167
  "below {value}": "{value} से नीचे",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "{better} के लिए बेहतर और {worse} के लिए बदतर: दोनों बराबर हो जाते हैं",
169
169
  "Between scenes": "दृश्यों के बीच",
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "{value}で復帰",
164
164
  "Backstory": "バックストーリー",
165
165
  "Before session zero": "セッションゼロの前",
166
- "Behind the screen": "スクリーンの裏",
166
+ "Behind the screen": "GMスクリーンの裏",
167
167
  "below {value}": "出目が{value}未満",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "{better}には有利、{worse}には不利なため、相殺されます。",
169
169
  "Between scenes": "シーンの合間",
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "일어남 {value}",
164
164
  "Backstory": "배경 이야기",
165
165
  "Before session zero": "세션 0 이전",
166
- "Behind the screen": "스크린 뒤",
166
+ "Behind the screen": "GM 스크린 뒤",
167
167
  "below {value}": "{value} 미만일 때",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "{better}에는 유리하고 {worse}에는 불리해서 서로 상쇄돼요",
169
169
  "Between scenes": "장면 사이",
@@ -163,7 +163,7 @@
163
163
  "Back up with {value}": "以 {value} 点生命站起",
164
164
  "Backstory": "背景故事",
165
165
  "Before session zero": "零号团之前",
166
- "Behind the screen": "幕后",
166
+ "Behind the screen": "暗骰",
167
167
  "below {value}": "低于{value}",
168
168
  "Better for {better} and worse for {worse}: they cancel out": "{better}更有利,{worse}更不利:两者相抵",
169
169
  "Between scenes": "场景之间",
@@ -416,7 +416,7 @@
416
416
  "In this campaign: the master searches its books.": "用于本战役:主持人会查阅其中的书。",
417
417
  "In use": "使用中",
418
418
  "In use · chosen in the setup": "使用中 · 在设置时选定",
419
- "In view": "公开",
419
+ "In view": "明骰",
420
420
  "In your words": "自定义",
421
421
  "Inn": "旅店",
422
422
  "Inscription": "铭文",
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  // A page's text as the player may read it, from its markdown (D-275): headings, paragraphs, lists, quotes, a secret discovered as a note of its own, bold and
3
3
  // italics, links as their names, or as links where the page reading it says where they lead. Never HTML: every piece is text, so nothing in a page can run in
4
4
  // the dashboard.
@@ -8,6 +8,10 @@ import { foldedText, listText, t } from "./text.js";
8
8
  export function Markdown({ text, link, secretKnowers }) {
9
9
  return _jsx("div", { class: "markdown", children: blocks(text, link, true, secretKnowers).map((block, index) => _jsx(Fragment, { children: block }, index)) });
10
10
  }
11
+ /** A line of a page that is not a whole text, as a value of its fields: its links and its bold and italics, as the text reads them. */
12
+ export function InlineText({ text, link }) {
13
+ return _jsx(_Fragment, { children: inline(text, link) });
14
+ }
11
15
  /** Who found out each secret, from what the view gives of a page: its secrets that only some of the player characters discovered; none when it gives none. */
12
16
  export function knowersOf(knownBy) {
13
17
  return knownBy === undefined || knownBy.length === 0 ? undefined : (title) => knownBy.find((one) => foldedText(one.secret.trim()) === foldedText(title))?.who;
@@ -153,7 +157,7 @@ function inline(text, link) {
153
157
  return [];
154
158
  }
155
159
  const name = linkedName(target);
156
- const words = said?.trim() || name;
160
+ const words = said?.trim() || targetWords(target);
157
161
  const plain = said === undefined || foldedText(said.trim()) === foldedText(name);
158
162
  const address = name === "" || !plain ? undefined : link?.(name);
159
163
  return address === undefined ? emphasis(words, index) : [_jsx("a", { class: "md-link", href: address, children: words }, index)];
@@ -172,7 +176,14 @@ function emphasis(text, at) {
172
176
  return /^([*_]).+\1$/.test(piece) ? _jsx("em", { children: piece.slice(1, -1) }, key) : piece;
173
177
  });
174
178
  }
175
- /** Links as their words: [[Page|name]] reads name, [[Page]] reads Page; a picture embedded reads nothing. */
179
+ /** Links as their words: [[Page|name]] reads name, [[Page]] reads Page, [[Page#Part]] Page › Part; a picture embedded reads nothing. */
176
180
  function linkWords(text) {
177
- return text.replace(/!?\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g, (whole, target, said) => whole.startsWith("!") && pictureFile.test(target.split("#")[0].trim()) ? "" : said?.trim() || linkedName(target));
181
+ return text.replace(/!?\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g, (whole, target, said) => whole.startsWith("!") && pictureFile.test(target.split("#")[0].trim()) ? "" : said?.trim() || targetWords(target));
182
+ }
183
+ /** The words of a link without its own, as Obsidian reads them: Page, Page › Part for a heading of it, Part alone for one of the same page; never a block's id. */
184
+ function targetWords(target) {
185
+ const name = linkedName(target);
186
+ const part = target.split("#").slice(1).join("#").trim();
187
+ const heading = part.startsWith("^") ? "" : part;
188
+ return [name, heading].filter((words) => words !== "").join(" › ");
178
189
  }
@@ -3,17 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
3
3
  // scene and who is in it; outside a scene who is there of those the character knows; the map. While the scene goes by turns, the turns first.
4
4
  import { useEffect, useRef, useState } from "preact/hooks";
5
5
  import { TalkName } from "./act-names.js";
6
+ import { sectionAddress } from "./address.js";
6
7
  import { WidgetCards } from "./extension-widgets.js";
7
8
  import { effectLabel, sinceDateLabel, terrainLabel } from "./game-words.js";
8
9
  import { cardIcons, Icon } from "./icons.js";
9
10
  import { phraseLabel, sceneTypeLabel, strangerLabel } from "./labels.js";
10
11
  import { biomeLabel, biomes } from "./map-symbols.js";
11
- import { knowersOf, Markdown } from "./markdown.js";
12
+ import { InlineText, knowersOf, Markdown } from "./markdown.js";
12
13
  import { sideOf, Token } from "./party.js";
13
14
  import { PlaceMap } from "./place-map-view.js";
14
15
  import { Card } from "./sheet.js";
15
16
  import { StatusPip } from "./status.js";
16
- import { t } from "./text.js";
17
+ import { foldedText, t } from "./text.js";
17
18
  import { CharacterCard, hasTurns, TurnBand, TurnsCard } from "./turns.js";
18
19
  import { BiomeSwatch } from "./world.js";
19
20
  // How long the band takes to come in or go out, the style sheet's --short, as the master's question folds.
@@ -69,17 +70,18 @@ function useBandMotion(turns) {
69
70
  function PlaceLine({ place }) {
70
71
  const [open, setOpen] = useState(false);
71
72
  const text = place.text.trim();
73
+ const link = placeLinks(place);
72
74
  if (place.image !== undefined) {
73
75
  return _jsx(PlaceBand, { place: place, fold: { open, onToggle: () => setOpen(!open) } });
74
76
  }
75
- return (_jsxs("section", { class: "place-line", "aria-labelledby": "place-name", children: [_jsxs("div", { class: "place-line-head", children: [_jsx("span", { class: "place-line-mark", role: "img", "aria-label": t("Place"), "data-tip": t("Place"), children: _jsx(Icon, { name: "scene" }) }), _jsx("h2", { id: "place-name", children: place.name }), place.around.length > 0 && (_jsx("ul", { class: "place-env", "aria-label": t("Around"), children: place.around.map((item) => _jsx(Surrounding, { item: item, name: place.name }, `${"effect" in item ? item.effect : item.name} ${item.place ?? ""}`)) })), text !== "" && _jsx(DescriptionToggle, { open: open, controls: "place-line-text", onToggle: () => setOpen(!open) })] }), open && (_jsx("div", { id: "place-line-text", class: "place-line-text", children: _jsx(Markdown, { text: text, secretKnowers: knowersOf(place.knownBy) }) }))] }));
77
+ return (_jsxs("section", { class: "place-line", "aria-labelledby": "place-name", children: [_jsxs("div", { class: "place-line-head", children: [_jsx("span", { class: "place-line-mark", role: "img", "aria-label": t("Place"), "data-tip": t("Place"), children: _jsx(Icon, { name: "scene" }) }), _jsx("h2", { id: "place-name", children: place.name }), place.around.length > 0 && (_jsx("ul", { class: "place-env", "aria-label": t("Around"), children: place.around.map((item) => _jsx(Surrounding, { item: item, name: place.name, link: link }, `${"effect" in item ? item.effect : item.name} ${item.place ?? ""}`)) })), text !== "" && _jsx(DescriptionToggle, { open: open, controls: "place-line-text", onToggle: () => setOpen(!open) })] }), open && (_jsx("div", { id: "place-line-text", class: "place-line-text", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowersOf(place.knownBy) }) }))] }));
76
78
  }
77
79
  /** The button that opens a place's text where it stands, its chevron saying which way. */
78
80
  function DescriptionToggle({ open, controls, onToggle }) {
79
81
  return (_jsxs("button", { type: "button", class: "place-line-toggle", "aria-expanded": open, "aria-controls": controls, onClick: onToggle, children: [t("Description"), _jsx("span", { class: "chevron-tip tip-left", "aria-hidden": "true", "data-tip": open ? t("Close") : t("Open"), children: _jsx("svg", { class: "chevron", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: "M6 9.5l6 6 6-6" }) }) })] }));
80
82
  }
81
83
  /** A place's text under its picture (D-444): three lines, and the rest at a click, which closes it again; a secret with who found it out (D-480 (7)). */
82
- function PlaceAbout({ text, knowers }) {
84
+ function PlaceAbout({ text, link, knowers }) {
83
85
  const [open, setOpen] = useState(false);
84
86
  const [long, setLong] = useState(false);
85
87
  const body = useRef(null);
@@ -94,7 +96,7 @@ function PlaceAbout({ text, knowers }) {
94
96
  sizes.observe(element);
95
97
  return () => sizes.disconnect();
96
98
  }, [text, open]);
97
- return (_jsxs("div", { class: "place-about", children: [_jsx("div", { ref: body, id: "place-about-text", class: open ? "place-about-text" : "place-about-text clamped", children: _jsx(Markdown, { text: text, secretKnowers: knowers }) }), (long || open) && (_jsx("button", { type: "button", class: "place-about-more", "aria-expanded": open, "aria-controls": "place-about-text", onClick: () => setOpen(!open), children: open ? t("less") : t("more") }))] }));
99
+ return (_jsxs("div", { class: "place-about", children: [_jsx("div", { ref: body, id: "place-about-text", class: open ? "place-about-text" : "place-about-text clamped", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowers }) }), (long || open) && (_jsx("button", { type: "button", class: "place-about-more", "aria-expanded": open, "aria-controls": "place-about-text", onClick: () => setOpen(!open), children: open ? t("less") : t("more") }))] }));
98
100
  }
99
101
  /**
100
102
  * The place's band (D-309, D-444): its picture with its name over it, or without one a compact band; the places that hold it, what holds there; its text under
@@ -103,28 +105,37 @@ function PlaceAbout({ text, knowers }) {
103
105
  function PlaceBand({ place, fold }) {
104
106
  const text = place.text.trim();
105
107
  const knowers = knowersOf(place.knownBy);
106
- const caption = (_jsxs("div", { class: "place-caption", children: [place.within.length > 0 && (_jsx("ol", { class: "place-path", "aria-label": t("Within"), children: place.within.map((name) => _jsx("li", { children: name }, name)) })), _jsx("h2", { id: "place-name", children: place.name }), place.around.length > 0 && (_jsx("ul", { class: "place-env", "aria-label": t("Around"), children: place.around.map((item) => _jsx(Surrounding, { item: item, name: place.name }, `${"effect" in item ? item.effect : item.name} ${item.place ?? ""}`)) })), fold && text !== "" && _jsx(DescriptionToggle, { open: fold.open, controls: "place-band-text", onToggle: fold.onToggle })] }));
108
+ const link = placeLinks(place);
109
+ const caption = (_jsxs("div", { class: "place-caption", children: [place.within.length > 0 && (_jsx("ol", { class: "place-path", "aria-label": t("Within"), children: place.within.map((name) => _jsx("li", { children: name }, name)) })), _jsx("h2", { id: "place-name", children: place.name }), place.around.length > 0 && (_jsx("ul", { class: "place-env", "aria-label": t("Around"), children: place.around.map((item) => _jsx(Surrounding, { item: item, name: place.name, link: link }, `${"effect" in item ? item.effect : item.name} ${item.place ?? ""}`)) })), fold && text !== "" && _jsx(DescriptionToggle, { open: fold.open, controls: "place-band-text", onToggle: fold.onToggle })] }));
107
110
  return place.image === undefined
108
- ? (_jsxs("header", { class: "place-band compact", children: [_jsxs("div", { class: "place-shot", children: [_jsx("div", { class: "place-disc", children: _jsx(Icon, { name: "house" }) }), caption] }), text !== "" && _jsx(PlaceAbout, { text: text, knowers: knowers })] }))
109
- : (_jsxs("header", { class: fold === undefined ? "place-band over" : `place-band over folding${fold.open ? "" : " low"}`, children: [_jsxs("div", { class: "place-shot", children: [_jsx("figure", { class: "place-image", children: _jsx("img", { src: `/images/${encodeURIComponent(place.image.file)}?v=${place.image.version}`, alt: "" }) }), caption] }), fold === undefined && text !== "" && _jsx(PlaceAbout, { text: text, knowers: knowers }), fold?.open === true && text !== "" && (_jsx("div", { class: "place-about", id: "place-band-text", children: _jsx("div", { class: "place-about-text", children: _jsx(Markdown, { text: text, secretKnowers: knowers }) }) }))] }));
111
+ ? (_jsxs("header", { class: "place-band compact", children: [_jsxs("div", { class: "place-shot", children: [_jsx("div", { class: "place-disc", children: _jsx(Icon, { name: "house" }) }), caption] }), text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers })] }))
112
+ : (_jsxs("header", { class: fold === undefined ? "place-band over" : `place-band over folding${fold.open ? "" : " low"}`, children: [_jsxs("div", { class: "place-shot", children: [_jsx("figure", { class: "place-image", children: _jsx("img", { src: `/images/${encodeURIComponent(place.image.file)}?v=${place.image.version}`, alt: "" }) }), caption] }), fold === undefined && text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers }), fold?.open === true && text !== "" && (_jsx("div", { class: "place-about", id: "place-band-text", children: _jsx("div", { class: "place-about-text", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowers }) }) }))] }));
110
113
  }
111
114
  /**
112
115
  * One thing that holds there: an entry of the environment as its name and value, as light dim, the biome and the terrain the engine reads in the page's language;
113
116
  * an effect with its end; the place it comes from, when another.
114
117
  */
115
- function Surrounding({ item, name }) {
118
+ function Surrounding({ item, name, link }) {
116
119
  const from = item.place === undefined || item.place === name ? undefined : item.place;
117
120
  const entry = "effect" in item ? undefined : environmentLabel(item.name, item.value);
118
121
  // A biome the page draws has its picture, as on the map, for the word before it.
119
122
  const look = "effect" in item || item.name.trim().toLowerCase() !== "biome" ? undefined : item.value.trim().toLowerCase();
120
123
  const biome = look !== undefined && biomes[look] !== undefined ? look : undefined;
121
- return (_jsxs("li", { class: biome === undefined ? undefined : "biome", children: ["effect" in item ? effectLabel({ name: item.effect, end: item.end }) : (_jsxs(_Fragment, { children: [biome !== undefined && _jsx(BiomeSwatch, { look: biome }), entry?.name !== "" && _jsx("span", { class: biome === undefined ? "k" : "visually-hidden", children: entry?.name }), entry?.name !== "" && biome === undefined && " ", entry?.value] })), from && _jsx("span", { class: "from", children: ` · ${from}` })] }));
124
+ return (_jsxs("li", { class: biome === undefined ? undefined : "biome", children: ["effect" in item ? effectLabel({ name: item.effect, end: item.end }) : (_jsxs(_Fragment, { children: [biome !== undefined && _jsx(BiomeSwatch, { look: biome }), entry?.name !== "" && _jsx("span", { class: biome === undefined ? "k" : "visually-hidden", children: entry?.name }), entry?.name !== "" && biome === undefined && " ", entry !== undefined && _jsx(InlineText, { text: entry.value, link: link })] })), from && _jsx("span", { class: "from", children: ` · ${from}` })] }));
122
125
  }
123
126
  /** An entry of a place's environment: the biome and the terrain, which the engine reads, in the page's language; any other as the master wrote it. */
124
127
  function environmentLabel(name, value) {
125
128
  const known = name.trim().toLowerCase();
126
129
  return known === "biome" ? { name: t("biome"), value: biomeLabel(value)?.toLowerCase() ?? value } : known === "terrain" ? { name: "", value: phraseLabel(terrainLabel(value)) } : { name, value };
127
130
  }
131
+ /** Where a link of a place's words leads: the place and those that hold it, which the character knows, to their pages in World; any other stays words. */
132
+ function placeLinks(place) {
133
+ const known = new Map([...place.within, place.name].map((name) => [foldedText(name), name]));
134
+ return (name) => {
135
+ const page = known.get(foldedText(name));
136
+ return page === undefined ? undefined : sectionAddress("world", "lore", page);
137
+ };
138
+ }
128
139
  /** The open scene (D-309): its title, type and since when, who is in it, and the round and whose turn it is when it has them. */
129
140
  function SceneCard({ scene }) {
130
141
  const turn = scene.turn === undefined
@@ -8884,8 +8884,9 @@ svg.icon {
8884
8884
  padding: 14px 18px 16px;
8885
8885
  }
8886
8886
 
8887
- /* The name over the picture, on a dark veil whatever the theme. */
8887
+ /* The name over the picture, on a dark veil whatever the theme: its links and the focus ring in gold, as on the dark page. */
8888
8888
  .place-band.over .place-caption {
8889
+ --accent: var(--gold);
8889
8890
  --muted: var(--on-veil-muted);
8890
8891
  --rule: rgb(255 255 255 / 0.22);
8891
8892
  position: absolute;
@@ -9154,6 +9155,7 @@ svg.icon {
9154
9155
  }
9155
9156
 
9156
9157
  .place-band.over .place-caption {
9158
+ --accent: inherit;
9157
9159
  --muted: inherit;
9158
9160
  --rule: inherit;
9159
9161
  position: static;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rpg-engine",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Play a tabletop role-playing game with an AI as your game master: the AI tells the story; RPG Engine remembers the world, rolls the dice and keeps the accounts.",
5
5
  "type": "module",
6
6
  "bin": {