rpg-engine 0.3.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.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/index.d.ts +1 -1
  3. package/dist/campaign/index.js +1 -1
  4. package/dist/campaign/settings.d.ts +10 -1
  5. package/dist/campaign/settings.js +9 -2
  6. package/dist/command-line.js +6 -1
  7. package/dist/commands/change.d.ts +7 -0
  8. package/dist/commands/change.js +34 -8
  9. package/dist/commands/config.d.ts +1 -1
  10. package/dist/commands/config.js +41 -7
  11. package/dist/commands/game-master-rolls.d.ts +17 -0
  12. package/dist/commands/game-master-rolls.js +36 -0
  13. package/dist/commands/game-mode.js +2 -1
  14. package/dist/commands/game-system-code.js +8 -1
  15. package/dist/commands/game-tables.d.ts +7 -0
  16. package/dist/commands/game-tables.js +40 -0
  17. package/dist/commands/game-upkeep.js +1 -1
  18. package/dist/commands/package.js +5 -3
  19. package/dist/commands/roll.d.ts +4 -0
  20. package/dist/commands/roll.js +73 -18
  21. package/dist/dashboard/i18n/ar.json +6 -0
  22. package/dist/dashboard/i18n/cs.json +6 -0
  23. package/dist/dashboard/i18n/da.json +6 -0
  24. package/dist/dashboard/i18n/de.json +6 -0
  25. package/dist/dashboard/i18n/el.json +6 -0
  26. package/dist/dashboard/i18n/es.json +6 -0
  27. package/dist/dashboard/i18n/fi.json +6 -0
  28. package/dist/dashboard/i18n/fr.json +6 -0
  29. package/dist/dashboard/i18n/he.json +6 -0
  30. package/dist/dashboard/i18n/hi.json +6 -0
  31. package/dist/dashboard/i18n/hu.json +6 -0
  32. package/dist/dashboard/i18n/is.json +6 -0
  33. package/dist/dashboard/i18n/it.json +6 -0
  34. package/dist/dashboard/i18n/ja.json +6 -0
  35. package/dist/dashboard/i18n/ko.json +6 -0
  36. package/dist/dashboard/i18n/nb.json +6 -0
  37. package/dist/dashboard/i18n/nl.json +6 -0
  38. package/dist/dashboard/i18n/pl.json +6 -0
  39. package/dist/dashboard/i18n/pt.json +6 -0
  40. package/dist/dashboard/i18n/ro.json +6 -0
  41. package/dist/dashboard/i18n/ru.json +6 -0
  42. package/dist/dashboard/i18n/sv.json +6 -0
  43. package/dist/dashboard/i18n/tr.json +6 -0
  44. package/dist/dashboard/i18n/uk.json +6 -0
  45. package/dist/dashboard/i18n/zh.json +6 -0
  46. package/dist/dashboard/labels.js +3 -0
  47. package/dist/dashboard/markdown.js +15 -4
  48. package/dist/dashboard/scene.js +21 -10
  49. package/dist/dashboard/settings.js +3 -3
  50. package/dist/dashboard/style.css +3 -1
  51. package/dist/dice/index.d.ts +2 -0
  52. package/dist/dice/index.js +3 -1
  53. package/dist/dice/oracle.d.ts +19 -0
  54. package/dist/dice/oracle.js +22 -0
  55. package/dist/dice/tables.d.ts +29 -0
  56. package/dist/dice/tables.js +123 -0
  57. package/dist/pages/index.d.ts +1 -1
  58. package/dist/pages/index.js +1 -1
  59. package/dist/pages/markdown.d.ts +8 -0
  60. package/dist/pages/markdown.js +27 -0
  61. package/dist/systems/system-code.d.ts +1 -1
  62. package/instructions/combat.md +1 -1
  63. package/instructions/core.md +1 -1
  64. package/instructions/play.md +1 -1
  65. package/package.json +2 -2
  66. package/systems/5e/instructions/play.md +1 -0
@@ -163,6 +163,7 @@
163
163
  "Back up with {value}": "{value} ile ayakta",
164
164
  "Backstory": "Geçmiş hikâyesi",
165
165
  "Before session zero": "Sıfırıncı oturumdan önce",
166
+ "Behind the screen": "Perdenin arkasında",
166
167
  "below {value}": "{value} altındaysa",
167
168
  "Better for {better} and worse for {worse}: they cancel out": "{better} için daha iyi, {worse} için daha kötü: birbirini götürür",
