Skip to content

RPG R3: rule-system packs, the dungeon-crawl pack, New game command - #71

Merged
luoxin9510 merged 7 commits into
mainfrom
rpg-r3-packs
Nov 10, 2026
Merged

luoxin9510 merged 7 commits into
mainfrom
rpg-r3-packs

Conversation

@luoxin9510

Copy link
Copy Markdown
Owner

RPG R3 (docs/rpg-engine-prd.md §5): rule-system packs, the first pack, and a "New game" command.

Packs

  • game.md names a pack with system: <folder> or system: { path, version }. src/game/system.ts layers the pack's system.md under the game's frontmatter: lists keyed by id are joined and the game's entry wins; anything else the game sets replaces the pack's. The pack's from: and image paths are moved so they are relative to the game.
  • A missing pack, or one whose major version differs from the game's, is reported as a problem (systemMissing / systemVersion).
  • The generated engine INCLUDEs the pack's rules.ink. Pack files are dependencies, so editing a pack marks the engine stale.
  • Markdown tables take spawn / count columns. check-ink skips the ink in a pack's own folder; its template/ is still checked.
  • loadGameNote reads the note from the file rather than the metadata cache, which lags behind a note that was just written.

Dungeon crawl (packs/dungeon-crawl, original rules)

  • A crew of four goes down room by room. Fights are 2d6; there are torches, potions, traps and shrines, and a warlord waits in the last room.
  • The story calls -> crawl -> and then reads crawl_result (won / left / fallen).
  • The pack has a playable template/ and a 说明.md. A test keeps the template's engine current and plays it to an ending in both languages.
  • Balance: a fixed-strategy bot (always strike, drink a potion at life ≤ 2) wins 68% of 500 runs.

New game

  • The packs are bundled into main.js (virtual:packs). The command "New game" opens a picker (the journal template or a pack), then asks for a folder.
  • It installs the pack into 规则包/<id> unless a copy is already there, copies the pack's template into the new folder with system: rewritten, and generates the engine. The API call is api.newGame(pack, folder?).

Verified in Obsidian

  • Made a game with the command; the panel shows the four crew cards with no diagnostics.
  • Editing the pack flags the engine as stale; reverting the edit clears the warning.
  • Vault tutorial 10.3 (using a pack) and its example (10.3 示例, a crew of three overriding the pack) were added. The example passes check-ink --random in zh and en and gen-engine --check.
  • Test folders were trashed and the tabs I opened were closed.

Tests: 580 pass; lint is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B

luoxin9510 and others added 6 commits November 10, 2026 16:47
A game note names a pack with system: path (or { path, version }). The
pack's system.md frontmatter goes under the game's: lists keyed by id are
joined (the game's entry wins), anything else the game sets replaces the
pack's; the pack's from: paths and pictures move to be relative to the
game. A missing pack or another major version is a problem. When the pack
has a rules.ink, the generated engine INCLUDEs it by a relative path.

- src/game/system.ts (systemRef, layerSystem, withSystem, joinPath), used
  by the disk loader and the vault loader (loadGameNote; the pack's note
  is a dependency).
- normalizePath keeps a leading .. instead of dropping it, so a pack
  outside the folder being checked is read, and a bad path fails loudly.
- Note tables take spawn/count columns; rows read from notes are checked.
- check-ink skips the ink of a pack folder (INCLUDEd by games).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
packs/dungeon-crawl: system.md (2d6, a crew of four, the foe kind with eight
templates, room and monster tables, torches/potions/gold), rules.ink (the
crawl tunnel: rooms, traps, shrines, fights with one hero striking per round,
potions, fleeing, the warlord in the last room), a playable template game and
说明.md. A test keeps the template's engine current and plays it in both
languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
…me/description

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
The packs are bundled (virtual:packs, scripts/packs-bundle.mjs). The pure
src/templates/packs.ts lists them (packList, the pack's name and description
from system.md's pack:) and plans the files (packGame: the pack into
规则包/<id> / Rule packs/<id>, the template into the new folder, system:
rewritten as the way from the game to the pack). main.ts: createGame (shared
with the journal template; the engine generated from the note as written,
its pack layered under it; folders made trashed on a failure), command
new-game with a picker, api.newGame(pack, folder?).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
The metadata cache lags behind a note just written, so generating the engine
right after making or editing game.md read no frontmatter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
@claude

claude Bot commented Nov 10, 2026

Copy link
Copy Markdown

Review: I read the diff and found no blocking bugs, but I did not run npm test or npm run lint. The Node-free src/ rule, T() zh/en coverage, the system.ts and packs.ts tests, and the use of vault.create/trashFile all look fine.

Two minor points, neither blocking:

  • main.ts newGame decides whether a pack is installed by checking <packsFolder>/<id>/system.md, and T().packsFolder follows the UI language. If the user switches language, a second copy lands in the other folder. If the folder exists but system.md is gone, vault.create throws on the other pack files and the whole game is trashed.
  • normalizePath in compile/paths.ts now keeps a leading ... That is intended, but no test covers the INCLUDE ../../规则包/x/rules.ink path from a game folder in the vault compile path. tests/system.test.ts covers the disk path.

I would merge as is.

…ths above the game

Review follow-ups: newGame looks for the pack under 规则包/ and Rule packs/,
writes only the pack files that are missing, and a test covers resolving a
pack's rules.ink from a game folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vdVgYTb9jm7MRdePSgs8B
@claude

claude Bot commented Nov 10, 2026

Copy link
Copy Markdown

Review: I found no blocking bugs, so I would merge as is.

I read system.ts and the main.ts new-game changes in full. I did not read the rest of the diff, such as the pack ink, the template or the tests. I did not run npm test or npm run lint.

  • The new strings go through T() with zh and en.
  • I found no Node or Electron APIs, no innerHTML and no default hotkeys.
  • On failure, createGame trashes the topmost folders it made.

Two minor edge cases, neither blocking:

  • newGame treats a pack as installed when <packs folder>/<id>/system.md exists. If that folder exists without system.md, vault.create throws on any pack file already there and the whole new game is rolled back.
  • withSystem builds ${dir}${ref.path} without normalising a system: value that starts with /, so a leading slash is read as a vault-relative path under the game folder.

@luoxin9510
luoxin9510 merged commit dee2d83 into main Nov 10, 2026
2 checks passed
@luoxin9510
luoxin9510 deleted the rpg-r3-packs branch November 10, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant