rpg-engine 0.11.0 → 0.13.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.
- package/README.md +1 -1
- package/dist/commands/effect.d.ts +1 -1
- package/dist/commands/shared/inputs.d.ts +2 -2
- package/dist/commands/shared/inputs.js +15 -2
- package/dist/commands/shared/page-words.d.ts +4 -0
- package/dist/commands/shared/page-words.js +7 -7
- package/dist/commands/shared/system-texts.d.ts +11 -0
- package/dist/commands/shared/system-texts.js +203 -0
- package/dist/commands/shared/world.d.ts +2 -0
- package/dist/commands/shared/world.js +13 -3
- package/dist/commands/view/view.d.ts +4 -0
- package/dist/commands/view/view.js +14 -3
- package/dist/commands/write/write.d.ts +3 -3
- package/dist/core/context.d.ts +16 -0
- package/dist/core/files.js +2 -3
- package/dist/core/language.d.ts +2 -0
- package/dist/core/language.js +8 -0
- package/dist/core/text.d.ts +2 -0
- package/dist/core/text.js +5 -0
- package/dist/dashboard/app.js +10 -9
- package/dist/dashboard/asked.js +2 -2
- package/dist/dashboard/dice/throw.js +2 -1
- package/dist/dashboard/dice/tray.js +1 -1
- package/dist/dashboard/guide/ar.md +2 -2
- package/dist/dashboard/guide/cs.md +2 -2
- package/dist/dashboard/guide/da.md +2 -2
- package/dist/dashboard/guide/de.md +2 -2
- package/dist/dashboard/guide/el.md +2 -2
- package/dist/dashboard/guide/en.md +1 -1
- package/dist/dashboard/guide/es.md +2 -2
- package/dist/dashboard/guide/fi.md +2 -2
- package/dist/dashboard/guide/fr.md +2 -2
- package/dist/dashboard/guide/he.md +2 -2
- package/dist/dashboard/guide/hi.md +2 -2
- package/dist/dashboard/guide/hu.md +2 -2
- package/dist/dashboard/guide/is.md +2 -2
- package/dist/dashboard/guide/it.md +2 -2
- package/dist/dashboard/guide/ja.md +2 -2
- package/dist/dashboard/guide/ko.md +2 -2
- package/dist/dashboard/guide/nb.md +2 -2
- package/dist/dashboard/guide/nl.md +2 -2
- package/dist/dashboard/guide/pl.md +2 -2
- package/dist/dashboard/guide/pt.md +2 -2
- package/dist/dashboard/guide/ro.md +2 -2
- package/dist/dashboard/guide/ru.md +2 -2
- package/dist/dashboard/guide/sv.md +2 -2
- package/dist/dashboard/guide/tr.md +2 -2
- package/dist/dashboard/guide/uk.md +2 -2
- package/dist/dashboard/guide/zh.md +2 -2
- package/dist/dashboard/i18n/ar.json +2 -1
- package/dist/dashboard/i18n/cs.json +2 -1
- package/dist/dashboard/i18n/da.json +2 -1
- package/dist/dashboard/i18n/de.json +2 -1
- package/dist/dashboard/i18n/el.json +2 -1
- package/dist/dashboard/i18n/es.json +2 -1
- package/dist/dashboard/i18n/fi.json +2 -1
- package/dist/dashboard/i18n/fr.json +2 -1
- package/dist/dashboard/i18n/he.json +2 -1
- package/dist/dashboard/i18n/hi.json +2 -1
- package/dist/dashboard/i18n/hu.json +2 -1
- package/dist/dashboard/i18n/is.json +2 -1
- package/dist/dashboard/i18n/it.json +2 -1
- package/dist/dashboard/i18n/ja.json +2 -1
- package/dist/dashboard/i18n/ko.json +2 -1
- package/dist/dashboard/i18n/nb.json +2 -1
- package/dist/dashboard/i18n/nl.json +2 -1
- package/dist/dashboard/i18n/pl.json +2 -1
- package/dist/dashboard/i18n/pt.json +2 -1
- package/dist/dashboard/i18n/ro.json +2 -1
- package/dist/dashboard/i18n/ru.json +2 -1
- package/dist/dashboard/i18n/sv.json +2 -1
- package/dist/dashboard/i18n/tr.json +2 -1
- package/dist/dashboard/i18n/uk.json +2 -1
- package/dist/dashboard/i18n/zh.json +2 -1
- package/dist/dashboard/journal.js +1 -1
- package/dist/dashboard/notices.js +9 -2
- package/dist/dashboard/packages/packages.js +5 -5
- package/dist/dashboard/packages/widgets.js +1 -1
- package/dist/dashboard/saves.js +1 -1
- package/dist/dashboard/settings.js +2 -2
- package/dist/dashboard/setup.js +1 -1
- package/dist/dashboard/text.js +7 -2
- package/dist/dashboard/world/lore.js +1 -1
- package/dist/dashboard/world/world.js +1 -1
- package/dist/documents/png.d.ts +2 -3
- package/dist/documents/png.js +6 -6
- package/dist/documents/read.js +2 -1
- package/dist/extensions/words.js +2 -1
- package/dist/languages/language-pack.js +2 -2
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/pages/world.d.ts +5 -0
- package/dist/pages/world.js +22 -11
- package/dist/server/dashboard/files.js +6 -5
- package/dist/server/dashboard/index.d.ts +3 -1
- package/dist/server/dashboard/index.js +3 -1
- package/dist/server/mcp.js +3 -1
- package/dist/systems/game-system.js +2 -1
- package/dist/systems/words.js +2 -1
- package/dist/testing/index.js +1 -1
- package/instructions/play.md +1 -1
- package/package.json +12 -12
package/dist/documents/read.js
CHANGED
|
@@ -94,7 +94,8 @@ async function readFolder(folder, options) {
|
|
|
94
94
|
*/
|
|
95
95
|
async function readPdf(path, options) {
|
|
96
96
|
const { extractText, getDocumentProxy } = await import("unpdf");
|
|
97
|
-
|
|
97
|
+
// pdf.js says its warnings on the standard output, which is the MCP server's channel: errors only.
|
|
98
|
+
const pdf = await getDocumentProxy(new Uint8Array(readFileSync(path)), { verbosity: 0 }).catch((error) => {
|
|
98
99
|
throw error?.name === "PasswordException" ? new Error(`${basename(path)} asks for a password to open: the engine never opens a locked document.`) : error;
|
|
99
100
|
});
|
|
100
101
|
const { text } = await extractText(pdf, { mergePages: false });
|
package/dist/extensions/words.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// the names of the fields it adds to the game system, and any word or phrase its widgets write, by the English as its code writes it. The core hands them on: a word the list lacks stays as written.
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
+
import { codeAndBase } from "../core/language.js";
|
|
5
6
|
import { files } from "../core/store.js";
|
|
6
7
|
import { readYamlValues } from "../core/yaml-file.js";
|
|
7
8
|
const wordsSchema = z.object({
|
|
@@ -12,7 +13,7 @@ const wordsSchema = z.object({
|
|
|
12
13
|
}, { error: "write its title, its about, the names of its fields and its words, each from the text the code writes to the language's own, such as {words: {Weather: Meteo}}" }).strict();
|
|
13
14
|
/** The words of the extension in this folder for a language, or for its base language (pt for pt-BR); undefined when it has none in it. It throws when they do not read. */
|
|
14
15
|
export function extensionWords(folder, language) {
|
|
15
|
-
const file =
|
|
16
|
+
const file = codeAndBase(language).map((code) => join(folder, "words", `${code}.yaml`)).find((path) => files().exists(path));
|
|
16
17
|
if (file === undefined) {
|
|
17
18
|
return undefined;
|
|
18
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { packageFoldersIn } from "../core/files.js";
|
|
4
|
+
import { codeAndBase } from "../core/language.js";
|
|
4
5
|
import { files } from "../core/store.js";
|
|
5
6
|
import { readYamlValues } from "../core/yaml-file.js";
|
|
6
7
|
/** The file that makes a package a language's (D-485 (3)): its code and its name. */
|
|
@@ -33,8 +34,7 @@ export function installedLanguages(folders) {
|
|
|
33
34
|
/** The package for a language: its own code, else its base language's (pt for pt-BR); undefined when none is installed. */
|
|
34
35
|
export function languagePackFor(folders, code) {
|
|
35
36
|
const packs = installedLanguages(folders);
|
|
36
|
-
|
|
37
|
-
return packs.find((pack) => pack.code.toLowerCase() === wanted) ?? packs.find((pack) => pack.code.toLowerCase() === wanted.split("-")[0]);
|
|
37
|
+
return codeAndBase(code).map((wanted) => packs.find((pack) => pack.code.toLowerCase() === wanted)).find((pack) => pack !== undefined);
|
|
38
38
|
}
|
|
39
39
|
/** A language package from its folder; it throws, saying what is wrong, when it does not read. */
|
|
40
40
|
export function readLanguagePack(folder) {
|
package/dist/pages/index.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ export { countedText, entryOfKind, type EntryReading, readEntry, withStackCount
|
|
|
14
14
|
export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, type HeldStack, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, type Stack, stackName, stacksOf } from "./stacks/kinds.ts";
|
|
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
|
-
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, withPage, type World, } from "./world.ts";
|
|
17
|
+
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
18
|
export { checkFieldChange, type PageChange, writePage } from "./write-page.ts";
|
package/dist/pages/index.js
CHANGED
|
@@ -15,5 +15,5 @@ export { countedText, entryOfKind, readEntry, withStackCount } from "./stacks/en
|
|
|
15
15
|
export { carriesKind, carriesNamed, entryKind, entryPage, goodsNamed, heldStacks, heldStacksOfKind, isKind, kindNamed, ownStack, pageNamedQuietly, stackName, stacksOf } from "./stacks/kinds.js";
|
|
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
|
-
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, withPage, } from "./world.js";
|
|
18
|
+
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
19
|
export { checkFieldChange, writePage } from "./write-page.js";
|
package/dist/pages/world.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export declare function loadWorld(root: string, options?: {
|
|
|
105
105
|
system?: SystemInfo & {
|
|
106
106
|
folder: string;
|
|
107
107
|
version?: {
|
|
108
|
+
name: string;
|
|
108
109
|
folder: string;
|
|
109
110
|
};
|
|
110
111
|
};
|
|
@@ -113,6 +114,8 @@ export declare function loadWorld(root: string, options?: {
|
|
|
113
114
|
missingSystem?: string;
|
|
114
115
|
noSystem?: boolean;
|
|
115
116
|
rigor?: string;
|
|
117
|
+
/** The folder of the system's pages translated on this computer into the campaign's language (D-539), where the system has no translation of its own. */
|
|
118
|
+
ownTranslations?: string;
|
|
116
119
|
}): World;
|
|
117
120
|
/**
|
|
118
121
|
* The page with this name, ignoring case and Unicode normalization: the campaign's, else the game system's (SYS-3). Two pages of the campaign with that name stop the command:
|
|
@@ -210,3 +213,5 @@ export declare function pageFileNamed(root: string, name: string): {
|
|
|
210
213
|
} | undefined;
|
|
211
214
|
/** The pages of the system's bonus lists a page names (FOR-5, D-449): an attuned ring, a feat; of a list given only while in another, only those in it too, as a ring worn (BND-4). */
|
|
212
215
|
export declare function bonusPages(world: World, fields: Record<string, unknown>): Page[];
|
|
216
|
+
/** Where a version's pages translated on this computer are, under the folder of the language's (D-539). */
|
|
217
|
+
export declare function versionTranslations(version: string): string;
|
package/dist/pages/world.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isReservedName } from "../core/archive-paths.js";
|
|
|
3
3
|
import { translationFolder } from "../core/files.js";
|
|
4
4
|
import { frozen } from "../core/frozen.js";
|
|
5
5
|
import { files } from "../core/store.js";
|
|
6
|
-
import { comparableText, valueNamed } from "../core/text.js";
|
|
6
|
+
import { comparableText, textPrint, valueNamed } from "../core/text.js";
|
|
7
7
|
import { linkedPages, links } from "./markdown.js";
|
|
8
8
|
import { readFields, splitPageFile } from "./page-file.js";
|
|
9
9
|
import { pageTypes, typeOfFolder, worldFolderName } from "./page-types.js";
|
|
@@ -27,12 +27,15 @@ export function createWorld(root) {
|
|
|
27
27
|
*/
|
|
28
28
|
export function loadWorld(root, options = {}) {
|
|
29
29
|
const campaign = readPages(root);
|
|
30
|
-
const { system, language, words, missingSystem, noSystem, rigor } = options;
|
|
30
|
+
const { system, language, words, missingSystem, noSystem, rigor, ownTranslations } = options;
|
|
31
31
|
if (system === undefined) {
|
|
32
32
|
return frozen({ root, ...campaign, language, missingSystem, noSystem, ...(rigor === undefined ? {} : { rigor }) });
|
|
33
33
|
}
|
|
34
|
-
const read = (folder) => translatedPages(packagePages(folder, system.name), folder, system.name, language);
|
|
35
|
-
|
|
34
|
+
const read = (folder, own) => translatedPages(packagePages(folder, system.name), folder, system.name, language, own);
|
|
35
|
+
// A version's pages translated on this computer have a folder of their own, as their text is the version's (D-539).
|
|
36
|
+
const systemPages = system.version === undefined
|
|
37
|
+
? read(system.folder, ownTranslations)
|
|
38
|
+
: versionPages(read(system.folder, ownTranslations), read(system.version.folder, ownTranslations === undefined ? undefined : join(ownTranslations, versionTranslations(system.version.name))));
|
|
36
39
|
const { name, title, fields, formulas, progression, itemFormulas, alwaysIn, uses, statusLine, load, lengthUnit, bonusLists, bonusWhile } = system;
|
|
37
40
|
const problems = [...campaign.problems, ...systemPages.problems];
|
|
38
41
|
return frozen({
|
|
@@ -364,27 +367,35 @@ function packagePages(folder, system) {
|
|
|
364
367
|
const packages = new Map();
|
|
365
368
|
/**
|
|
366
369
|
* A system's pages with their text and their name in the campaign's language beside their own, where the system has a translation of them in it, by the same
|
|
367
|
-
* path under translations/<language> (D-542); their fields and text stay, which the engine reads. Read once in a process, as the pages are.
|
|
370
|
+
* path under translations/<language> (D-542); their fields and text stay, which the engine reads. Read once in a process, as the pages are. Where the system
|
|
371
|
+
* has none, those translated on this computer (D-539), each while the text it was made from is the page's: read through the store, as they grow.
|
|
368
372
|
*/
|
|
369
|
-
function translatedPages(read, folder, system, language) {
|
|
373
|
+
function translatedPages(read, folder, system, language, own) {
|
|
370
374
|
const translations = translationFolder(folder, language);
|
|
371
375
|
if (translations === undefined) {
|
|
372
|
-
return read;
|
|
376
|
+
return own === undefined ? read : withTranslations(read, readPages(own, system), true);
|
|
373
377
|
}
|
|
374
378
|
const key = `${translations}|${system}`;
|
|
375
|
-
const known = translated.get(key) ?? withTranslations(read, readPages(translations, system));
|
|
379
|
+
const known = translated.get(key) ?? withTranslations(read, readPages(translations, system), false);
|
|
376
380
|
translated.set(key, known);
|
|
377
381
|
return known;
|
|
378
382
|
}
|
|
379
383
|
const translated = new Map();
|
|
380
|
-
function withTranslations(read, translations) {
|
|
384
|
+
function withTranslations(read, translations, printed) {
|
|
381
385
|
const byPath = new Map(translations.pages.map((page) => [page.path, page]));
|
|
382
386
|
const pages = read.pages.map((page) => {
|
|
383
|
-
const
|
|
387
|
+
const found = byPath.get(page.path);
|
|
388
|
+
// A translation made on this computer from a text the system has since changed is no longer the page's.
|
|
389
|
+
const other = printed && found?.fields.source !== textPrint(page.body) ? undefined : found;
|
|
384
390
|
const title = typeof other?.fields.name === "string" && other.fields.name.trim() !== "" ? other.fields.name.trim() : undefined;
|
|
385
391
|
return other === undefined ? page : frozen({ ...page, translated: other.body, ...(title === undefined ? {} : { title }) });
|
|
386
392
|
});
|
|
387
|
-
|
|
393
|
+
// A file of this computer's that does not read is no problem of the campaign's: the page is translated again, over it.
|
|
394
|
+
return { pages, problems: printed ? read.problems : [...read.problems, ...translations.problems] };
|
|
395
|
+
}
|
|
396
|
+
/** Where a version's pages translated on this computer are, under the folder of the language's (D-539). */
|
|
397
|
+
export function versionTranslations(version) {
|
|
398
|
+
return join("versions", version);
|
|
388
399
|
}
|
|
389
400
|
/** A system's pages with those of the version of its rules over them (VER-3): a page of the version takes the place of a common one with its name. */
|
|
390
401
|
function versionPages(common, version) {
|
|
@@ -40,9 +40,9 @@ export const builtPage = fileURLToPath(new URL("../../../dist/dashboard/", impor
|
|
|
40
40
|
// beside it; three's loader of the dice's models imports two of its utilities beside it; the room the metal dice mirror is three's too; Rapier's module
|
|
41
41
|
// moves the dice.
|
|
42
42
|
const vendorModules = {
|
|
43
|
-
"preact.js": ["preact", "dist/preact.
|
|
44
|
-
"hooks.js": ["preact", "hooks/dist/hooks.
|
|
45
|
-
"jsx-runtime.js": ["preact", "jsx-runtime/dist/jsxRuntime.
|
|
43
|
+
"preact.js": ["preact", "dist/preact.mjs"],
|
|
44
|
+
"hooks.js": ["preact", "hooks/dist/hooks.mjs"],
|
|
45
|
+
"jsx-runtime.js": ["preact", "jsx-runtime/dist/jsxRuntime.mjs"],
|
|
46
46
|
"three.module.js": ["three", "build/three.module.js"],
|
|
47
47
|
"three.core.js": ["three", "build/three.core.js"],
|
|
48
48
|
"three/addons/loaders/GLTFLoader.js": ["three", "examples/jsm/loaders/GLTFLoader.js"],
|
|
@@ -248,7 +248,8 @@ export async function pageWords(request, response, served, url) {
|
|
|
248
248
|
sendJson(response, 400, { error: "Send the language and the phrases the page lacks now, { language, first }." });
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
|
-
|
|
251
|
+
// Through the session, which keeps the system's words translated on this computer (D-539).
|
|
252
|
+
withFiles(served.session, () => served.words.ask(parsed.data.language.toLowerCase(), parsed.data.first));
|
|
252
253
|
sendJson(response, 202, {});
|
|
253
254
|
return;
|
|
254
255
|
}
|
|
@@ -262,7 +263,7 @@ export async function pageWords(request, response, served, url) {
|
|
|
262
263
|
const found = root === undefined ? undefined : campaignSystem(root, served.context);
|
|
263
264
|
return found === undefined ? undefined : { name: found.name, folder: found.folder };
|
|
264
265
|
});
|
|
265
|
-
sendJson(response, 200, served.words.read(language.toLowerCase(), system));
|
|
266
|
+
sendJson(response, 200, withFiles(served.session, () => served.words.read(language.toLowerCase(), system)));
|
|
266
267
|
}
|
|
267
268
|
/** A request's body as bytes, up to `most`; undefined when it is more. */
|
|
268
269
|
export async function readBytes(request, most) {
|
|
@@ -2,7 +2,7 @@ import { type ServerResponse } from "node:http";
|
|
|
2
2
|
import type { PlayerSetting } from "../../commands/config.ts";
|
|
3
3
|
import type { Catalog } from "../../commands/shared/packages/catalog.ts";
|
|
4
4
|
import { type PageTranslator } from "../../commands/shared/page-words.ts";
|
|
5
|
-
import type { Context, Player } from "../../core/context.ts";
|
|
5
|
+
import type { Context, Player, SystemTexts } from "../../core/context.ts";
|
|
6
6
|
import type { SessionStore } from "../../core/session-store.ts";
|
|
7
7
|
import { type Acts } from "../player-acts.ts";
|
|
8
8
|
import { type Asked, type ShownCard } from "./player.ts";
|
|
@@ -85,6 +85,8 @@ export interface Served {
|
|
|
85
85
|
notify(): void;
|
|
86
86
|
/** The page in a language the package does not ship, translated on the fly (D-406). */
|
|
87
87
|
words: PageTranslator;
|
|
88
|
+
/** The game system's pages in the campaign's language, translated as the page reads them (D-539): the page's alone, never the master's calls. */
|
|
89
|
+
texts: SystemTexts;
|
|
88
90
|
/** The package the player is adding, updating or taking away on the page, while npm works (D-475): one at a time. */
|
|
89
91
|
packageWork?: {
|
|
90
92
|
name: string;
|
|
@@ -8,6 +8,7 @@ import { importShown } from "../../commands/import/import.js";
|
|
|
8
8
|
import { loadCampaignCode } from "../../commands/shared/packages/code.js";
|
|
9
9
|
import { campaignWidgets, packageWidget } from "../../commands/shared/packages/widgets.js";
|
|
10
10
|
import { pageTranslator } from "../../commands/shared/page-words.js";
|
|
11
|
+
import { systemTexts } from "../../commands/shared/system-texts.js";
|
|
11
12
|
import { view } from "../../commands/view/view.js";
|
|
12
13
|
import { isBoolean } from "../../core/registry.js";
|
|
13
14
|
import { withFiles } from "../../core/store.js";
|
|
@@ -66,6 +67,7 @@ export async function startDashboard(context, session, options = {}) {
|
|
|
66
67
|
shared: new Map(),
|
|
67
68
|
notify: () => undefined,
|
|
68
69
|
words: pageTranslator(context, options.page ?? builtPage, () => served.notify()),
|
|
70
|
+
texts: systemTexts(context, () => served.notify()),
|
|
69
71
|
acts: newActs(),
|
|
70
72
|
queue: options.queue ?? codexQueue(),
|
|
71
73
|
};
|
|
@@ -380,7 +382,7 @@ async function runCommand(name, parameters, response, served) {
|
|
|
380
382
|
}
|
|
381
383
|
try {
|
|
382
384
|
await served.session.ready();
|
|
383
|
-
const result = await command.run(parsed.data, served.context);
|
|
385
|
+
const result = await command.run(parsed.data, { ...served.context, texts: served.texts });
|
|
384
386
|
keepProblems(served, result);
|
|
385
387
|
sendJson(response, 200, isSetup(result) ? { ...result, left: result.questions.filter((question) => served.left.has(question.name) && question.value === undefined && question.items === undefined).map((question) => question.name) } : result);
|
|
386
388
|
}
|
package/dist/server/mcp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import { findCampaign, hasCharacterAgent, readTextSetting, refreshHostFiles } from "../campaign/index.js";
|
|
6
7
|
import { commands } from "../commands/index.js";
|
|
@@ -134,7 +135,8 @@ export async function startMcpServer() {
|
|
|
134
135
|
};
|
|
135
136
|
// The systems' code, loaded once for the session, as the engine's own: a system changed since needs the server started again (D-448).
|
|
136
137
|
context.systemCode = await loadSystemCode(context.systemFolders);
|
|
137
|
-
|
|
138
|
+
// The game systems, and what this computer translated of them, written only through the session (D-539).
|
|
139
|
+
const session = new SessionStore({ systemFolders: [...context.systemFolders, ...(context.home === undefined ? [] : [join(context.home, "systems")])] });
|
|
138
140
|
const served = { ...context, files: session };
|
|
139
141
|
server = createMcpServer(served, process.env, dashboardOpener(served, session).open);
|
|
140
142
|
// The extensions' tools are there in the first list the host asks for.
|
|
@@ -4,6 +4,7 @@ import { fieldKinds } from "../core/field-kind.js";
|
|
|
4
4
|
import { formulaOf, readFormulas } from "../core/formula.js";
|
|
5
5
|
import { frozen } from "../core/frozen.js";
|
|
6
6
|
import { readParts } from "../core/instruction-parts.js";
|
|
7
|
+
import { codeAndBase } from "../core/language.js";
|
|
7
8
|
import { lengthHelp, readLength, readSpeed, speedHelp } from "../core/length.js";
|
|
8
9
|
import { declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
|
|
9
10
|
import { files } from "../core/store.js";
|
|
@@ -105,7 +106,7 @@ export function withSettings(system, valueOf) {
|
|
|
105
106
|
*/
|
|
106
107
|
export function rollName(system, dice, language) {
|
|
107
108
|
const names = system.rollNames[plainRoll(dice)];
|
|
108
|
-
return names === undefined ? undefined : (
|
|
109
|
+
return names === undefined ? undefined : ([language, ...codeAndBase(language).slice(1)].map((code) => names[code]).find((name) => name !== undefined) ?? names[system.language]);
|
|
109
110
|
}
|
|
110
111
|
/** The systems installed in these folders, nearest folder first: each folder in them with a system.yaml. A name found twice is the nearest one. */
|
|
111
112
|
export function installedSystems(folders) {
|
package/dist/systems/words.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { codeAndBase } from "../core/language.js";
|
|
6
7
|
import { readYamlValues } from "../core/yaml-file.js";
|
|
7
8
|
const named = z.record(z.string().min(1), z.string().min(1));
|
|
8
9
|
const wordsSchema = z.object({ groups: named.optional(), fields: named.optional(), words: named.optional(), names: named.optional(), headline: z.string().min(1).optional() }, {
|
|
@@ -10,7 +11,7 @@ const wordsSchema = z.object({ groups: named.optional(), fields: named.optional(
|
|
|
10
11
|
}).strict();
|
|
11
12
|
/** The words of the system in this folder for a language, or for its base language (pt for pt-BR); undefined when the system has none in it. */
|
|
12
13
|
export function systemWords(folder, language) {
|
|
13
|
-
const file =
|
|
14
|
+
const file = codeAndBase(language).map((code) => join(folder, "words", `${code}.yaml`)).find((path) => existsSync(path));
|
|
14
15
|
if (file === undefined) {
|
|
15
16
|
return undefined;
|
|
16
17
|
}
|
package/dist/testing/index.js
CHANGED
|
@@ -161,7 +161,7 @@ function inPlay(folder) {
|
|
|
161
161
|
}
|
|
162
162
|
/** The dashboard of a test campaign, with a page open on it that the server has heard from, so that questions go to the page. */
|
|
163
163
|
async function testDashboard(context) {
|
|
164
|
-
const session = new SessionStore({ systemFolders: context.systemFolders, watchFolder: () => ({ close: () => undefined }) });
|
|
164
|
+
const session = new SessionStore({ systemFolders: [...(context.systemFolders ?? []), ...(context.home === undefined ? [] : [join(context.home, "systems")])], watchFolder: () => ({ close: () => undefined }) });
|
|
165
165
|
const dashboard = await startDashboard({ ...context, files: session }, session, { ports: [0], page: context.folder });
|
|
166
166
|
if (dashboard === undefined) {
|
|
167
167
|
session.close();
|
package/instructions/play.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
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
|
-
- `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.
|
|
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
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.
|
|
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"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));\""
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
47
|
+
"node": ">=24"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"rpg",
|
|
@@ -73,24 +73,24 @@
|
|
|
73
73
|
"homepage": "https://github.com/stefanocaronia/rpg-engine#readme",
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
76
|
-
"@types/node": "^
|
|
77
|
-
"@types/three": "^0.
|
|
76
|
+
"@types/node": "^24.19.2",
|
|
77
|
+
"@types/three": "^0.187.0",
|
|
78
78
|
"@typescript-eslint/parser": "^8.71.0",
|
|
79
79
|
"betasim": "git+https://github.com/stefanocaronia/betasim.git",
|
|
80
|
-
"dprint": "^0.
|
|
80
|
+
"dprint": "^0.64.3",
|
|
81
81
|
"eslint": "^10.11.0",
|
|
82
82
|
"fast-check": "^4.10.2",
|
|
83
|
-
"playwright-core": "~1.
|
|
83
|
+
"playwright-core": "~1.64.1",
|
|
84
84
|
"typescript": "^6.0.3",
|
|
85
|
-
"vitest": "^5.0.
|
|
85
|
+
"vitest": "^5.0.5"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@dimforge/rapier3d-compat": "^0.
|
|
89
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
88
|
+
"@dimforge/rapier3d-compat": "^0.21.0",
|
|
89
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
90
90
|
"fflate": "^0.8.2",
|
|
91
|
-
"preact": "^
|
|
92
|
-
"three": "^0.
|
|
93
|
-
"unpdf": "1.
|
|
91
|
+
"preact": "^11.2.0",
|
|
92
|
+
"three": "^0.187.0",
|
|
93
|
+
"unpdf": "2.1.0",
|
|
94
94
|
"yaml": "^2.9.1",
|
|
95
95
|
"zod": "^4.6.5"
|
|
96
96
|
}
|