[PR #6682] [MERGED] feat(game): sheet values that read play, list sums, caps and wider hide rules #7284

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-sheet-reads


📝 Commits (4)

  • a528fca feat(game): sheet values that read play, list sums, caps and wider hide rules
  • 590331d fix(game): a scaled column cannot add itself up; say a live limit as a number
  • 6f7c093 fix(game): a scaled column reads no list sum
  • 1996900 fix(game): a notEquals or in value must fit its field's range and length

📊 Changes

30 files changed (+3321 additions, -234 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+41 -0)
📝 docs/examples/rulesets/ember-roads.json (+31 -13)
📝 docs/examples/rulesets/gravewatch.json (+34 -2)
📝 docs/extending/ruleset.schema.json (+2011 -135)
📝 docs/extending/writing-rulesets.md (+12 -4)
📝 docs/game/party-and-npcs.md (+2 -0)
📝 packages/client/src/components/game/GameRulesetSheet.tsx (+3 -1)
📝 packages/client/src/components/rulesets/RulesetSheetEditor.tsx (+6 -2)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+41 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+13 -0)
📝 packages/server/src/services/game/skill-check-resolution.service.ts (+6 -4)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+4 -2)
📝 packages/shared/src/features/rulesets/live-state.ts (+13 -0)
📝 packages/shared/src/features/rulesets/sheet-math.ts (+121 -15)
📝 packages/shared/src/features/rulesets/sheet-prompt.ts (+1 -1)
📝 packages/shared/src/schemas/capability-package.schema.ts (+7 -1)
📝 packages/shared/src/schemas/ruleset.schema.ts (+261 -31)
📝 scripts/generate-ruleset-schema.mjs (+25 -0)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+4 -4)

...and 10 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

Closes #6653

Why this change

The author of Marinara-RPG-Extension wrote two of their shipped tabletop systems as ruleset.json files. A sheet's calculated values could only read the build, so three kinds of everyday rule ended up as hand-typed fields that drift the moment play moves on:

  • Nothing read the live state. A rating capped by another one the character is losing, a number that depends on a resource pool, a wound penalty that also comes off something else, a slower walk while exhausted: none could be said.
  • Nothing added up a list. Armour soak, weight carried and bonuses from equipped gear were typed in beside the list they repeat.
  • hideWhen took one value. A file with three or more kinds of character could not say "hide unless the kind is this one".

This is slice 3 of the series in the plan doc (§ Gaps a ruleset author found). Slices 1 and 2 were #6663 and #6669.

What changed

