rpg-engine 0.3.0 → 0.4.1
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.
- package/README.md +1 -1
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +10 -1
- package/dist/campaign/settings.js +9 -2
- package/dist/command-line.js +6 -1
- package/dist/commands/change.d.ts +7 -0
- package/dist/commands/change.js +34 -8
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +41 -7
- package/dist/commands/game-master-rolls.d.ts +17 -0
- package/dist/commands/game-master-rolls.js +36 -0
- package/dist/commands/game-mode.js +2 -1
- package/dist/commands/game-system-code.js +8 -1
- package/dist/commands/game-tables.d.ts +7 -0
- package/dist/commands/game-tables.js +40 -0
- package/dist/commands/game-upkeep.js +1 -1
- package/dist/commands/package.js +5 -3
- package/dist/commands/roll.d.ts +4 -0
- package/dist/commands/roll.js +73 -18
- package/dist/dashboard/i18n/ar.json +6 -0
- package/dist/dashboard/i18n/cs.json +6 -0
- package/dist/dashboard/i18n/da.json +6 -0
- package/dist/dashboard/i18n/de.json +6 -0
- package/dist/dashboard/i18n/el.json +6 -0
- package/dist/dashboard/i18n/es.json +6 -0
- package/dist/dashboard/i18n/fi.json +6 -0
- package/dist/dashboard/i18n/fr.json +6 -0
- package/dist/dashboard/i18n/he.json +6 -0
- package/dist/dashboard/i18n/hi.json +6 -0
- package/dist/dashboard/i18n/hu.json +6 -0
- package/dist/dashboard/i18n/is.json +6 -0
- package/dist/dashboard/i18n/it.json +6 -0
- package/dist/dashboard/i18n/ja.json +6 -0
- package/dist/dashboard/i18n/ko.json +6 -0
- package/dist/dashboard/i18n/nb.json +6 -0
- package/dist/dashboard/i18n/nl.json +6 -0
- package/dist/dashboard/i18n/pl.json +6 -0
- package/dist/dashboard/i18n/pt.json +6 -0
- package/dist/dashboard/i18n/ro.json +6 -0
- package/dist/dashboard/i18n/ru.json +6 -0
- package/dist/dashboard/i18n/sv.json +6 -0
- package/dist/dashboard/i18n/tr.json +6 -0
- package/dist/dashboard/i18n/uk.json +6 -0
- package/dist/dashboard/i18n/zh.json +6 -0
- package/dist/dashboard/labels.js +3 -0
- package/dist/dashboard/markdown.js +15 -4
- package/dist/dashboard/scene.js +21 -10
- package/dist/dashboard/settings.js +3 -3
- package/dist/dashboard/style.css +3 -1
- package/dist/dice/index.d.ts +2 -0
- package/dist/dice/index.js +3 -1
- package/dist/dice/oracle.d.ts +19 -0
- package/dist/dice/oracle.js +22 -0
- package/dist/dice/tables.d.ts +29 -0
- package/dist/dice/tables.js +123 -0
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/markdown.d.ts +8 -0
- package/dist/pages/markdown.js +27 -0
- package/dist/systems/system-code.d.ts +1 -1
- package/instructions/combat.md +1 -1
- package/instructions/core.md +1 -1
- package/instructions/play.md +1 -1
- package/package.json +2 -2
- package/systems/5e/instructions/play.md +1 -0
package/dist/pages/markdown.js
CHANGED
|
@@ -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
|
|
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;
|
package/instructions/combat.md
CHANGED
|
@@ -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
|
|
package/instructions/core.md
CHANGED
|
@@ -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
|
|
package/instructions/play.md
CHANGED
|
@@ -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
|
+
"version": "0.4.1",
|
|
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.
|