rpg-engine 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/settings.d.ts +1 -0
  3. package/dist/campaign/settings.js +6 -5
  4. package/dist/command-line.js +12 -5
  5. package/dist/commands/advance.js +1 -1
  6. package/dist/commands/ask.d.ts +37 -2
  7. package/dist/commands/ask.js +106 -35
  8. package/dist/commands/change.js +28 -17
  9. package/dist/commands/config.d.ts +1 -1
  10. package/dist/commands/config.js +69 -21
  11. package/dist/commands/effect.js +42 -23
  12. package/dist/commands/find.js +1 -1
  13. package/dist/commands/game-adventures.js +2 -2
  14. package/dist/commands/game-catalog.d.ts +13 -0
  15. package/dist/commands/game-catalog.js +26 -2
  16. package/dist/commands/game-checks.js +23 -21
  17. package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
  18. package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
  19. package/dist/commands/game-effects.d.ts +12 -4
  20. package/dist/commands/game-effects.js +21 -13
  21. package/dist/commands/game-examples.d.ts +22 -0
  22. package/dist/commands/game-examples.js +72 -0
  23. package/dist/commands/game-extension-list.d.ts +31 -3
  24. package/dist/commands/game-extension-list.js +94 -6
  25. package/dist/commands/game-images.d.ts +1 -1
  26. package/dist/commands/game-images.js +3 -2
  27. package/dist/commands/game-library.d.ts +3 -0
  28. package/dist/commands/game-library.js +2 -2
  29. package/dist/commands/game-mode.js +1 -1
  30. package/dist/commands/game-package-code.d.ts +87 -0
  31. package/dist/commands/game-package-code.js +648 -0
  32. package/dist/commands/game-package-hooks.d.ts +37 -0
  33. package/dist/commands/game-package-hooks.js +116 -0
  34. package/dist/commands/game-recipes.js +2 -2
  35. package/dist/commands/game-reminders.d.ts +5 -2
  36. package/dist/commands/game-reminders.js +7 -4
  37. package/dist/commands/game-rules.d.ts +4 -1
  38. package/dist/commands/game-rules.js +7 -1
  39. package/dist/commands/game-upkeep.js +3 -3
  40. package/dist/commands/game-view-place.d.ts +8 -20
  41. package/dist/commands/game-view-place.js +16 -35
  42. package/dist/commands/game-widgets.d.ts +42 -8
  43. package/dist/commands/game-widgets.js +182 -31
  44. package/dist/commands/game-world.d.ts +32 -3
  45. package/dist/commands/game-world.js +113 -24
  46. package/dist/commands/image.js +1 -1
  47. package/dist/commands/init.js +2 -2
  48. package/dist/commands/mode.d.ts +1 -1
  49. package/dist/commands/package.d.ts +15 -1
  50. package/dist/commands/package.js +96 -24
  51. package/dist/commands/progression.d.ts +2 -0
  52. package/dist/commands/progression.js +7 -2
  53. package/dist/commands/roll.d.ts +2 -0
  54. package/dist/commands/roll.js +50 -24
  55. package/dist/commands/rules.js +6 -4
  56. package/dist/commands/scene.d.ts +2 -2
  57. package/dist/commands/scene.js +13 -10
  58. package/dist/commands/sheet.js +10 -1
  59. package/dist/commands/status.d.ts +1 -0
  60. package/dist/commands/status.js +14 -4
  61. package/dist/commands/trade.js +6 -4
  62. package/dist/commands/translate.js +2 -2
  63. package/dist/commands/travel.js +1 -1
  64. package/dist/commands/validate.js +2 -2
  65. package/dist/commands/view.d.ts +12 -4
  66. package/dist/commands/view.js +11 -8
  67. package/dist/commands/worked-out.js +11 -5
  68. package/dist/commands/write.d.ts +8 -1
  69. package/dist/commands/write.js +84 -25
  70. package/dist/core/command-reference.js +3 -2
  71. package/dist/core/consents.d.ts +18 -0
  72. package/dist/core/consents.js +93 -0
  73. package/dist/core/context.d.ts +68 -27
  74. package/dist/core/context.js +3 -1
  75. package/dist/core/examples.d.ts +25 -0
  76. package/dist/core/examples.js +19 -0
  77. package/dist/core/files.d.ts +2 -0
  78. package/dist/core/files.js +10 -1
  79. package/dist/core/package-api.d.ts +388 -0
  80. package/dist/core/package-declarations.d.ts +102 -0
  81. package/dist/core/package-declarations.js +81 -0
  82. package/dist/core/registry.d.ts +4 -0
  83. package/dist/core/text.d.ts +5 -0
  84. package/dist/core/text.js +12 -0
  85. package/dist/dashboard/acts.js +31 -24
  86. package/dist/dashboard/address.js +4 -1
  87. package/dist/dashboard/api.js +65 -3
  88. package/dist/dashboard/app.js +222 -98
  89. package/dist/dashboard/ask-card.js +169 -0
  90. package/dist/dashboard/asked-dice.js +57 -0
  91. package/dist/dashboard/dice/tray.js +6 -4
  92. package/dist/dashboard/extension-widgets.js +136 -16
  93. package/dist/dashboard/faces.js +6 -4
  94. package/dist/dashboard/help.js +10 -3
  95. package/dist/dashboard/i18n/ar.json +34 -29
  96. package/dist/dashboard/i18n/cs.json +34 -29
  97. package/dist/dashboard/i18n/da.json +34 -29
  98. package/dist/dashboard/i18n/de.json +34 -29
  99. package/dist/dashboard/i18n/el.json +34 -29
  100. package/dist/dashboard/i18n/es.json +34 -29
  101. package/dist/dashboard/i18n/fi.json +34 -29
  102. package/dist/dashboard/i18n/fr.json +34 -29
  103. package/dist/dashboard/i18n/he.json +34 -29
  104. package/dist/dashboard/i18n/hi.json +34 -29
  105. package/dist/dashboard/i18n/hu.json +34 -29
  106. package/dist/dashboard/i18n/is.json +34 -29
  107. package/dist/dashboard/i18n/it.json +34 -29
  108. package/dist/dashboard/i18n/ja.json +34 -29
  109. package/dist/dashboard/i18n/ko.json +34 -29
  110. package/dist/dashboard/i18n/nb.json +34 -29
  111. package/dist/dashboard/i18n/nl.json +34 -29
  112. package/dist/dashboard/i18n/pl.json +34 -29
  113. package/dist/dashboard/i18n/pt.json +34 -29
  114. package/dist/dashboard/i18n/ro.json +34 -29
  115. package/dist/dashboard/i18n/ru.json +34 -29
  116. package/dist/dashboard/i18n/sv.json +34 -29
  117. package/dist/dashboard/i18n/tr.json +34 -29
  118. package/dist/dashboard/i18n/uk.json +34 -29
  119. package/dist/dashboard/i18n/zh.json +34 -29
  120. package/dist/dashboard/icons.js +4 -1
  121. package/dist/dashboard/kit.js +35 -0
  122. package/dist/dashboard/labels.js +1 -0
  123. package/dist/dashboard/pack-card.js +97 -0
  124. package/dist/dashboard/package-page.js +50 -0
  125. package/dist/dashboard/packages.js +180 -24
  126. package/dist/dashboard/page-code.js +248 -0
  127. package/dist/dashboard/party.js +13 -14
  128. package/dist/dashboard/people.js +4 -0
  129. package/dist/dashboard/person-panel.js +110 -0
  130. package/dist/dashboard/place-map-view.js +11 -6
  131. package/dist/dashboard/rolls.js +2 -2
  132. package/dist/dashboard/scene.js +12 -9
  133. package/dist/dashboard/settings.js +55 -9
  134. package/dist/dashboard/sheet.js +21 -13
  135. package/dist/dashboard/status.js +69 -15
  136. package/dist/dashboard/style.css +859 -574
  137. package/dist/dashboard/top.js +75 -25
  138. package/dist/dashboard/turns.js +34 -13
  139. package/dist/dashboard/widgets.js +9 -2
  140. package/dist/dashboard-server.js +246 -11
  141. package/dist/dice/roll-dice.js +1 -1
  142. package/dist/effects/effect.d.ts +7 -4
  143. package/dist/effects/effect.js +12 -9
  144. package/dist/extensions/engine.d.ts +4 -0
  145. package/dist/extensions/engine.js +74 -0
  146. package/dist/extensions/extension.d.ts +28 -33
  147. package/dist/extensions/extension.js +37 -46
  148. package/dist/extensions/index.d.ts +4 -3
  149. package/dist/extensions/index.js +5 -2
  150. package/dist/extensions/packages.d.ts +14 -0
  151. package/dist/extensions/packages.js +148 -12
  152. package/dist/extensions/words.d.ts +2 -1
  153. package/dist/extensions/words.js +5 -4
  154. package/dist/index.d.ts +1 -3
  155. package/dist/mcp-server.js +52 -15
  156. package/dist/page-words.d.ts +4 -0
  157. package/dist/page-words.js +4 -4
  158. package/dist/page.d.ts +218 -0
  159. package/dist/page.js +2 -0
  160. package/dist/pages/index.d.ts +1 -1
  161. package/dist/pages/index.js +1 -1
  162. package/dist/pages/load.d.ts +7 -1
  163. package/dist/pages/load.js +10 -5
  164. package/dist/pages/page-file.js +1 -1
  165. package/dist/pages/stack-writes.js +5 -4
  166. package/dist/pages/standard-fields.d.ts +2 -0
  167. package/dist/pages/standard-fields.js +8 -1
  168. package/dist/pages/world.d.ts +8 -0
  169. package/dist/pages/world.js +9 -2
  170. package/dist/systems/game-system.d.ts +61 -30
  171. package/dist/systems/game-system.js +159 -50
  172. package/dist/systems/index.d.ts +3 -3
  173. package/dist/systems/index.js +3 -3
  174. package/dist/systems/system-code.d.ts +29 -88
  175. package/dist/systems/system-code.js +68 -23
  176. package/dist/systems/words.d.ts +2 -0
  177. package/dist/systems/words.js +11 -0
  178. package/dist/testing.d.ts +76 -0
  179. package/dist/testing.js +197 -0
  180. package/instructions/combat.md +2 -2
  181. package/instructions/core.md +2 -2
  182. package/instructions/dashboard.md +1 -1
  183. package/instructions/mentor-tutorial.md +1 -1
  184. package/instructions/play.md +2 -2
  185. package/instructions/setup.md +1 -1
  186. package/package.json +15 -2
  187. package/systems/5e/LICENSE.md +13 -3
  188. package/systems/5e/dist/dying.js +83 -16
  189. package/systems/5e/dist/index.js +2 -2
  190. package/systems/5e/dist/page-style.js +634 -0
  191. package/systems/5e/dist/page.js +166 -0
  192. package/systems/5e/dist/shown.js +23 -0
  193. package/systems/5e/instructions/combat.md +1 -0
  194. package/systems/5e/package.json +4 -2
  195. package/systems/5e/system.yaml +35 -7
  196. package/systems/5e/versions/srd-5.1/system.yaml +2 -0
  197. package/systems/5e/words/ar.yaml +30 -0
  198. package/systems/5e/words/cs.yaml +30 -0
  199. package/systems/5e/words/da.yaml +30 -0
  200. package/systems/5e/words/de.yaml +30 -0
  201. package/systems/5e/words/el.yaml +30 -0
  202. package/systems/5e/words/es.yaml +30 -0
  203. package/systems/5e/words/fi.yaml +30 -0
  204. package/systems/5e/words/fr.yaml +30 -0
  205. package/systems/5e/words/he.yaml +30 -0
  206. package/systems/5e/words/hi.yaml +30 -0
  207. package/systems/5e/words/hu.yaml +30 -0
  208. package/systems/5e/words/is.yaml +30 -0
  209. package/systems/5e/words/it.yaml +30 -0
  210. package/systems/5e/words/ja.yaml +30 -0
  211. package/systems/5e/words/ko.yaml +30 -0
  212. package/systems/5e/words/nb.yaml +30 -0
  213. package/systems/5e/words/nl.yaml +30 -0
  214. package/systems/5e/words/pl.yaml +30 -0
  215. package/systems/5e/words/pt.yaml +30 -0
  216. package/systems/5e/words/ro.yaml +30 -0
  217. package/systems/5e/words/ru.yaml +30 -0
  218. package/systems/5e/words/sv.yaml +30 -0
  219. package/systems/5e/words/tr.yaml +30 -0
  220. package/systems/5e/words/uk.yaml +30 -0
  221. package/systems/5e/words/zh.yaml +30 -0
  222. package/dist/commands/game-extensions.d.ts +0 -34
  223. package/dist/commands/game-extensions.js +0 -182
  224. package/dist/commands/game-system-code.d.ts +0 -25
  225. package/dist/commands/game-system-code.js +0 -172
  226. package/dist/dashboard/death-save.js +0 -67
  227. package/dist/dashboard/dying.js +0 -46
  228. package/dist/dashboard/save-outcome.js +0 -42
  229. package/dist/dashboard/spend.js +0 -115
  230. package/dist/extensions/api.d.ts +0 -155
  231. /package/dist/{extensions/api.js → core/package-api.js} +0 -0
