rpg-engine 0.23.1 → 0.24.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 (124) hide show
  1. package/README.md +2 -2
  2. package/dist/campaign/create-campaign.d.ts +1 -1
  3. package/dist/campaign/create-campaign.js +1 -1
  4. package/dist/campaign/find-campaign.js +11 -1
  5. package/dist/campaign/host-files.d.ts +5 -6
  6. package/dist/campaign/host-files.js +100 -60
  7. package/dist/campaign/settings.d.ts +3 -3
  8. package/dist/campaign/settings.js +5 -4
  9. package/dist/cli/cli.js +11 -2
  10. package/dist/commands/config/config.js +1 -1
  11. package/dist/commands/config/dashboard.js +23 -6
  12. package/dist/commands/config/words.js +1 -0
  13. package/dist/commands/image.js +3 -3
  14. package/dist/commands/import/import.d.ts +3 -1
  15. package/dist/commands/import/import.js +13 -5
  16. package/dist/commands/instructions.js +1 -1
  17. package/dist/commands/shared/campaign/images.js +3 -2
  18. package/dist/commands/shared/campaign/mode.js +1 -1
  19. package/dist/commands/shared/characters/voices.d.ts +2 -2
  20. package/dist/commands/shared/characters/voices.js +9 -9
  21. package/dist/commands/shared/sheet/sheet.d.ts +2 -2
  22. package/dist/commands/shared/sheet/sheet.js +3 -3
  23. package/dist/core/context.d.ts +8 -2
  24. package/dist/dashboard/acts/acts.js +39 -11
  25. package/dist/dashboard/acts/head.js +7 -0
  26. package/dist/dashboard/acts/names.js +4 -2
  27. package/dist/dashboard/acts/sending.js +23 -22
  28. package/dist/dashboard/acts/sheet.js +7 -149
  29. package/dist/dashboard/acts/strip.js +10 -14
  30. package/dist/dashboard/acts/talk.js +51 -0
  31. package/dist/dashboard/acts/thing.js +169 -0
  32. package/dist/dashboard/app.js +3 -3
  33. package/dist/dashboard/guide/ar.md +13 -13
  34. package/dist/dashboard/guide/cs.md +12 -12
  35. package/dist/dashboard/guide/da.md +12 -12
  36. package/dist/dashboard/guide/de.md +11 -11
  37. package/dist/dashboard/guide/el.md +11 -11
  38. package/dist/dashboard/guide/en.md +10 -10
  39. package/dist/dashboard/guide/es.md +11 -11
  40. package/dist/dashboard/guide/fi.md +11 -11
  41. package/dist/dashboard/guide/fr.md +12 -12
  42. package/dist/dashboard/guide/he.md +11 -11
  43. package/dist/dashboard/guide/hi.md +11 -11
  44. package/dist/dashboard/guide/hu.md +11 -11
  45. package/dist/dashboard/guide/is.md +11 -11
  46. package/dist/dashboard/guide/it.md +38 -38
  47. package/dist/dashboard/guide/ja.md +11 -11
  48. package/dist/dashboard/guide/ko.md +12 -12
  49. package/dist/dashboard/guide/nb.md +11 -11
  50. package/dist/dashboard/guide/nl.md +11 -11
  51. package/dist/dashboard/guide/pl.md +11 -11
  52. package/dist/dashboard/guide/pt.md +11 -11
  53. package/dist/dashboard/guide/ro.md +12 -12
  54. package/dist/dashboard/guide/ru.md +12 -12
  55. package/dist/dashboard/guide/sv.md +12 -12
  56. package/dist/dashboard/guide/tr.md +12 -12
  57. package/dist/dashboard/guide/uk.md +11 -11
  58. package/dist/dashboard/guide/zh.md +12 -12
  59. package/dist/dashboard/i18n/ar.json +24 -10
  60. package/dist/dashboard/i18n/cs.json +24 -10
  61. package/dist/dashboard/i18n/da.json +24 -10
  62. package/dist/dashboard/i18n/de.json +24 -10
  63. package/dist/dashboard/i18n/el.json +24 -10
  64. package/dist/dashboard/i18n/es.json +24 -10
  65. package/dist/dashboard/i18n/fi.json +24 -10
  66. package/dist/dashboard/i18n/fr.json +24 -10
  67. package/dist/dashboard/i18n/he.json +24 -10
  68. package/dist/dashboard/i18n/hi.json +24 -10
  69. package/dist/dashboard/i18n/hu.json +24 -10
  70. package/dist/dashboard/i18n/is.json +24 -10
  71. package/dist/dashboard/i18n/it.json +102 -88
  72. package/dist/dashboard/i18n/ja.json +24 -10
  73. package/dist/dashboard/i18n/ko.json +24 -10
  74. package/dist/dashboard/i18n/nb.json +24 -10
  75. package/dist/dashboard/i18n/nl.json +24 -10
  76. package/dist/dashboard/i18n/pl.json +24 -10
  77. package/dist/dashboard/i18n/pt.json +24 -10
  78. package/dist/dashboard/i18n/ro.json +24 -10
  79. package/dist/dashboard/i18n/ru.json +24 -10
  80. package/dist/dashboard/i18n/sv.json +24 -10
  81. package/dist/dashboard/i18n/tr.json +24 -10
  82. package/dist/dashboard/i18n/uk.json +24 -10
  83. package/dist/dashboard/i18n/zh.json +24 -10
  84. package/dist/dashboard/packages/packages.js +1 -1
  85. package/dist/dashboard/parts/icons.js +2 -0
  86. package/dist/dashboard/parts/labels.js +1 -0
  87. package/dist/dashboard/parts/layout.js +34 -0
  88. package/dist/dashboard/parts/widgets.js +6 -2
  89. package/dist/dashboard/settings/language-choice.js +1 -1
  90. package/dist/dashboard/settings/settings.js +61 -36
  91. package/dist/dashboard/settings/tabs.js +14 -0
  92. package/dist/dashboard/sheet/sheet.js +54 -33
  93. package/dist/dashboard/shell/notices.js +2 -2
  94. package/dist/dashboard/style.css +122 -47
  95. package/dist/helpers/antigravity.d.ts +47 -0
  96. package/dist/helpers/antigravity.js +434 -0
  97. package/dist/helpers/chosen.d.ts +11 -7
  98. package/dist/helpers/chosen.js +64 -37
  99. package/dist/helpers/index.d.ts +1 -0
  100. package/dist/helpers/index.js +2 -1
  101. package/dist/helpers/opencode.js +117 -24
  102. package/dist/helpers/programs.d.ts +8 -0
  103. package/dist/helpers/programs.js +35 -2
  104. package/dist/helpers/stop.d.ts +2 -0
  105. package/dist/helpers/stop.js +20 -1
  106. package/dist/helpers/svg.d.ts +4 -1
  107. package/dist/helpers/svg.js +16 -4
  108. package/dist/instructions/index.d.ts +4 -2
  109. package/dist/instructions/index.js +6 -3
  110. package/dist/server/bell/antigravity.d.ts +7 -2
  111. package/dist/server/bell/antigravity.js +24 -6
  112. package/dist/server/bell/index.d.ts +1 -1
  113. package/dist/server/bell/index.js +1 -1
  114. package/dist/server/bell/listener.js +6 -1
  115. package/dist/server/fence.d.ts +21 -0
  116. package/dist/server/fence.js +69 -0
  117. package/dist/server/mcp.js +26 -0
  118. package/dist/server/player-acts.js +1 -1
  119. package/dist/server/subagent.d.ts +4 -0
  120. package/dist/server/subagent.js +30 -0
  121. package/instructions/voices-antigravity.md +1 -0
  122. package/instructions/voices-codex.md +1 -0
  123. package/instructions/voices-opencode.md +1 -1
  124. package/package.json +1 -1
