rpg-engine 0.6.2 → 0.6.4
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/dist/commands/ask.d.ts +1 -0
- package/dist/commands/ask.js +15 -2
- package/dist/commands/roll.js +5 -2
- package/dist/commands/sheet.d.ts +5 -0
- package/dist/commands/sheet.js +10 -0
- package/dist/core/package-declarations.d.ts +3 -2
- package/dist/core/package-declarations.js +3 -2
- package/dist/systems/game-system.d.ts +2 -0
- package/dist/systems/game-system.js +6 -0
- package/instructions/core.md +2 -2
- package/instructions/play.md +5 -5
- package/instructions/session.md +1 -1
- package/instructions/voices.md +1 -1
- package/package.json +2 -2
- package/systems/5e/package.json +1 -1
- package/systems/5e/system.yaml +3 -0
package/dist/commands/ask.d.ts
CHANGED
package/dist/commands/ask.js
CHANGED
|
@@ -17,6 +17,7 @@ import { newDatedLogEntry } from "./game-time.js";
|
|
|
17
17
|
import { campaignSystem, campaignWorld, systemWordsOf } from "./game-world.js";
|
|
18
18
|
import { placeOnMap } from "./move.js";
|
|
19
19
|
import { hasNames, namesAsZero, rollerOf, sheetDiceOf, withSheetValues } from "./roll.js";
|
|
20
|
+
import { knowledgeNote } from "./sheet.js";
|
|
20
21
|
// The words of the buttons, in the campaign's language, as the dashboard's languages (playtest 15); English for the others (ASK-7).
|
|
21
22
|
const buttonWords = {
|
|
22
23
|
en: { roll: "Roll", change: "Change my mind", choice: "Choice", square: "Move", rest: "Rest", done: "Done" },
|
|
@@ -108,7 +109,7 @@ export const ask = defineCommand({
|
|
|
108
109
|
format(result) {
|
|
109
110
|
switch (result.kind) {
|
|
110
111
|
case "roll":
|
|
111
|
-
return `${result.id} ${result.who}, ${result.check}: ${result.text}, rolled by the player. Tell the outcome in the story, with the roll in brackets right after the moment it decides; write nothing until your message is ready.${(result.notes ?? []).map((line) => `\n${line}`).join("")}`;
|
|
112
|
+
return `${result.id} ${result.who}, ${result.check}: ${result.text}, rolled by the player. Tell the outcome in the story, with the roll in brackets right after the moment it decides; write nothing until your message is ready.${[result.knowledge, ...(result.notes ?? [])].filter((line) => line !== undefined).map((line) => `\n${line}`).join("")}`;
|
|
112
113
|
case "changed":
|
|
113
114
|
return "The player changed their mind: no roll. Ask what they do instead, and stop.";
|
|
114
115
|
case "chose":
|
|
@@ -232,7 +233,19 @@ async function rollChosen(root, context, question, checks, who, words, told) {
|
|
|
232
233
|
appendLogEntry(root, entry);
|
|
233
234
|
// What the packages' code makes of the roll, as the 5e's death save (D-448).
|
|
234
235
|
const notes = allSaid(packagesRolled(root, context, { who, notation: diceRoll.notation, total: diceRoll.total, faces: diceRoll.faces, dice: diceRoll.dice, text: diceRoll.text, id: entry.id }));
|
|
235
|
-
|
|
236
|
+
// A check of what the character knows is told as knowledge (sheet-knowledge).
|
|
237
|
+
const knowledge = knowledgeNote(campaignSystem(root, context), check.field === undefined ? [] : [check.field]);
|
|
238
|
+
return {
|
|
239
|
+
kind: "roll",
|
|
240
|
+
id: entry.id,
|
|
241
|
+
who,
|
|
242
|
+
check: check.label,
|
|
243
|
+
text: diceRoll.text,
|
|
244
|
+
total: diceRoll.total,
|
|
245
|
+
faces: diceRoll.faces,
|
|
246
|
+
...(knowledge === undefined ? {} : { knowledge }),
|
|
247
|
+
...(notes.length === 0 ? {} : { notes }),
|
|
248
|
+
};
|
|
236
249
|
}
|
|
237
250
|
/**
|
|
238
251
|
* Where the player's character moves on the map of its place (ASK-11): only the page can show the map; the square touched moves it, as move with at, and the
|
package/dist/commands/roll.js
CHANGED
|
@@ -6,7 +6,7 @@ import { defineCommand } from "../core/registry.js";
|
|
|
6
6
|
import { comparableText, sameName, valueNamed } from "../core/text.js";
|
|
7
7
|
import { readCounter } from "../counters/index.js";
|
|
8
8
|
import { askOracle, DiceError, rollDice, sha256 } from "../dice/index.js";
|
|
9
|
-
import { declaredKind, findPage, pagesWithName, writePage } from "../pages/index.js";
|
|
9
|
+
import { declaredKind, findPage, isPlayerCharacter, pagesWithName, writePage } from "../pages/index.js";
|
|
10
10
|
import { effectiveFields, effectsOf } from "./effect-layer.js";
|
|
11
11
|
import { systemNamed } from "./game-effects.js";
|
|
12
12
|
import { behindTheScreen, namesNoOne, ofTheParty, screenNote, screenUp, sealHiddenRoll } from "./game-master-rolls.js";
|
|
@@ -16,6 +16,7 @@ import { rollPageTable } from "./game-tables.js";
|
|
|
16
16
|
import { newDatedLogEntry } from "./game-time.js";
|
|
17
17
|
import { campaignSystem, campaignSystemWords, campaignWorld, missingSystemHint } from "./game-world.js";
|
|
18
18
|
import { firstInChat } from "./parts.js";
|
|
19
|
+
import { knowledgeNote } from "./sheet.js";
|
|
19
20
|
import { itemList, signedText, workedFields } from "./worked-out.js";
|
|
20
21
|
// Faces arrive as "14,7" or "14 7" from a shell (PowerShell turns 14,7 into "14 7"), or as an array.
|
|
21
22
|
export const faceValues = z.preprocess((value) => (typeof value === "string" ? value.split(/[\s,;]+/).filter(Boolean).map(Number) : value), z.array(z.number()));
|
|
@@ -106,7 +107,9 @@ export const roll = defineCommand({
|
|
|
106
107
|
: packagesRolled(root, context, { who: input.who, notation: diceRoll.notation, total: diceRoll.total, faces: diceRoll.faces, dice: diceRoll.dice, text, id: entry.id });
|
|
107
108
|
const own = said.lines.length > 0 ? said.lines.join("\n") : roller === undefined ? undefined : rollerNote(roller.world, system, roller.page, campaignSystemWords(root, context));
|
|
108
109
|
// The system's lines take the place of the engine's note, as a death save does; the extensions' come after it (D-514).
|
|
109
|
-
|
|
110
|
+
// A check of what the player character knows is told as knowledge (sheet-knowledge).
|
|
111
|
+
const knowledge = roller !== undefined && isPlayerCharacter(roller.page) ? knowledgeNote(system, Object.keys(named.taken)) : undefined;
|
|
112
|
+
const note = [own, knowledge, ...said.added, said.problem].filter((line) => line !== undefined && line !== "").join("\n") || undefined;
|
|
110
113
|
const shown = { kind: "roll", id: entry.id, text, total: diceRoll.total, why: input.why, who: input.who, check: input.check, physical, hidden, fingerprint: shownFingerprint, note, kept };
|
|
111
114
|
// A who of no page may be a party member named wrongly: the master is told how to undo the screen (review of 25 October).
|
|
112
115
|
const stranger = screened && input.who !== undefined && namesNoOne(root, context, input.who) ? { stranger: true } : {};
|
package/dist/commands/sheet.d.ts
CHANGED
|
@@ -175,3 +175,8 @@ export declare function counterOf(world: World, fields: Record<string, unknown>,
|
|
|
175
175
|
export declare function experienceProgress(world: World, fields: Record<string, unknown>, field: string): Progress | undefined;
|
|
176
176
|
/** What the points of the field that counts the experience say of the levels (PRO-6); none for another field, or at the last level. */
|
|
177
177
|
export declare function experienceNeed(world: World, fields: Record<string, unknown>, field: string): LevelNeed | undefined;
|
|
178
|
+
/**
|
|
179
|
+
* What the master is told as a roll of the player character recalls what they know, as History, by the fields the system declares (sheet-knowledge): its
|
|
180
|
+
* outcome said as knowledge, never as an episode of their past the player did not tell (Elena's tests of 28 October, where a high roll brought one).
|
|
181
|
+
*/
|
|
182
|
+
export declare function knowledgeNote(system: GameSystem | undefined, fields: string[]): string | undefined;
|
package/dist/commands/sheet.js
CHANGED
|
@@ -604,3 +604,13 @@ function wrongText(system, field, wrong, onSheet) {
|
|
|
604
604
|
const names = wrong.map((name) => `"${name}"`).join(", ");
|
|
605
605
|
return `${names} ${wrong.length === 1 ? "is not one of the names" : "are not names"} ${field} takes in the system ${system.name}: ${allowed.join(", ")}.${list}${own}`;
|
|
606
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* What the master is told as a roll of the player character recalls what they know, as History, by the fields the system declares (sheet-knowledge): its
|
|
609
|
+
* outcome said as knowledge, never as an episode of their past the player did not tell (Elena's tests of 28 October, where a high roll brought one).
|
|
610
|
+
*/
|
|
611
|
+
export function knowledgeNote(system, fields) {
|
|
612
|
+
const knowledge = new Set((system?.sheetKnowledge ?? []).map(comparableText));
|
|
613
|
+
return fields.some((field) => knowledge.has(comparableText(field)))
|
|
614
|
+
? "What it reveals is what the world shows or their trade knows, said as knowledge: an episode of their past the player has not told is a question to them."
|
|
615
|
+
: undefined;
|
|
616
|
+
}
|
|
@@ -4,9 +4,10 @@ export type { CardPage, FigureSize };
|
|
|
4
4
|
/**
|
|
5
5
|
* The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
|
|
6
6
|
* system.yaml may declare. It goes up with every addition a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
|
|
7
|
-
* additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package
|
|
7
|
+
* additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package, 6 the fields of
|
|
8
|
+
* knowledge of a game system (sheet-knowledge).
|
|
8
9
|
*/
|
|
9
|
-
export declare const packageApi =
|
|
10
|
+
export declare const packageApi = 6;
|
|
10
11
|
/**
|
|
11
12
|
* Our game systems (D-513): the name a campaign gives each, which package install takes alone, its package, and what it is; the setup offers them even when
|
|
12
13
|
* npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
|
|
@@ -5,9 +5,10 @@ import { cardPages } from "../page.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* The version of the API a package is made for, which its package.json names as rpg-engine.api: the contract its code is given and what its extension.yaml or
|
|
7
7
|
* system.yaml may declare. It goes up with every addition a package may use, and the engine reads a range (D-515): 2 added the widgets, 3 an extension's
|
|
8
|
-
* additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package
|
|
8
|
+
* additions to the game system and asking the player, 4 the code in the dashboard's page, 5 one contract for every kind of package, 6 the fields of
|
|
9
|
+
* knowledge of a game system (sheet-knowledge).
|
|
9
10
|
*/
|
|
10
|
-
export const packageApi =
|
|
11
|
+
export const packageApi = 6;
|
|
11
12
|
/**
|
|
12
13
|
* Our game systems (D-513): the name a campaign gives each, which package install takes alone, its package, and what it is; the setup offers them even when
|
|
13
14
|
* npm does not answer. A list of names, as our scope is, never a game's code; Ironsworn joins it once it is playable.
|
|
@@ -256,6 +256,8 @@ export interface GameSystem {
|
|
|
256
256
|
sheet: SheetGroup[];
|
|
257
257
|
/** By field, the dice a number of the sheet is rolled with, for the dashboard's free roll (D-280), such as 1d20 by insight. */
|
|
258
258
|
sheetDice: Record<string, string>;
|
|
259
|
+
/** The fields of the sheet whose rolls recall what the character knows, as History: their outcome is told as knowledge (D-530, Elena's tests of 28 October). */
|
|
260
|
+
sheetKnowledge: string[];
|
|
259
261
|
/**
|
|
260
262
|
* The dice of a better and a worse free roll, and the fields of the sheet that formulas make better or worse above 0, as Stealth in heavy armor or a check
|
|
261
263
|
* at exhaustion 1; both cancel out (D-445).
|
|
@@ -147,6 +147,7 @@ const systemSchema = z.object({
|
|
|
147
147
|
"sheet-dice": z.record(z.string().regex(sheetDicePattern), z.array(z.string().min(1)).min(1), {
|
|
148
148
|
error: "write it as dice alone, as 1d20 or 2d6+1d4, and the fields of the sheet rolled with them, such as 1d20: [athletics, stealth]",
|
|
149
149
|
}).optional(),
|
|
150
|
+
"sheet-knowledge": z.array(z.string().min(1)).min(1).optional(),
|
|
150
151
|
"sheet-odds": z.object({
|
|
151
152
|
better: z.string().regex(rollNamePattern),
|
|
152
153
|
worse: z.string().regex(rollNamePattern),
|
|
@@ -438,6 +439,10 @@ function readSystem(folder, name, layers = [], ruleset) {
|
|
|
438
439
|
if (twice !== undefined) {
|
|
439
440
|
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-dice: ${twice[0]} is listed twice; give each field one set of dice.`);
|
|
440
441
|
}
|
|
442
|
+
const unknownKnowledge = (data["sheet-knowledge"] ?? []).find((field) => kindOf(field) === undefined);
|
|
443
|
+
if (unknownKnowledge !== undefined) {
|
|
444
|
+
throw new Error(`The game system ${name} cannot be read, because ${path} is not valid: sheet-knowledge: ${unknownKnowledge} is not declared in fields.`);
|
|
445
|
+
}
|
|
441
446
|
// The cards the dashboard places are groups of the sheet (D-295); at hand in a fight, its fields too (D-315).
|
|
442
447
|
for (const [key, names] of Object.entries(data["sheet-cards"] ?? {})) {
|
|
443
448
|
const fields = key === "at-hand" ? sheet.flatMap((group) => group.entries.map((entry) => comparableText(entry.field))) : [];
|
|
@@ -511,6 +516,7 @@ function readSystem(folder, name, layers = [], ruleset) {
|
|
|
511
516
|
...(data.grid === undefined ? {} : { grid: gridOf(data.grid) }),
|
|
512
517
|
sheet,
|
|
513
518
|
sheetDice: Object.fromEntries(rolled),
|
|
519
|
+
sheetKnowledge: data["sheet-knowledge"] ?? [],
|
|
514
520
|
...(data["sheet-odds"] === undefined ? {} : {
|
|
515
521
|
sheetOdds: {
|
|
516
522
|
better: data["sheet-odds"].better,
|
package/instructions/core.md
CHANGED
|
@@ -8,9 +8,9 @@ You are the game master of this table. It is a craft, and you inhabit it as an a
|
|
|
8
8
|
|
|
9
9
|
1. To the player, never name tools, commands, pages, files, folders, logs, codes, notes, the engine or extensions; speak of the campaign and its game system as players do at the table: "I keep it all: we pick up from here next time."
|
|
10
10
|
2. Everything you write reaches the player, before and between your tool calls too: write only what is for them, never your plans or reasoning, and only once it is ready.
|
|
11
|
-
3. While the tools work, write nothing
|
|
11
|
+
3. While the tools work, write nothing, even when the app asks what you are doing: no "Un momento, sto preparando", no note to yourself such as "Fails the save." or "Torch out at midnight"; keep those in your thinking.
|
|
12
12
|
4. The campaign lives in its files, not in this chat: start every session from them, and change them, page text included, only through the tools.
|
|
13
|
-
5. Speak the campaign's language. Out of setup, off-game talk, yours or the player's, goes in square brackets, [like this]; answer theirs first, so the message ends in the story.
|
|
13
|
+
5. Speak the campaign's language. Out of setup, off-game talk, yours or the player's, goes in square brackets, [like this], in a sentence or two; answer theirs first, only what they asked, so the message ends in the story.
|
|
14
14
|
6. Inside the story, never break it. Asked in earnest, off-game, whether you are an AI, say yes in one line in brackets, then go back to the game.
|
|
15
15
|
|
|
16
16
|
### Truth and rulings
|
package/instructions/play.md
CHANGED
|
@@ -9,10 +9,10 @@ The story is on. Besides the tools above:
|
|
|
9
9
|
|
|
10
10
|
### The character is the player's
|
|
11
11
|
|
|
12
|
-
1. Never make the character act, take, speak, feel, conclude or decide anything the player did not say, even in passing: not "you pocket the coins" but "the coins are there", not "your stomach tightens" but what they see; when in doubt, ask.
|
|
13
|
-
2. Start from the world's answer, retelling
|
|
12
|
+
1. Never make the character act, take, speak, feel, remember, conclude or decide anything the player did not say, even in passing: not "you pocket the coins" but "the coins are there", not "your stomach tightens" but what they see, what their trade teaches comes as knowledge, never as a memory, and a memory the player has not given is a question to them; when in doubt, ask.
|
|
13
|
+
2. Start from the world's answer to what they did and said, retelling it only as far as the outcome needs, never with a line, gesture or reason they did not give. A line said to no one is heard by the scene: a companion's glance, a silence, the place itself.
|
|
14
14
|
3. A failed roll or an effect such as fear may move the character's body, never their choice.
|
|
15
|
-
4. 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, never twice in a row.
|
|
15
|
+
4. End every description by handing the choice back with the scene itself: a question, a threat, an open door, never a sign already shown. A plain "What do you do?" ("Cosa fai?") only when the scene asks nothing, never twice in a row.
|
|
16
16
|
|
|
17
17
|
### Rolls
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ The story is on. Besides the tools above:
|
|
|
28
28
|
|
|
29
29
|
### Telling
|
|
30
30
|
|
|
31
|
-
14. Short, concrete messages:
|
|
31
|
+
14. Short, concrete messages: under 150 words of story, brackets aside; one scene: after a cut, open the next in a few lines and stop; two companions speak at most, the others in one sentence or not at all. Second person, present tense, unless the player asks otherwise.
|
|
32
32
|
|
|
33
33
|
### Scenes
|
|
34
34
|
|
|
@@ -76,4 +76,4 @@ The story is on. Besides the tools above:
|
|
|
76
76
|
|
|
77
77
|
### Before you send
|
|
78
78
|
|
|
79
|
-
Read your message once as the player will. Does it make their character act, speak or
|
|
79
|
+
Read your message once as the player will. Does it make their character act, speak, feel or remember what they did not say? Does it name a tool, a page or a file? Does it tell what the character has not found out? Does a roll come without its stakes said first? Does the story pass 150 words, one scene or two companions speaking, or a bracket two sentences? Does it end with the scene handing the choice back?
|
package/instructions/session.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Before this session opens, choose about ten secrets not tied to places, from the pages of everyone in play, companions too, and ready one scene of what the player enjoys most. Open it with a short recap of what the files hold, at the game time and place where the last one ended, with no time passed between, then something happening.
|
|
1
|
+
Before this session opens, choose about ten secrets not tied to places, from the pages of everyone in play, companions too, and ready one scene of what the player enjoys most. Open it with a short recap of what the files hold, at the game time and place where the last one ended, with no time passed between, then something happening, and stop at the first choice it asks.
|
package/instructions/voices.md
CHANGED
|
@@ -11,4 +11,4 @@ Once per moment; again only when something new is put to them: a proof, an offer
|
|
|
11
11
|
|
|
12
12
|
Before you ask, roll what the moment needs, the player's rolls as Play says under Rolls. Begin with their name, then write to them in the campaign's language, in the second person, present: what they see and hear now, what was said to them word for word, how it landed (a roll as how it felt, never its number), and the question: what they do and say, never their secrets offered as a choice. Never another's secrets, nor your plans. A secret of their page that they know reaches them only through `reveal`: if it is not yet theirs, reveal it to them before you ask. What their page decides about them for you ("breaks before two proofs") is no secret of theirs: write it as their nature ("two proofs, and you cannot hold it any longer"), never as a rule.
|
|
13
13
|
|
|
14
|
-
Their words and choice bind you: say
|
|
14
|
+
Their words and choice bind you: say their words, shortened if need be, never softened or rewritten; add only gestures that fit; a no stays no. What they keep stays behind the scenes: it reaches the player only through what they do, or a roll that earns it. The story, the rules, the dice and what follows are yours. Record what they decided or learned (`write`, `reveal`, `mood`), and what they keep when it is a new fact or plan, as their secret. If their choice breaks an established fact, ask again with that fact; never overrule them. What they claim of others or of the world is their belief, not a fact: the truth is yours. Only what you record becomes canon: a detail of their own that their page left blank, and that holds, write on their page.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
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": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"rpg-engine": {
|
|
12
12
|
"kind": "engine",
|
|
13
|
-
"api":
|
|
13
|
+
"api": 6
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
package/systems/5e/package.json
CHANGED
package/systems/5e/system.yaml
CHANGED
|
@@ -90,6 +90,9 @@ sheet:
|
|
|
90
90
|
Attacks: [attack, damage-roll]
|
|
91
91
|
Equipment: [money?, lifestyle?, attuned?, inventory?]
|
|
92
92
|
Spells: [caster-level?, spell-save-dc?, spell-attack?, slots-1?, slots-2?, slots-3?, slots-4?, slots-5?, slots-6?, slots-7?, slots-8?, slots-9?, spell-slots?, mystic-arcanum-6?, mystic-arcanum-7?, mystic-arcanum-8?, mystic-arcanum-9?, signature-spell-1?, signature-spell-2?, max-prepared?, spells?, prepared?]
|
|
93
|
+
# The skills whose checks recall what a character knows, of lore, history, the body, nature and the gods (pp. 81–82): what a check reveals is told as
|
|
94
|
+
# knowledge.
|
|
95
|
+
sheet-knowledge: [arcana, history, medicine, nature, religion]
|
|
93
96
|
# The dice each number of the sheet is rolled with, for the dashboard's free roll (D-280): an ability check, a saving throw and an attack roll each roll a d20
|
|
94
97
|
# and add the number (pp. 77, 83, 94).
|
|
95
98
|
sheet-dice:
|