rpg-engine 0.14.0 → 0.15.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 (82) hide show
  1. package/README.md +2 -0
  2. package/dist/campaign/index.d.ts +1 -1
  3. package/dist/campaign/index.js +1 -1
  4. package/dist/campaign/last-choices.js +1 -1
  5. package/dist/campaign/settings.d.ts +19 -5
  6. package/dist/campaign/settings.js +16 -8
  7. package/dist/commands/config.d.ts +2 -2
  8. package/dist/commands/config.js +42 -11
  9. package/dist/commands/find.d.ts +4 -4
  10. package/dist/commands/instructions.js +12 -1
  11. package/dist/commands/mode.js +10 -2
  12. package/dist/commands/shared/mode.js +6 -2
  13. package/dist/commands/shared/parts.d.ts +7 -0
  14. package/dist/commands/shared/parts.js +23 -0
  15. package/dist/commands/show.d.ts +1 -1
  16. package/dist/commands/status.js +6 -1
  17. package/dist/commands/write/write.d.ts +1 -1
  18. package/dist/commands/write/write.js +2 -2
  19. package/dist/dashboard/choices.js +22 -17
  20. package/dist/dashboard/guide/ar.md +12 -7
  21. package/dist/dashboard/guide/cs.md +12 -7
  22. package/dist/dashboard/guide/da.md +12 -7
  23. package/dist/dashboard/guide/de.md +12 -7
  24. package/dist/dashboard/guide/el.md +12 -7
  25. package/dist/dashboard/guide/en.md +11 -6
  26. package/dist/dashboard/guide/es.md +12 -7
  27. package/dist/dashboard/guide/fi.md +12 -7
  28. package/dist/dashboard/guide/fr.md +12 -7
  29. package/dist/dashboard/guide/he.md +12 -7
  30. package/dist/dashboard/guide/hi.md +12 -7
  31. package/dist/dashboard/guide/hu.md +13 -8
  32. package/dist/dashboard/guide/is.md +12 -7
  33. package/dist/dashboard/guide/it.md +13 -8
  34. package/dist/dashboard/guide/ja.md +12 -7
  35. package/dist/dashboard/guide/ko.md +14 -9
  36. package/dist/dashboard/guide/nb.md +12 -7
  37. package/dist/dashboard/guide/nl.md +12 -7
  38. package/dist/dashboard/guide/pl.md +12 -7
  39. package/dist/dashboard/guide/pt.md +12 -7
  40. package/dist/dashboard/guide/ro.md +12 -7
  41. package/dist/dashboard/guide/ru.md +12 -7
  42. package/dist/dashboard/guide/sv.md +12 -7
  43. package/dist/dashboard/guide/tr.md +12 -7
  44. package/dist/dashboard/guide/uk.md +13 -8
  45. package/dist/dashboard/guide/zh.md +12 -7
  46. package/dist/dashboard/i18n/ar.json +17 -0
  47. package/dist/dashboard/i18n/cs.json +17 -0
  48. package/dist/dashboard/i18n/da.json +17 -0
  49. package/dist/dashboard/i18n/de.json +17 -0
  50. package/dist/dashboard/i18n/el.json +17 -0
  51. package/dist/dashboard/i18n/es.json +17 -0
  52. package/dist/dashboard/i18n/fi.json +17 -0
  53. package/dist/dashboard/i18n/fr.json +17 -0
  54. package/dist/dashboard/i18n/he.json +17 -0
  55. package/dist/dashboard/i18n/hi.json +17 -0
  56. package/dist/dashboard/i18n/hu.json +17 -0
  57. package/dist/dashboard/i18n/is.json +17 -0
  58. package/dist/dashboard/i18n/it.json +17 -0
  59. package/dist/dashboard/i18n/ja.json +17 -0
  60. package/dist/dashboard/i18n/ko.json +17 -0
  61. package/dist/dashboard/i18n/nb.json +17 -0
  62. package/dist/dashboard/i18n/nl.json +17 -0
  63. package/dist/dashboard/i18n/pl.json +17 -0
  64. package/dist/dashboard/i18n/pt.json +17 -0
  65. package/dist/dashboard/i18n/ro.json +17 -0
  66. package/dist/dashboard/i18n/ru.json +17 -0
  67. package/dist/dashboard/i18n/sv.json +17 -0
  68. package/dist/dashboard/i18n/tr.json +17 -0
  69. package/dist/dashboard/i18n/uk.json +17 -0
  70. package/dist/dashboard/i18n/zh.json +17 -0
  71. package/dist/dashboard/labels.js +6 -0
  72. package/dist/dashboard/setup.js +1 -1
  73. package/dist/dashboard/style.css +31 -11
  74. package/dist/library/books.js +2 -0
  75. package/dist/server/dashboard/choices.d.ts +8 -5
  76. package/dist/server/dashboard/choices.js +6 -4
  77. package/dist/server/dashboard/writes.js +1 -1
  78. package/instructions/length-a-few-sessions.md +1 -0
  79. package/instructions/length-one-evening.md +1 -0
  80. package/instructions/session-zero.md +1 -1
  81. package/instructions/setup.md +1 -1
  82. package/package.json +1 -1