@@ -1,10 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ // The page's top (D-276, D-293, D-333): the master large, the campaign's name with the product's and the system's below it, and as chips the game's time and
3
+ // whether the game is live; under the name the sections, then the saves, the settings and About at the row's end, what does not fit in a menu there; under them
4
+ // all, where the party is. It stays on top: down the page it draws itself together, the master and the name smaller, the product and the place folded away,
5
+ // the sections still there (D-295); what the master asks and the rolls stay in sight under it. The robot shows the master's mood, a moment's face, and sleeps
6
+ // while the chat is away (D-305). On a phone the sections at the bottom, the rest in the menu (D-309).
7
+ import { Fragment } from "preact";
2
8
  import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
3
- import { menuPages, sectionAddress, sectionLabel, sections } from "./address.js";
4
- import { WidgetChips } from "./extension-widgets.js";
9
+ import { menuPages, packagePages, sectionAddress, sectionLabel, sections } from "./address.js";
10
+ import { Drawn, WidgetChips } from "./extension-widgets.js";
5
11
  import { calendarDayLabel, gameDateLabel } from "./game-words.js";
6
12
  import { Icon } from "./icons.js";
7
13
  import { Master } from "./master.js";
14
+ import { ownKey } from "./page-code.js";
8
15
  import { usePrefChange } from "./prefs.js";
