rpg-engine 0.12.0 → 0.14.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 (146) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/choices.d.ts +30 -0
  3. package/dist/campaign/choices.js +84 -0
  4. package/dist/campaign/index.d.ts +4 -1
  5. package/dist/campaign/index.js +4 -1
  6. package/dist/campaign/last-choices.d.ts +6 -0
  7. package/dist/campaign/last-choices.js +34 -0
  8. package/dist/campaign/levels.d.ts +50 -0
  9. package/dist/campaign/levels.js +189 -0
  10. package/dist/campaign/settings.d.ts +35 -13
  11. package/dist/campaign/settings.js +20 -51
  12. package/dist/commands/ask.d.ts +8 -0
  13. package/dist/commands/ask.js +2 -1
  14. package/dist/commands/change/change.js +6 -4
  15. package/dist/commands/choices.d.ts +64 -0
  16. package/dist/commands/choices.js +216 -0
  17. package/dist/commands/config.d.ts +8 -1
  18. package/dist/commands/config.js +165 -21
  19. package/dist/commands/effect.d.ts +1 -1
  20. package/dist/commands/index.js +2 -0
  21. package/dist/commands/init.d.ts +1 -0
  22. package/dist/commands/init.js +8 -4
  23. package/dist/commands/rename.js +8 -3
  24. package/dist/commands/save.d.ts +1 -1
  25. package/dist/commands/shared/experience.d.ts +9 -2
  26. package/dist/commands/shared/experience.js +42 -7
  27. package/dist/commands/shared/inputs.d.ts +2 -2
  28. package/dist/commands/shared/inputs.js +15 -2
  29. package/dist/commands/shared/knowledge.d.ts +2 -0
  30. package/dist/commands/shared/knowledge.js +5 -0
  31. package/dist/commands/shared/mode.js +10 -3
  32. package/dist/commands/shared/offers.d.ts +3 -1
  33. package/dist/commands/shared/offers.js +6 -1
  34. package/dist/commands/shared/page-words.d.ts +4 -0
  35. package/dist/commands/shared/page-words.js +7 -7
  36. package/dist/commands/shared/rules.js +5 -1
  37. package/dist/commands/shared/system-texts.d.ts +11 -0
  38. package/dist/commands/shared/system-texts.js +203 -0
  39. package/dist/commands/shared/time.d.ts +6 -0
  40. package/dist/commands/shared/time.js +35 -3
  41. package/dist/commands/shared/upkeep.js +3 -3
  42. package/dist/commands/shared/world.d.ts +2 -0
  43. package/dist/commands/shared/world.js +20 -7
  44. package/dist/commands/status.d.ts +2 -0
  45. package/dist/commands/status.js +15 -7
  46. package/dist/commands/view/view.d.ts +4 -0
  47. package/dist/commands/view/view.js +24 -10
  48. package/dist/commands/write/write.d.ts +3 -3
  49. package/dist/commands/write/write.js +5 -2
  50. package/dist/core/context.d.ts +16 -0
  51. package/dist/core/files.js +2 -3
  52. package/dist/core/language.d.ts +2 -0
  53. package/dist/core/language.js +8 -0
  54. package/dist/core/text.d.ts +2 -0
  55. package/dist/core/text.js +5 -0
  56. package/dist/dashboard/address.js +8 -1
  57. package/dist/dashboard/api.js +20 -0
  58. package/dist/dashboard/app.js +20 -7
  59. package/dist/dashboard/choices.js +338 -0
  60. package/dist/dashboard/guide/ar.md +8 -8
  61. package/dist/dashboard/guide/cs.md +8 -8
  62. package/dist/dashboard/guide/da.md +9 -9
  63. package/dist/dashboard/guide/de.md +8 -8
  64. package/dist/dashboard/guide/el.md +10 -10
  65. package/dist/dashboard/guide/en.md +7 -7
  66. package/dist/dashboard/guide/es.md +8 -8
  67. package/dist/dashboard/guide/fi.md +8 -8
  68. package/dist/dashboard/guide/fr.md +8 -8
  69. package/dist/dashboard/guide/he.md +8 -8
  70. package/dist/dashboard/guide/hi.md +8 -8
  71. package/dist/dashboard/guide/hu.md +8 -8
  72. package/dist/dashboard/guide/is.md +9 -9
  73. package/dist/dashboard/guide/it.md +8 -8
  74. package/dist/dashboard/guide/ja.md +8 -8
  75. package/dist/dashboard/guide/ko.md +9 -9
  76. package/dist/dashboard/guide/nb.md +9 -9
  77. package/dist/dashboard/guide/nl.md +8 -8
  78. package/dist/dashboard/guide/pl.md +8 -8
  79. package/dist/dashboard/guide/pt.md +8 -8
  80. package/dist/dashboard/guide/ro.md +8 -8
  81. package/dist/dashboard/guide/ru.md +8 -8
  82. package/dist/dashboard/guide/sv.md +8 -8
  83. package/dist/dashboard/guide/tr.md +8 -8
  84. package/dist/dashboard/guide/uk.md +8 -8
  85. package/dist/dashboard/guide/zh.md +8 -8
  86. package/dist/dashboard/i18n/ar.json +81 -1
  87. package/dist/dashboard/i18n/cs.json +81 -1
  88. package/dist/dashboard/i18n/da.json +81 -1
  89. package/dist/dashboard/i18n/de.json +81 -1
  90. package/dist/dashboard/i18n/el.json +81 -1
  91. package/dist/dashboard/i18n/es.json +81 -1
  92. package/dist/dashboard/i18n/fi.json +81 -1
  93. package/dist/dashboard/i18n/fr.json +81 -1
  94. package/dist/dashboard/i18n/he.json +81 -1
  95. package/dist/dashboard/i18n/hi.json +81 -1
  96. package/dist/dashboard/i18n/hu.json +81 -1
  97. package/dist/dashboard/i18n/is.json +81 -1
  98. package/dist/dashboard/i18n/it.json +81 -1
  99. package/dist/dashboard/i18n/ja.json +81 -1
  100. package/dist/dashboard/i18n/ko.json +81 -1
  101. package/dist/dashboard/i18n/nb.json +81 -1
  102. package/dist/dashboard/i18n/nl.json +81 -1
  103. package/dist/dashboard/i18n/pl.json +81 -1
  104. package/dist/dashboard/i18n/pt.json +81 -1
  105. package/dist/dashboard/i18n/ro.json +81 -1
  106. package/dist/dashboard/i18n/ru.json +81 -1
  107. package/dist/dashboard/i18n/sv.json +81 -1
  108. package/dist/dashboard/i18n/tr.json +81 -1
  109. package/dist/dashboard/i18n/uk.json +81 -1
  110. package/dist/dashboard/i18n/zh.json +81 -1
  111. package/dist/dashboard/icons.js +4 -0
  112. package/dist/dashboard/labels.js +32 -0
  113. package/dist/dashboard/notices.js +9 -2
  114. package/dist/dashboard/party.js +13 -5
  115. package/dist/dashboard/saves.js +1 -1
  116. package/dist/dashboard/settings.js +89 -40
  117. package/dist/dashboard/setup.js +1 -1
  118. package/dist/dashboard/sheet.js +3 -2
  119. package/dist/dashboard/style.css +729 -1
  120. package/dist/dashboard/text.js +7 -2
  121. package/dist/dashboard/top.js +8 -4
  122. package/dist/documents/png.d.ts +2 -3
  123. package/dist/documents/png.js +6 -6
  124. package/dist/documents/read.js +2 -1
  125. package/dist/extensions/words.js +2 -1
  126. package/dist/languages/language-pack.js +2 -2
  127. package/dist/pages/index.d.ts +1 -1
  128. package/dist/pages/index.js +1 -1
  129. package/dist/pages/world.d.ts +5 -0
  130. package/dist/pages/world.js +22 -11
  131. package/dist/server/dashboard/choices.d.ts +38 -0
  132. package/dist/server/dashboard/choices.js +174 -0
  133. package/dist/server/dashboard/files.js +3 -2
  134. package/dist/server/dashboard/index.d.ts +3 -1
  135. package/dist/server/dashboard/index.js +20 -2
  136. package/dist/server/mcp.js +3 -1
  137. package/dist/systems/game-system.js +2 -1
  138. package/dist/systems/words.js +2 -1
  139. package/dist/testing/index.js +1 -1
  140. package/dist/time/game-date.d.ts +9 -0
  141. package/dist/time/game-date.js +9 -0
  142. package/dist/time/index.d.ts +1 -1
  143. package/dist/time/index.js +1 -1
  144. package/instructions/dashboard-guide.md +1 -1
  145. package/instructions/play.md +1 -1
  146. package/package.json +4 -4
