rpg-engine 0.17.1 → 0.18.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/dist/commands/change/change.d.ts +1 -0
- package/dist/commands/change/recipe-pace.d.ts +5 -0
- package/dist/commands/change/recipe-pace.js +20 -1
- package/dist/commands/change/recipe.d.ts +4 -0
- package/dist/commands/change/recipe.js +9 -5
- package/dist/commands/reveal.d.ts +2 -0
- package/dist/commands/reveal.js +22 -3
- package/dist/commands/scene/close.js +3 -1
- package/dist/commands/scene/open.js +1 -1
- package/dist/commands/scene/scene.js +3 -2
- package/dist/commands/shared/packages/updates.d.ts +6 -0
- package/dist/commands/shared/packages/updates.js +114 -0
- package/dist/commands/shared/scene/scene.js +4 -0
- package/dist/commands/shared/time/recipes.d.ts +5 -0
- package/dist/commands/shared/time/recipes.js +19 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +5 -0
- package/dist/commands/travel/travel.js +1 -0
- package/dist/commands/view/place.d.ts +6 -0
- package/dist/commands/view/place.js +37 -13
- package/dist/commands/view/result.d.ts +2 -0
- package/dist/commands/view/view.d.ts +1 -0
- package/dist/commands/view/view.js +34 -11
- package/dist/core/context.d.ts +5 -0
- package/dist/dashboard/app.js +1 -1
- package/dist/dashboard/dice/tray.js +7 -5
- package/dist/dashboard/parts/labels.js +26 -4
- package/dist/dashboard/parts/widgets.js +1 -1
- package/dist/dashboard/play/rolls.js +3 -3
- package/dist/dashboard/settings/setup.js +30 -13
- package/dist/dashboard/shell/table.js +7 -3
- package/dist/packages/npm.js +32 -7
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/scene/scene.d.ts +4 -1
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/play.md +4 -4
- package/package.json +1 -1
package/dist/packages/npm.js
CHANGED
|
@@ -17,6 +17,8 @@ const localFolder = "local";
|
|
|
17
17
|
// An npm name with a version or a tag, or nothing a shell would read otherwise: the master writes it, and npm runs in a shell.
|
|
18
18
|
const npmSpec = /^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(@[0-9A-Za-z.+-]+)?$/;
|
|
19
19
|
const installWait = 5 * 60 * 1000;
|
|
20
|
+
// How long the check for newer versions waits for the registry, at the start of a session (D-569): offline it gives up at once or after this.
|
|
21
|
+
const checkWait = 3000;
|
|
20
22
|
// An npm package's name alone, without a version: a .tgz's becomes the name of its folder.
|
|
21
23
|
const packageName = /^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
|
|
22
24
|
// A folder's copy installed as files, never as a link, which Node may not follow where the app keeps the player's data; npm's package.json still names it
|
|
@@ -85,6 +87,14 @@ export function npmPackages(folder, run = runNpm) {
|
|
|
85
87
|
return { failed: `npm's registry could not be reached: ${error instanceof Error ? error.message : String(error)}` };
|
|
86
88
|
}
|
|
87
89
|
},
|
|
90
|
+
newest: async (name) => {
|
|
91
|
+
try {
|
|
92
|
+
return await newestReadable(name);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
88
98
|
};
|
|
89
99
|
}
|
|
90
100
|
/** Whether a text is an npm package's name alone, such as notes or @me/notes: never a path, nor a version. */
|
|
@@ -227,14 +237,29 @@ function madeForNewer(info) {
|
|
|
227
237
|
* that reads it. The latest alone when no version reads, which is then refused.
|
|
228
238
|
*/
|
|
229
239
|
async function readableVersion(name, latest) {
|
|
230
|
-
const
|
|
231
|
-
const kind = latest.kind === "system" ? "system" : "extension";
|
|
232
|
-
const readable = Object.values(all?.versions ?? {}).map(infoOf).filter((one) => !one.version.includes("-") && readsApi(one.api, kind));
|
|
233
|
-
const newest = readable.reduce((best, one) => (best === undefined || isNewerVersion(one.version, best.version) ? one : best), undefined);
|
|
240
|
+
const newest = newestOf(await json(`${registry}/${name.replace("/", "%2f")}`), latest);
|
|
234
241
|
const engine = await engineReading(latest.api ?? 0);
|
|
235
242
|
const newer = { version: latest.version, ...(engine === undefined ? {} : { engine }) };
|
|
236
243
|
return newest === undefined ? latest : { ...newest, newer };
|
|
237
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* The newest version of a package this engine reads (D-569): its latest, else the newest of all its versions that reads; undefined when it has none. Asked
|
|
247
|
+
* within a short wait in all, as at the start of a session, which never waits on npm for long.
|
|
248
|
+
*/
|
|
249
|
+
async function newestReadable(name) {
|
|
250
|
+
const address = `${registry}/${checkedSpec(name).replace("/", "%2f")}`;
|
|
251
|
+
const signal = AbortSignal.timeout(checkWait);
|
|
252
|
+
const latest = await json(`${address}/latest`, signal);
|
|
253
|
+
const info = latest === undefined ? undefined : infoOf(latest);
|
|
254
|
+
return info === undefined || !madeForNewer(info) ? info?.version : newestOf(await json(address, signal), info)?.version;
|
|
255
|
+
}
|
|
256
|
+
/** The newest of all the versions npm's registry gives of a package that this engine reads, of the latest's kind, never a prerelease. */
|
|
257
|
+
function newestOf(all, latest) {
|
|
258
|
+
const versions = all?.versions ?? {};
|
|
259
|
+
const kind = latest.kind === "system" ? "system" : "extension";
|
|
260
|
+
const readable = Object.values(versions).map(infoOf).filter((one) => !one.version.includes("-") && readsApi(one.api, kind));
|
|
261
|
+
return readable.reduce((best, one) => (best === undefined || isNewerVersion(one.version, best.version) ? one : best), undefined);
|
|
262
|
+
}
|
|
238
263
|
/** The first version of rpg-engine on npm that reads a package made for this API, as its package.json says; undefined when none does yet, or npm does not say. */
|
|
239
264
|
async function engineReading(api) {
|
|
240
265
|
try {
|
|
@@ -372,9 +397,9 @@ function infoOf(read) {
|
|
|
372
397
|
function authorOf(read) {
|
|
373
398
|
return typeof read.author === "string" ? read.author : read.author?.name;
|
|
374
399
|
}
|
|
375
|
-
/** A JSON answer of the registry; undefined when it has none, 404. */
|
|
376
|
-
async function json(url) {
|
|
377
|
-
const answer = await fetch(url, { headers: { accept: "application/json" }, signal
|
|
400
|
+
/** A JSON answer of the registry, given up when the signal says; undefined when it has none, 404. */
|
|
401
|
+
async function json(url, signal = AbortSignal.timeout(20_000)) {
|
|
402
|
+
const answer = await fetch(url, { headers: { accept: "application/json" }, signal });
|
|
378
403
|
if (answer.status === 404) {
|
|
379
404
|
return undefined;
|
|
380
405
|
}
|
package/dist/pages/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, type HeldS
|
|
|
15
15
|
export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.ts";
|
|
16
16
|
export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.ts";
|
|
17
17
|
export { type PageType, pageTypeNames, worldFolderName } from "./types.ts";
|
|
18
|
-
export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, type Page, pageFileNamed, type PageMatch, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, type SystemInfo, systemPageNamed, type SystemPages, textsIn, validHoldersOf, versionTranslations, withPage, type World, } from "./world.ts";
|
|
18
|
+
export { type Backlink, backlinks, bonusPages, concernsPlayer, createWorld, findPage, heldNames, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, type Page, pageFileNamed, type PageMatch, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, type SystemInfo, systemPageNamed, type SystemPages, textsIn, validHoldersOf, versionTranslations, withPage, type World, } from "./world.ts";
|
|
19
19
|
export { type LayerWrite, removeLayer, writeLayer } from "./write-layer.ts";
|
|
20
20
|
export { checkFieldChange, type PageChange, writePage } from "./write-page.ts";
|
package/dist/pages/index.js
CHANGED
|
@@ -16,6 +16,6 @@ export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, heldStacks
|
|
|
16
16
|
export { canHold, containerFieldOf, isCoreField, isCounterField, isEmptyField, isStandardField, listFieldNames, misspelledFieldProblem, misspelledStandardField, newPageFields, standardValues } from "./standard-fields.js";
|
|
17
17
|
export { alwaysInList, declaredKind, hidingMessage, isDeclaredUncounted, kindMessage, readOnlyMessage, systemKnowsReason, systemLabel } from "./system-pages.js";
|
|
18
18
|
export { pageTypeNames, worldFolderName } from "./types.js";
|
|
19
|
-
export { backlinks, bonusPages, concernsPlayer, createWorld, findPage, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, pageFileNamed, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, systemPageNamed, textsIn, validHoldersOf, versionTranslations, withPage, } from "./world.js";
|
|
19
|
+
export { backlinks, bonusPages, concernsPlayer, createWorld, findPage, heldNames, isCountedItem, isInParty, isPartyMember, isPlayerCharacter, linksIn, loadWorld, locate, namesakes, pageFileNamed, pageNamed, pagesWithName, pagesWithNameOrAlias, pageWithPath, parsePageReference, playerCharacters, searchPages, searchSystemPages, systemFirstFix, systemPageNamed, textsIn, validHoldersOf, versionTranslations, withPage, } from "./world.js";
|
|
20
20
|
export { removeLayer, writeLayer } from "./write-layer.js";
|
|
21
21
|
export { checkFieldChange, writePage } from "./write-page.js";
|
package/dist/scene/scene.d.ts
CHANGED
|
@@ -34,7 +34,10 @@ export interface Scene {
|
|
|
34
34
|
used?: Record<string, string[]>;
|
|
35
35
|
/** Who attacks the party, as the master marks them, characters or copies by name (D-415): the player's dashboard shows it in a fight. */
|
|
36
36
|
hostile?: string[];
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* What the player character sees of someone, by the character's or the creature's name, such as brigante incappucciato (D-416): the player is given it
|
|
39
|
+
* instead of the name, known or not, while the scene keeps them (D-568).
|
|
40
|
+
*/
|
|
38
41
|
seen?: Record<string, string>;
|
|
39
42
|
}
|
|
40
43
|
/** The open scene, checked; a scene written wrongly by hand fails with what is wrong. */
|
package/instructions/combat.md
CHANGED
|
@@ -10,8 +10,8 @@ Give the fight a question beyond who wins, such as holding the gate or saving th
|
|
|
10
10
|
- A lone foe against a party falls fast: give it help, ground that shields it, or a change as it is hurt, such as calling the guards or taking to the air.
|
|
11
11
|
- When the party may lose, keep a way to lose short of death, such as retreat, surrender, capture or a deal; foes take it when their motives allow, and the loss moves the story on.
|
|
12
12
|
|
|
13
|
-
Tell the turns in order, as story; once the threat is in sight, their order in brackets; 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 and how strong they look, 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.
|
|
13
|
+
Tell the turns in order, as story; once the threat is in sight, their order in brackets; 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 and how strong they look, 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, stopping before a blow that could fell their character or cross a limit they set.
|
|
14
14
|
|
|
15
15
|
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.
|
|
16
16
|
|
|
17
|
-
In a turn of a foe or a companion, send its calls together: its rolls in one message; in the next, what they change, with `change`, then `scene next` and the rolls of whoever acts next. Never roll a later turn before the one before it is settled: who falls or flees changes what comes after.
|
|
17
|
+
In a turn of a foe or a companion, send its calls together: its rolls in one message; in the next, what they change, with `change`, then `scene next` and the rolls of whoever acts next. Never roll a later turn before the one before it is settled, in a run told in one go too: who falls or flees changes what comes after. Mark a reaction, anyone's, with `scene use` before you resolve it.
|
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, 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.
|
|
11
|
+
3. While the tools work, write nothing, in brackets either, 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], in a sentence or two; answer theirs first, only what they asked, 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 and nothing the story is about to tell, 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
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
The story is on. Besides the tools above:
|
|
4
4
|
|
|
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.
|
|
5
|
+
- `move`: whenever someone or something goes somewhere, before you narrate it: the party (a journey: `travel`, and how long it takes: `route`, before anyone says it), a person who leaves, whoever climbs into a cart or gets out of it to act, an item given or taken.
|
|
6
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
|
-
- `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
|
|
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 or recognize 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
|
|
|
10
10
|
### The character is the player's
|
|
@@ -55,7 +55,7 @@ The story is on. Besides the tools above:
|
|
|
55
55
|
|
|
56
56
|
### Fights and difficulty
|
|
57
57
|
|
|
58
|
-
29. Size what you
|
|
58
|
+
29. Size what you add to the party's way, encounter tables too, to the party as it stands, what it has left included, as the difficulty says; a fight a page held before this session, and what they go looking for, keep their own numbers and strength: adapt only how the foes fight.
|
|
59
59
|
30. After two failures at the same wall, let the world show another way or a sign.
|
|
60
60
|
|
|
61
61
|
### The sheet
|
|
@@ -64,4 +64,4 @@ The story is on. Besides the tools above:
|
|
|
64
64
|
|
|
65
65
|
### Before you send
|
|
66
66
|
|
|
67
|
-
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?
|
|
67
|
+
Read your message once as the player will. Does it answer all they did, rolled and asked? 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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": {
|