9
16
  import { t } from "./text.js";
10
17
  import { pickTheme, shownTheme } from "./theme.js";
@@ -23,25 +30,60 @@ export function Top(top) {
23
30
  setPoke({ id: String(Date.now()), mood: pokedMoods[Date.now() % pokedMoods.length] ?? "happy" });
24
31
  };
25
32
  const title = top.campaign ?? top.product;
26
- return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: room, class: "top-room", children: [_jsx("span", { class: "top-mark far", "aria-hidden": "true" }), _jsx("span", { class: "top-mark near", "aria-hidden": "true" })] }), _jsxs("header", { ref: header, class: compact ? "top compact" : "top", children: [_jsx(MasterHome, { top: top, poke: poke, onHome: home }), _jsxs("div", { class: "titles", children: [_jsx("h1", { children: _jsx("a", { class: "title-home", href: sectionAddress("party"), onClick: home, children: title }) }), top.campaign !== undefined && (_jsxs("p", { class: "product", children: [top.product, top.system && _jsx("span", { class: "system-chip", children: top.system })] }))] }), _jsx(StatusChips, { now: top.now, calendar: top.calendar, live: top.live }), _jsx(Navigation, { current: top.section, fight: top.fight, yourTurn: top.yourTurn, turnName: top.turnName }), top.path !== undefined && top.path.length > 0 && _jsx(PlacePath, { path: top.path })] }), _jsx(ThemeCorner, {})] }));
33
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: room, class: "top-room", children: [_jsx("span", { class: "top-mark far", "aria-hidden": "true" }), _jsx("span", { class: "top-mark near", "aria-hidden": "true" })] }), _jsxs("header", { ref: header, class: compact ? "top compact" : "top", children: [_jsx(MasterHome, { top: top, poke: poke, onHome: home }), _jsxs("div", { class: "titles", children: [_jsx("h1", { children: _jsx("a", { class: "title-home", href: sectionAddress("party"), onClick: home, children: title }) }), top.campaign !== undefined && (_jsxs("p", { class: "product", children: [top.product, top.system && _jsx("span", { class: "system-chip", children: top.system })] }))] }), _jsx(StatusChips, { now: top.now, calendar: top.calendar, live: top.live }), _jsx(Navigation, { current: top.section, fight: top.fight, yourTurn: top.yourTurn, turnName: top.turnName, ownPages: top.ownPages ?? [], ownShown: top.ownShown }), top.path !== undefined && top.path.length > 0 && _jsx(PlacePath, { path: top.path })] }), _jsx(ThemeCorner, {})] }));
27
34
  }