@@ -1,38 +1,49 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
2
  import { useContext, useEffect, useRef, useState } from "preact/hooks";
3
3
  import { sectionLabel } from "../address.js";
4
4
  import { changeSetting, readSettings } from "../api.js";
5
5
  import { coinDesignPref, coinDesigns, coinLook, coinMetals, coinPref, diceEdgesPref, diceLook, diceSetPref, diceSets, texturePath } from "../dice/sets.js";
6
6
  import { WidgetsContext } from "../packages/widgets.js";
7
+ import { CardHead } from "../parts/card.js";
7
8
  import { CoinFace } from "../parts/faces.js";
8
- import { DieSwatch, Icon } from "../parts/icons.js";
9
+ import { cardIcons, DieSwatch, Icon, iconPath } from "../parts/icons.js";
9
10
  import { customLabel, itemLabel, leveledItemLabel, phraseLabel, rateParts, settingLabel, valueLabel } from "../parts/labels.js";
10
11
  import { PageHead } from "../shell/pages.js";
11
12
  import { byHandPref, conditionsPref, readChoice, soundPref, tokenSymbolsPref, useChoice, usePref, usePrefChange, writeChoice } from "../shell/prefs.js";
12
13
  import { applyGameStyle, gameStyle, installedStyle, systemStylePref } from "../shell/system-style.js";
14
+ import { PageTabs } from "../shell/tabs.js";
13
15
  import { pickTheme, shownTheme } from "../shell/theme.js";
14
16
  import { arrowStep, t } from "../text.js";
15
17
  import { LanguageChoice, languageLine } from "./language-choice.js";
16
18
  import { Confirm } from "./saves.js";
17
- // 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
18
- // master plays holds who voices the characters (D-490) and how much the master thinks (D-462) too.
19
+ import { settingsTab, settingsTabLabel, settingsTabs } from "./tabs.js";
20
+ // The cards of the campaign's settings, in the order groupTitle names them: each in its tab, with its picture and its settings in order. A setting the game
21
+ // system adds goes with the dice, as whether the master's rolls are shown (D-287). The master's style holds who voices the characters (D-490) and how much the
22
+ // master thinks (D-462) too.
19
23
  const groups = [
20
- { names: ["ruleset", "difficulty", "lethality", "saves", "rigor", "between-sessions"] },
21
- { names: ["mentor", "learned"] },
22
- { names: ["prose", "story", "author", "style", "voices", "effort"] },
23
- { names: ["dice", "master-rolls", "units"], system: true },
24
- { names: ["lines", "veils"] },
25
- { names: ["orders"] },
26
- { names: ["pictures", "pictures-by", "language"] },
24
+ { tab: "game", key: "rules", icon: () => iconPath("combat"), names: ["ruleset", "difficulty", "lethality", "saves", "rigor", "between-sessions"] },
25
+ { tab: "game", key: "dice", icon: () => iconPath("dice"), names: ["dice", "master-rolls", "units"], system: true },
26
+ { tab: "game", key: "learning", icon: () => iconPath("help"), names: ["mentor", "learned"] },
27
+ { tab: "master", key: "style", icon: () => cardIcons.backstory, names: ["prose", "story", "author", "style", "voices", "effort"] },
28
+ { tab: "master", key: "limits", icon: () => iconPath("hand"), names: ["lines", "veils"] },
29
+ { tab: "master", key: "companions", icon: () => cardIcons.here, names: ["orders"] },
30
+ { tab: "campaign", key: "pictures", icon: () => iconPath("picture"), names: ["pictures", "pictures-by", "language"] },
27
31
  // Only where the campaign's folder is a git repository (D-576).
28
32
  // What a public repository would show of the player (D-576).
29
33
  {
34
+ tab: "campaign",
35
+ key: "git",
36
+ icon: () => iconPath("branch"),
30
37
  names: ["git", "git-saves", "git-sessions"],
31
38
  note: () => t("Keep the repository private. It holds the log of your sessions and your user's name on this computer; with the chats in, everything you wrote to the master too."),
32
39
  },
33
40
  ];
