[PR #6362] [MERGED] feat(game): ruleset catalogs keep scaled values, offer newer text, and the Game Master can use an ability by name #7148

Closed
opened 2026-10-23 04:16:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6362
Author: @kolacheee
Created: 9/19/2026
Status: ✅ Merged
Merged: 9/19/2026
Merged by: @kolacheee

Base: staging ← Head: feat/rulesets-8c


📝 Commits (10+)

  • 27ea2c9 feat(game): catalog entry rows can scale a number column from the sheet
  • f72f51f feat(game): the sheet command can use a catalog entry and pay what it costs
  • 44e7cd5 test(game): pin scaled rows, the use command and the 1.23 install gate
  • 016b439 docs(game): scaled catalog values, the use command and Capability API 1.23
  • c7b4307 feat(game): the sheet editor keeps the ruleset's own cells and offers newer catalog text
  • 9ebeefb test(game): pin what a catalog refresh offers and what applying it writes
  • 5749f7e docs(game): refresh from ruleset and the cells a ruleset keeps
  • 807c421 refactor(game): name the patched build in the sheet editor's commit
  • 7bc5f06 fix(game): refuse using a catalog entry whose own counter has no uses
  • f11fd04 fix(game): address the first local review of slice 8c

📊 Changes

37 files changed (+2517 additions, -133 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/characters/colors-and-stats.md (+5 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+22 -5)
📝 docs/development/optional-agent-packages.md (+29 -0)
📝 docs/examples/rulesets/ember-roads.json (+8 -3)
📝 docs/extending/ruleset.schema.json (+92 -0)
📝 docs/extending/writing-rulesets.md (+89 -1)
📝 docs/game/party-and-npcs.md (+5 -1)
📝 packages/client/src/components/game/GameRulesetSheet.tsx (+3 -0)
➕ packages/client/src/components/rulesets/RulesetCatalogRefreshModal.tsx (+116 -0)
📝 packages/client/src/components/rulesets/RulesetSheetEditor.tsx (+187 -17)
📝 packages/client/src/components/ui/DraftNumberInput.tsx (+3 -0)
📝 packages/client/src/lib/ruleset-catalog.ts (+165 -4)
📝 packages/client/src/localization/locales/en.json (+16 -0)
📝 packages/server/src/routes/capability-packages.routes.ts (+10 -32)
📝 packages/server/src/routes/generate.routes.ts (+2 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+42 -5)
📝 packages/server/src/services/game/gm-prompts.ts (+7 -0)
➕ packages/server/src/services/game/ruleset-catalog.service.ts (+85 -0)
📝 packages/server/src/services/game/ruleset-sheet-turn.service.ts (+55 -1)

...and 17 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Part of #6314 (slice 8c of the ruleset plan; it does not close the issue). Builds on #6345 (catalogs) and #6348 (the combat bridge), both merged.

Why this change

  • Rows a player picks from a ruleset's catalog are copies, and three things about them were still done by hand. A class resource that grows with the character (Ki points equal to the level, Rage uses from a table, a trick's uses equal to an ability score) kept the number it was picked with. When a ruleset author corrected the text of an entry, sheets that already held it never heard about it. And the Game Master had to know what an ability costs and what the pool is called to write a spend for it.
  • The plan reserved these as slice 8c: level-scaled maximums, Refresh from ruleset, and the cast helper. None of them is 5e-shaped: every rule is proven on the 2d6 Ember Roads example as well as on the 5e one.

What changed

  • Scaled row values. A catalog entry row may carry scaled: { "<number column>": { from: <value reference>, table?: <step table> } }. Without a table the column takes the referenced value, with one the value is looked up, and anything fancier is a derived value the ruleset already knows how to declare, so no new math vocabulary is added. It is checked like every other reference (a number column of the row's list, a valid reference, and the row must be the entry's only row for its list so a picked row maps to it without guessing).
  • On edit, never on read. The sheet editor recomputes those cells inside its one change path and shows them read-only with the hint "Set by the ruleset". Live state, the prompt block, the battle bridge and the server keep reading the stored number. A sheet that is only opened is never rewritten; if the catalogs arrive after the user has already edited, one recompute runs then. The editor loads only the catalogs the sheet's own picked rows name, through the query the picker and the battle prefetch already share.
  • Refresh from ruleset. When a picked row's text differs from the entry it came from, the list shows one line ("2 rows have newer text in the ruleset") with a Review button. The review lists each row with the sheet's text beside the ruleset's, a checkbox per row, and Update selected writes only the differing columns in one change. Only text-like columns are compared (text, longtext, dice, enum): booleans and numbers are where a player's own state lives (prepared, proficient, a magic weapon's bonus), and there is no stored base to merge against. Nothing is shown when nothing differs.
  • The use command (the plan's cast helper, kept system-neutral): [sheet: who="Name" op="use" name="Fireball"], with op="cast" and spell= accepted as aliases. It finds the picked row by the name the Game Master was shown, pays every mechanics.cost term (a term naming a pool group pays from the first pool of the group that can afford it), plus one from each counter row the same entry wrote (Rage, a trick's uses). pool= is the upcast: the same single price from another pool of the same group. There is no automatic climb to a higher pool, because a group is not always a ladder. All or nothing; an entry with no cost is accepted and changes nothing; a counter scaled down to 0 uses is refused rather than used for free. New refusal reasons unknown-entry, ambiguous-entry, bad-pool, with their phrases.
  • Server. A turn reads catalog files only when the reply carries a use command, and only the catalogs the party's rows point at. The "read and check one catalog" part of the catalog route moved into a small service both callers share; the route's status codes, ETag and 304 behaviour are unchanged and still pinned. The Game Master prompt lists use only when the ruleset declares catalogs.
  • Capability API 1.23 gates scaled for packages, for inline catalogs and for catalog files (the install path already holds the verified bytes of every declared asset, so it looks inside them).
  • Docs: the authoring guide (scaled values, what Refresh compares, the use command), docs/game/party-and-npcs.md, docs/characters/colors-and-stats.md, docs/development/optional-agent-packages.md, the plan (what slice 8c settled), the generated schema, and Ember Roads gains a scaled trick (uses follow Heart).
  • Regressions: game-ruleset-scaled-rows (new), use cases in game-ruleset-live, the 1.23 install gate, the catalogs regression for the moved service, and the client lane ruleset-catalog-refresh (new).

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Commands run locally by the agent: pnpm check (exit 0), pnpm localization:check, the full node regression lane (pnpm regression:node, 319 of 319), and the new regressions. Six complete local CodeRabbit sweeps were run before opening (4, 2, 2, 2, 2 and 0 findings). Every finding was fixed except one, declined: an in-process cache of parsed catalogs in the new catalog service. A catalog file is read only on a turn whose reply carries a use command, and the route already answers 304 before it parses anything, so a cache would add invalidation rules for very little. The e2e suite was checked by reading it: no spec mentions a ruleset, mocks the ruleset routes or drives the sheet editor, and the new button texts match no existing locator. Playwright was not run locally.

The agent drove a scratch server on port 7820 with a fresh data folder: imported the Ember Roads example, and opened a character whose sheet held a picked Last Ember with old text and an out-of-date uses value. Opening the sheet changed nothing (uses stayed as stored). The Uses cell was disabled with the hint. Changing Heart from 2 to 3 set the trick's uses to 3. The Knacks list showed "1 row has newer text in the ruleset.", the review listed the old and the new text with its checkbox ticked, Update selected restored the ruleset's text and the notice went away, and saving the character kept both catalog marks.

Still to verify by hand:

  • Manually play a turn with a real model where the Game Master writes a use command (a slot spell, an upcast with pool=, and a feature with its own counter), and confirm the sheet and the refusal phrases.
  • Manually check the same editor behaviour from the in-game Edit sheet, saved through its own Save.
  • Manually verify the review window and the locked cell in light mode and at a phone-width viewport.
  • Manually confirm a ruleset without catalogs, and a sheet with no picked rows, behave exactly as before (no catalog request is made).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs touched: CHANGELOG.md, docs/extending/writing-rulesets.md, docs/game/party-and-npcs.md, docs/characters/colors-and-stats.md, docs/development/optional-agent-packages.md, the plan, the Ember Roads example and the generated schema. The [docs-i18n] follow-up is batched for the ruleset slices.

UI evidence (if applicable)

To be added by a human: the locked cell with its hint, the refresh notice, and the review window.

Summary by CodeRabbit

  • New Features

    • Character sheets can review and refresh outdated catalog text, updating only selected text while preserving player-entered values.
    • Rulesets can keep selected numeric values synchronized with abilities, fields, or level-based scaling.
    • Game Masters can use catalog abilities by name, including optional higher resource pools. Costs are handled atomically, so failed uses spend nothing.
    • Catalog-based rulesets now support Capability API 1.23.
  • Documentation

    • Updated user and ruleset-authoring guides with catalog refresh, scaled values, and ability-use behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6362 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/19/2026 **Status:** ✅ Merged **Merged:** 9/19/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/rulesets-8c` --- ### 📝 Commits (10+) - [`27ea2c9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/27ea2c9bb9a2cb3b9e92a311e0c9d8b5544430eb) feat(game): catalog entry rows can scale a number column from the sheet - [`f72f51f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f72f51fa9a2f32b9089fe7068a2269de3fa15006) feat(game): the sheet command can use a catalog entry and pay what it costs - [`44e7cd5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/44e7cd57418f8738fa33f65e16d4f4a8e0298005) test(game): pin scaled rows, the use command and the 1.23 install gate - [`016b439`](https://github.com/Pasta-Devs/Marinara-Engine/commit/016b43996eab1070c4a47050d642e22f56e11998) docs(game): scaled catalog values, the use command and Capability API 1.23 - [`c7b4307`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c7b4307852a5a248fe51d176cd9dc88f55dc5a8b) feat(game): the sheet editor keeps the ruleset's own cells and offers newer catalog text - [`9ebeefb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9ebeefbac8d0f0c5516c6f54358eeb2d87c231c7) test(game): pin what a catalog refresh offers and what applying it writes - [`5749f7e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5749f7e2a9f5ef128a91dee30eadafed1694f3d0) docs(game): refresh from ruleset and the cells a ruleset keeps - [`807c421`](https://github.com/Pasta-Devs/Marinara-Engine/commit/807c421a4be441fca3d0d2d4c80dc827701fde03) refactor(game): name the patched build in the sheet editor's commit - [`7bc5f06`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7bc5f068ae6f0b6974c6f0b97792247a708fa618) fix(game): refuse using a catalog entry whose own counter has no uses - [`f11fd04`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f11fd04bd59080e2084e5cbe8a8a6f44bb50c54b) fix(game): address the first local review of slice 8c ### 📊 Changes **37 files changed** (+2517 additions, -133 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/characters/colors-and-stats.md` (+5 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+22 -5) 📝 `docs/development/optional-agent-packages.md` (+29 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+8 -3) 📝 `docs/extending/ruleset.schema.json` (+92 -0) 📝 `docs/extending/writing-rulesets.md` (+89 -1) 📝 `docs/game/party-and-npcs.md` (+5 -1) 📝 `packages/client/src/components/game/GameRulesetSheet.tsx` (+3 -0) ➕ `packages/client/src/components/rulesets/RulesetCatalogRefreshModal.tsx` (+116 -0) 📝 `packages/client/src/components/rulesets/RulesetSheetEditor.tsx` (+187 -17) 📝 `packages/client/src/components/ui/DraftNumberInput.tsx` (+3 -0) 📝 `packages/client/src/lib/ruleset-catalog.ts` (+165 -4) 📝 `packages/client/src/localization/locales/en.json` (+16 -0) 📝 `packages/server/src/routes/capability-packages.routes.ts` (+10 -32) 📝 `packages/server/src/routes/generate.routes.ts` (+2 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+42 -5) 📝 `packages/server/src/services/game/gm-prompts.ts` (+7 -0) ➕ `packages/server/src/services/game/ruleset-catalog.service.ts` (+85 -0) 📝 `packages/server/src/services/game/ruleset-sheet-turn.service.ts` (+55 -1) _...and 17 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Part of #6314 (slice 8c of the ruleset plan; it does not close the issue). Builds on #6345 (catalogs) and #6348 (the combat bridge), both merged. ## Why this change - Rows a player picks from a ruleset's catalog are copies, and three things about them were still done by hand. A class resource that grows with the character (Ki points equal to the level, Rage uses from a table, a trick's uses equal to an ability score) kept the number it was picked with. When a ruleset author corrected the text of an entry, sheets that already held it never heard about it. And the Game Master had to know what an ability costs and what the pool is called to write a spend for it. - The plan reserved these as slice 8c: level-scaled maximums, Refresh from ruleset, and the cast helper. None of them is 5e-shaped: every rule is proven on the 2d6 Ember Roads example as well as on the 5e one. ## What changed - **Scaled row values.** A catalog entry row may carry `scaled: { "<number column>": { from: <value reference>, table?: <step table> } }`. Without a table the column takes the referenced value, with one the value is looked up, and anything fancier is a `derived` value the ruleset already knows how to declare, so no new math vocabulary is added. It is checked like every other reference (a number column of the row's list, a valid reference, and the row must be the entry's only row for its list so a picked row maps to it without guessing). - **On edit, never on read.** The sheet editor recomputes those cells inside its one change path and shows them read-only with the hint "Set by the ruleset". Live state, the prompt block, the battle bridge and the server keep reading the stored number. A sheet that is only opened is never rewritten; if the catalogs arrive after the user has already edited, one recompute runs then. The editor loads only the catalogs the sheet's own picked rows name, through the query the picker and the battle prefetch already share. - **Refresh from ruleset.** When a picked row's text differs from the entry it came from, the list shows one line ("2 rows have newer text in the ruleset") with a **Review** button. The review lists each row with the sheet's text beside the ruleset's, a checkbox per row, and **Update selected** writes only the differing columns in one change. Only text-like columns are compared (`text`, `longtext`, `dice`, `enum`): booleans and numbers are where a player's own state lives (prepared, proficient, a magic weapon's bonus), and there is no stored base to merge against. Nothing is shown when nothing differs. - **The `use` command** (the plan's cast helper, kept system-neutral): `[sheet: who="Name" op="use" name="Fireball"]`, with `op="cast"` and `spell=` accepted as aliases. It finds the picked row by the name the Game Master was shown, pays every `mechanics.cost` term (a term naming a pool group pays from the first pool of the group that can afford it), plus one from each counter row the same entry wrote (Rage, a trick's uses). `pool=` is the upcast: the same single price from another pool of the same group. There is no automatic climb to a higher pool, because a group is not always a ladder. All or nothing; an entry with no cost is accepted and changes nothing; a counter scaled down to 0 uses is refused rather than used for free. New refusal reasons `unknown-entry`, `ambiguous-entry`, `bad-pool`, with their phrases. - **Server.** A turn reads catalog files only when the reply carries a `use` command, and only the catalogs the party's rows point at. The "read and check one catalog" part of the catalog route moved into a small service both callers share; the route's status codes, ETag and 304 behaviour are unchanged and still pinned. The Game Master prompt lists `use` only when the ruleset declares catalogs. - **Capability API 1.23** gates `scaled` for packages, for inline catalogs and for catalog files (the install path already holds the verified bytes of every declared asset, so it looks inside them). - Docs: the authoring guide (scaled values, what Refresh compares, the `use` command), `docs/game/party-and-npcs.md`, `docs/characters/colors-and-stats.md`, `docs/development/optional-agent-packages.md`, the plan (what slice 8c settled), the generated schema, and Ember Roads gains a scaled trick (uses follow Heart). - Regressions: `game-ruleset-scaled-rows` (new), `use` cases in `game-ruleset-live`, the 1.23 install gate, the catalogs regression for the moved service, and the client lane `ruleset-catalog-refresh` (new). ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Commands run locally by the agent: `pnpm check` (exit 0), `pnpm localization:check`, the full node regression lane (`pnpm regression:node`, 319 of 319), and the new regressions. Six complete local CodeRabbit sweeps were run before opening (4, 2, 2, 2, 2 and 0 findings). Every finding was fixed except one, declined: an in-process cache of parsed catalogs in the new catalog service. A catalog file is read only on a turn whose reply carries a `use` command, and the route already answers 304 before it parses anything, so a cache would add invalidation rules for very little. The e2e suite was checked by reading it: no spec mentions a ruleset, mocks the ruleset routes or drives the sheet editor, and the new button texts match no existing locator. Playwright was not run locally. The agent drove a scratch server on port 7820 with a fresh data folder: imported the Ember Roads example, and opened a character whose sheet held a picked Last Ember with old text and an out-of-date uses value. Opening the sheet changed nothing (uses stayed as stored). The Uses cell was disabled with the hint. Changing Heart from 2 to 3 set the trick's uses to 3. The Knacks list showed "1 row has newer text in the ruleset.", the review listed the old and the new text with its checkbox ticked, **Update selected** restored the ruleset's text and the notice went away, and saving the character kept both catalog marks. Still to verify by hand: - Manually play a turn with a real model where the Game Master writes a `use` command (a slot spell, an upcast with `pool=`, and a feature with its own counter), and confirm the sheet and the refusal phrases. - Manually check the same editor behaviour from the in-game **Edit sheet**, saved through its own Save. - Manually verify the review window and the locked cell in light mode and at a phone-width viewport. - Manually confirm a ruleset without catalogs, and a sheet with no picked rows, behave exactly as before (no catalog request is made). ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs touched: `CHANGELOG.md`, `docs/extending/writing-rulesets.md`, `docs/game/party-and-npcs.md`, `docs/characters/colors-and-stats.md`, `docs/development/optional-agent-packages.md`, the plan, the Ember Roads example and the generated schema. The `[docs-i18n]` follow-up is batched for the ruleset slices. ## UI evidence (if applicable) To be added by a human: the locked cell with its hint, the refresh notice, and the review window. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Character sheets can review and refresh outdated catalog text, updating only selected text while preserving player-entered values. - Rulesets can keep selected numeric values synchronized with abilities, fields, or level-based scaling. - Game Masters can use catalog abilities by name, including optional higher resource pools. Costs are handled atomically, so failed uses spend nothing. - Catalog-based rulesets now support Capability API 1.23. - **Documentation** - Updated user and ruleset-authoring guides with catalog refresh, scaled values, and ability-use behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:16:57 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7148
No description provided.