28
35
  /**
29
- * The sections, each a link to its address (D-276, D-309), the one shown marked, then the saves, Help, the settings and About as icons at the row's end (D-333, D-409): what does not
30
- * fit goes into the menu, those three first, then the sections from the last.
36
+ * The sections, each a link to its address (D-276, D-309), the one shown marked, then the packages' pages that are tabs (D-512); then the saves, Help, the
37
+ * settings, the packages and About as icons at the row's end (D-333, D-409), the packages a menu of the packages' other pages when they have some: what does
38
+ * not fit goes into the menu, those icons first, then the tabs from the last.
31
39
  */
32
- function Navigation({ current, fight, yourTurn, turnName }) {
40
+ function Navigation({ current, fight, yourTurn, turnName, ownPages, ownShown }) {
33
41
  // While the scene goes by turns the Scene's name is in gold; on the player's turn, from another section, it pulses (D-315, D-349, D-351, D-444).
34
- const shown = [...sections];
35
42
  const turns = fight === true && current !== "scene";
36
43
  const turn = yourTurn === true && current !== "scene";
44
+ const tabs = [...sections.map((section) => sectionTab(section, current)), ...ownPages.filter((page) => page.nav === "tab").map((page) => ownTab(page, ownShown))];
45
+ const inMenu = ownPages.filter((page) => page.nav === "menu");
37
46
  const row = useRef(null);
38
- const fitting = useFitting(row, shown.length, `${shown.join()} ${turn}`);
39
- const away = [...shown.slice(fitting.sections), ...(fitting.pages ? [] : menuPages)];
40
- return (_jsxs("div", { ref: row, class: "nav-row", children: [_jsx("nav", { class: "sections main-nav", "aria-label": t("Sections"), children: [...shown, ...menuPages].map((section, index) => {
41
- const gone = away.includes(section);
42
- const kinds = [section === "scene" && turns ? (turn ? "your-turn" : "in-turns") : "", index === shown.length ? "pages-start" : "", index >= shown.length ? "page-link tip-below" : "", gone ? "away" : ""];
43
- return (_jsxs("a", { href: sectionAddress(section), class: kinds.filter((kind) => kind !== "").join(" ") || undefined, "aria-label": index >= shown.length ? sectionLabel(section) : undefined, "data-tip": index >= shown.length ? sectionLabel(section) : undefined, "aria-current": section === current ? "page" : undefined, "aria-hidden": gone ? true : undefined, tabIndex: gone ? -1 : undefined, children: [_jsx("span", { class: "section-mark", children: _jsx(Icon, { name: section }) }), index < shown.length && sectionLabel(section), section === "scene" && turn && _jsx("span", { class: "visually-hidden", children: `, ${turnName === undefined ? t("your turn") : t("It's {name}'s turn", { name: turnName })}` })] }, section));
44
- }) }), _jsx(Menu, { current: current, away: away })] }));
47
+ const fitting = useFitting(row, tabs.length, `${tabs.map((tab) => tab.key).join()} ${turn} ${inMenu.length}`);
48
+ const awayTabs = tabs.slice(fitting.sections);
49
+ const awayPages = fitting.pages ? [] : menuPages;
50
+ return (_jsxs("div", { ref: row, class: "nav-row", children: [_jsxs("nav", { class: "sections main-nav", "aria-label": t("Sections"), children: [tabs.map((tab) => {
51
+ const gone = awayTabs.includes(tab);
52
+ const kinds = [tab.key === "scene" && turns ? (turn ? "your-turn" : "in-turns") : "", tab.own ? "own-tab" : "", gone ? "away" : ""];
53
+ return (_jsxs("a", { href: tab.href, class: kinds.filter((kind) => kind !== "").join(" ") || undefined, "aria-current": tab.current ? "page" : undefined, "aria-hidden": gone ? true : undefined, tabIndex: gone ? -1 : undefined, children: [_jsx("span", { class: "section-mark", children: tab.icon }), _jsx("span", { class: "section-name", dir: "auto", children: tab.label }), tab.key === "scene" && turn && _jsx("span", { class: "visually-hidden", children: `, ${turnName === undefined ? t("your turn") : t("It's {name}'s turn", { name: turnName })}` })] }, tab.key));
54
+ }), menuPages.map((page, index) => {
55
+ const gone = !fitting.pages;
56
+ const kinds = ["page-link tip-below", index === 0 ? "pages-start" : "", gone ? "away" : ""].filter((kind) => kind !== "").join(" ");
57
+ return page === "packages" && inMenu.length > 0
58
+ ? _jsx(PackagesMenu, { pages: inMenu, current: current, ownShown: ownShown, kinds: kinds, gone: gone }, page)
59
+ : (_jsx("a", { href: sectionAddress(page), class: kinds, "aria-label": sectionLabel(page), "data-tip": sectionLabel(page), "aria-current": page === current ? "page" : undefined, "aria-hidden": gone ? true : undefined, tabIndex: gone ? -1 : undefined, children: _jsx("span", { class: "section-mark", children: _jsx(Icon, { name: page }) }) }, page));
60
+ })] }), _jsx(Menu, { current: current, awayTabs: awayTabs, awayPages: awayPages, ownMenu: inMenu, ownShown: ownShown })] }));
61
+ }
62
+ function sectionTab(section, current) {
63
+ return { key: section, href: sectionAddress(section), label: sectionLabel(section), icon: _jsx(Icon, { name: section }), current: section === current, own: false };
64
+ }
65
+ function ownTab(page, shown) {
66
+ const key = ownKey(page);
67
+ return { key, href: sectionAddress(packagePages, page.package, page.name), label: page.title, icon: ownIcon(page), current: key === shown, own: true };
68
+ }
69
+ function ownIcon(page) {
70
+ return page.icon === undefined ? _jsx(Icon, { name: "packages" }) : _jsx(Drawn, { path: page.icon, kind: "icon" });
71
+ }
72
+ /**
73
+ * The packages' icon as a menu (D-512), when their pages that are no tabs are some: those pages by their titles, then Packages, where packages are added and
74
+ * taken away. Lit while one of them, or Packages, is shown.
75
+ */
76
+ function PackagesMenu({ pages, current, ownShown, kinds, gone }) {
77
+ const [open, setOpen] = useState(false);
78
+ const holder = useRef(null);
79
+ const shown = current === "packages" || pages.some((page) => ownKey(page) === ownShown);
80
+ const label = t("Menu: {pages}", { pages: listOf([...pages.map((page) => page.title), sectionLabel("packages")]) });
81
+ useClosing(holder, open, setOpen);
82
+ return (_jsxs("div", { ref: holder, class: `packages-menu ${kinds}`, "aria-hidden": gone ? true : undefined, children: [_jsx("button", { type: "button", class: shown ? "packages-menu-button shown" : "packages-menu-button", "aria-label": label, "data-tip": label, "aria-expanded": open, tabIndex: gone ? -1 : undefined, onClick: () => setOpen(!open), children: _jsx("span", { class: "section-mark", children: _jsx(Icon, { name: "packages" }) }) }), open && (_jsxs("div", { class: "menu-pop", children: [_jsx(OwnPageLinks, { pages: pages, ownShown: ownShown, onPick: () => setOpen(false) }), _jsxs("a", { class: "menu-manage", href: sectionAddress("packages"), "aria-current": current === "packages" ? "page" : undefined, onClick: () => setOpen(false), children: [_jsx(Icon, { name: "packages" }), sectionLabel("packages")] })] }))] }));
83
+ }
84
+ /** The packages' pages as links of a menu, each its icon and title. */
85
+ function OwnPageLinks({ pages, ownShown, onPick }) {
86
+ return (_jsx(_Fragment, { children: pages.map((page) => (_jsxs("a", { href: sectionAddress(packagePages, page.package, page.name), "aria-current": ownKey(page) === ownShown ? "page" : undefined, dir: "auto", onClick: onPick, children: [ownIcon(page), page.title] }, ownKey(page)))) }));
45
87
  }
46
88
  /**
47
89
  * Whether the top is drawn together, down the page: two marks in its room, one this far down and one near the very top, tell it, with no work while the page
@@ -96,7 +138,7 @@ function useFitting(row, count, shape) {
96
138
  }
97
139
  // Every link stays in the row, what does not fit unseen, so that each can be measured.
98
140
  const measure = () => {
99
- const widths = [...element.querySelectorAll("nav > a")].map((link) => link.offsetWidth + linkGap);
141
+ const widths = [...element.querySelectorAll("nav > a, nav > .packages-menu")].map((link) => link.offsetWidth + linkGap);
100
142
  const total = (from, to) => widths.slice(from, to).reduce((sum, width) => sum + width, 0);
101
143
  const room = element.clientWidth;
102
144
  const left = phone.matches ? Infinity : room - menuRoom;
@@ -115,12 +157,23 @@ function useFitting(row, count, shape) {
115
157
  }, [count, shape]);
116
158
  return fitting;
117
159
  }
118
- /** The menu (D-309, D-333): what does not fit in the row, and on a phone the theme too, which has no switch of its own there; none when all fits. */
119
- function Menu({ current, away }) {
160
+ /**
161
+ * The menu (D-309, D-333): what does not fit in the row, the tabs and the pages at its end, the packages' pages that are no tabs after Packages (D-512); on a
162
+ * phone the theme too, which has no switch of its own there; none when all fits.
163
+ */
164
+ function Menu({ current, awayTabs, awayPages, ownMenu, ownShown }) {
120
165
  const [open, setOpen] = useState(false);
121
166
  const holder = useRef(null);
122
167
  const [theme, flip] = useTheme();
123
- // A touch outside or Escape closes it.
168
+ useClosing(holder, open, setOpen);
169
+ if (awayTabs.length + awayPages.length === 0) {
170
+ return null;
171
+ }
172
+ const names = listOf([...awayTabs.map((tab) => tab.label), ...awayPages.map(sectionLabel)]);
173
+ return (_jsxs("div", { class: "menu", ref: holder, children: [_jsx("button", { type: "button", class: "icon-button tonal menu-button tip-left", "aria-label": t("Menu: {pages}", { pages: names }), "data-tip": t("Menu: {pages}", { pages: names }), "aria-expanded": open, onClick: () => setOpen(!open), children: _jsx(Icon, { name: "menu" }) }), open && (_jsxs("div", { class: "menu-pop", children: [awayTabs.map((tab) => (_jsxs("a", { href: tab.href, "aria-current": tab.current ? "page" : undefined, dir: "auto", onClick: () => setOpen(false), children: [tab.icon, tab.label] }, tab.key))), awayPages.map((page) => (_jsxs(Fragment, { children: [_jsxs("a", { href: sectionAddress(page), "aria-current": page === current ? "page" : undefined, onClick: () => setOpen(false), children: [_jsx(Icon, { name: page }), sectionLabel(page)] }), page === "packages" && ownMenu.length > 0 && (_jsx("div", { class: "menu-sub", children: _jsx(OwnPageLinks, { pages: ownMenu, ownShown: ownShown, onPick: () => setOpen(false) }) }))] }, page))), _jsxs("button", { type: "button", class: "menu-theme", onClick: flip, children: [_jsx(Icon, { name: theme.next === "dark" ? "moon" : "sun" }), theme.name] })] }))] }));
174
+ }
175
+ /** A touch outside an open menu, or Escape, closes it; Escape gives the focus back to its button. */
176
+ function useClosing(holder, open, setOpen) {
124
177
  useEffect(() => {
125
178
  if (!open) {
126
179
  return;
@@ -133,6 +186,7 @@ function Menu({ current, away }) {
133
186
  const escape = (event) => {
134
187
  if (event.key === "Escape") {
135
188
  setOpen(false);
189
+ holder.current?.querySelector("button")?.focus();
136
190
  }
137
191
  };
138
192
  document.addEventListener("pointerdown", away);
@@ -142,10 +196,6 @@ function Menu({ current, away }) {
142
196
  document.removeEventListener("keydown", escape);
143
197
  };
144
198
  }, [open]);
145
- if (away.length === 0) {
146
- return null;
147
- }
148
- return (_jsxs("div", { class: "menu", ref: holder, children: [_jsx("button", { type: "button", class: "icon-button tonal menu-button tip-left", "aria-label": t("Menu: {pages}", { pages: pagesList(away) }), "data-tip": t("Menu: {pages}", { pages: pagesList(away) }), "aria-expanded": open, onClick: () => setOpen(!open), children: _jsx(Icon, { name: "menu" }) }), open && (_jsxs("div", { class: "menu-pop", children: [away.map((page) => (_jsxs("a", { href: sectionAddress(page), "aria-current": page === current ? "page" : undefined, onClick: () => setOpen(false), children: [_jsx(Icon, { name: page }), sectionLabel(page)] }, page))), _jsxs("button", { type: "button", class: "menu-theme", onClick: flip, children: [_jsx(Icon, { name: theme.next === "dark" ? "moon" : "sun" }), theme.name] })] }))] }));
149
199
  }
150
200
  /** In the setup, which has no sections (D-379): whether the game is live and the switch of the theme, small at the top right. */
151
201
  export function SetupCorner({ live }) {
@@ -210,7 +260,7 @@ function useWrapped(row) {
210
260
  };
211
261
  }, []);
212
262
  }
213
- /** The pages a menu holds as a list in the page's language: Rules, Saves and Settings; ルール、セーブ、設定. */
214
- function pagesList(pages) {
215
- return new Intl.ListFormat(document.documentElement.lang || "en", { type: "conjunction" }).format(pages.map(sectionLabel));
263
+ /** Names as a list in the page's language: Rules, Saves and Settings; ルール、セーブ、設定. */
264
+ function listOf(names) {
265
+ return new Intl.ListFormat(document.documentElement.lang || "en", { type: "conjunction" }).format(names);
216
266
  }
@@ -3,17 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
3
3
  // title and line of now, gold when it is the player's turn; the order of the turns, fixed, the mark moving, each one a small card (D-419): their place in a
4
4
  // strip that lights up on their turn, their counter, the party's as numbers and a foe's in words, their state as icons, what they keep, the death saves at 0;
5
5
  // and the player's character's card, the fields and groups of its sheet the system names. The page never decides a rule: it shows.
6
- import { useEffect, useRef } from "preact/hooks";
6
+ import { useContext, useEffect, useRef } from "preact/hooks";
7
7
  import { TalkName } from "./act-names.js";
8
8
  import { CardHead, CardHeader, useOpen } from "./card.js";
9
- import { DeathSaves } from "./dying.js";
9
+ import { WidgetsContext } from "./extension-widgets.js";
10
10
  import { Icon, iconPath } from "./icons.js";
11
11
  import { fieldLabel, itemLabel, phraseLabel, shownText, strangerLabel } from "./labels.js";
12
12
  import { stripCounter } from "./layout.js";
13
13
  import { sideOf, Token } from "./party.js";
14
- import { dyingState } from "./save-outcome.js";
14
+ import { PersonPanel, personShown } from "./person-panel.js";
15
15
  import { SheetAtHand } from "./sheet.js";
16
- import { StatusIcons, StatusPip } from "./status.js";
16
+ import { downTint, personState, StatusIcons, StatusPip } from "./status.js";
17
17
  import { arrowStep, t } from "./text.js";
18
18
  import { Bar } from "./widgets.js";
19
19
  /** Whether the open scene goes by turns. */
@@ -51,12 +51,17 @@ function TurnMarks({ marks }) {
51
51
  */
52
52
  export function CharacterCard({ lead, scene, own, party = [], onShow }) {
53
53
  const fighter = scene.fighters.find((one) => one.role === "pc" && one.name === lead?.name);
54
+ const widgets = useContext(WidgetsContext);
54
55
  if (lead === undefined || fighter === undefined || (own.cards?.atHand.length ?? 0) === 0) {
55
56
  return null;
56
57
  }
58
+ // At 0 the panels of the packages' widgets on them (D-516).
59
+ const person = personShown(widgets, lead.name);
57
60
  const players = onShow === undefined ? [] : party.filter((member) => member.role === "pc" && scene.fighters.some((one) => one.role === "pc" && one.name === member.name));
58
61
  const switching = players.length > 1 && onShow !== undefined;
59
- return (_jsxs("aside", { class: "at-hand", "aria-labelledby": "at-hand-title", children: [_jsxs(CardHead, { icon: iconPath("party"), title: _jsx("h3", { id: "at-hand-title", children: lead.name }), ...(lead.headline === undefined || switching ? {} : { note: lead.headline }), children: [switching && _jsx(CardSwitch, { players: players, shown: lead.name, onShow: onShow }), _jsx("a", { class: "icon-button tip-left", href: `#/party/${encodeURIComponent(lead.name)}`, "aria-label": t("The whole sheet"), "data-tip": t("The whole sheet"), children: _jsx(Icon, { name: "party" }) })] }), fighter.dying ? _jsx(DeathSaves, { dying: fighter.dying }) : (_jsxs(_Fragment, { children: [fighter.keeps && _jsx("p", { class: "keeping", children: t("Keeping {what}", { what: fighter.keeps.join(", ") }) }), _jsx(SheetAtHand, { member: lead, sheet: own.sheet, names: own.cards?.atHand ?? [], version: own.version, onRoll: own.onRoll })] }))] }));
62
+ return (_jsxs("aside", { class: "at-hand", "aria-labelledby": "at-hand-title", children: [_jsxs(CardHead, { icon: iconPath("party"), title: _jsx("h3", { id: "at-hand-title", children: lead.name }), ...(lead.headline === undefined || switching ? {} : { note: lead.headline }), children: [switching && _jsx(CardSwitch, { players: players, shown: lead.name, onShow: onShow }), _jsx("a", { class: "icon-button tip-left", href: `#/party/${encodeURIComponent(lead.name)}`, "aria-label": t("The whole sheet"), "data-tip": t("The whole sheet"), children: _jsx(Icon, { name: "party" }) })] }), person.length > 0
63
+ ? person.map((shown) => _jsx(PersonPanel, { shown: shown }, shown.widget.id))
64
+ : (_jsxs(_Fragment, { children: [fighter.keeps && _jsx("p", { class: "keeping", children: t("Keeping {what}", { what: fighter.keeps.join(", ") }) }), _jsx(SheetAtHand, { member: lead, sheet: own.sheet, names: own.cards?.atHand ?? [], version: own.version, onRoll: own.onRoll })] }))] }));
60
65
  }
61
66
  /** The tokens of the player characters in a fight, the one whose card shows pressed: one stop of Tab, the arrows along them (D-480 (7)). */
62
67
  function CardSwitch({ players, shown, onShow }) {
@@ -112,35 +117,51 @@ export function TurnsCard({ scene, party, several = false, beside = false }) {
112
117
  function FighterRow({ fighter, member, place, acting, several }) {
113
118
  // One of the party has the bar of their strip (D-419), the icons under it.
114
119
  const counter = member === undefined ? undefined : stripCounter(member);
120
+ const widgets = useContext(WidgetsContext);
121
+ const person = fighter.role === "other" ? [] : personShown(widgets, fighter.name);
115
122
  return (_jsxs("li", { class: ["turn-row", fighter.role, acting ? "now" : ""].filter((part) => part !== "").join(" "), "aria-current": acting ? "step" : undefined, children: [_jsx("span", { class: "turn-place", children: place }), _jsx(FighterToken, { fighter: fighter, state: false }), _jsxs("div", { class: "turn-main", children: [_jsx("p", { class: "turn-name", children: fighter.role === "pc"
116
123
  ? (_jsxs(_Fragment, { children: [shownName(fighter), !several && _jsx("span", { class: "you", children: t("You") })] }))
117
124
  : _jsx(TalkName, { name: shownName(fighter), children: shownName(fighter) }) }), counter !== undefined && _jsx(Bar, { value: counter, label: fieldLabel(counter.field) }), _jsxs("div", { class: "turn-facts", children: [counter === undefined && fighter.health
118
125
  && (fighter.role === "other"
119
126
  ? _jsx("span", { class: fighter.wound === undefined ? "wound" : `wound ${fighter.wound}`, children: phraseLabel(itemLabel(fighter.health)) })
120
- : _jsx("span", { class: "turn-health num", children: shownText(fighter.health) })), _jsx(StatusIcons, { status: fighterStatus(fighter), downSaid: counter === undefined && fighter.role === "other" && fighter.wound === "down" })] }), fighter.keeps && _jsx("p", { class: "keeping", children: t("Keeping {what}", { what: fighter.keeps.join(", ") }) }), fighter.dying && _jsx(DeathSaves, { dying: fighter.dying, compact: true })] })] }));
127
+ : _jsx("span", { class: "turn-health num", children: shownText(fighter.health) })), _jsx(StatusIcons, { status: fighterStatus(fighter, widgets), said: saidInRow(fighter, person, counter !== undefined) })] }), fighter.keeps && _jsx("p", { class: "keeping", children: t("Keeping {what}", { what: fighter.keeps.join(", ") }) }), person.map((shown) => _jsx(PersonPanel, { shown: shown, compact: true }, shown.widget.id))] })] }));
121
128
  }
