rpg-engine 0.3.0 → 0.4.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 (61) hide show
  1. package/README.md +1 -1
  2. package/dist/campaign/index.d.ts +1 -1
  3. package/dist/campaign/index.js +1 -1
  4. package/dist/campaign/settings.d.ts +10 -1
  5. package/dist/campaign/settings.js +9 -2
  6. package/dist/command-line.js +6 -1
  7. package/dist/commands/config.d.ts +1 -1
  8. package/dist/commands/config.js +41 -7
  9. package/dist/commands/game-master-rolls.d.ts +15 -0
  10. package/dist/commands/game-master-rolls.js +34 -0
  11. package/dist/commands/game-mode.js +2 -1
  12. package/dist/commands/game-system-code.js +8 -1
  13. package/dist/commands/game-tables.d.ts +7 -0
  14. package/dist/commands/game-tables.js +40 -0
  15. package/dist/commands/game-upkeep.js +1 -1
  16. package/dist/commands/package.js +5 -3
  17. package/dist/commands/roll.d.ts +4 -0
  18. package/dist/commands/roll.js +73 -18
  19. package/dist/dashboard/i18n/ar.json +6 -0
  20. package/dist/dashboard/i18n/cs.json +6 -0
  21. package/dist/dashboard/i18n/da.json +6 -0
  22. package/dist/dashboard/i18n/de.json +6 -0
  23. package/dist/dashboard/i18n/el.json +6 -0
  24. package/dist/dashboard/i18n/es.json +6 -0
  25. package/dist/dashboard/i18n/fi.json +6 -0
  26. package/dist/dashboard/i18n/fr.json +6 -0
  27. package/dist/dashboard/i18n/he.json +6 -0
  28. package/dist/dashboard/i18n/hi.json +6 -0
  29. package/dist/dashboard/i18n/hu.json +6 -0
  30. package/dist/dashboard/i18n/is.json +6 -0
  31. package/dist/dashboard/i18n/it.json +6 -0
  32. package/dist/dashboard/i18n/ja.json +6 -0
  33. package/dist/dashboard/i18n/ko.json +6 -0
  34. package/dist/dashboard/i18n/nb.json +6 -0
  35. package/dist/dashboard/i18n/nl.json +6 -0
  36. package/dist/dashboard/i18n/pl.json +6 -0
  37. package/dist/dashboard/i18n/pt.json +6 -0
  38. package/dist/dashboard/i18n/ro.json +6 -0
  39. package/dist/dashboard/i18n/ru.json +6 -0
  40. package/dist/dashboard/i18n/sv.json +6 -0
  41. package/dist/dashboard/i18n/tr.json +6 -0
  42. package/dist/dashboard/i18n/uk.json +6 -0
  43. package/dist/dashboard/i18n/zh.json +6 -0
  44. package/dist/dashboard/labels.js +3 -0
  45. package/dist/dashboard/settings.js +3 -3
  46. package/dist/dice/index.d.ts +2 -0
  47. package/dist/dice/index.js +3 -1
  48. package/dist/dice/oracle.d.ts +19 -0
  49. package/dist/dice/oracle.js +22 -0
  50. package/dist/dice/tables.d.ts +29 -0
  51. package/dist/dice/tables.js +123 -0
  52. package/dist/pages/index.d.ts +1 -1
  53. package/dist/pages/index.js +1 -1
  54. package/dist/pages/markdown.d.ts +8 -0
  55. package/dist/pages/markdown.js +27 -0
  56. package/dist/systems/system-code.d.ts +1 -1
  57. package/instructions/combat.md +1 -1
  58. package/instructions/core.md +1 -1
  59. package/instructions/play.md +1 -1
  60. package/package.json +2 -2
  61. package/systems/5e/instructions/play.md +1 -0