Capability API 1.39 (file keys: liveTrack with read, livePool and listSum in any value reference, cap on skills and saves, and notEquals / in on hideWhen). None of it names one game's words.

  • Values that read play. A value reference may read a live track, { "liveTrack": "harm", "read": "remaining" } (value, filled, remaining, or on a wound track penalty), or what is left in a pool, { "livePool": "resolve" }. A hidden one reads 0. They read the live state as it stands when a check is rolled, a fight begins or the Game Master's sheet block is written, and where there is none (the sheet editor, an import review) the state play starts in. Named differently from the issue on purpose: the issue proposed { "track": … } and { "pool": … }, but the combat block already uses exactly those shapes for its health and energy, so the install gate and every reader would have had to guess which was meant. "live" also says why a maximum cannot use one.
  • Where they cannot go. Nothing worked out before there is a live state may read one: a pool's or track's maximum, the proficiency bonus, a catalog's scaled column or scaling. That is checked through derived values (one pass, since a derived value only reads the ones above it) and through a skill a live value caps, and the import names the value that does.
  • Caps. A skill or save may carry cap, the most its check may come to. The sheet shows and every check rolls the capped number, and a with= swap is worked out on the number before the cap and capped again. A cap reads no skill or save, nor does any derived value up to the one it reads (the proficiency bonus's existing rule), so the sheet is still worked out in one pass.
  • List sums. { "listSum": { "list": "gear", "column": "bulk", "onlyWhen": "packed" } } adds a number column over the rows a boolean column marks. An empty cell is its column's default and a hidden list adds nothing. It reads only the build, so even a maximum may use it.
  • Wider hide rules. hideWhen takes exactly one of equals, notEquals or in, each value checked against the field one at a time, and a layer cannot remove any value one of them compares with. A rule now reads the value the sheet editor shows: an unset field is the value a blank sheet starts with (an enum's first value, an unticked box), and an enum value the ruleset no longer offers is the field's default. This changes an edge case for existing files on purpose: before, an unset field without a default matched nothing, while the editor showed it holding its first value.
  • One evaluator, two entry points. evaluateRulesetSheet(definition, build, live?) takes the resolved live state, and the new evaluateRulesetSheetLive(definition, build, stored?) resolves it first. The check context, the Game Master's sheet block, the game's sheet screen, a fight's combatants and the sheet editor all use the live one. The evaluated sheet carries the live values it was worked out with, so a modifier off the sheet (adjust), a spend's limit and a fight's defense read the same snapshot.
  • Reminder: a spend's limit read off the live state or a list is described in words ("as many times per check as the Resolve left").
  • Install gate: every new key needs 1.39, in the ruleset or a catalog file. The new keys are camelCase, which no sheet id can be, so the whole document is walked for them; cap is read only on skills and saves.
  • Docs: author guide (docs/extending/writing-rulesets.md), player page (docs/game/party-and-npcs.md), the regenerated JSON Schema (with the one-comparison rule for hideWhen and read kept beside liveTrack), the plan doc's slice 3 notes, CHANGELOG. Ember Roads' Burden is now the bulk of the gear a character has packed, with a step table turning it into the Brawn modifier slice 2 added (the typed-in burden field is gone). Gravewatch caps Soothe at the Resolve left, shows "Harm still to take" off the live track, and keeps lantern oil to the night watch with notEquals.

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

Run by the agent on a528fca04 (this branch's one commit on staging 54897c221), all exit 0: pnpm check, pnpm localization:check, pnpm regression:node (379/379), pnpm ruleset:schema (no diff after regeneration), pnpm smoke:ui (7/7), and pnpm regression:ui e2e/ruleset-wound-sheet.e2e.ts e2e/game-combat-director.e2e.ts --project=desktop-chromium --workers=1 (6/6: the game sheet on Gravewatch in light and dark, and the ruleset fights on Ember Roads). Mobile projects were not run locally, since no layout changed. Local CodeRabbit, three passes: two findings, both fixed (the in-game sheet editor showed live values at their starting point instead of as they stand; a hide rule compared the raw stored value rather than the one the editor shows, which notEquals would have made visible for an unset field), and the third pass found nothing.

  • New lane scripts/regressions/game-ruleset-sheet-reads.regression.ts covers every import refusal, every live read at its defaults and in play, caps with and without a swap, list sums, the three hide comparisons, the check context, a fight's combatant, the reminder and the 1.39 gate (a catalog file included). Forty deliberate breaks of the new code were each caught.
  • Existing lanes that test an older gate on the shipped examples now also strip the 1.39 keys, the JSON Schema lane pins the new refinements, and the slice 2 lane now loads real gear for Ember Roads' Burden.

Still to verify by hand (not done by the agent):

  • In a Game Mode game on Gravewatch, open the ruleset sheet: confirm "Harm still to take" reads 4, mark two knocks on Harm and confirm it reads 2.
  • On the same sheet, spend Resolve down to 1 and confirm Soothe drops to 1 die; then have the Game Master roll [skill_check: skill="Soothe" dc="1"] and confirm the dice card throws one die (plus any a 10 rolls again).
  • Set the warden's Watch to Dusk in the sheet editor and confirm Lantern oil disappears; set it back to Night and confirm it returns.
  • In a game on Ember Roads, add two pieces of gear with Bulk 3 (one unpacked), and confirm Burden reads 3 and "Burden on Brawn rolls" reads -1, in light and dark mode and at mobile width.
  • Open the sheet editor on a Gravewatch character card (no game): confirm "Harm still to take" shows 4 and Soothe is capped at the starting Resolve.
  • In the Gravewatch game above, with two knocks marked, click Edit sheet: confirm the editor also shows "Harm still to take" as 2, not 4.

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: docs/extending/writing-rulesets.md (not carried by docs-i18n), docs/game/party-and-npcs.md (carried by docs-i18n), docs/extending/ruleset.schema.json, docs/examples/rulesets/gravewatch.json, docs/examples/rulesets/ember-roads.json, docs/development/game-rulesets-and-sheets-implementation.md (internal plan), CHANGELOG.md. Translations are batched into one later pass by the maintainer's standing decision, so no per-PR [docs-i18n] issue is opened here.

UI evidence (if applicable)

None captured. No component changed shape: the sheet screen and the sheet editor show the same values they always did, now worked out with the live state (or its starting point), and a hidden field disappears exactly as before. See the manual steps above.

Summary by CodeRabbit

  • New Features
    • Ruleset sheets can derive values from live pools and tracks, sum numeric list columns, and cap skill or save values.
    • Sheet items can be shown or hidden using equality, inequality, or multiple-value conditions.
    • Live-derived values inform checks, combat statistics, and game-master reminders. Capability API 1.39 supports these ruleset features.
  • Documentation
    • Updated ruleset guidance and examples to demonstrate live values, caps, conditional visibility, and gear-based burden calculations.

🔄 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/6682 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/25/2026 **Status:** ✅ Merged **Merged:** 9/25/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-sheet-reads` --- ### 📝 Commits (4) - [`a528fca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a528fca04b93656b6f8abf9f9a9ae1a61dd58b0a) feat(game): sheet values that read play, list sums, caps and wider hide rules - [`590331d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/590331dcd5a7b391b16af21138ae6fd1e8755b13) fix(game): a scaled column cannot add itself up; say a live limit as a number - [`6f7c093`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6f7c0934c2001c4973db57d1883cd828673aae88) fix(game): a scaled column reads no list sum - [`1996900`](https://github.com/Pasta-Devs/Marinara-Engine/commit/199690028f71c8dcace423cacd3e1c4ba530af8d) fix(game): a notEquals or in value must fit its field's range and length ### 📊 Changes **30 files changed** (+3321 additions, -234 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+41 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+31 -13) 📝 `docs/examples/rulesets/gravewatch.json` (+34 -2) 📝 `docs/extending/ruleset.schema.json` (+2011 -135) 📝 `docs/extending/writing-rulesets.md` (+12 -4) 📝 `docs/game/party-and-npcs.md` (+2 -0) 📝 `packages/client/src/components/game/GameRulesetSheet.tsx` (+3 -1) 📝 `packages/client/src/components/rulesets/RulesetSheetEditor.tsx` (+6 -2) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+41 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+13 -0) 📝 `packages/server/src/services/game/skill-check-resolution.service.ts` (+6 -4) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+4 -2) 📝 `packages/shared/src/features/rulesets/live-state.ts` (+13 -0) 📝 `packages/shared/src/features/rulesets/sheet-math.ts` (+121 -15) 📝 `packages/shared/src/features/rulesets/sheet-prompt.ts` (+1 -1) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+7 -1) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+261 -31) 📝 `scripts/generate-ruleset-schema.mjs` (+25 -0) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+4 -4) _...and 10 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 Closes #6653 ## Why this change The author of [Marinara-RPG-Extension](https://github.com/Kenhito/Marinara-RPG-Extension) wrote two of their shipped tabletop systems as `ruleset.json` files. A sheet's calculated values could only read the build, so three kinds of everyday rule ended up as hand-typed fields that drift the moment play moves on: - **Nothing read the live state.** A rating capped by another one the character is losing, a number that depends on a resource pool, a wound penalty that also comes off something else, a slower walk while exhausted: none could be said. - **Nothing added up a list.** Armour soak, weight carried and bonuses from equipped gear were typed in beside the list they repeat. - **`hideWhen` took one value.** A file with three or more kinds of character could not say "hide unless the kind is this one". This is slice 3 of the series in the plan doc (§ Gaps a ruleset author found). Slices 1 and 2 were #6663 and #6669. ## What changed Capability API **1.39** (file keys: `liveTrack` with `read`, `livePool` and `listSum` in any value reference, `cap` on skills and saves, and `notEquals` / `in` on `hideWhen`). None of it names one game's words. - **Values that read play.** A value reference may read a live track, `{ "liveTrack": "harm", "read": "remaining" }` (`value`, `filled`, `remaining`, or on a wound track `penalty`), or what is left in a pool, `{ "livePool": "resolve" }`. A hidden one reads 0. They read the live state as it stands when a check is rolled, a fight begins or the Game Master's sheet block is written, and where there is none (the sheet editor, an import review) the state play starts in. **Named differently from the issue on purpose:** the issue proposed `{ "track": … }` and `{ "pool": … }`, but the combat block already uses exactly those shapes for its health and energy, so the install gate and every reader would have had to guess which was meant. "live" also says why a maximum cannot use one. - **Where they cannot go.** Nothing worked out before there is a live state may read one: a pool's or track's maximum, the proficiency bonus, a catalog's scaled column or scaling. That is checked through derived values (one pass, since a derived value only reads the ones above it) and through a skill a live value caps, and the import names the value that does. - **Caps.** A skill or save may carry `cap`, the most its check may come to. The sheet shows and every check rolls the capped number, and a `with=` swap is worked out on the number before the cap and capped again. A cap reads no skill or save, nor does any derived value up to the one it reads (the proficiency bonus's existing rule), so the sheet is still worked out in one pass. - **List sums.** `{ "listSum": { "list": "gear", "column": "bulk", "onlyWhen": "packed" } }` adds a number column over the rows a boolean column marks. An empty cell is its column's default and a hidden list adds nothing. It reads only the build, so even a maximum may use it. - **Wider hide rules.** `hideWhen` takes exactly one of `equals`, `notEquals` or `in`, each value checked against the field one at a time, and a layer cannot remove any value one of them compares with. A rule now reads the value the sheet editor shows: an unset field is the value a blank sheet starts with (an enum's first value, an unticked box), and an enum value the ruleset no longer offers is the field's default. **This changes an edge case for existing files on purpose:** before, an unset field without a default matched nothing, while the editor showed it holding its first value. - **One evaluator, two entry points.** `evaluateRulesetSheet(definition, build, live?)` takes the resolved live state, and the new `evaluateRulesetSheetLive(definition, build, stored?)` resolves it first. The check context, the Game Master's sheet block, the game's sheet screen, a fight's combatants and the sheet editor all use the live one. The evaluated sheet carries the live values it was worked out with, so a modifier off the sheet (`adjust`), a spend's limit and a fight's defense read the same snapshot. - **Reminder:** a spend's limit read off the live state or a list is described in words ("as many times per check as the Resolve left"). - **Install gate:** every new key needs 1.39, in the ruleset or a catalog file. The new keys are camelCase, which no sheet id can be, so the whole document is walked for them; `cap` is read only on skills and saves. - **Docs:** author guide (`docs/extending/writing-rulesets.md`), player page (`docs/game/party-and-npcs.md`), the regenerated JSON Schema (with the one-comparison rule for `hideWhen` and `read` kept beside `liveTrack`), the plan doc's slice 3 notes, CHANGELOG. **Ember Roads**' Burden is now the bulk of the gear a character has packed, with a step table turning it into the Brawn modifier slice 2 added (the typed-in `burden` field is gone). **Gravewatch** caps Soothe at the Resolve left, shows "Harm still to take" off the live track, and keeps lantern oil to the night watch with `notEquals`. ## 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 Run by the agent on a528fca04 (this branch's one commit on staging 54897c221), all exit 0: `pnpm check`, `pnpm localization:check`, `pnpm regression:node` (379/379), `pnpm ruleset:schema` (no diff after regeneration), `pnpm smoke:ui` (7/7), and `pnpm regression:ui e2e/ruleset-wound-sheet.e2e.ts e2e/game-combat-director.e2e.ts --project=desktop-chromium --workers=1` (6/6: the game sheet on Gravewatch in light and dark, and the ruleset fights on Ember Roads). Mobile projects were not run locally, since no layout changed. Local CodeRabbit, three passes: two findings, both fixed (the in-game sheet editor showed live values at their starting point instead of as they stand; a hide rule compared the raw stored value rather than the one the editor shows, which `notEquals` would have made visible for an unset field), and the third pass found nothing. - New lane `scripts/regressions/game-ruleset-sheet-reads.regression.ts` covers every import refusal, every live read at its defaults and in play, caps with and without a swap, list sums, the three hide comparisons, the check context, a fight's combatant, the reminder and the 1.39 gate (a catalog file included). Forty deliberate breaks of the new code were each caught. - Existing lanes that test an older gate on the shipped examples now also strip the 1.39 keys, the JSON Schema lane pins the new refinements, and the slice 2 lane now loads real gear for Ember Roads' Burden. Still to verify by hand (not done by the agent): - In a Game Mode game on Gravewatch, open the ruleset sheet: confirm "Harm still to take" reads 4, mark two knocks on Harm and confirm it reads 2. - On the same sheet, spend Resolve down to 1 and confirm Soothe drops to 1 die; then have the Game Master roll `[skill_check: skill="Soothe" dc="1"]` and confirm the dice card throws one die (plus any a 10 rolls again). - Set the warden's Watch to Dusk in the sheet editor and confirm Lantern oil disappears; set it back to Night and confirm it returns. - In a game on Ember Roads, add two pieces of gear with Bulk 3 (one unpacked), and confirm Burden reads 3 and "Burden on Brawn rolls" reads -1, in light and dark mode and at mobile width. - Open the sheet editor on a Gravewatch character card (no game): confirm "Harm still to take" shows 4 and Soothe is capped at the starting Resolve. - In the Gravewatch game above, with two knocks marked, click **Edit sheet**: confirm the editor also shows "Harm still to take" as 2, not 4. ## 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: `docs/extending/writing-rulesets.md` (not carried by `docs-i18n`), `docs/game/party-and-npcs.md` (carried by `docs-i18n`), `docs/extending/ruleset.schema.json`, `docs/examples/rulesets/gravewatch.json`, `docs/examples/rulesets/ember-roads.json`, `docs/development/game-rulesets-and-sheets-implementation.md` (internal plan), `CHANGELOG.md`. Translations are batched into one later pass by the maintainer's standing decision, so no per-PR `[docs-i18n]` issue is opened here. ## UI evidence (if applicable) None captured. No component changed shape: the sheet screen and the sheet editor show the same values they always did, now worked out with the live state (or its starting point), and a hidden field disappears exactly as before. See the manual steps above. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Ruleset sheets can derive values from live pools and tracks, sum numeric list columns, and cap skill or save values. * Sheet items can be shown or hidden using equality, inequality, or multiple-value conditions. * Live-derived values inform checks, combat statistics, and game-master reminders. Capability API 1.39 supports these ruleset features. * **Documentation** * Updated ruleset guidance and examples to demonstrate live values, caps, conditional visibility, and gear-based burden calculations. <!-- 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:18:15 +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#7284
No description provided.