168
169
  "Between scenes": "Sahneler arası",
@@ -362,6 +363,7 @@
362
363
  "Here": "Burası",
363
364
  "hidden": "gizli",
364
365
  "Hidden": "Gizli",
366
+ "hidden: the master tells you only what comes of them": "gizli: oyun yöneticisi sana yalnızca sonucunu söyler",
365
367
  "Hide the panel": "Paneli gizle",
366
368
  "High": "Yüksek",
367
369
  "highest of {count}": "{count} atışın en yükseği",
@@ -414,6 +416,7 @@
414
416
  "In this campaign: the master searches its books.": "Bu kampanyada: oyun yöneticisi kitaplarına başvurur.",
415
417
  "In use": "Kullanımda",
416
418
  "In use · chosen in the setup": "Kullanımda · kurulumda seçilir",
419
+ "In view": "Açıkta",
417
420
  "In your words": "Kendi sözlerinle",
418
421
  "Inn": "Han",
419
422
  "Inscription": "Yazıt",
@@ -492,6 +495,7 @@
492
495
  "Map of {place}": "{place} haritası",
493
496
  "Maps": "Haritalar",
494
497
  "Marble": "Mermer",
498
+ "Master's rolls": "Oyun yöneticisinin atışları",
495
499
  "Master's thinking": "Oyun yöneticisinin düşünceleri",
496
500
  "Medium": "Orta",
497
501
  "Mentor": "Akıl hocası",
@@ -723,6 +727,7 @@
723
727
  "Show on the map": "Haritada göster",
724
728
  "Show the other {count}": "Diğer {count} öğeyi göster",
725
729
  "Show the panel": "Paneli göster",
730
+ "shown among the rolls, beside yours": "atışlar arasında, seninkilerin yanında gösterilir",
726
731
  "Shrine": "Mabet",
727
732
  "Side quest": "Yan görev",
728
733
  "Simulation": "Simülasyon",
@@ -845,6 +850,7 @@
845
850
  "the master teaches it as much as you need": "oyun yöneticisi ihtiyacın kadar öğretir",
846
851
  "the master, always": "oyun yöneticisi, her zaman",
847
852
  "The master's roll:": "Oyun yöneticisinin atışı:",
853
+ "the master's rolls for foes and the characters you meet; yours and your companions' are always in view": "oyun yöneticisinin düşmanlar ve karşılaştığın karakterler için yaptığı atışlar; seninkiler ve yoldaşlarınınkiler her zaman açıkta",
848
854
  "The master's style": "Oyun yöneticisinin üslubu",
849
855
  "The means of production should belong to the people.": "Üretim araçları halka ait olmalı.",
850
856
  "the mirror of {map}": "{map} haritasının aynası",
@@ -163,6 +163,7 @@
163
163
  "Back up with {value}": "На ногах з {value}",
164
164
  "Backstory": "Передісторія",
165
165
  "Before session zero": "Перед нульовою сесією",
166
+ "Behind the screen": "За ширмою",
166
167
  "below {value}": "нижче {value}",
167
168
  "Better for {better} and worse for {worse}: they cancel out": "Краще для {better}, гірше для {worse}: це зводиться нанівець",
168
169
  "Between scenes": "Між сценами",
@@ -362,6 +363,7 @@
362
363
  "Here": "Тут",
363
364
  "hidden": "приховано",
364
365
  "Hidden": "Приховано",
366
+ "hidden: the master tells you only what comes of them": "приховані: майстер каже тобі лише, чим вони закінчилися",
365
367
  "Hide the panel": "Сховати панель",
366
368
  "High": "Найвищі",
367
369
  "highest of {count}": "найвищий з {count}",
@@ -414,6 +416,7 @@
414
416
  "In this campaign: the master searches its books.": "У цій кампанії: майстер шукає в її книгах.",
415
417
  "In use": "Використовується",
416
418
  "In use · chosen in the setup": "Використовується · обирається під час налаштування",
419
+ "In view": "Відкрито",
417
420
  "In your words": "Своїми словами",
418
421
  "Inn": "Корчма",
419
422
  "Inscription": "Напис",
@@ -492,6 +495,7 @@
492
495
  "Map of {place}": "Мапа: {place}",
493
496
  "Maps": "Мапи",
494
497
  "Marble": "Мармур",