122
129
  /**
123
130
  * A fighter's token; a foe the master marked glows red a little, with no pip (D-415); one of the party with the pip of their side unless it is too small for one
124
131
  * (D-414); with the pip of their state unless `state` is false (D-419).
125
132
  */
126
133
  function FighterToken({ fighter, pip = true, state = true }) {
127
- const status = state ? fighterStatus(fighter) : undefined;
134
+ const widgets = useContext(WidgetsContext);
135
+ const status = state ? fighterStatus(fighter, widgets) : undefined;
128
136
  // A stranger's number, as Creature 2's or, with more kinds, Creature B1's, the same on their token on the map (D-325, D-331).
129
137
  const number = fighter.stranger ? /[A-Z]?\d+$/.exec(fighter.name)?.[0] : undefined;
130
138
  const hostile = fighter.hostile === true;
131
139
  // A stranger with a picture of their own, made from what is seen, shows it, with their number in its corner (D-420).
132
140
  return fighter.stranger && fighter.image === undefined
133
141
  ? (_jsxs("span", { class: ["token stranger", number === undefined ? "" : "numbered", hostile ? "hostile" : ""].filter((name) => name !== "").join(" "), "aria-hidden": "true", children: [number ?? _jsx(Icon, { name: "stranger" }), _jsx(StatusPip, { status: status })] }))
134
- : (_jsx(Token, { member: { name: fighter.name, role: fighter.role, ...(fighter.image === undefined ? {} : { image: fighter.image }), ...(fighter.icon === undefined ? {} : { icon: fighter.icon }) }, hostile: hostile, side: pip ? sideOf(fighter.role) : undefined, dying: dyingState(fighter.dying) ?? (fighter.wound === "down" ? "down" : undefined), ...(status === undefined ? {} : { status }), number: number }));
142
+ : (_jsx(Token, { member: { name: fighter.name, role: fighter.role, ...(fighter.image === undefined ? {} : { image: fighter.image }), ...(fighter.icon === undefined ? {} : { icon: fighter.icon }) }, hostile: hostile, side: pip ? sideOf(fighter.role) : undefined, dying: downTint(status ?? fighterStatus(fighter, widgets)), ...(status === undefined ? {} : { status }), number: number }));
135
143
  }