34
- /** The Settings section; with `several` player characters, what a value means says so where it speaks of one character (D-480 (2)). */
35
- export function SettingsView({ version, several = false }) {
41
+ /**
42
+ * The Settings section, on the tab its address names; with `several` player characters, what a value means says so where it speaks of one character
43
+ * (D-480 (2)).
44
+ */
45
+ export function SettingsView({ version, tab, several = false }) {
46
+ const shownTab = settingsTab(tab);
36
47
  const [settings, setSettings] = useState();
37
48
  const [problem, setProblem] = useState();
38
49
  const reads = useRef(0);
@@ -60,16 +71,21 @@ export function SettingsView({ version, several = false }) {
60
71
  return said;
61
72
  };
62
73
  const known = new Set([...groups.flatMap((group) => group.names), ...Object.values(customParts)]);
63
- return (_jsxs("section", { class: "settings", "aria-labelledby": "settings-title", children: [_jsx(PageHead, { section: "settings", id: "settings-title" }), _jsx("p", { class: "settings-lead", children: t("A change counts at once, from now on: what is already in play stays as it is. The master hears of it at their next move, and of nothing you put back as it was.") }), problem !== undefined && _jsx("p", { class: "settings-problem", role: "alert", children: problem }), settings !== undefined && groups.map((group, index) => {
64
- const shown = [
65
- ...group.names.flatMap((name) => settings.filter((setting) => setting.name === name)),
66
- ...(group.system ? settings.filter((setting) => !known.has(setting.name)) : []),
67
- ];
68
- if (shown.length === 0) {
69
- return null;
70
- }
71
- return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: groupTitle(index) }), group.note !== undefined && (_jsxs("div", { class: "settings-group-note setting-note fix", children: [_jsx(Icon, { name: "lock" }), _jsx("p", { children: group.note() })] })), shown.map((setting) => (_jsx(SettingRow, { setting: setting, off: offBy(setting, settings), several: several, parts: settings.find((one) => one.name === customParts[setting.name]), onChange: change }, setting.name)))] }, group.names[0]));
72
- }), _jsx(WidgetSettings, { onChange: change }), _jsx(PageSettings, {})] }));
74
+ return (_jsxs("section", { class: "page-stack settings", "aria-labelledby": "settings-title", children: [_jsx(PageHead, { section: "settings", id: "settings-title" }), _jsx("p", { class: "settings-lead", children: t("A change counts at once, from now on: what is already in play stays as it is. The master hears of it at their next move, and of nothing you put back as it was.") }), problem !== undefined && _jsx("p", { class: "settings-problem", role: "alert", children: problem }), _jsx(PageTabs, { section: "settings", label: t("Settings"), chosen: shownTab, tabs: settingsTabs.map((key) => ({ key, name: settingsTabLabel(key) })) }), _jsxs("div", { class: "settings-panel", id: "settings-panel", role: "tabpanel", "aria-labelledby": `settings-tab-${shownTab}`, children: [settings !== undefined && groups.map((group, index) => {
75
+ const shown = group.tab !== shownTab ? [] : [
76
+ ...group.names.flatMap((name) => settings.filter((setting) => setting.name === name)),
77
+ ...(group.system ? settings.filter((setting) => !known.has(setting.name)) : []),
78
+ ];
79
+ if (shown.length === 0) {
80
+ return null;
81
+ }
82
+ return (_jsxs(SettingsCard, { name: group.key, icon: group.icon(), title: groupTitle(index), children: [group.note !== undefined && (_jsxs("div", { class: "settings-card-note setting-note fix", children: [_jsx(Icon, { name: "lock" }), _jsx("p", { children: group.note() })] })), shown.map((setting) => (_jsx(SettingRow, { setting: setting, off: offBy(setting, settings), several: several, parts: settings.find((one) => one.name === customParts[setting.name]), onChange: change }, setting.name)))] }, group.key));
83
+ }), shownTab === "campaign" && _jsx(WidgetSettings, { onChange: change }), shownTab === "page" && _jsx(PageSettings, {})] })] }));
84
+ }
85
+ /** A card of settings, always open: its picture and its title, then its rows, a rule between them. */
86
+ function SettingsCard({ name, icon, title, children }) {
87
+ const id = `settings-${name}`;
88
+ return (_jsxs("section", { class: "card", "aria-labelledby": id, children: [_jsx(CardHead, { icon: icon, title: _jsx("h3", { id: id, children: title }) }), _jsx("div", { class: "card-body settings-body", children: children })] }));
73
89
  }
