rpg-engine 0.1.2 → 0.2.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 +3 -1
- package/dist/campaign/index.d.ts +1 -1
- package/dist/campaign/index.js +1 -1
- package/dist/campaign/settings.d.ts +5 -1
- package/dist/campaign/settings.js +18 -3
- package/dist/command-line.js +26 -8
- package/dist/commands/advance.js +26 -7
- package/dist/commands/ask.d.ts +6 -0
- package/dist/commands/ask.js +3 -3
- package/dist/commands/config.js +40 -10
- package/dist/commands/game-advance.d.ts +6 -0
- package/dist/commands/game-advance.js +9 -2
- package/dist/commands/game-extension-list.d.ts +27 -0
- package/dist/commands/game-extension-list.js +92 -0
- package/dist/commands/game-extensions.d.ts +27 -0
- package/dist/commands/game-extensions.js +177 -0
- package/dist/commands/game-mode.js +2 -1
- package/dist/commands/game-time.d.ts +15 -3
- package/dist/commands/game-time.js +76 -6
- package/dist/commands/game-world.js +6 -3
- package/dist/commands/index.js +2 -0
- package/dist/commands/package.d.ts +64 -0
- package/dist/commands/package.js +293 -0
- package/dist/commands/problems.js +3 -1
- package/dist/commands/scene.d.ts +3 -3
- package/dist/commands/sheet.js +7 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +10 -5
- package/dist/commands/travel.js +4 -2
- package/dist/commands/validate.js +4 -2
- package/dist/commands/view.d.ts +5 -0
- package/dist/commands/view.js +3 -1
- package/dist/core/context.d.ts +38 -0
- package/dist/core/context.js +11 -0
- package/dist/core/instruction-parts.d.ts +10 -0
- package/dist/core/instruction-parts.js +32 -0
- package/dist/core/store.d.ts +2 -0
- package/dist/core/store.js +8 -0
- package/dist/dashboard/app.js +2 -1
- package/dist/dashboard/game-words.js +21 -0
- package/dist/dashboard/i18n/ar.json +7 -0
- package/dist/dashboard/i18n/cs.json +7 -0
- package/dist/dashboard/i18n/da.json +7 -0
- package/dist/dashboard/i18n/de.json +7 -0
- package/dist/dashboard/i18n/el.json +7 -0
- package/dist/dashboard/i18n/es.json +7 -0
- package/dist/dashboard/i18n/fi.json +7 -0
- package/dist/dashboard/i18n/fr.json +7 -0
- package/dist/dashboard/i18n/he.json +7 -0
- package/dist/dashboard/i18n/hi.json +7 -0
- package/dist/dashboard/i18n/hu.json +7 -0
- package/dist/dashboard/i18n/is.json +7 -0
- package/dist/dashboard/i18n/it.json +7 -0
- package/dist/dashboard/i18n/ja.json +7 -0
- package/dist/dashboard/i18n/ko.json +7 -0
- package/dist/dashboard/i18n/nb.json +7 -0
- package/dist/dashboard/i18n/nl.json +7 -0
- package/dist/dashboard/i18n/pl.json +7 -0
- package/dist/dashboard/i18n/pt.json +7 -0
- package/dist/dashboard/i18n/ro.json +7 -0
- package/dist/dashboard/i18n/ru.json +7 -0
- package/dist/dashboard/i18n/sv.json +7 -0
- package/dist/dashboard/i18n/tr.json +7 -0
- package/dist/dashboard/i18n/uk.json +7 -0
- package/dist/dashboard/i18n/zh.json +7 -0
- package/dist/dashboard/icons.js +1 -0
- package/dist/dashboard/top.js +5 -5
- package/dist/extensions/api.d.ts +73 -0
- package/dist/extensions/api.js +1 -0
- package/dist/extensions/extension.d.ts +43 -0
- package/dist/extensions/extension.js +113 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/packages.d.ts +11 -0
- package/dist/extensions/packages.js +155 -0
- package/dist/index.d.ts +1 -0
- package/dist/mcp-server.js +50 -4
- package/dist/systems/game-system.d.ts +1 -5
- package/dist/systems/game-system.js +6 -31
- package/dist/systems/index.d.ts +1 -1
- package/dist/time/calendar.d.ts +36 -0
- package/dist/time/calendar.js +84 -0
- package/dist/time/index.d.ts +1 -0
- package/dist/time/index.js +2 -1
- package/package.json +2 -3
- package/systems/5e/instructions/play.md +1 -0
- package/systems/5e/system.yaml +2 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { comparableText } from "../core/text.js";
|
|
3
|
+
/** The core's calendar (D-437): the twelve real months, with the seasons of the northern hemisphere. */
|
|
4
|
+
export const realCalendar = {
|
|
5
|
+
months: [
|
|
6
|
+
["January", 31, "winter"],
|
|
7
|
+
["February", 28, "winter"],
|
|
8
|
+
["March", 31, "spring"],
|
|
9
|
+
["April", 30, "spring"],
|
|
10
|
+
["May", 31, "spring"],
|
|
11
|
+
["June", 30, "summer"],
|
|
12
|
+
["July", 31, "summer"],
|
|
13
|
+
["August", 31, "summer"],
|
|
14
|
+
["September", 30, "autumn"],
|
|
15
|
+
["October", 31, "autumn"],
|
|
16
|
+
["November", 30, "autumn"],
|
|
17
|
+
["December", 31, "winter"],
|
|
18
|
+
].map(([name, days, season]) => ({ name, days, season })),
|
|
19
|
+
};
|
|
20
|
+
const calendarExample = "months: [{name: January, days: 31, season: winter}, {name: February, days: 28, season: winter}, ...]";
|
|
21
|
+
const calendarSchema = z.object({
|
|
22
|
+
months: z.array(z.object({ name: z.string().trim().min(1), days: z.int().min(1).max(10_000), season: z.string().trim().min(1).optional() }).strict()).min(1),
|
|
23
|
+
}).strict();
|
|
24
|
+
// "14 April" or "14 April 1491": the day, the month's name, which may hold spaces, and the year.
|
|
25
|
+
const startPattern = /^(\d{1,5})\s+(.*?)(?:\s+(-?\d{1,6}))?$/;
|
|
26
|
+
/** The calendar as a system, an extension or campaign.yaml writes it; it throws what is wrong, with how to write it. */
|
|
27
|
+
export function readCalendar(value) {
|
|
28
|
+
const parsed = calendarSchema.safeParse(value);
|
|
29
|
+
if (!parsed.success) {
|
|
30
|
+
throw new Error(`The calendar does not read: ${z.prettifyError(parsed.error).replace(/\s+/g, " ")}. Write it as ${calendarExample}.`);
|
|
31
|
+
}
|
|
32
|
+
const names = parsed.data.months.map((month) => comparableText(month.name));
|
|
33
|
+
const twice = parsed.data.months.find((_, index) => names.indexOf(names[index]) !== index);
|
|
34
|
+
if (twice !== undefined) {
|
|
35
|
+
throw new Error(`The calendar names the month ${twice.name} twice: give each month a name of its own.`);
|
|
36
|
+
}
|
|
37
|
+
return parsed.data;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* When the story starts: day 1, undefined, when only the days are counted; else the day of the calendar that is day 1, written as 14 April or 14 April 1491, with
|
|
41
|
+
* a month of the calendar in any case. It throws what is wrong, with what it takes.
|
|
42
|
+
*/
|
|
43
|
+
export function readCalendarStart(text, calendar) {
|
|
44
|
+
if (/^day\s+1$/i.test(text.trim())) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const match = startPattern.exec(text.trim().replace(/\s+/g, " "));
|
|
48
|
+
const month = match === null ? -1 : calendar.months.findIndex((candidate) => comparableText(candidate.name) === comparableText(match[2]));
|
|
49
|
+
const names = calendar.months.map((candidate) => candidate.name).join(", ");
|
|
50
|
+
if (match === null || match[2] === "") {
|
|
51
|
+
const first = calendar.months[0].name;
|
|
52
|
+
throw new Error(`"${text}" is not when the story starts: write day 1 to count the days, or a day of the calendar, the year if wanted, such as 14 ${first} or 14 ${first} 1491.`);
|
|
53
|
+
}
|
|
54
|
+
if (month === -1) {
|
|
55
|
+
throw new Error(`The calendar has no month "${match[2]}": its months are ${names}.`);
|
|
56
|
+
}
|
|
57
|
+
const day = Number(match[1]);
|
|
58
|
+
const { name, days } = calendar.months[month];
|
|
59
|
+
if (day < 1 || day > days) {
|
|
60
|
+
throw new Error(`${name} has days 1 to ${days}, not ${day}: give a day it has.`);
|
|
61
|
+
}
|
|
62
|
+
return match[3] === undefined ? { day, month } : { day, month, year: Number(match[3]) };
|
|
63
|
+
}
|
|
64
|
+
/** The day of the calendar that a game day falls on, counting from the start as day 1; after the last month the first comes again, a year later. */
|
|
65
|
+
export function calendarDay(calendar, start, gameDay) {
|
|
66
|
+
const { months } = calendar;
|
|
67
|
+
const yearDays = months.reduce((total, month) => total + month.days, 0);
|
|
68
|
+
const beforeStart = months.slice(0, start.month).reduce((total, month) => total + month.days, 0) + start.day - 1;
|
|
69
|
+
const sinceYearStart = beforeStart + gameDay - 1;
|
|
70
|
+
let left = sinceYearStart % yearDays;
|
|
71
|
+
let index = 0;
|
|
72
|
+
while (left >= months[index].days) {
|
|
73
|
+
left -= months[index].days;
|
|
74
|
+
index += 1;
|
|
75
|
+
}
|
|
76
|
+
const month = months[index];
|
|
77
|
+
const year = start.year === undefined ? {} : { year: start.year + Math.floor(sinceYearStart / yearDays) };
|
|
78
|
+
return { day: left + 1, month: month.name, ...(month.season === undefined ? {} : { season: month.season }), ...year };
|
|
79
|
+
}
|
|
80
|
+
/** A day of the calendar as it is written: 15 April, spring; 15 April 1491, spring; 15 April when the month has no season. */
|
|
81
|
+
export function formatCalendarDay(date) {
|
|
82
|
+
const day = `${date.day} ${date.month}${date.year === undefined ? "" : ` ${date.year}`}`;
|
|
83
|
+
return date.season === undefined ? day : `${day}, ${date.season}`;
|
|
84
|
+
}
|
package/dist/time/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
+
export { type Calendar, type CalendarDay, calendarDay, type CalendarMonth, type CalendarStart, formatCalendarDay, readCalendar, readCalendarStart, realCalendar } from "./calendar.ts";
|
|
1
2
|
export { addDuration, formatDuration, formatGameDate, type GameDate, lastGameDay, minutesBetween, readDuration, readGameDate } from "./game-date.ts";
|
package/dist/time/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
// Game time for any game: the date of the story, counted in days from the start of the adventure, and
|
|
1
|
+
// Game time for any game: the date of the story, counted in days from the start of the adventure, durations, and the calendar that shows a date as a day of a month.
|
|
2
|
+
export { calendarDay, formatCalendarDay, readCalendar, readCalendarStart, realCalendar } from "./calendar.js";
|
|
2
3
|
export { addDuration, formatDuration, formatGameDate, lastGameDay, minutesBetween, readDuration, readGameDate } from "./game-date.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-engine",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.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": {
|
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
"systems",
|
|
20
20
|
"!systems/*/test",
|
|
21
21
|
"!systems/*/build",
|
|
22
|
-
"extensions",
|
|
23
22
|
"instructions"
|
|
24
23
|
],
|
|
25
24
|
"scripts": {
|
|
26
|
-
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc && tsc -p src/dashboard && node -e \"require('node:fs').cpSync('src/dashboard', 'dist/dashboard', { recursive: true, filter: (path) => !/[.](tsx?|py)$|tsconfig[.]json$/.test(path) })\"",
|
|
25
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc && tsc -p src/dashboard && node -e \"require('node:fs').cpSync('src/dashboard', 'dist/dashboard', { recursive: true, filter: (path) => !/[.](tsx?|py)$|tsconfig[.]json$/.test(path) })\" && tsc -p extensions/weather",
|
|
27
26
|
"dev": "tsc --watch",
|
|
28
27
|
"demo": "npm run build && node --experimental-strip-types --no-warnings test/demo/dashboard.ts --ask --port 5760",
|
|
29
28
|
"betasim": "npm run build && node --experimental-strip-types --no-warnings test/betasim/run.ts",
|
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
- At difficulty normal, fights run from moderate to high difficulty (XP budget per character); easier or harder as the difficulty says.
|
|
4
4
|
- A condition or effect that changes a check is rolled in: disadvantage on Athletics is 2d20kl1+athletics, named Athletics alone: the dice say the rest, and why goes in the question.
|
|
5
5
|
- A roll in brackets: [Persuasion 14 + 3 = 17].
|
|
6
|
+
- Alignment describes a character, it never limits what the player does. When their choices keep going another way, you may say so once in brackets and offer a new alignment; change it only with their yes. It matters in play only where a page says so, as a talisman that only a good creature can attune to.
|
package/systems/5e/system.yaml
CHANGED
|
@@ -118,6 +118,8 @@ token-icons:
|
|
|
118
118
|
# The names a list takes (pp. 77, 83): write refuses others, giving these, and validate reports those written by hand. Only lists the game closes:
|
|
119
119
|
# expertise is open, since a feature may give it in any tool (D-216).
|
|
120
120
|
values:
|
|
121
|
+
# The alignments (pp. 58–59): the nine of a character, and those the SRD's creatures have.
|
|
122
|
+
alignment: [lawful good, neutral good, chaotic good, lawful neutral, neutral, chaotic neutral, lawful evil, neutral evil, chaotic evil, unaligned, any alignment, any chaotic alignment, any evil alignment, any non-good alignment, any non-lawful alignment, "neutral good (50%) or neutral evil (50%)"]
|
|
121
123
|
save-proficiencies: [str, dex, con, int, wis, cha]
|
|
122
124
|
skill-proficiencies: [Acrobatics, Animal Handling, Arcana, Athletics, Deception, History, Insight, Intimidation, Investigation, Medicine, Nature, Perception, Performance, Persuasion, Religion, Sleight of Hand, Stealth, Survival]
|
|
123
125
|
# The classes give the row of their table at the character's level in each (pp. 8–55, D-201, D-219): its columns as values of the sheet, such as Rage Damage,
|