@@ -52,7 +52,7 @@ export function SetupView({ setup }) {
52
52
  go(at + 1);
53
53
  }
54
54
  };
55
- return (_jsxs("section", { class: "setup", "aria-labelledby": "setup-title", children: [_jsx("div", { class: "setup-host", children: _jsx(Master, { mood: "happy" }) }), _jsx(CampaignName, { name: setup.name }), _jsx("h1", { id: "setup-title", class: "visually-hidden", children: t("Setting up {campaign}", { campaign: setup.name }) }), _jsx("ol", { class: "setup-steps", "aria-label": t("Steps"), children: steps.map((one, index) => (_jsxs("li", { class: index < step ? "done" : index === step ? "now" : undefined, "aria-current": index === step ? "step" : undefined, children: [_jsx("span", { class: "setup-step-dot", "aria-hidden": "true", children: index < step ? "✓" : index + 1 }), stepName(one)] }, one))) }), said !== undefined && _jsx("p", { class: "setup-problem", role: "alert", children: said }), !done && question !== undefined && (_jsx(Question, { question: question, count: t("{value} of {max}", { value: at + 1, max: questions.length }), left: left.has(question.name), focus: moved, onBack: at > 0 ? () => go(at - 1) : undefined, onNext: () => go(at + 1), onLeave: () => void leave(question.name), onProblem: setSaid }, question.name)), done && _jsx(Ready, { setup: setup, left: left, focus: moved, onGo: go, onProblem: setSaid }), _jsx("ol", { class: "setup-dots", "aria-label": t("Questions"), children: questions.map((one, index) => (_jsx("li", { children: _jsx("button", { type: "button", class: [answered(one) ? "answered" : left.has(one.name) ? "left" : "", index === at ? "here" : ""].filter((name) => name !== "").join(" "), "aria-label": answered(one) ? t("{setting}: answered", { setting: settingLabel(one.name) }) : left.has(one.name) ? t("{setting}: left to the master", { setting: settingLabel(one.name) }) : settingLabel(one.name), "aria-current": index === at ? "step" : undefined, onClick: () => go(index) }) }, one.name))) }), _jsx("p", { class: "setup-chat", children: t("You can also tell the master in the chat: they hear what you choose here.") })] }));
55
+ return (_jsxs("section", { class: "setup", "aria-labelledby": "setup-title", children: [_jsx("div", { class: "setup-host", children: _jsx(Master, { mood: "happy" }) }), _jsx(CampaignName, { name: setup.name }), _jsx("h1", { id: "setup-title", class: "visually-hidden", children: t("Setting up {campaign}", { campaign: setup.name }) }), _jsx("ol", { class: "setup-steps", "aria-label": t("Steps"), children: steps.map((one, index) => (_jsxs("li", { class: index < step ? "done" : index === step ? "now" : undefined, "aria-current": index === step ? "step" : undefined, children: [_jsx("span", { class: "setup-step-dot", "aria-hidden": "true", children: index < step ? "✓" : index + 1 }), stepName(one)] }, one))) }), said !== undefined && _jsx("p", { class: "setup-problem", role: "alert", children: said }), !done && question !== undefined && (_jsx(Question, { question: question, count: t("{value} of {max}", { value: at + 1, max: questions.length }), left: left.has(question.name), focus: moved, onBack: at > 0 ? () => go(at - 1) : undefined, onNext: () => go(at + 1), onLeave: () => void leave(question.name), onProblem: setSaid }, question.name)), done && _jsx(Ready, { setup: setup, left: left, focus: moved, onGo: go, onProblem: setSaid }), _jsx("ol", { class: "setup-dots", "aria-label": t("Questions"), style: { "--count": String(questions.length) }, children: questions.map((one, index) => (_jsx("li", { children: _jsx("button", { type: "button", class: [answered(one) ? "answered" : left.has(one.name) ? "left" : "", index === at ? "here" : ""].filter((name) => name !== "").join(" "), "aria-label": answered(one) ? t("{setting}: answered", { setting: settingLabel(one.name) }) : left.has(one.name) ? t("{setting}: left to the master", { setting: settingLabel(one.name) }) : settingLabel(one.name), "aria-current": index === at ? "step" : undefined, onClick: () => go(index) }) }, one.name))) }), _jsx("p", { class: "setup-chat", children: t("You can also tell the master in the chat: they hear what you choose here.") })] }));
56
56
  }