74
90
  /**
75
91
  * What a value of a setting means, in the page's language; with more than one player character, checkpoint goes back when all die, or when one does and the
@@ -423,7 +439,10 @@ function gameStyleRows() {
423
439
  function idOf(name) {
424
440
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
425
441
  }
426
- /** The page's own settings, in this browser alone: the theme, the game's style, the tokens' symbols and conditions, the dice's sound, set and edges, the coins, rolling by hand. */
442
+ /**
443
+ * The page's own settings, in this browser alone, in three cards: its look, the theme and the game's style; the tokens' symbols and conditions; the dice's
444
+ * sound, set and edges, the coins, rolling by hand.
445
+ */
427
446
  function PageSettings() {
428
447
  usePrefChange();
429
448
  const [sound, setSound] = usePref(soundPref);
@@ -434,7 +453,7 @@ function PageSettings() {
434
453
  const [byHand, setByHand] = usePref(byHandPref);
435
454
  const [symbols, setSymbols] = usePref(tokenSymbolsPref);
436
455
  const [conditions, setConditions] = useChoice(conditionsPref);
437
- const rows = [
456
+ const look = [
438
457
  {
439
458
  key: "theme",
440
459
  name: t("Theme"),
@@ -444,6 +463,8 @@ function PageSettings() {
444
463
  pick: (value) => pickTheme(value === "dark" ? "dark" : "light"),
445
464
  },
446
465
  ...gameStyleRows(),
466
+ ];
467
+ const tokens = [
447
468
  {
448
469
  key: "token-symbols",
449
470
  name: t("Token symbols"),
@@ -460,6 +481,8 @@ function PageSettings() {
460
481
  value: conditions,
461
482
  pick: setConditions,
462
483
  },
484
+ ];
485
+ const dice = [
463
486
  { key: "dice-sound", name: t("Dice sound"), about: t("the dice as they roll"), options: [{ value: "on", label: t("On") }, { value: "off", label: t("Off") }], value: sound ? "on" : "off", pick: (value) => setSound(value === "on") },
464
487
  {
465
488
  key: "dice-set",
@@ -513,16 +536,18 @@ function PageSettings() {
513
536
  pick: (value) => setByHand(value === "hand"),
514
537
  },
515
538
  ];
516
- return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: t("This page") }), _jsx("p", { class: "setting-about", children: t("Kept in this browser alone.") }), rows.map((row) => {
517
- const id = `page-${row.key}`;
518
- const chosen = row.options.find((option) => option.value === row.value);
519
- const described = [`${id}-about`, ...(chosen?.means === undefined ? [] : [`${id}-means`]), ...(row.note === undefined ? [] : [`${id}-note`])].join(" ");
520
- return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: described, options: row.options, value: row.value, onPick: row.pick }), (chosen?.means !== undefined || row.note !== undefined) && (_jsxs("div", { class: "setting-after", children: [chosen?.means !== undefined && (_jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] })), row.note !== undefined && _jsx("p", { class: "setting-means", id: `${id}-note`, children: row.note })] }))] }, row.key));
521
- })] }));
539
+ return (_jsxs(_Fragment, { children: [_jsx("p", { class: "settings-kept", children: t("Kept in this browser alone: the master hears nothing of them.") }), _jsx(SettingsCard, { name: "look", icon: iconPath("theme"), title: t("Look"), children: look.map((row) => _jsx(PageSetting, { row: row }, row.key)) }), _jsx(SettingsCard, { name: "tokens", icon: iconPath("party"), title: t("Tokens"), children: tokens.map((row) => _jsx(PageSetting, { row: row }, row.key)) }), _jsx(SettingsCard, { name: "dice-set", icon: iconPath("dice"), title: t("Dice and coins"), children: dice.map((row) => _jsx(PageSetting, { row: row }, row.key)) })] }));
540
+ }
541
+ /** One of the page's own settings: its name and what it is, its values, what the chosen one means and the line under it. */
542
+ function PageSetting({ row }) {
543
+ const id = `page-${row.key}`;
544
+ const chosen = row.options.find((option) => option.value === row.value);
545
+ const described = [`${id}-about`, ...(chosen?.means === undefined ? [] : [`${id}-means`]), ...(row.note === undefined ? [] : [`${id}-note`])].join(" ");
546
+ return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: described, options: row.options, value: row.value, onPick: row.pick }), (chosen?.means !== undefined || row.note !== undefined) && (_jsxs("div", { class: "setting-after", children: [chosen?.means !== undefined && (_jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] })), row.note !== undefined && _jsx("p", { class: "setting-means", id: `${id}-note`, children: row.note })] }))] }));
522
547
  }
523
548
  /**
524
- * Where the page shows the extensions' widgets (D-502), for the campaign: each in the top, the table's column, a page, or nowhere, and which page; the place its
525
- * extension gives it sends it back there. None without a widget; never one on each of the party.
549
+ * Where the page shows the extensions' widgets (D-502), for the campaign, in a card of the campaign's tab: each in the top, the table's column, a page, or
550
+ * nowhere, and which page; the place its extension gives it sends it back there. None without a widget; never one on each of the party.
526
551
  */