136
- /** A fighter's state: what is on them, whether they act, and at 0 the party's dying point or a foe down. */
137
- function fighterStatus(fighter) {
144
+ /**
145
+ * The states a row of the turns already says in words, which its icons do not say again to a screen reader (D-516): the word of a package's panel, a foe's
146
+ * down beside a counter in words.
147
+ */
148
+ export function saidInRow(fighter, person, counted) {
149
+ const worded = person.some(({ shows }) => shows.parts?.some((part) => "lead" in part) === true);
150
+ return worded
151
+ ? ["dying", "stable", "down", "dead"]
152
+ : !counted && fighter.role === "other" && fighter.wound === "down"
153
+ ? ["down"]
154
+ : [];
155
+ }
156
+ /** A fighter's state: what is on them, whether they act, and at 0 the party's down point, with what a package's widget on them says (D-514), or a foe down. */
157
+ function fighterStatus(fighter, widgets) {
158
+ const person = fighter.role === "other" ? undefined : personState(widgets, fighter.name);
138
159
  return {
160
+ ...(person === undefined ? {} : { person }),
139
161
  effects: fighter.effects,
140
162
  inactive: fighter.inactive === true,
141
- down: fighter.dying !== undefined || fighter.wound === "down",
142
- dying: dyingState(fighter.dying),
143
- counters: fighter.dying,
163
+ down: fighter.down === true || fighter.wound === "down",
164
+ ...(person?.dead === true ? { dead: true } : {}),
144
165
  party: fighter.role !== "other",
145
166
  };
146
167
  }
@@ -6,7 +6,7 @@ import { Coins } from "./coins.js";
6
6
  import { besideLabel, burnsLabel, effectEndLabel, effectLabel, effectName } from "./game-words.js";
7
7
  import { itemLabel, shownText } from "./labels.js";
8
8
  import { progressShare, trackPlaces, widgetOf } from "./layout.js";
9
- import { t } from "./text.js";
9
+ import { numberText, t } from "./text.js";
10
10
  // Below this share of its maximum a bar is low: hatched, not only red.
11
11
  const low = 0.25;
12
12
  // A list with an item of so many words is of sentences, as "advantage on saving throws against poison": lines, not chips.
@@ -72,5 +72,12 @@ function Items({ items, field, fields }) {
72
72
  /** Someone's effects as tags, each with its end; past `most`, how many more. */
73
73
  export function Effects({ effects, most }) {
74
74
  const shown = most === undefined ? effects : effects.slice(0, most);
75
- return effects.length === 0 ? null : (_jsxs("span", { class: "effects", children: [shown.map((effect) => (_jsxs("span", { class: "effect", title: effectLabel(effect), children: [effectName(effect.name), effect.end && most === undefined ? _jsx("span", { class: "end", children: `· ${effectEndLabel(effect.end)}` }) : null, effect.burns && most === undefined ? _jsx("span", { class: "end", children: `· ${burnsLabel(effect.name, effect.burns)}` }) : null] }, effect.text))), effects.length > shown.length && _jsxs("span", { class: "effect more", children: ["+", effects.length - shown.length] })] }));
75
+ // Where few fit (`most`), one with a drawing is its icon alone, its words in its tooltip and for a screen reader (D-516); else its icon before its words.
76
+ return effects.length === 0 ? null : (_jsxs("span", { class: "effects", children: [shown.map((effect) => effect.icon !== undefined && most !== undefined
77
+ ? (_jsx("span", { class: "effect icon-only", role: "img", "aria-label": effectLabel(effect), "data-tip": effectLabel(effect), children: _jsx(EffectIcon, { path: effect.icon }) }, effect.text))
78
+ : (_jsxs("span", { class: effect.icon === undefined ? "effect" : "effect with-icon", title: effectLabel(effect), children: [effect.icon !== undefined && _jsx(EffectIcon, { path: effect.icon }), effectName(effect.name), effect.end && most === undefined ? _jsx("span", { class: "end", children: `· ${effectEndLabel(effect.end)}` }) : null, effect.burns && most === undefined ? _jsx("span", { class: "end", children: `· ${burnsLabel(effect.name, effect.burns)}` }) : null] }, effect.text))), effects.length > shown.length && _jsx("span", { class: "effect more", dir: "ltr", "data-tip": effects.slice(shown.length).map((effect) => effectLabel(effect)).join(", "), children: `+${numberText(effects.length - shown.length)}` })] }));
79
+ }
80
+ /** The drawing of an effect, a path on a grid of 24 stroked as the page's icons. */
81
+ function EffectIcon({ path }) {
82
+ return (_jsx("svg", { class: "effect-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: path }) }));
76
83
  }