rpg-engine 0.17.0 → 0.18.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 (42) hide show
  1. package/dist/commands/change/recipe.d.ts +2 -0
  2. package/dist/commands/change/recipe.js +4 -2
  3. package/dist/commands/reveal.d.ts +2 -0
  4. package/dist/commands/reveal.js +22 -3
  5. package/dist/commands/scene/close.js +3 -1
  6. package/dist/commands/scene/open.js +1 -1
  7. package/dist/commands/scene/scene.js +3 -2
  8. package/dist/commands/shared/packages/updates.d.ts +6 -0
  9. package/dist/commands/shared/packages/updates.js +114 -0
  10. package/dist/commands/shared/scene/scene.js +4 -0
  11. package/dist/commands/shared/time/recipes.d.ts +5 -0
  12. package/dist/commands/shared/time/recipes.js +19 -1
  13. package/dist/commands/status.d.ts +1 -0
  14. package/dist/commands/status.js +5 -0
  15. package/dist/commands/travel/travel.js +1 -0
  16. package/dist/commands/view/layers.d.ts +4 -2
  17. package/dist/commands/view/layers.js +15 -6
  18. package/dist/commands/view/place.d.ts +6 -0
  19. package/dist/commands/view/place.js +37 -13
  20. package/dist/commands/view/result.d.ts +2 -0
  21. package/dist/commands/view/view.d.ts +1 -0
  22. package/dist/commands/view/view.js +35 -12
  23. package/dist/core/context.d.ts +5 -0
  24. package/dist/core/length.d.ts +4 -1
  25. package/dist/core/length.js +13 -2
  26. package/dist/dashboard/app.js +1 -1
  27. package/dist/dashboard/dice/tray.js +7 -5
  28. package/dist/dashboard/parts/labels.js +26 -4
  29. package/dist/dashboard/parts/widgets.js +1 -1
  30. package/dist/dashboard/play/rolls.js +3 -3
  31. package/dist/dashboard/settings/setup.js +30 -13
  32. package/dist/dashboard/shell/table.js +7 -3
  33. package/dist/packages/npm.js +32 -7
  34. package/dist/pages/index.d.ts +2 -2
  35. package/dist/pages/index.js +2 -2
  36. package/dist/pages/load.d.ts +2 -0
  37. package/dist/pages/load.js +16 -3
  38. package/dist/scene/scene.d.ts +4 -1
  39. package/instructions/combat.md +2 -2
  40. package/instructions/core.md +2 -2
  41. package/instructions/play.md +3 -3
  42. package/package.json +1 -1
@@ -14,6 +14,15 @@ export function weightUnit(world, field) {
14
14
  const written = (world.system?.pages ?? []).map((page) => page.fields[field]).find((value) => typeof value === "string" && /\p{L}/u.test(value));
15
15
  return typeof written === "string" ? /(\p{L}[\p{L}.]*)\s*$/u.exec(written)?.[1] : undefined;
16
16
  }
17
+ /** A weight written in pounds told in kilograms at the system's pound, its note kept: 6 lb is 3 kg, 5 lb (full) 2.5 kg (full); any other text unchanged. */
18
+ export function poundsInKilograms(text, pound) {
19
+ const match = /^\s*([\d,]*(?:\.\d+)?)\s*(½|¼|¾|\d+\/\d+)?\s*(?:lbs?\.?|pounds?)\s*(\([^()]*\))?\s*$/iu.exec(text);
20
+ if (match === null || (match[1] === "" && match[2] === undefined)) {
21
+ return text;
22
+ }
23
+ const kilograms = Math.round(writtenWeight(match[1], match[2]) * pound * 1000) / 1000;
24
+ return match[3] === undefined ? `${kilograms} kg` : `${kilograms} kg ${match[3]}`;
25
+ }
17
26
  /** How many pieces one of a kind holds, by the field the system declares for its bundle: 1 for a kind not sold by the bundle (STK-2). */
18
27
  export function bundleOf(field, kind) {
19
28
  const pieces = field === undefined ? Number.NaN : Number(valueNamed(kind.fields, field));
@@ -56,10 +65,14 @@ function weightOf(world, field, page) {
56
65
  if (match === null || (match[1] === "" && match[2] === undefined)) {
57
66
  return 0;
58
67
  }
68
+ return writtenWeight(match[1], match[2]);
69
+ }
70
+ /** A weight's number from its whole part and its fraction, as written: 1,000, 0,5, 1 and ½, and 1/4. */
71
+ function writtenWeight(whole, fraction) {
59
72
  // A comma before three digits groups thousands, as 1,000; any other is a decimal comma, as 0,5.
60
- const whole = match[1] === "" ? 0 : Number(match[1].replace(/,(?=\d{3}(?!\d))/g, "").replace(",", "."));
61
- const part = match[2] === undefined ? 0 : { "½": 0.5, "¼": 0.25, "¾": 0.75 }[match[2]] ?? Number(match[2].split("/")[0]) / Number(match[2].split("/")[1]);
62
- return whole + part;
73
+ const number = whole === "" ? 0 : Number(whole.replace(/,(?=\d{3}(?!\d))/g, "").replace(",", "."));
74
+ const part = fraction === undefined ? 0 : { "½": 0.5, "¼": 0.25, "¾": 0.75 }[fraction] ?? Number(fraction.split("/")[0]) / Number(fraction.split("/")[1]);
75
+ return number + part;
63
76
  }
64
77
  /** What the coins of a purse weigh, as many coins as the system says make one unit of weight; 0 when it says none. */
65
78
  function coinsWeight(fields, perUnit) {
@@ -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
- /** What the player character sees of who it does not know by name, by the character's or the creature's name, such as brigante incappucciato (D-416). */
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. */
@@ -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.
@@ -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
@@ -4,7 +4,7 @@ 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
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 by name comes in with `seen`, two or three words of what they see, until `reveal` gives the name.
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 put on the party's way, encounter tables too, to the party as it stands, what it has left included, as the difficulty says; what they go looking for keeps its own strength.
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.17.0",
3
+ "version": "0.18.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": {