527
552
  function WidgetSettings({ onChange }) {
528
553
  // One on each of the party stands where its package puts it: there is nowhere else for it (D-514).
@@ -530,7 +555,7 @@ function WidgetSettings({ onChange }) {
530
555
  if (widgets.length === 0) {
531
556
  return null;
532
557
  }
533
- return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: t("Extensions on the page") }), _jsx("p", { class: "setting-about", children: t("Where the page shows what the extensions add, in this campaign.") }), widgets.map((widget) => _jsx(WidgetRow, { widget: widget, onChange: onChange }, widget.id))] }));
558
+ return (_jsx(SettingsCard, { name: "widgets", icon: iconPath("packages"), title: t("Extensions on the page"), children: widgets.map((widget) => _jsx(WidgetRow, { widget: widget, onChange: onChange }, widget.id)) }));
534
559
  }
535
560
  // The pages a widget's card may stand in, in the order of the sections.
536
561
  const widgetPages = ["sheet", "scene", "journal", "world"];
@@ -591,9 +616,9 @@ function Segmented({ label, described, options, value, onPick }) {
591
616
  };
592
617
  return (_jsx("span", { class: "segmented", role: "radiogroup", "aria-labelledby": label, "aria-describedby": described, onKeyDown: move, children: options.map((option, index) => (_jsxs("button", { type: "button", role: "radio", "aria-checked": option.value === value, tabIndex: index === Math.max(at, 0) ? 0 : -1, onClick: () => option.value !== value && onPick(option.value, false), children: [option.picture, option.label] }, option.value))) }));
593
618
  }
594
- /** A group of the campaign's settings by its place, in the page's language. */
619
+ /** A card of the campaign's settings by its place, in the page's language. */
595
620
  function groupTitle(index) {
596
- return [t("The game"), t("Learning the game"), t("The master's style"), t("Dice and measures"), t("Limits"), t("Your companions"), t("Pictures and language"), t("Git")][index] ?? "";
621
+ return [t("Rules and difficulty"), t("Dice and measures"), t("Learning the game"), t("The master's style"), t("Limits"), t("Your companions"), t("Pictures and language"), t("Git")][index] ?? "";
597
622
  }
598
623
  /** What a list's field suggests, as an example. */