57
57
  /**
58
58
  * One question as its card shows it: what it is, its choices large with what each means and the one the game suggests, or a list's items; back, next, or left
@@ -378,7 +378,7 @@
378
378
  outline-offset: 0 !important;
379
379
  }
380
380
 
381
- .filter-chips button:focus-visible,
381
+ .filter-chips :is(button, a):focus-visible,
382
382
  .package-show:focus-visible,
383
383
  .package-row:focus-visible {
384
384
  outline: 2px solid var(--accent) !important;
@@ -2064,7 +2064,7 @@
2064
2064
  margin: 6px 0 4px;
2065
2065
  }
2066
2066
 
2067
- .filter-chips button {
2067
+ .filter-chips :is(button, a) {
2068
2068
  display: inline-flex;
2069
2069
  align-items: center;
2070
2070
  gap: 6px;
@@ -2080,18 +2080,18 @@
2080
2080
  cursor: pointer;
2081
2081
  }
2082
2082
 
2083
- .filter-chips button:hover {
2083
+ .filter-chips :is(button, a):hover {
2084
2084
  background: color-mix(in srgb, var(--ink) 5%, transparent);
2085
2085
  }
2086
2086
 
2087
- .filter-chips button[aria-pressed="true"] {
2087
+ .filter-chips :is(button[aria-pressed="true"], a[aria-current="page"]) {
2088
2088
  border-color: var(--accent);
2089
2089
  background: color-mix(in srgb, var(--accent) 14%, transparent);
2090
2090
  }
2091
2091
 
2092
2092
  /* A finger needs the room of a target, after the chip's own height. */
2093
2093
  @media (pointer: coarse) {
2094
- .filter-chips button {
2094
+ .filter-chips :is(button, a) {
2095
2095
  min-height: var(--target);
2096
2096
  }
2097
2097
  }
@@ -10263,15 +10263,20 @@
10263
10263
  border-color: color-mix(in srgb, var(--gold) 60%, var(--rule));
10264
10264
  }
10265
10265
 
10266
- /* Each dot is drawn at 12 pixels in a target of 24; where the player is, a wider pill. */
10266
+ /* Each dot is drawn at 12 pixels in a target of 24; where the player is, a wider pill. The dots wrap as words do, balanced: when one row is too narrow
10267
+ for them, two even rows, never one dot alone. */
10267
10268
  .setup-dots {
10268
- display: flex;
10269
- flex-wrap: wrap;
10270
- justify-content: center;
10271
- gap: 0;
10269
+ justify-self: stretch;
10272
10270
  margin: 0;
10273
10271
  padding: 0;
10274
10272
  list-style: none;
10273
+ text-align: center;
10274
+ text-wrap: balance;
10275
+ }
10276
+
10277
+ .setup-dots > li {
10278
+ display: inline-block;
10279
+ vertical-align: top;
10275
10280
  }
10276
10281
 
10277
10282
  .setup-dots button {
@@ -10328,8 +10333,13 @@
10328
10333
  }
10329
10334
 
10330
10335
  @media (pointer: coarse) {
10336
+ /* Touch targets as large as one row of questions allows, never under 24px; the list spans the column, so the share is of a known width. */
10337
+ .setup-dots > li {
10338
+ width: clamp(24px, calc(100% / var(--count, 12)), 30px);
10339
+ }
10340
+
10331
10341
  .setup-dots button {
10332
- width: 30px;
10342
+ width: 100%;
10333
10343
  height: 30px;
10334
10344
  }
10335
10345
 
@@ -15304,6 +15314,16 @@
15304
15314
  justify-content: space-between;
15305
15315
  }
15306
15316
 