@@ -0,0 +1,22 @@
1
+ // A yes/no oracle: a d100 against the odds, yes when it is no higher; a double (11, 22, … 00) makes the answer extreme.
2
+ import { DiceError } from "./notation.js";
3
+ import { rollDice } from "./roll-dice.js";
4
+ /** The odds an oracle is asked with, and the chance of a yes in a hundred. */
5
+ export const oracleOdds = { "almost certain": 90, likely: 75, "50/50": 50, unlikely: 25, "small chance": 10 };
6
+ /** Asks the oracle with the odds named, in any case, with hyphens for spaces too; refused, with the five odds, for any other. */
7
+ export function askOracle(odds, source) {
8
+ const name = odds.trim().toLowerCase().replace(/[-\s]+/g, " ");
9
+ const chance = Object.hasOwn(oracleOdds, name) ? oracleOdds[name] : undefined;
10
+ if (chance === undefined) {
11
+ throw new DiceError(`"${odds}" are no odds of the oracle: give one of ${Object.keys(oracleOdds).join(", ")}.`);
12
+ }
13
+ const roll = rollDice("d100", source);
14
+ const { yes, extreme } = oracleResult(chance, roll.total);
15
+ const answer = yes ? (extreme ? "Yes, and more: something beyond what was asked." : "Yes.") : extreme ? "No, and worse." : "No.";
16
+ const shown = `${name[0].toUpperCase()}${name.slice(1)} (${chance}%)`;
17
+ return { odds: name, chance, roll, yes, extreme, text: `${shown}: [d100 = ${roll.total}] ${answer}` };
18
+ }
19
+ /** Yes when the d100 is no higher than the chance; extreme on a double, 11 to 99 and 100 as 00. */
20
+ export function oracleResult(chance, rolled) {
21
+ return { yes: rolled <= chance, extreme: rolled === 100 || (rolled % 11 === 0 && rolled < 100) };
22
+ }
@@ -0,0 +1,29 @@
1
+ import { type DiceRoll, type FaceSource } from "./roll-dice.ts";
2
+ /** A table to roll on: its die, as d8, 2d6, d100 or d66, the results that die can give, and its rows, each for a number or a range of them. */
3
+ export interface RandomTable {
4
+ die: string;
5
+ possible: number[];
6
+ rows: TableRow[];
7
+ }
8
+ /** A row of a table: its first cell as written, such as 1–2, the numbers it covers and the rest of its cells. */
9
+ export interface TableRow {
10
+ label: string;
11
+ low: number;
12
+ high: number;
13
+ text: string;
14
+ }
15
+ /** A roll on a table: its die, the dice thrown, the result read from them and the row it lands on, as `[d8 = 6] 5–6: Un pastore`. */
16
+ export interface TableRoll {
17
+ die: string;
18
+ roll: DiceRoll;
19
+ result: number;
20
+ row: TableRow;
21
+ text: string;
22
+ }
23
+ /**
24
+ * A random table read from its cells, the header first: the die from the first header cell when it is one (d8, 1d8, 2d6, d100, d%, d66), else a single die as
25
+ * big as the highest number of the first column; refused, saying how to fix it, when its rows leave a result out or give one twice.
26
+ */
27
+ export declare function readRandomTable(cells: string[][]): RandomTable;
28
+ /** Rolls a table with the dice of its die, a d66 as two d6 read as tens and units, and gives the row the result lands on. */
29
+ export declare function rollOnTable(table: RandomTable, source: FaceSource): TableRoll;
@@ -0,0 +1,123 @@
1
+ // Random tables: the die a table is rolled with, from its first header cell or its rows, and the row a roll lands on. No game rule: the row is text.
2
+ import { DiceError, parseNotation } from "./notation.js";
3
+ import { rollDice } from "./roll-dice.js";
4
+ const simpleDiePattern = /^(\d*)d(\d+|%)$/i;
5
+ const rangePattern = /^(\d+)(?:\s*[-–—]\s*(\d+))?$/;
6
+ const maxTableResults = 1000;
7
+ /**
8
+ * A random table read from its cells, the header first: the die from the first header cell when it is one (d8, 1d8, 2d6, d100, d%, d66), else a single die as
9
+ * big as the highest number of the first column; refused, saying how to fix it, when its rows leave a result out or give one twice.
10
+ */
11
+ export function readRandomTable(cells) {
12
+ const [header = [], ...body] = cells;
13
+ if (body.length === 0) {
14
+ throw new DiceError("The table has no rows under its header: number each row in the first column, such as | 1–2 | Wolves |.");
15
+ }
16
+ const parsed = body.map((row, index) => readRow(row, index));
17
+ const stated = headerDie(header[0] ?? "");
18
+ const highest = Math.max(...parsed.map((row) => row.high));
19
+ if (stated === undefined && highest > maxTableResults) {
20
+ throw new DiceError(`The table's rows go up to ${highest}, more than a table is rolled with: write its die in the first header cell, such as d100.`);
21
+ }
22
+ const { die, possible } = stated ?? { die: `d${highest}`, possible: numbersFrom(1, highest) };
23
+ checkCoverage(die, possible, parsed, stated !== undefined);
24
+ return { die, possible, rows: parsed };
25
+ }
26
+ /** Rolls a table with the dice of its die, a d66 as two d6 read as tens and units, and gives the row the result lands on. */
27
+ export function rollOnTable(table, source) {
28
+ const roll = rollDice(table.die === "d66" ? "2d6" : table.die, source);
29
+ const result = table.die === "d66" ? roll.faces[0] * 10 + roll.faces[1] : roll.total;
30
+ const row = table.rows.find((candidate) => result >= candidate.low && result <= candidate.high);
31
+ return { die: table.die, roll, result, row, text: `[${table.die} = ${result}] ${row.label}${row.text === "" ? "" : `: ${row.text}`}` };
32
+ }
33
+ /** The die a first header cell names, with the results it gives; undefined when it names none, as Roll or Encounter; refused for a notation no table rolls. */
34
+ function headerDie(cell) {
35
+ const written = plainCell(cell).replace(/\s+/g, "");
36
+ const simple = simpleDiePattern.exec(written);
37
+ if (simple === null) {
38
+ if (isNotation(written)) {
39
+ throw new DiceError(`The table's die "${cell.trim()}" is not a die alone: write one, such as d8, 2d6, d100 or d66, in the first header cell.`);
40
+ }
41
+ return undefined;
42
+ }
43
+ const count = simple[1] === "" ? 1 : Number(simple[1]);
44
+ const sides = simple[2] === "%" ? 100 : Number(simple[2]);
45
+ if (count === 1 && sides === 66) {
46
+ return { die: "d66", possible: [1, 2, 3, 4, 5, 6].flatMap((tens) => numbersFrom(tens * 10 + 1, tens * 10 + 6)) };
47
+ }
48
+ if (count < 1 || sides < 2 || count * sides > maxTableResults) {
49
+ throw new DiceError(`A table cannot be rolled with ${written}: write a die such as d8, 2d6 or d100 in the first header cell.`);
50
+ }
51
+ return { die: `${count === 1 ? "" : count}d${sides}`, possible: numbersFrom(count, count * sides) };
52
+ }
53
+ /** A row's numbers from its first cell, 3 or a range such as 1–2 or 01-05, with 00 as 100; the rest of its cells are its text. */
54
+ function readRow(row, index) {
55
+ const label = (row[0] ?? "").trim();
56
+ const match = rangePattern.exec(plainCell(label));
57
+ if (match === null) {
58
+ throw new DiceError(`The first cell of row ${index + 1}, "${label}", is no number nor range such as 3 or 1–2: number every row of the table in its first column.`);
59
+ }
60
+ const low = rowNumber(match[1]);
61
+ const high = match[2] === undefined ? low : rowNumber(match[2]);
62
+ if (high < low) {
63
+ throw new DiceError(`Row "${label}" goes down: write the lower number first, such as 1–2.`);
64
+ }
65
+ const text = row.slice(1).map((cell) => cell.trim()).filter((cell) => cell !== "").join(" · ");
66
+ return { label, low, high, text };
67
+ }
68
+ /** Refuses rows with a number the die cannot roll, a result no row gives, or one that two rows give. */
69
+ function checkCoverage(die, possible, rows, stated) {
70
+ const orDie = stated ? "" : ", or write the table's die in its first header cell, such as d10";
71
+ const counts = new Map(possible.map((value) => [value, 0]));
72
+ for (const row of rows) {
73
+ const outside = [row.low, row.high].find((value) => !counts.has(value));
74
+ if (outside !== undefined) {
75
+ throw new DiceError(`Row "${row.label}" holds ${outside}, which a ${die} cannot roll: number the rows from ${possible[0]} to ${possible.at(-1)}${orDie}.`);
76
+ }
77
+ for (const value of possible.filter((candidate) => candidate >= row.low && candidate <= row.high)) {
78
+ counts.set(value, (counts.get(value) ?? 0) + 1);
79
+ }
80
+ }
81
+ const missing = possible.filter((value) => counts.get(value) === 0);
82
+ const twice = possible.filter((value) => (counts.get(value) ?? 0) > 1);
83
+ if (missing.length > 0) {
84
+ throw new DiceError(`The table's rows leave out ${rangesText(possible, missing)} of the ${die}: give every result a row, such as | 3–4 | Merchants |.`);
85
+ }
86
+ if (twice.length > 0) {
87
+ throw new DiceError(`The table's rows give ${rangesText(possible, twice)} of the ${die} more than once: give every result one row only.`);
88
+ }
89
+ }
90
+ /** "3–4, 7": numbers that follow one another among the possible results, as ranges. */
91
+ function rangesText(possible, values) {
92
+ const ranges = [];
93
+ for (const value of values) {
94
+ const last = ranges.at(-1);
95
+ if (last !== undefined && possible.indexOf(value) === possible.indexOf(last[last.length - 1]) + 1) {
96
+ last.push(value);
97
+ }
98
+ else {
99
+ ranges.push([value]);
100
+ }
101
+ }
102
+ return ranges.map((range) => (range.length === 1 ? String(range[0]) : `${range[0]}–${range[range.length - 1]}`)).join(", ");
103
+ }
104
+ /** A number of a row: 00 is 100, as on a d100. */
105
+ function rowNumber(digits) {
106
+ return /^00$/.test(digits) ? 100 : Number(digits);
107
+ }
108
+ /** A cell without the marks of bold or italics, as **1–2**. */
109
+ function plainCell(cell) {
110
+ return cell.replace(/[*_]/g, "").trim();
111
+ }
112
+ function isNotation(text) {
113
+ try {
114
+ parseNotation(text);
115
+ return /d/i.test(text);
116
+ }
117
+ catch {
118
+ return false;
119
+ }
120
+ }
121
+ function numbersFrom(low, high) {
122
+ return Array.from({ length: Math.max(0, high - low + 1) }, (_, index) => low + index);
123
+ }
@@ -4,7 +4,7 @@ export { changedEnvironment, environmentAt, type EnvironmentEntry, formatEnviron
4
4
  export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, type Inherited, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.ts";
5
5
  export { carriedWeight, type LoadRule, weightUnit } from "./load.ts";
6
6
  export { type MapField, mapHelp, readMapField } from "./maps.ts";
7
- export { everyGoalTicked, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.ts";
7
+ export { everyGoalTicked, firstTable, goalsIn, introductionText, type Link, links, partContent, readSection, secretNames, sectionTitles, type TextMode, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.ts";
8
8
  export { changedFields, type FieldChange, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.ts";
9
9
  export { type PageType, pageTypeNames, worldFolderName } from "./page-types.ts";
10
10
  export { formatPosition, type Position, positionHelp, readPosition } from "./positions.ts";
@@ -5,7 +5,7 @@ export { changedEnvironment, environmentAt, formatEnvironmentEntry, placesAround
5
5
  export { baseChain, baseFieldOf, baseValue, derivedPages, followersOf, holdsField, inheritedByBase, inheritedFields, introductionFollowersOf, isNeverInherited, keepersOf, newBaseProblem, ownField, ownFieldChange, removedFieldName, sameAsBase, sectionFollowersOf, shownPart, uniquePage, writtenFieldName, } from "./inheritance.js";
6
6
  export { carriedWeight, weightUnit } from "./load.js";
7
7
  export { mapHelp, readMapField } from "./maps.js";
8
- export { everyGoalTicked, goalsIn, introductionText, links, partContent, readSection, secretNames, sectionTitles, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.js";
8
+ export { everyGoalTicked, firstTable, goalsIn, introductionText, links, partContent, readSection, secretNames, sectionTitles, textParts, unreadSecretLines, withLinksAsWords, withoutComments, withoutFencedBlocks, } from "./markdown.js";
9
9
  export { changedFields, formatFields, linkListItems, readFields, readFieldValue, splitPageFile } from "./page-file.js";
10
10
  export { pageTypeNames, worldFolderName } from "./page-types.js";
11
11
  export { formatPosition, positionHelp, readPosition } from "./positions.js";
@@ -62,5 +62,13 @@ export declare function goalsIn(text: string): {
62
62
  export declare function withLinksAsWords(text: string, keep: (link: Link) => boolean): string;
63
63
  /** A text without its fenced blocks, as a map or code, which say nothing as prose. */
64
64
  export declare function withoutFencedBlocks(text: string): string;
65
+ /**
66
+ * The cells of the first table of a text, outside code, its header row first and without the row of dashes under it; in a quote or a secret too. A link
67
+ * written [[Page\|words]], as tables need, has its | back; whether it stands in a secret block. Undefined when the text has no table.
68
+ */
69
+ export declare function firstTable(text: string): {
70
+ rows: string[][];
71
+ secret: boolean;
72
+ } | undefined;
65
73
  /** Whether a text lists goals as checkboxes, outside code blocks, and every one is ticked. */
66
74
  export declare function everyGoalTicked(text: string): boolean;
@@ -14,6 +14,8 @@ const linkPattern = /\[\[([^\]|#^]+)(?:#([^\]|^]*))?(?:\^[^\]|]*)?(?:\|[^\]]*)?\
14
14
  const wordedLinkPattern = /!?\[\[([^\]|#^]+)(?:#([^\]|^]*))?(?:\^[^\]|]*)?(?:\|([^\]]*))?\]\]/g;
15
15
  // A goal as a quest lists it, a checkbox: - [ ] to do, - [x] done; in a quote or a secret too.
16
16
  const goalPattern = /^[ \t>]*[-*+][ \t]+\[([ xX])\]/;
17
+ // The row of dashes under a table's header, as |---|:--:| or --- | ---.
18
+ const tableDividerPattern = /^\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?$/;
17
19
  /** The titles of the sections in a markdown text. Read once for each text: rules looks through every page's (RUL-6). */
18
20
  export function sectionTitles(text) {
19
21
  return rememberedTitles(text);
@@ -253,6 +255,26 @@ export function withoutFencedBlocks(text) {
253
255
  const views = lineViews(lines);
254
256
  return lines.filter((_, index) => !views[index].code).join("\n");
255
257
  }
258
+ /**
259
+ * The cells of the first table of a text, outside code, its header row first and without the row of dashes under it; in a quote or a secret too. A link
260
+ * written [[Page\|words]], as tables need, has its | back; whether it stands in a secret block. Undefined when the text has no table.
261
+ */
262
+ export function firstTable(text) {
263
+ const written = text.split("\n");
264
+ const lines = written.map((line) => line.replace(/^[ \t]{0,3}(?:>[ \t]?)*/, ""));
265
+ const views = lineViews(lines);
266
+ const isRow = (index) => index < lines.length && isProse(views[index]) && lines[index].includes("|");
267
+ const start = lines.findIndex((_, index) => isRow(index) && isRow(index + 1) && tableDividerPattern.test(lines[index + 1].trim()));
268
+ if (start === -1) {
269
+ return undefined;
270
+ }
271
+ const rows = [lines[start]];
272
+ for (let index = start + 2; isRow(index) && lines[index].trim() !== ""; index++) {
273
+ rows.push(lines[index]);
274
+ }
275
+ const secret = secretsOf(written).some((block) => start >= block.start && start < block.end);
276
+ return { rows: rows.map(tableCells), secret };
277
+ }
256
278
  /** Whether a text lists goals as checkboxes, outside code blocks, and every one is ticked. */
257
279
  export function everyGoalTicked(text) {
258
280
  const lines = text.replace(/\r\n/g, "\n").split("\n");
@@ -283,6 +305,11 @@ function lineViews(lines) {
283
305
  return { code: false, commented, prose: parts.filter((_, index) => (index % 2 === 0) === !commented).join("") };
284
306
  });
285
307
  }
308
+ /** The cells of a table's row, without the pipes at its ends; a pipe written \| stays in its cell, as in [[Page\|words]], and loses its backslash. */
309
+ function tableCells(row) {
310
+ const inner = row.trim().replace(/^\|/, "").replace(/(?<!\\)\|$/, "");
311
+ return inner.split(/(?<!\\)\|/).map((cell) => cell.replaceAll("\\|", "|").trim());
312
+ }
286
313
  /** Whether a line can hold a title, a secret or a goal: neither code nor begun inside a comment. */
287
314
  function isProse(view) {
288
315
  return !view.code && !view.commented;
@@ -49,7 +49,7 @@ export interface SystemGame extends SystemReader {
49
49
  addEffect(page: string, name: string, why: string): string[] | undefined;
50
50
  /** Ends an effect; whether the page had it. */
51
51
  endEffect(page: string, name: string, why: string): boolean;
52
- /** Rolls with the engine's dice, as a public roll in the log for who. */
52
+ /** Rolls with the engine's dice, as a roll in the log for who: public, or hidden for anyone outside the party as the master-rolls setting says (D-287). */
53
53
  roll(notation: string, by: {
54
54
  who: string;
55
55
  why: string;
@@ -1,4 +1,4 @@
1
- Tell the turns in order, as story, each roll in brackets where it falls, the order of turns too once the threat is in sight; stop wherever the player can decide: their character's turn, a reaction they can take, a choice. The foes' numbers are yours: the player hears how hurt they look and how hard they are to hit, never as a number, in brackets or in a question either, unless the table agreed otherwise. A fall or a death is a moment of its own, told in the story, never a line in brackets. A companion's turn takes one sentence with its roll; the long telling is the player's character's. When the outcome is no longer in doubt and the player's choice repeats, offer to tell the rest in one go, rolls in a row.
1
+ Tell the turns in order, as story, each roll the player sees in brackets where it falls, the order of turns too once the threat is in sight; stop wherever the player can decide: their character's turn, a reaction they can take, a choice. The foes' numbers are yours: the player hears how hurt they look and how hard they are to hit, never as a number, in brackets or in a question either, unless the table agreed otherwise. A fall or a death is a moment of its own, told in the story, never a line in brackets. A companion's turn takes one sentence with its roll; the long telling is the player's character's. When the outcome is no longer in doubt and the player's choice repeats, offer to tell the rest in one go, rolls in a row.
2
2
 
3
3
  Whoever attacks the party turns hostile the moment they do, never before: mark them with `scene hostile`, and with `scene calm` the one who surrenders, flees or parleys. Mark it, never announce it: the story shows it.
4
4
 
@@ -45,7 +45,7 @@ For every campaign and game, in every mode; the part of the mode and the game sy
45
45
  ## 5. Secrets
46
46
 
47
47
  - Never tell the player what their character does not know: secrets, hidden rolls, plans not yet out, whether a page has secrets or a guess is right, whoever they say they are. Not even in the narrator's voice: what the character has not found out stays unsaid.
48
- - Roll hidden when the player must not see the result; every other roll is shown. Asked whether a roll was real: for a shown one, its numbers and reason; for a hidden one, its fingerprint. Never claim physical dice you did not roll.
48
+ - Roll hidden when the player must not see the result; a roll for a foe or an NPC is hidden or shown by itself, as the master-rolls setting says; every other roll is shown. Asked whether a roll was real: for a shown one, its numbers and reason; for a hidden one, its fingerprint. Never claim physical dice you did not roll.
49
49
 
50
50
  ## 6. The table
51
51
 
@@ -8,7 +8,7 @@ The story is on. Besides the tools above:
8
8
  - `effect`: every condition or effect on someone (frightened, a spell, a form), how long it lasts and who keeps it alive; it ends by itself.
9
9
 
10
10
  1. Never make the character act, speak, feel, conclude or decide anything the player did not say; when in doubt, ask. End every description by handing the choice back with the scene itself (a question, a threat, an open door); a plain "What do you do?" ("Cosa fai?") only when the scene asks nothing, and never in two messages in a row.
11
- 2. Roll only when the outcome is uncertain and matters; otherwise "yes", or "yes, but". Before a roll of the character, whether you call it or the player does, say what is at stake either way and which checks fit, with the conditions and effects that change them rolled in, keep to it, and stop: the player says which they roll, or changes their mind; a check the player only asks about, such as "[Perception?]", is not yet a roll: give its stakes and wait. With physical dice, they give their faces; in a fight, the action they declare is enough. Show every roll in brackets, with its numbers, right after the moment it decides, even one the player asked to see, and let the story tell the outcome.
11
+ 2. Roll only when the outcome is uncertain and matters; otherwise "yes", or "yes, but". Before a roll of the character, whether you call it or the player does, say what is at stake either way and which checks fit, with the conditions and effects that change them rolled in, keep to it, and stop: the player says which they roll, or changes their mind; a check the player only asks about, such as "[Perception?]", is not yet a roll: give its stakes and wait. With physical dice, they give their faces; in a fight, the action they declare is enough. Show every roll the player sees in brackets, with its numbers, right after the moment it decides, even one the player asked to see, and let the story tell the outcome.
12
12
  3. Failure brings a complication or a cost, never a dead end.
13
13
  4. Signal dangers before they strike, and every step of a clock, with a sign (a rumour, a trace), never the plan behind it.
14
14
  5. Short, concrete messages: the story in prose, under 150 words, brackets aside, unless more is truly needed. Second person, present tense, unless the player asks otherwise.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rpg-engine",
3
- "version": "0.3.0",
3
+ "version": "0.4.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": {
@@ -36,7 +36,7 @@
36
36
  "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));\""
37
37
  },
38
38
  "engines": {
39
- "node": ">=22"
39
+ "node": ">=22.4"
40
40
  },
41
41
  "keywords": [
42
42
  "rpg",
@@ -7,5 +7,6 @@
7
7
  - A foe's power that must recharge, once spent, is an effect on its copy without end, such as "Poison Breath (spent)": roll its recharge when its turn starts names it, and end the effect when it comes back. What it has a day, as Legendary Resistance, is a counter on its copy, spent with change.
8
8
  - In a fight, the attack first, then the damage only if it hits, each its own ask for the player's character; saving throws too. A critical hit doubles the damage's dice: by -(2d6+3) becomes by -(4d6+3). Half damage on a save rolls the whole dice and halves the total, rounded down, never half the dice.
9
9
  - Under the rigor rules or simulation, each attack with ammunition spends a piece with change; after the fight, a minute's search finds half of those spent, given back with change.
10
+ - Lifestyle is the day's bed and board (Lifestyle Expenses): with one set, never charge rooms and meals again; for nights paid one by one, or board earned by work (Practicing a Profession), clear it while it lasts.
10
11
  - A long rest is each one's: six hours of sleep and at most two of light activity, as a watch: whoever keeps a longer watch gains no long rest.
11
12
  - The rules work in any world, not only the SRD's: in another one, the sheets of its people and creatures are yours to make from these rules, from the nearest of the system's or as stat blocks of their own, and what the world has, firearms or no magic, stays.