599
624
  function exampleOf(name) {
@@ -0,0 +1,14 @@
1
+ // The tabs of Settings: the game, the master and the campaign, whose settings are the campaign's, then the page's own, kept in this browser; each in the
2
+ // address, as #/settings/master.
3
+ import { t } from "../text.js";
4
+ /** The tabs, in the order the page shows them: the first one's address is the section's own, #/settings. */
5
+ export const settingsTabs = ["game", "master", "campaign", "page"];
6
+ /** The tab an address names; the first for none, or for one Settings do not have. */
7
+ export function settingsTab(written) {
8
+ return settingsTabs.find((tab) => tab === written) ?? settingsTabs[0];
9
+ }
10
+ /** A tab's name, in the page's language. */
11
+ export function settingsTabLabel(tab) {
12
+ const labels = { game: t("Game"), master: t("Master"), campaign: t("Campaign"), page: t("This page") };
13
+ return labels[tab];
14
+ }
@@ -1,7 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ // Someone's sheet (D-273, D-276, D-284): a band with their line and effects, then the system's groups as cards, those of a few short numbers in a rail beside
3
+ // the others in columns that stay as the player opens and closes them (D-383), and the page's text the whole width, in two columns where there is room, the
4
+ // player character's story in a card of its own, where the player writes their own character's story (D-373); a click on a number the system rolls throws it for fun (D-280), and its tooltip says how it is made
5
+ // (FOR-8). While the master asks a roll, the number its check names lights up and answers it (D-330, ASK-12). A companion who keeps no sheet shows the stat
6
+ // block of its creature (D-275).
7
+ import { Fragment } from "preact";
2
8
  import { useContext, useEffect, useId, useRef, useState } from "preact/hooks";
3
- import { itemVerbs } from "../acts/acts.js";
4
- import { ActName, usePlayerActs } from "../acts/names.js";
9
+ import { itemVerbs, thingKey, thingVerbs } from "../acts/acts.js";
10
+ import { ActName, ThingVerbsContext, usePlayerActs } from "../acts/names.js";
5
11
  import { readExplanations } from "../api.js";
6
12
  import { WidgetCards, WidgetsContext } from "../packages/widgets.js";
7
13
  import { CardHeader, useOpen } from "../parts/card.js";
@@ -9,7 +15,7 @@ import { ChangedLine, ChangedMark } from "../parts/changed.js";
9
15
  import { besideLabel, memberPlaceLabel } from "../parts/game-words.js";
10
16
  import { cardIcons, DieIcon, Icon } from "../parts/icons.js";
11
17
  import { fieldLabel, groupLabels, itemLabel, phraseLabel, readableIds, rollLabel, shownNotation, shownText } from "../parts/labels.js";
12
- import { arrangedGroups, groupLayout, orderedValues, widgetOf } from "../parts/layout.js";
18
+ import { arrangedGroups, equippedFirst, groupLayout, orderedValues, widgetOf } from "../parts/layout.js";
13
19
  import { knowersOf, Markdown, plainLine } from "../parts/markdown.js";
14
20
  import { MoodFace, moodLabel } from "../parts/mood.js";
15
21
  import { PictureSpot } from "../parts/picture.js";
@@ -38,9 +44,11 @@ export function MemberSheet({ member, headline, layered, sheet, cards, text, kno
38
44
  const shownApart = personFields([...person, ...boxes]);
39
45
  // The player character's story has its own card: the rest of the page's text is its description (D-386).
40
46
  const described = story !== undefined && story.trim() !== "" && text.startsWith(story) ? text.slice(story.length).trimStart() : text;
41
- return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(PictureSpot, { page: member.name, has: member.image !== undefined, children: _jsx(MemberToken, { member: member, large: true, status: status }) }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
42
- ? (_jsxs("p", { class: "headline", children: [headline, headline !== undefined && headline !== "" && member.mood !== undefined && " · ", member.mood !== undefined && (_jsxs("span", { class: "mood-word", children: [_jsx(MoodFace, { mood: member.mood }), moodLabel(member.mood)] }))] }))
43
- : null, member.place && (_jsxs("p", { class: "place", children: [_jsx(Icon, { name: "place" }), memberPlaceLabel(member.place)] })), layered === true && _jsx(ChangedLine, {})] })] }), choices.map((set) => _jsx(ChoicesNotice, { set: set }, set.id)), person.map((shown) => _jsx(PersonPanel, { shown: shown }, shown.widget.id)), _jsx(ValueLine, { values: member.counters.filter((value) => !shownApart.has(value.field)), fields: fields, boxes: boxes }), _jsx(Effects, { effects: besideWord(member.effects, status.person) })] }), _jsxs("div", { class: "sheet-body", children: [rail.length > 0 && _jsx("div", { class: "rail", children: rail.map(group) }), _jsxs("div", { class: "sheet-main", children: [_jsx(FixedColumns, { cards: others.map((shown) => ({ key: shown.name, node: group(shown) })) }), _jsxs("div", { class: "wide-cards", children: [story !== undefined && (_jsxs(Card, { name: backstoryCard, title: t("Backstory"), icon: cardIcons.backstory, layout: "lore", preview: plainLine(story) ?? t("Not written yet"), children: [story.trim() !== "" && _jsx(Markdown, { text: story }), _jsx(StoryBox, { story: story, who: member.name })] })), described.trim() !== "" && (_jsx(Card, { name: descriptionCard, title: t("Description"), icon: cardIcons.description, layout: "lore", preview: plainLine(described), children: _jsx(Markdown, { text: described, secretKnowers: knowersOf(knownBy) }) }))] }), _jsx(WidgetCards, { place: "page", page: "sheet", who: member.name, view: member })] })] })] }));
47
+ // A thing has the same verbs wherever the sheet has it (D-581 (D)).
48
+ const verbs = thingVerbs(usePlayerActs()?.actions, sheet);
49
+ return (_jsx(ThingVerbsContext.Provider, { value: verbs, children: _jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(PictureSpot, { page: member.name, has: member.image !== undefined, children: _jsx(MemberToken, { member: member, large: true, status: status }) }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
50
+ ? (_jsxs("p", { class: "headline", children: [headline, headline !== undefined && headline !== "" && member.mood !== undefined && " · ", member.mood !== undefined && (_jsxs("span", { class: "mood-word", children: [_jsx(MoodFace, { mood: member.mood }), moodLabel(member.mood)] }))] }))
51
+ : null, member.place && (_jsxs("p", { class: "place", children: [_jsx(Icon, { name: "place" }), memberPlaceLabel(member.place)] })), layered === true && _jsx(ChangedLine, {})] })] }), choices.map((set) => _jsx(ChoicesNotice, { set: set }, set.id)), person.map((shown) => _jsx(PersonPanel, { shown: shown }, shown.widget.id)), _jsx(ValueLine, { values: member.counters.filter((value) => !shownApart.has(value.field)), fields: fields, boxes: boxes }), _jsx(Effects, { effects: besideWord(member.effects, status.person) })] }), _jsxs("div", { class: "sheet-body", children: [rail.length > 0 && _jsx("div", { class: "rail", children: rail.map(group) }), _jsxs("div", { class: "sheet-main", children: [_jsx(FixedColumns, { cards: others.map((shown) => ({ key: shown.name, node: group(shown) })) }), _jsxs("div", { class: "wide-cards", children: [story !== undefined && (_jsxs(Card, { name: backstoryCard, title: t("Backstory"), icon: cardIcons.backstory, layout: "lore", preview: plainLine(story) ?? t("Not written yet"), children: [story.trim() !== "" && _jsx(Markdown, { text: story }), _jsx(StoryBox, { story: story, who: member.name })] })), described.trim() !== "" && (_jsx(Card, { name: descriptionCard, title: t("Description"), icon: cardIcons.description, layout: "lore", preview: plainLine(described), children: _jsx(Markdown, { text: described, secretKnowers: knowersOf(knownBy) }) }))] }), _jsx(WidgetCards, { place: "page", page: "sheet", who: member.name, view: member })] })] })] }) }));
44
52
  }
45
53
  /** What of someone's sheet the Combat section keeps at hand (D-315): the fields it names in a line of boxes, as under the name, then the groups it names as their cards. */