498
+ "Master's rolls": "Кидки майстра",
495
499
  "Master's thinking": "Роздуми майстра",
496
500
  "Medium": "Середній",
497
501
  "Mentor": "Наставник",
@@ -723,6 +727,7 @@
723
727
  "Show on the map": "Показати на мапі",
724
728
  "Show the other {count}": "Показати решту ({count})",
725
729
  "Show the panel": "Показати панель",
730
+ "shown among the rolls, beside yours": "показані серед кидків, поруч із твоїми",
726
731
  "Shrine": "Святилище",
727
732
  "Side quest": "Додаткове завдання",
728
733
  "Simulation": "Симуляція",
@@ -845,6 +850,7 @@
845
850
  "the master teaches it as much as you need": "майстер навчає стільки, скільки потрібно",
846
851
  "the master, always": "майстер, завжди",
847
852
  "The master's roll:": "Кидок майстра:",
853
+ "the master's rolls for foes and the characters you meet; yours and your companions' are always in view": "кидки майстра за ворогів і персонажів, яких ти зустрічаєш; твої кидки й кидки супутників завжди видно",
848
854
  "The master's style": "Стиль майстра",
849
855
  "The means of production should belong to the people.": "Засоби виробництва мають належати народові.",
850
856
  "the mirror of {map}": "дзеркало {map}",
@@ -163,6 +163,7 @@
163
163
  "Back up with {value}": "以 {value} 点生命站起",
164
164
  "Backstory": "背景故事",
165
165
  "Before session zero": "零号团之前",
166
+ "Behind the screen": "暗骰",
166
167
  "below {value}": "低于{value}",
167
168
  "Better for {better} and worse for {worse}: they cancel out": "{better}更有利,{worse}更不利:两者相抵",
168
169
  "Between scenes": "场景之间",
@@ -362,6 +363,7 @@
362
363
  "Here": "此处",
363
364
  "hidden": "隐藏",
364
365
  "Hidden": "隐藏",
366
+ "hidden: the master tells you only what comes of them": "隐藏:主持人只告诉你结果",
365
367
  "Hide the panel": "隐藏面板",
366
368
  "High": "最高",
367
369
  "highest of {count}": "{count}个中取最高",
@@ -414,6 +416,7 @@
414
416
  "In this campaign: the master searches its books.": "用于本战役:主持人会查阅其中的书。",
415
417
  "In use": "使用中",
416
418
  "In use · chosen in the setup": "使用中 · 在设置时选定",
419
+ "In view": "明骰",
417
420
  "In your words": "自定义",
418
421
  "Inn": "旅店",
419
422
  "Inscription": "铭文",
@@ -492,6 +495,7 @@
492
495
  "Map of {place}": "{place}的地图",
493
496
  "Maps": "地图",
494
497
  "Marble": "大理石",
498
+ "Master's rolls": "主持人的掷骰",
495
499
  "Master's thinking": "主持人的思考",
496
500
  "Medium": "中等",
497
501
  "Mentor": "导师",
@@ -723,6 +727,7 @@
723
727
  "Show on the map": "在地图上显示",
724
728
  "Show the other {count}": "显示其余 {count} 个",
725
729
  "Show the panel": "显示面板",
730
+ "shown among the rolls, beside yours": "显示在掷骰列表中,与你的并列",
726
731
  "Shrine": "圣祠",
727
732
  "Side quest": "支线任务",
728
733
  "Simulation": "模拟",
@@ -845,6 +850,7 @@
845
850
  "the master teaches it as much as you need": "主持人会按你的需要来教",
846
851
  "the master, always": "始终由主持人",
847
852
  "The master's roll:": "主持人的掷骰:",
853
+ "the master's rolls for foes and the characters you meet; yours and your companions' are always in view": "主持人为敌人和你遇到的角色掷的骰;你和同伴的掷骰始终公开",
848
854
  "The master's style": "主持人的风格",
849
855
  "The means of production should belong to the people.": "生产资料应当属于人民。",
850
856
  "the mirror of {map}": "{map}的镜像",
@@ -192,6 +192,7 @@ export function settingLabel(name) {
192
192
  author: t("Write like"),
193
193
  style: t("In your words"),
194
194
  dice: t("Dice"),
195
+ "master-rolls": t("Master's rolls"),
195
196
  units: t("Units"),
196
197
  voices: t("Character voices"),
197
198
  pictures: t("Pictures"),
@@ -259,6 +260,8 @@ export function valueLabel(value) {
259
260
  master: t("The master"),
260
261
  important: t("Main characters"),
261
262
  always: t("Everyone"),
263
+ "behind the screen": t("Behind the screen"),
264
+ "in view": t("In view"),
262
265
  };
263
266
  return labels[value] ?? itemLabel(value);
264
267
  }