@@ -4,6 +4,7 @@ import { fieldKinds } from "../core/field-kind.js";
4
4
  import { formulaOf, readFormulas } from "../core/formula.js";
5
5
  import { frozen } from "../core/frozen.js";
6
6
  import { readParts } from "../core/instruction-parts.js";
7
+ import { codeAndBase } from "../core/language.js";
7
8
  import { lengthHelp, readLength, readSpeed, speedHelp } from "../core/length.js";
8
9
  import { declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
9
10
  import { files } from "../core/store.js";
@@ -105,7 +106,7 @@ export function withSettings(system, valueOf) {
105
106
  */
106
107
  export function rollName(system, dice, language) {
107
108
  const names = system.rollNames[plainRoll(dice)];
108
- return names === undefined ? undefined : (names[language] ?? names[language.split("-")[0]] ?? names[system.language]);
109
+ return names === undefined ? undefined : ([language, ...codeAndBase(language).slice(1)].map((code) => names[code]).find((name) => name !== undefined) ?? names[system.language]);
109
110
  }
110
111
  /** The systems installed in these folders, nearest folder first: each folder in them with a system.yaml. A name found twice is the nearest one. */
111
112
  export function installedSystems(folders) {
@@ -3,6 +3,7 @@
3
3
  import { existsSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { z } from "zod";
6
+ import { codeAndBase } from "../core/language.js";
6
7
  import { readYamlValues } from "../core/yaml-file.js";
7
8
  const named = z.record(z.string().min(1), z.string().min(1));
8
9
  const wordsSchema = z.object({ groups: named.optional(), fields: named.optional(), words: named.optional(), names: named.optional(), headline: z.string().min(1).optional() }, {
@@ -10,7 +11,7 @@ const wordsSchema = z.object({ groups: named.optional(), fields: named.optional(
10
11
  }).strict();
11
12
  /** The words of the system in this folder for a language, or for its base language (pt for pt-BR); undefined when the system has none in it. */
12
13
  export function systemWords(folder, language) {
13
- const file = [language, language.split("-")[0]].map((code) => join(folder, "words", `${code.toLowerCase()}.yaml`)).find((path) => existsSync(path));
14
+ const file = codeAndBase(language).map((code) => join(folder, "words", `${code}.yaml`)).find((path) => existsSync(path));
14
15
  if (file === undefined) {
15
16
  return undefined;
16
17
  }
@@ -161,7 +161,7 @@ function inPlay(folder) {
161
161
  }
162
162
  /** The dashboard of a test campaign, with a page open on it that the server has heard from, so that questions go to the page. */
163
163
  async function testDashboard(context) {
164
- const session = new SessionStore({ systemFolders: context.systemFolders, watchFolder: () => ({ close: () => undefined }) });
164
+ const session = new SessionStore({ systemFolders: [...(context.systemFolders ?? []), ...(context.home === undefined ? [] : [join(context.home, "systems")])], watchFolder: () => ({ close: () => undefined }) });
165
165
  const dashboard = await startDashboard({ ...context, files: session }, session, { ports: [0], page: context.folder });
166
166
  if (dashboard === undefined) {
167
167
  session.close();
@@ -12,6 +12,15 @@ export declare function readGameDate(value: unknown): GameDate | undefined;
12
12
  export declare function formatGameDate(date: GameDate): string;
13
13
  /** A duration in minutes, written with days, hours and minutes in this order, such as 10m, 4h or 1d 6h; undefined for anything else, and for no time at all. */
14
14
  export declare function readDuration(text: string): number | undefined;
15
+ /** A rate of game time to real time: the minutes of each. */
16
+ export interface TimeRate {
17
+ game: number;
18
+ real: number;
19
+ }
20
+ /** A rate of game time to real time, written as 1d per 7d; undefined for anything else. */
21
+ export declare function readTimeRate(text: string): TimeRate | undefined;
22
+ /** The game time between sessions as a setting writes it (D-133): stops, or a rate of game time to real time; undefined when it reads as neither. */
23
+ export declare function readBetweenSessions(text: string): "stops" | TimeRate | undefined;
15
24
  /** A duration as it is written: 1d 6h, 45m; 0m for no time. */
16
25
  export declare function formatDuration(minutes: number): string;
17
26
  /** The date after some minutes have passed. It keeps a time of day when the date has one, or when the minutes are not whole days. */
@@ -35,6 +35,15 @@ export function readDuration(text) {
35
35
  const total = days * minutesInDay + hours * 60 + minutes;
36
36
  return total > 0 ? total : undefined;
37
37
  }
38
+ /** A rate of game time to real time, written as 1d per 7d; undefined for anything else. */
39
+ export function readTimeRate(text) {
40
+ const [game, real, ...more] = text.trim().split(/\s+per\s+/i).map(readDuration);
41
+ return game === undefined || real === undefined || more.length > 0 ? undefined : { game, real };
42
+ }
43
+ /** The game time between sessions as a setting writes it (D-133): stops, or a rate of game time to real time; undefined when it reads as neither. */
44
+ export function readBetweenSessions(text) {
45
+ return text.trim().toLowerCase() === "stops" ? "stops" : readTimeRate(text);
46
+ }
38
47
  /** A duration as it is written: 1d 6h, 45m; 0m for no time. */
39
48
  export function formatDuration(minutes) {
40
49
  const parts = [[Math.floor(minutes / minutesInDay), "d"], [Math.floor((minutes % minutesInDay) / 60), "h"], [minutes % 60, "m"]];
@@ -1,2 +1,2 @@
1
1
  export { type Calendar, type CalendarDay, calendarDay, type CalendarMonth, type CalendarStart, formatCalendarDay, readCalendar, readCalendarStart, realCalendar } from "./calendar.ts";
2
- export { addDuration, formatDuration, formatGameDate, type GameDate, lastGameDay, minutesBetween, readDuration, readGameDate } from "./game-date.ts";
2
+ export { addDuration, formatDuration, formatGameDate, type GameDate, lastGameDay, minutesBetween, readBetweenSessions, readDuration, readGameDate, readTimeRate, type TimeRate } from "./game-date.ts";
@@ -1,3 +1,3 @@
1
1
  // Game time for any game: the date of the story, counted in days from the start of the adventure, durations, and the calendar that shows a date as a day of a month.
2
2
  export { calendarDay, formatCalendarDay, readCalendar, readCalendarStart, realCalendar } from "./calendar.js";
3
- export { addDuration, formatDuration, formatGameDate, lastGameDay, minutesBetween, readDuration, readGameDate } from "./game-date.js";
3
+ export { addDuration, formatDuration, formatGameDate, lastGameDay, minutesBetween, readBetweenSessions, readDuration, readGameDate, readTimeRate } from "./game-date.js";
@@ -1,6 +1,6 @@
1
1
  How the player uses their dashboard, to answer in a few words, as part of the game, naming the sections as the page shows them in the player's language:
2
2
  - Before play, while the campaign is in its setup, the page has no sections: it is the setup, with the campaign's name to change, the steps Settings, Session zero and Play, and one question at a time as a card, each choice with what it means and the one suggested. A question can be left to you with "You decide", or skipped; lines and veils are the player's alone, and "I'm ready" tells you they are done. What they choose there reaches you at your next call; the premise and the world stay in the chat.
3
- - Party: their character's sheet and the companions'. A click on a number of the sheet rolls it for fun, never logged; their rolls and those of yours they may see are in a column beside it.
3
+ - Party: their character's sheet and the companions'. A click on a number of the sheet rolls it for fun, never logged; their rolls and those of yours they may see are in a column beside it. Choices you prepared with `choices`, such as a new level, open from a notice on the sheet: the player picks when they like, reads the pages the options name, rolls where an option rolls, and confirms.
4
4
  - Scene: where the party is, with its picture and text, its map with who stands where, and the open scene. While a scene goes by turns, as a fight, it shows on top whose turn it is and who comes next, and their character's card beside the map; on other sections a notice leads there on their turn.
5
5
  - Journal: the quests, those followed with their star beside the page; the story by scenes; the companions' diaries; their own notes, which they may share with you.
6
6
  - World: what their character knows of the world, in four tabs: Map, the places they know with distances; Lore, the pages they know; Documents, what they have read; Calendar, the days and what is set on them.
@@ -3,7 +3,7 @@
3
3
  The story is on. Besides the tools above:
4
4
 
5
5
  - `move`: whenever someone or something goes somewhere, before you narrate it: the party (a journey: `travel`), a person who leaves, whoever climbs into a cart or gets out of it to act, an item given or taken.
6
- - `advance`: whenever time passes in the story, in a scene too, before you narrate it: once for a stretch of the story, not for each gesture. When it stops at an event, do as it says, and write the traces where they will be found.
6
+ - `advance`: whenever time passes in the story, in a scene too, before you narrate it: once for a stretch of the story, not for each gesture. When it stops at an event, do as it says, and write the traces where they will be found. A rest the game system has a recipe for, whenever the characters take it: its hours with `advance`, then `change` with the recipe.
7
7
  - `scene`: open one when a scene of any kind starts, not only a fight, with the type it is, and close it when it ends: a chase, a heist, a ritual or a race is a challenge; a deal that matters, social. Whoever the character does not know by name comes in with `seen`, two or three words of what they see, until `reveal` gives the name.
8
8
  - `effect`: every condition or effect on someone (frightened, a curse, a form), how long it lasts and who keeps it alive; it ends by itself.
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rpg-engine",
3
- "version": "0.12.0",
3
+ "version": "0.14.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": {
@@ -44,7 +44,7 @@
44
44
  "docs": "node --experimental-strip-types --input-type=module -e \"import { writeFileSync } from 'node:fs'; import { commands } from './src/commands/index.ts'; import { commandReference } from './src/core/command-reference.ts'; writeFileSync('docs/commands.md', commandReference(commands));\""
45
45
  },
46
46
  "engines": {
47
- "node": ">=22.4"
47
+ "node": ">=24"
48
48
  },
49
49
  "keywords": [
50
50
  "rpg",
@@ -73,7 +73,7 @@
73
73
  "homepage": "https://github.com/stefanocaronia/rpg-engine#readme",
74
74
  "devDependencies": {
75
75
  "@stylistic/eslint-plugin": "^5.10.0",
76
- "@types/node": "^22.20.4",
76
+ "@types/node": "^24.19.2",
77
77
  "@types/three": "^0.187.0",
78
78
  "@typescript-eslint/parser": "^8.71.0",
79
79
  "betasim": "git+https://github.com/stefanocaronia/betasim.git",
@@ -90,7 +90,7 @@
90
90
  "fflate": "^0.8.2",
91
91
  "preact": "^11.2.0",
92
92
  "three": "^0.187.0",
93
- "unpdf": "1.8.1",
93
+ "unpdf": "2.1.0",
94
94
  "yaml": "^2.9.1",
95
95
  "zod": "^4.6.5"
96
96
  }