46
54
  export function SheetAtHand({ member, sheet, names, version, onRoll }) {
@@ -51,7 +59,9 @@ export function SheetAtHand({ member, sheet, names, version, onRoll }) {
51
59
  const counted = personFields(boxes);
52
60
  const line = names.flatMap((wanted) => sheet.flatMap((group) => group.values).filter((value) => same(value.field, wanted) && !counted.has(value.field)));
53
61
  const groups = names.flatMap((wanted) => sheet.filter((group) => same(group.name, wanted)));
54
- return (_jsxs(_Fragment, { children: [(line.length > 0 || boxes.length > 0) && _jsx(ValueLine, { values: line, fields: fields, boxes: boxes }), groups.map((group) => _jsx(Group, { member: member.name, group: group, fields: fields, version: version, onRoll: onRoll }, group.name))] }));
62
+ // The verbs of the whole sheet, not only of the groups at hand (D-581 (D)).
63
+ const verbs = thingVerbs(usePlayerActs()?.actions, sheet);
64
+ return (_jsxs(ThingVerbsContext.Provider, { value: verbs, children: [(line.length > 0 || boxes.length > 0) && _jsx(ValueLine, { values: line, fields: fields, boxes: boxes }), groups.map((group) => _jsx(Group, { member: member.name, group: group, fields: fields, version: version, onRoll: onRoll }, group.name))] }));
55
65
  }
56
66
  /** What a row shows beside its value, when it says something more: a written speed equal to the one that counts now says nothing. */
57
67
  function shownBeside(value) {
@@ -208,8 +218,11 @@ function systemText(word) {
208
218
  */
209
219
  function ItemsTable({ group, fields }) {
210
220
  const acts = usePlayerActs();
221
+ const verbsOf = useContext(ThingVerbsContext);
211
222
  const [closed, setClosed] = useState(new Set());
212
- const items = group.items ?? [];
223
+ // What is equipped first, under its own heading, then a rule and the rest (D-581 (6)).
224
+ const { equipped, rest } = equippedFirst(group.items ?? []);
225
+ const items = [...equipped, ...rest];
213
226
  const columns = items[0]?.values.map((value) => value.field) ?? [];
214
227
  const labels = groupLabels(columns, fields);
215
228
  const depths = items.map((item) => item.depth ?? 0);
@@ -226,31 +239,39 @@ function ItemsTable({ group, fields }) {
226
239
  // What is carried tells how many after its name, as Torce (6), with no column of its own (Stefano, 15 October).
227
240
  const carried = columns.length === 1 && columns[0] === "quantity";
228
241
  const count = (item) => (carried ? item.values[0]?.text ?? "" : "");
229
- return (_jsxs("table", { class: ["items", marked ? "marked" : "", carried ? "carried" : ""].filter((name) => name !== "").join(" "), children: [_jsx("thead", { class: carried ? "visually-hidden" : undefined, children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: _jsx("span", { class: "visually-hidden", children: t("Name") }) }), !carried && columns.map((field) => _jsx("th", { scope: "col", children: phraseLabel(labels.get(field) ?? fieldLabel(field, fields)) }, field))] }) }), _jsx("tbody", { children: items.map((item, index) => {
230
- if (!shown[index]) {
231
- return null;
232
- }
233
- const name = itemName(item.item);
234
- const bonds = (item.bonds ?? []).map((list) => fieldLabel(list, fields));
235
- const parts = [
236
- item.inside === undefined ? undefined : t("in {container}", { container: itemName(item.inside) }),
237
- item.equipped === true ? t("Equipped") : undefined,
238
- ...bonds,
239
- ].filter((part) => part !== undefined);
240
- const said = parts.map((part) => `, ${part}`).join("");
241
- // What the thing's card says under its name: how many, where it is, whether equipped.
242
- const facts = [...(count(item) === "" ? [] : [`×${count(item)}`]), ...parts];
243
- const words = (_jsxs(_Fragment, { children: [marked && _jsx(ItemPicture, { image: item.image, equipped: item.equipped === true }), _jsx("span", { children: name }), count(item) !== "" && _jsx("span", { class: "item-count", children: ` (${count(item)})` }), bonds.length > 0 && (_jsx("span", { class: "item-bond", "data-tip": bonds.join(", "), "aria-hidden": "true", children: _jsx(Icon, { name: "bond" }) })), said !== "" && _jsx("span", { class: "visually-hidden", children: said })] }));
244
- // The campaign changed its page of the game system (D-564): an asterisk after its name, outside what acts.
245
- const changed = item.layered === true && _jsx(ChangedMark, {});
246
- // The name opens the thing's card, with its verbs when the system names some; a container's opens and closes what it holds (D-495).
247
- const verbs = holds(index) ? undefined : itemVerbs(acts?.actions, item);
248
- return (_jsxs("tr", { class: item.depth === undefined ? undefined : "inside", children: [_jsxs("th", { scope: "row", class: holds(index) ? "holds" : undefined, style: item.depth === undefined ? undefined : { "--depth": item.depth }, children: [holds(index)
249
- ? (_jsxs("button", { type: "button", class: "fold", "aria-expanded": !closed.has(key(index)), onClick: () => toggle(index), children: [_jsx(Icon, { name: "fold" }), words] }))
250
- : acts === undefined
251
- ? words
252
- : (_jsx(ActName, { verbs: verbs ?? [], item: name, page: item.item, facts: facts, ...(item.document === true ? { document: true } : {}), said: `${count(item) === "" ? "" : ` (${count(item)})`}${said}`, children: words })), changed] }), !carried && item.values.map((value) => _jsx("td", { class: widgetOf(value) === "text" ? undefined : "num", children: shownText(value.text, value.kind) }, value.field))] }, key(index)));
253
- }) })] }));
242
+ const span = carried ? 1 : columns.length + 1;
243
+ // The verbs of a thing, the same wherever the sheet has it (D-581 (D)).
244
+ const verbsFor = (item) => verbsOf?.get(thingKey(item.item)) ?? itemVerbs(acts?.actions, item) ?? [];
245
+ return (_jsxs("table", { class: ["items", marked ? "marked" : "", carried ? "carried" : ""].filter((name) => name !== "").join(" "), children: [_jsx("thead", { class: carried ? "visually-hidden" : undefined, children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: _jsx("span", { class: "visually-hidden", children: t("Name") }) }), !carried && columns.map((field) => _jsx("th", { scope: "col", children: phraseLabel(labels.get(field) ?? fieldLabel(field, fields)) }, field))] }) }), _jsxs("tbody", { children: [equipped.length > 0 && (_jsx("tr", { class: "items-head", children: _jsx("th", { scope: "colgroup", colSpan: span, class: "eyebrow", children: t("Equipped") }) })), items.map((item, index) => {
246
+ if (!shown[index]) {
247
+ return null;
248
+ }
249
+ const name = itemName(item.item);
250
+ const bonds = (item.bonds ?? []).map((list) => fieldLabel(list, fields));
251
+ const parts = [
252
+ item.inside === undefined ? undefined : t("in {container}", { container: itemName(item.inside) }),
253
+ item.equipped === true ? t("Equipped") : undefined,
254
+ ...bonds,
255
+ ].filter((part) => part !== undefined);
256
+ const said = parts.map((part) => `, ${part}`).join("");
257
+ // What the thing's card says under its name: how many, where it is, whether equipped.
258
+ const facts = [...(count(item) === "" ? [] : [`×${count(item)}`]), ...parts];
259
+ const words = (_jsxs(_Fragment, { children: [marked && _jsx(ItemPicture, { image: item.image, equipped: item.equipped === true }), _jsx("span", { children: name }), count(item) !== "" && _jsx("span", { class: "item-count", children: ` (${count(item)})` }), bonds.length > 0 && (_jsx("span", { class: "item-bond", "data-tip": bonds.join(", "), "aria-hidden": "true", children: _jsx(Icon, { name: "bond" }) })), said !== "" && _jsx("span", { class: "visually-hidden", children: said })] }));
260
+ // The campaign changed its page of the game system (D-564): an asterisk after its name, outside what acts.
261
+ const changed = item.layered === true && _jsx(ChangedMark, {});
262
+ // The name opens the thing's card, with its verbs when the system names some; a container's opens and closes what it holds, and its info
263
+ // icon opens its card (D-495, D-581).
264
+ const about = t("About {item}", { item: name });
265
+ const line = (_jsxs("tr", { class: item.depth === undefined ? undefined : "inside", children: [_jsxs("th", { scope: "row", class: holds(index) ? "holds" : undefined, style: item.depth === undefined ? undefined : { "--depth": item.depth }, children: [holds(index)
266
+ ? (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", class: "fold", "aria-expanded": !closed.has(key(index)), onClick: () => toggle(index), children: [_jsx(Icon, { name: "fold" }), words] }), acts !== undefined && (_jsx("button", { type: "button", class: "icon-button item-info", "aria-label": about, "data-tip": about, onClick: (event) => acts.start({ verbs: verbsFor(item), item: name, page: item.item, facts }, event.currentTarget), children: _jsx(Icon, { name: "info" }) }))] }))
267
+ : acts === undefined
268
+ ? words
269
+ : (_jsx(ActName, { verbs: verbsFor(item), item: name, page: item.item, facts: facts, ...(item.document === true ? { document: true } : {}), said: `${count(item) === "" ? "" : ` (${count(item)})`}${said}`, children: words })), changed] }), !carried && item.values.map((value) => _jsx("td", { class: widgetOf(value) === "text" ? undefined : "num", children: shownText(value.text, value.kind) }, value.field))] }, key(index)));
270
+ // A rule between what is equipped and the rest, when both have lines.
271
+ return index === equipped.length && index > 0
272
+ ? (_jsxs(Fragment, { children: [_jsx("tr", { class: "items-rule", "aria-hidden": "true", children: _jsx("td", { colSpan: span }) }), line] }, key(index)))
273
+ : line;
274
+ })] })] }));
254
275
  }