@@ -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
@@ -11,13 +11,13 @@ import { PageHead } from "./pages.js";
11
11
  import { byHandPref, conditionsPref, soundPref, tokenSymbolsPref, useChoice, usePref, usePrefChange } from "./prefs.js";
12
12
  import { arrowStep, t } from "./text.js";
13
13
  import { pickTheme, shownTheme } from "./theme.js";
14
- // The groups of the campaign's settings, in order; a setting the game system adds goes with the dice. How the master plays holds who voices the characters
15
- // (D-490) and how much the master thinks (D-462) too.
14
+ // The groups of the campaign's settings, in order; a setting the game system adds goes with the dice, as whether the master's rolls are shown (D-287). How the
15
+ // master plays holds who voices the characters (D-490) and how much the master thinks (D-462) too.
16
16
  const groups = [
17
17
  { names: ["difficulty", "lethality", "saves", "rigor"] },
18
18
  { names: ["mentor", "learned"] },
19
19
  { names: ["prose", "story", "author", "style", "voices", "effort"] },
20
- { names: ["dice", "units"], system: true },
20
+ { names: ["dice", "master-rolls", "units"], system: true },
21
21
  { names: ["lines", "veils"] },
22
22
  { names: ["pictures", "language"] },
23
23
  ];
@@ -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;
@@ -1,4 +1,6 @@
1
1
  export { DiceError, parseNotation } from "./notation.ts";
2
+ export { askOracle, type OracleAnswer, oracleOdds, oracleResult } from "./oracle.ts";
2
3
  export { createProof, fingerprint, sha256 } from "./proof.ts";
3
4
  export { type DiceRoll, type FaceSource, rollDice, type ThrownDie } from "./roll-dice.ts";
5
+ export { type RandomTable, readRandomTable, rollOnTable, type TableRoll, type TableRow } from "./tables.ts";
4
6
  export { type NotationPart, notationParts } from "./words.ts";
@@ -1,5 +1,7 @@
1
- // Dice for any game: notation, digital or physical faces, proofs for hidden rolls. Depends on nothing else in rpg-engine.
1
+ // Dice for any game: notation, digital or physical faces, proofs for hidden rolls, random tables, a yes/no oracle. Depends on nothing else in rpg-engine.
2
2
  export { DiceError, parseNotation } from "./notation.js";
3
+ export { askOracle, oracleOdds, oracleResult } from "./oracle.js";
3
4
  export { createProof, fingerprint, sha256 } from "./proof.js";
4
5
  export { rollDice } from "./roll-dice.js";
6
+ export { readRandomTable, rollOnTable } from "./tables.js";
5
7
  export { notationParts } from "./words.js";