15317
+ /* The other pages an option names, each a chip that opens it in the reader. */
15318
+ .choices-pages {
15319
+ margin: 0;
15320
+ padding: 2px 16px 8px;
15321
+ }
15322
+
15323
+ .choices-pages a {
15324
+ text-decoration: none;
15325
+ }
15326
+
15307
15327
  .choice-picked {
15308
15328
  display: inline-flex;
15309
15329
  align-items: center;
@@ -277,6 +277,8 @@ function writeIndex(folder, index) {
277
277
  mkdirSync(dirname(file), { recursive: true });
278
278
  writeFileSync(`${file}.part`, JSON.stringify(index));
279
279
  replaceFile(`${file}.part`, file);
280
+ // Two writes of one size within a tick of the file clock look the same: the index read before is no longer it.
281
+ loaded.delete(file);
280
282
  }
281
283
  const pause = new Int32Array(new SharedArrayBuffer(4));
282
284
  /**
@@ -1,14 +1,17 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { Served } from "./index.ts";
3
- /** An option as the page shows it: the master's words, its label without dice, its dice when it is a roll, the page it names with that page's first sentence. */
3
+ /** An option as the page shows it: the master's words, its label without dice, its dice when it is a roll, the pages it names with their titles and first sentences. */
4
4
  export interface ShownOption {
5
5
  text: string;
6
6
  label: string;
7
7
  notation?: string;
8
- page?: {
9
- name: string;
10
- opening: string;
11
- };
8
+ pages?: OptionPage[];
9
+ }
10
+ /** A page an option names: its name, its title in the campaign's language, its first sentence as the character may read it. */
11
+ export interface OptionPage {
12
+ name: string;
13
+ title: string;
14
+ opening: string;
12
15
  }
13
16
  /** A set of choices as the page shows it. */
14
17
  export interface ShownChoices {
@@ -87,14 +87,16 @@ function shownChoices(root, served) {
87
87
  }
88
88
  function shownOption(world, knowledge, option) {
89
89
  const parts = optionParts(option);
90
- const page = parts.pages.length === 0 ? undefined : findPage(world, parts.pages[0]);
91
- const introduction = page === undefined ? "" : knowledge === undefined ? withoutComments(introductionText(page.translated ?? page.body)) : knownIntroduction(world, knowledge, page);
92
- const opening = firstSentence(linkWords(world, introduction).replace(/\s+/g, " ").trim());
90
+ const found = parts.pages.map((name) => findPage(world, name)).filter((page) => page !== undefined);
91
+ const pages = found.filter((page, index) => found.findIndex((other) => other.name === page.name) === index).map((page) => {
92
+ const introduction = knowledge === undefined ? withoutComments(introductionText(page.translated ?? page.body)) : knownIntroduction(world, knowledge, page);
93
+ return { name: page.name, title: page.title ?? page.name, opening: firstSentence(linkWords(world, introduction).replace(/\s+/g, " ").trim()) };
94
+ });
93
95
  return {
94
96
  text: option,
95
97
  label: linkWords(world, parts.label).trim(),
96
98
  ...(parts.notation === undefined ? {} : { notation: parts.notation }),
97
- ...(page === undefined ? {} : { page: { name: page.name, opening } }),
99
+ ...(pages.length === 0 ? {} : { pages }),
98
100
  };
99
101
  }
100
102
  /** A text's links as their words; one without words as its page's name in the campaign's language, a system page's title (D-542). */
@@ -86,7 +86,7 @@ export async function changeSetting(request, response, served) {
86
86
  const change = parsed.data;
87
87
  const refused = withFiles(served.session, () => {
88
88
  const root = requireCampaign(served.context.folder);
89
- // In the setup, how companions come, the preparation and the name are the player's too (D-370).
89
+ // In the setup, how the character and the companions come, the preparation, the length and the name are the player's too (D-370).
90
90
  const setup = campaignMode(root, campaignWorld(root, served.context)) === "setup";
91
91
  // Where the page shows the extensions' widgets is the page's own: the master hears nothing of it (D-502).
92
92
  if (change.setting.trim() === "widgets" && !("add" in change)) {
@@ -0,0 +1 @@
1
+ The campaign plays a few sessions, about a week of evenings: size each adventure for three to five sessions, its goal clear in the first, a turn halfway, its climax in the last. Give each session one step of the goal, and when the player ends it, close on that step and a hook to the next; keep the threads to what this adventure can close. A written adventure keeps its own size. Once it closes, give an epilogue of what the character changed, then ask the player whether to go on: if so, the next adventure has the same length unless they change it, which you set with config length.
@@ -0,0 +1 @@
1
+ The campaign plays one evening: size each adventure for one session of two or three hours, about five scenes. One place and what lies close to it, three or four people who each want something, the hook in the first scene, a hard choice halfway, and a climax that ends it that night; at most two fights, the bigger one at the climax. Session zero is part of the evening: make the character in a few questions. Cut what does not lead to the end; when the scenes run out, bring the climax. A written adventure keeps its own size. Once it closes, give an epilogue of what the character changed, then ask the player whether to go on: if so, the next adventure has the same length unless they change it, which you set with config length.
@@ -1,3 +1,3 @@
1
1
  ## Session zero
2
2
 
3
- Play, as with a human game master, in the second person, present tense, unless the player asks otherwise. Make the player character with the player, as the system says below, and the companions as the setup agreed: made with the player, or by you, each with its sheet. Every choice about the player character is the player's, unless they ask you to make it. A player character taken from the world's pages, as a book's, keeps their past, bonds and nature: make the sheet from their page, the player confirming each choice, then make them the player character with role pc, and reveal what they knew, their plans too, told as theirs to keep or change; what the story had them do next is no longer written anywhere. Their story is never required: write it in the player's words and read it back to them once; behind the scenes, tie its people, places and bonds to the world where they fit, what the character does not know in secrets. Once the player character is made, ask the player for a picture of them: a file of theirs, given with image and file, or one made from how they describe the character, with image and describe: their people as this world has them, then the look the player gives, or yours if they leave it to you; where the campaign makes pictures.
3
+ Play, as with a human game master, in the second person, present tense, unless the player asks otherwise. Make the player character as the setup agreed in character, and the companions as it agreed in companions: made with the player, or by you, each with its sheet, as the system says below. Made with the player, every choice about the player character is theirs, unless they ask you to make it. Made by you, ask for a few words of what they want, make it all, and read it back once. The player's own, they bring a character they already have, pasted in the chat, as a file on their computer, a photo or a PDF of a sheet too, or as its page: read it whole, write its sheet as the system says, at the level it has, and check it against the rules and this campaign; what does not hold, such as a score, an item or a power the world lacks, tell them and agree the change, never change it silently; what it lacks, as when they bring only a description, make with them, choice by choice. In a game with levels, ask from which level a character made here starts, the first unless the player wants another; the adventures fit the level they play. A player character taken from the world's pages, as a book's, keeps their past, bonds and nature: make the sheet from their page, the player confirming each choice, then make them the player character with role pc, and reveal what they knew, their plans too, told as theirs to keep or change; what the story had them do next is no longer written anywhere. Their story is never required: write it in the player's words and read it back to them once; behind the scenes, tie its people, places and bonds to the world where they fit, what the character does not know in secrets. Once the player character is made, ask the player for a picture of them: a file of theirs, given with image and file, or one made from how they describe the character, with image and describe: their people as this world has them, then the look the player gives, or yours if they leave it to you; where the campaign makes pictures.
@@ -1,3 +1,3 @@
1
1
  ## Setup
2
2
 
3
- Out of the game, without brackets. The game system comes first, in the chat: offer those status names, installed or to install, free always among them, and say that the campaign keeps the one chosen once its first character is made; install it with package install if it is not here, then config system, and ask its version of the rules when it has more than one. If it cannot be installed, give the player both ways its answer names, and free as a third. Then ask the player for what status says is still missing, at most three questions per message, the minimum to start first: give each choice with what its values mean, and offer the usual ones together, so that one answer can settle several. Take the language from how the player writes and save it with config at once, without asking, so the page speaks it too; change it only if they ask for another. "You decide" is an answer: then choose, and say what you chose. Save any other setting with config only once the player has confirmed it. Without a written world, the player chooses its genre, tone and a few elements, and in the same question what they enjoy most in a game, such as fights, mysteries, talk or exploring: all of it is the premise. You build the rest, at the start or as it is needed, as the preparation says, with several factions whose wants clash, so that many stories can start, never one plot.
3
+ Out of the game, without brackets. The game system comes first, in the chat: offer those status names, installed or to install, free always among them, and say that the campaign keeps the one chosen once its first character is made; install it with package install if it is not here, then config system, and ask its version of the rules when it has more than one. If it cannot be installed, give the player both ways its answer names, and free as a third. Then ask the player for what status says is still missing, at most three questions per message, the minimum to start first: give each choice with what its values mean, and offer the usual ones together, so that one answer can settle several. Take the language from how the player writes and save it with config at once, without asking, so the page speaks it too; change it only if they ask for another. "You decide" is an answer: then choose, and say what you chose. Save any other setting with config only once the player has confirmed it. Without a written world, the player chooses its genre, tone and a few elements, and in the same question what they enjoy most in a game, such as fights, mysteries, talk or exploring: all of it is the premise. You build the rest, at the start or as it is needed, as the preparation says, and as big as the length needs: several factions whose wants clash, so that many stories can start, never one plot; for one evening, only what its adventure needs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rpg-engine",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Play a tabletop role-playing game with an AI as your game master: the AI tells the story; RPG Engine remembers the world, rolls the dice and keeps the accounts.",
5
5
  "type": "module",
6
6
  "bin": {