255
276
  /** A thing's picture, one colour as the words beside it, gold when equipped: the game's drawing of its kind as a mask, or the page's own of any thing. */
256
277
  function ItemPicture({ image, equipped }) {
@@ -43,9 +43,9 @@ export function gameNotices(problems, textsTranslating) {
43
43
  text: problems === 1 ? t("The campaign has a problem in its files: the master sees it and fixes it.") : t("The campaign has {count} problems in its files: the master sees them and fixes them.", { count: problems }),
44
44
  }]),
45
45
  ...(translation?.state === "translating" ? [{ kind: "info", text: t("This computer is translating the page into {language}: until then it stays in English.", { language }) }] : []),
46
- ...(translation?.state === "unable" ? [{ kind: "info", text: t("The page stays in English: Codex or Claude Code would translate it into {language} on this computer.", { language }) }] : []),
46
+ ...(translation?.state === "unable" ? [{ kind: "info", text: t("The page stays in English: your AI app would translate it into {language} on this computer, but none can now.", { language }) }] : []),
47
47
  ...(textsTranslating !== undefined
48
- ? [{ kind: "info", text: t("With your account, Codex, Claude Code or OpenCode is translating the game's rules into {language}: until then they stay in English.", { language: textsLanguage }) }]
48
+ ? [{ kind: "info", text: t("With your account, your AI app is translating the game's rules into {language}: until then they stay in English.", { language: textsLanguage }) }]
49
49
  : []),
50
50
  ];
51
51
  }