@@ -0,0 +1,19 @@
1
+ import { type DiceRoll, type FaceSource } from "./roll-dice.ts";
2
+ /** The odds an oracle is asked with, and the chance of a yes in a hundred. */
3
+ export declare const oracleOdds: Record<string, number>;
4
+ /** An oracle's answer: the odds, the d100 rolled, yes or no and whether a double made it extreme, as `Likely (75%): [d100 = 41] Yes.` */
5
+ export interface OracleAnswer {
6
+ odds: string;
7
+ chance: number;
8
+ roll: DiceRoll;
9
+ yes: boolean;
10
+ extreme: boolean;
11
+ text: string;
12
+ }
13
+ /** Asks the oracle with the odds named, in any case, with hyphens for spaces too; refused, with the five odds, for any other. */
14
+ export declare function askOracle(odds: string, source: FaceSource): OracleAnswer;
15
+ /** Yes when the d100 is no higher than the chance; extreme on a double, 11 to 99 and 100 as 00. */
16
+ export declare function oracleResult(chance: number, rolled: number): {
17
+ yes: boolean;
18
+ extreme: boolean;
19
+ };
@@ -0,0 +1,22 @@
1
+ // A yes/no oracle: a d100 against the odds, yes when it is no higher; a double (11, 22, … 00) makes the answer extreme.
2
+ import { DiceError } from "./notation.js";
3
+ import { rollDice } from "./roll-dice.js";
4
+ /** The odds an oracle is asked with, and the chance of a yes in a hundred. */
5
+ export const oracleOdds = { "almost certain": 90, likely: 75, "50/50": 50, unlikely: 25, "small chance": 10 };
6
+ /** Asks the oracle with the odds named, in any case, with hyphens for spaces too; refused, with the five odds, for any other. */
7
+ export function askOracle(odds, source) {
8
+ const name = odds.trim().toLowerCase().replace(/[-\s]+/g, " ");
9
+ const chance = Object.hasOwn(oracleOdds, name) ? oracleOdds[name] : undefined;
10
+ if (chance === undefined) {
11
+ throw new DiceError(`"${odds}" are no odds of the oracle: give one of ${Object.keys(oracleOdds).join(", ")}.`);
12
+ }
13
+ const roll = rollDice("d100", source);
14
+ const { yes, extreme } = oracleResult(chance, roll.total);
15
+ const answer = yes ? (extreme ? "Yes, and more: something beyond what was asked." : "Yes.") : extreme ? "No, and worse." : "No.";
16
+ const shown = `${name[0].toUpperCase()}${name.slice(1)} (${chance}%)`;
17
+ return { odds: name, chance, roll, yes, extreme, text: `${shown}: [d100 = ${roll.total}] ${answer}` };
18
+ }
19
+ /** Yes when the d100 is no higher than the chance; extreme on a double, 11 to 99 and 100 as 00. */
20
+ export function oracleResult(chance, rolled) {
21
+ return { yes: rolled <= chance, extreme: rolled === 100 || (rolled % 11 === 0 && rolled < 100) };
22
+ }
@@ -0,0 +1,29 @@
1
+ import { type DiceRoll, type FaceSource } from "./roll-dice.ts";
2
+ /** A table to roll on: its die, as d8, 2d6, d100 or d66, the results that die can give, and its rows, each for a number or a range of them. */
3
+ export interface RandomTable {
4
+ die: string;
5
+ possible: number[];
6
+ rows: TableRow[];
7
+ }
8
+ /** A row of a table: its first cell as written, such as 1–2, the numbers it covers and the rest of its cells. */
9
+ export interface TableRow {
10
+ label: string;
11
+ low: number;
12
+ high: number;
13
+ text: string;
14
+ }
15
+ /** A roll on a table: its die, the dice thrown, the result read from them and the row it lands on, as `[d8 = 6] 5–6: Un pastore`. */
16
+ export interface TableRoll {
17
+ die: string;
18
+ roll: DiceRoll;
19
+ result: number;
20
+ row: TableRow;
21
+ text: string;
22
+ }
23
+ /**
24
+ * A random table read from its cells, the header first: the die from the first header cell when it is one (d8, 1d8, 2d6, d100, d%, d66), else a single die as
25
+ * big as the highest number of the first column; refused, saying how to fix it, when its rows leave a result out or give one twice.
26
+ */
27
+ export declare function readRandomTable(cells: string[][]): RandomTable;
28
+ /** Rolls a table with the dice of its die, a d66 as two d6 read as tens and units, and gives the row the result lands on. */
29
+ export declare function rollOnTable(table: RandomTable, source: FaceSource): TableRoll;
@@ -0,0 +1,123 @@
1
+ // Random tables: the die a table is rolled with, from its first header cell or its rows, and the row a roll lands on. No game rule: the row is text.
2
+ import { DiceError, parseNotation } from "./notation.js";
3
+ import { rollDice } from "./roll-dice.js";
4
+ const simpleDiePattern = /^(\d*)d(\d+|%)$/i;
5
+ const rangePattern = /^(\d+)(?:\s*[-–—]\s*(\d+))?$/;
6
+ const maxTableResults = 1000;
7
+ /**
8
+ * A random table read from its cells, the header first: the die from the first header cell when it is one (d8, 1d8, 2d6, d100, d%, d66), else a single die as
9
+ * big as the highest number of the first column; refused, saying how to fix it, when its rows leave a result out or give one twice.
10
+ */
11
+ export function readRandomTable(cells) {
12
+ const [header = [], ...body] = cells;
13
+ if (body.length === 0) {
14
+ throw new DiceError("The table has no rows under its header: number each row in the first column, such as | 1–2 | Wolves |.");
15
+ }
16
+ const parsed = body.map((row, index) => readRow(row, index));
17
+ const stated = headerDie(header[0] ?? "");
18
+ const highest = Math.max(...parsed.map((row) => row.high));
19
+ if (stated === undefined && highest > maxTableResults) {
20
+ throw new DiceError(`The table's rows go up to ${highest}, more than a table is rolled with: write its die in the first header cell, such as d100.`);
21
+ }
22
+ const { die, possible } = stated ?? { die: `d${highest}`, possible: numbersFrom(1, highest) };
23
+ checkCoverage(die, possible, parsed, stated !== undefined);
24
+ return { die, possible, rows: parsed };
25
+ }
26
+ /** Rolls a table with the dice of its die, a d66 as two d6 read as tens and units, and gives the row the result lands on. */
27
+ export function rollOnTable(table, source) {
28
+ const roll = rollDice(table.die === "d66" ? "2d6" : table.die, source);
29
+ const result = table.die === "d66" ? roll.faces[0] * 10 + roll.faces[1] : roll.total;
30
+ const row = table.rows.find((candidate) => result >= candidate.low && result <= candidate.high);
31
+ return { die: table.die, roll, result, row, text: `[${table.die} = ${result}] ${row.label}${row.text === "" ? "" : `: ${row.text}`}` };
32
+ }
33
+ /** The die a first header cell names, with the results it gives; undefined when it names none, as Roll or Encounter; refused for a notation no table rolls. */
34
+ function headerDie(cell) {
35
+ const written = plainCell(cell).replace(/\s+/g, "");
36
+ const simple = simpleDiePattern.exec(written);
37
+ if (simple === null) {
38
+ if (isNotation(written)) {
39
+ throw new DiceError(`The table's die "${cell.trim()}" is not a die alone: write one, such as d8, 2d6, d100 or d66, in the first header cell.`);
40
+ }
41
+ return undefined;
42
+ }
43
+ const count = simple[1] === "" ? 1 : Number(simple[1]);
44
+ const sides = simple[2] === "%" ? 100 : Number(simple[2]);
45
+ if (count === 1 && sides === 66) {
46
+ return { die: "d66", possible: [1, 2, 3, 4, 5, 6].flatMap((tens) => numbersFrom(tens * 10 + 1, tens * 10 + 6)) };
47
+ }
48
+ if (count < 1 || sides < 2 || count * sides > maxTableResults) {
49
+ throw new DiceError(`A table cannot be rolled with ${written}: write a die such as d8, 2d6 or d100 in the first header cell.`);
50
+ }
51
+ return { die: `${count === 1 ? "" : count}d${sides}`, possible: numbersFrom(count, count * sides) };
52
+ }
53
+ /** A row's numbers from its first cell, 3 or a range such as 1–2 or 01-05, with 00 as 100; the rest of its cells are its text. */
54
+ function readRow(row, index) {
55
+ const label = (row[0] ?? "").trim();
56
+ const match = rangePattern.exec(plainCell(label));
57
+ if (match === null) {
58
+ throw new DiceError(`The first cell of row ${index + 1}, "${label}", is no number nor range such as 3 or 1–2: number every row of the table in its first column.`);
59
+ }
60
+ const low = rowNumber(match[1]);
61
+ const high = match[2] === undefined ? low : rowNumber(match[2]);
62
+ if (high < low) {
63
+ throw new DiceError(`Row "${label}" goes down: write the lower number first, such as 1–2.`);
64
+ }
65
+ const text = row.slice(1).map((cell) => cell.trim()).filter((cell) => cell !== "").join(" · ");
66
+ return { label, low, high, text };
67
+ }
68
+ /** Refuses rows with a number the die cannot roll, a result no row gives, or one that two rows give. */
69
+ function checkCoverage(die, possible, rows, stated) {
70
+ const orDie = stated ? "" : ", or write the table's die in its first header cell, such as d10";
71
+ const counts = new Map(possible.map((value) => [value, 0]));
72
+ for (const row of rows) {
73
+ const outside = [row.low, row.high].find((value) => !counts.has(value));
74
+ if (outside !== undefined) {
75
+ throw new DiceError(`Row "${row.label}" holds ${outside}, which a ${die} cannot roll: number the rows from ${possible[0]} to ${possible.at(-1)}${orDie}.`);
76
+ }
77
+ for (const value of possible.filter((candidate) => candidate >= row.low && candidate <= row.high)) {
78
+ counts.set(value, (counts.get(value) ?? 0) + 1);
79
+ }
80
+ }
81
+ const missing = possible.filter((value) => counts.get(value) === 0);
82
+ const twice = possible.filter((value) => (counts.get(value) ?? 0) > 1);
83
+ if (missing.length > 0) {
84
+ throw new DiceError(`The table's rows leave out ${rangesText(possible, missing)} of the ${die}: give every result a row, such as | 3–4 | Merchants |.`);
85
+ }
86
+ if (twice.length > 0) {
87
+ throw new DiceError(`The table's rows give ${rangesText(possible, twice)} of the ${die} more than once: give every result one row only.`);
88
+ }
89
+ }
90
+ /** "3–4, 7": numbers that follow one another among the possible results, as ranges. */
91
+ function rangesText(possible, values) {
92
+ const ranges = [];
93
+ for (const value of values) {
94
+ const last = ranges.at(-1);
95
+ if (last !== undefined && possible.indexOf(value) === possible.indexOf(last[last.length - 1]) + 1) {
96
+ last.push(value);
97
+ }
98
+ else {
99
+ ranges.push([value]);
100
+ }
101
+ }
102
+ return ranges.map((range) => (range.length === 1 ? String(range[0]) : `${range[0]}–${range[range.length - 1]}`)).join(", ");
103
+ }
104
+ /** A number of a row: 00 is 100, as on a d100. */
105
+ function rowNumber(digits) {
106
+ return /^00$/.test(digits) ? 100 : Number(digits);
107
+ }
108
+ /** A cell without the marks of bold or italics, as **1–2**. */
109
+ function plainCell(cell) {
110
+ return cell.replace(/[*_]/g, "").trim();
111
+ }
112
+ function isNotation(text) {
113
+ try {
114
+ parseNotation(text);
115
+ return /d/i.test(text);
116
+ }
117
+ catch {
118
+ return false;
119
+ }
120
+ }
121
+ function numbersFrom(low, high) {
122
+ return Array.from({ length: Math.max(0, high - low + 1) }, (_, index) => low + index);
123
+ }
@@ -4,7 +4,7 @@ export { changedEnvironment, environmentAt, type EnvironmentEntry, formatEnviron
4
4
  export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, type Inherited, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.ts";
5
5
  export { carriedWeight, type LoadRule, weightUnit } from "./load.ts";
6
6
  export { type MapField, mapHelp, readMapField } from "./maps.ts";
7
- export { everyGoalTicked, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.ts";
7
+ export { everyGoalTicked, firstTable, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.ts";
8
8
  export { changedFields, type FieldChange, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.ts";
9
9
  export { type PageType, pageTypeNames, worldFolderName } from "./page-types.ts";
10
10
  export { formatPosition, type Position, positionHelp, readPosition } from "./positions.ts";
@@ -5,7 +5,7 @@ export { changedEnvironment, environmentAt, formatEnvironmentEntry, placesAround
5
5
  export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.js";
6
6
  export { carriedWeight, weightUnit } from "./load.js";
7
7
  export { mapHelp, readMapField } from "./maps.js";
8
- export { everyGoalTicked, goalsIn, introductionText, links, partContent, readSection, secretNames, sectionTitles, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.js";
8
+ export { everyGoalTicked, firstTable, goalsIn, introductionText, links, partContent, readSection, secretNames, sectionTitles, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.js";
9
9
  export { changedFields, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.js";
10
10
  export { pageTypeNames, worldFolderName } from "./page-types.js";
11
11
  export { formatPosition, positionHelp, readPosition } from "./positions.js";
@@ -62,5 +62,13 @@ export declare function goalsIn(text: string): {
62
62
  export declare function withLinksAsWords(text: string, keep: (link: Link) => boolean): string;
63
63
  /** A text without its fenced blocks, as a map or code, which say nothing as prose. */
64
64
  export declare function withoutFencedBlocks(text: string): string;
65
+ /**
66
+ * The cells of the first table of a text, outside code, its header row first and without the row of dashes under it; in a quote or a secret too. A link
67
+ * written [[Page\|words]], as tables need, has its | back; whether it stands in a secret block. Undefined when the text has no table.
68
+ */
69
+ export declare function firstTable(text: string): {
70
+ rows: string[][];
71
+ secret: boolean;
72
+ } | undefined;
65
73
  /** Whether a text lists goals as checkboxes, outside code blocks, and every one is ticked. */
66
74
  export declare function everyGoalTicked(text: string): boolean;