[PR #6706] [MERGED] feat(game): live states and the numbers that follow them; the combat picker walks round a wall #7294

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-live-states


📝 Commits (1)

  • 3854dd4 feat(game): live states and the numbers that follow them; the combat picker walks round a wall

📊 Changes

33 files changed (+1722 additions, -47 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+49 -4)
📝 docs/examples/rulesets/ember-roads.json (+25 -2)
📝 docs/examples/rulesets/gravewatch.json (+32 -2)
📝 docs/extending/ruleset.schema.json (+339 -1)
📝 docs/extending/writing-rulesets.md (+50 -5)
📝 docs/game/party-and-npcs.md (+3 -2)
➕ e2e/ruleset-live-states.e2e.ts (+97 -0)
📝 packages/client/src/components/game/GameRulesetSheet.tsx (+25 -0)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+22 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+14 -0)
📝 packages/server/src/services/game/ruleset-combat-director.service.ts (+7 -4)
📝 packages/shared/src/features/ruleset-combat/grid.ts (+50 -0)
📝 packages/shared/src/features/ruleset-combat/index.ts (+1 -0)
📝 packages/shared/src/features/rulesets/live-state.ts (+81 -1)
📝 packages/shared/src/features/rulesets/sheet-math.ts (+18 -5)
📝 packages/shared/src/features/rulesets/sheet-prompt.ts (+4 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+6 -1)
📝 packages/shared/src/schemas/ruleset.schema.ts (+130 -6)

...and 13 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 #6656
Closes #6678

Why this change

#6656. The author of Marinara-RPG-Extension wrote two of their shipped tabletop systems as ruleset.json files. An enum field is chosen when a character is made and no sheet command changes it, and a condition is only on or off. So a shapeshifter's form, a frenzy, a stance or how lit a lantern is could not be said: each is one value out of a closed set that changes in play, and numbers hang off it (one form adds to Strength). This is slice 6, the last of the series in the plan doc (§ Gaps a ruleset author found). Slices 1 to 5 were #6663, #6669, #6682, #6689 and #6704.

#6678, folded in on the maintainer's request. The browser case for a positioned Ember Roads fight sometimes ended without an outcome after 80 AI turns, on staging and on unrelated PRs. Replaying that fight in node across 2000 seeds showed it was a stall rather than a long fight. About one seed in seventy-five froze for good: the two fighters stood two squares apart with mountains and water between them. The AI's closing move only walked to a square that was closer in a straight line, and every such square was impassable, so neither ever moved, although a route round existed.

What changed

Capability API 1.42 (file keys: states in the live section, the enumTable derived op, and a rest step's state). None of it names one game's words.

  • Live states. sheet.live.states: up to twelve, each with two to forty values, optional valueLabels, a default (else the first value) and hideWhen. Values follow the rule every label follows and never hold a double quote, because the command quotes them. Stored sparse (only when away from the default); a stored value the state no longer offers reads as the default; a hidden state is not on the sheet.
  • The command. [sheet: who="Name" op="state" state="Form" value="Crinos"], naming the state by id or label and the value by itself or its label, refused with the new reasons unknown-state and unknown-value. The tag's state= names the state on this op and still means on or off on a condition. The Game Master's sheet block always says each state's value, its default included, because a form is a fact the narration needs every turn. The reminder adds the command and a States: line listing every value, only when the ruleset has a state. The game's sheet screen shows a picker per state. New strings are localized in en.json.
  • Numbers that follow. A derived value enumTable gives a number for each value of an enum field or a live state, with a default for the rest. Differs from the issue on purpose: the issue keyed it { "state": … }; it is { "liveState": … }, because every read of the live state is named live (liveTrack, livePool), which is how an author and the import tell what a maximum cannot use. A field's table is build-only and may feed a maximum. A state's table is a live read, refused wherever a live read is, directly or through another derived value. It reaches the dice through slice 2's adjust, limited to an ability. A layer may remove a field value a table has a row for; the row is just never read while the layer is on.
  • Rests. A restore step may name a state, with to set to "default" or one of its values. to on any other step is still "max", "min" or a number.
  • Install gate: each new key needs 1.42. Published schema: the generator now also says an enum table has exactly one source and one to forty rows, and that a word in a rest step's to belongs only to a state.
  • #6678, the combat picker. The closing move now measures "closer" by walking distance: rulesetWalkingDistances in the shared grid module, using the same steps, terrain costs and corner rule a walk pays. Reach and range stay straight-line, and on open ground the choice is the same as before. Across the same 2000 seeds every fight now ends, the longest in seven turns.
  • Docs: author guide (docs/extending/writing-rulesets.md, a new "Live states" section plus the sheet, modifiers, rests and Game Master text parts), player page (docs/game/party-and-npcs.md), the regenerated JSON Schema, the plan doc's slice 6 notes (and a correction to slice 5's, which still described the settled-ask guard as living in isEngineRollableSkillCheckTag), CHANGELOG. Ember Roads gains a Stance (Guarded, Steady, Reckless) that adds -1 or +2 to Brawn rolls and that making camp settles. Gravewatch gains a Light (Lit, Shuttered, Out) that costs one or two Nerve dice and that standing down from the vigil relights, plus a table on its watch field that gives a dawn warden one more Resolve. Both defaults read 0, so no existing number moves.

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 3854dd48e (this branch's one commit on staging d427f4a67), all exit 0: pnpm check, pnpm localization:check, pnpm version:check, pnpm regression:node (400/400), pnpm ruleset:schema (no diff after regeneration), pnpm smoke:ui (7/7), and pnpm regression:ui e2e/ruleset-live-states.e2e.ts e2e/ruleset-sheet-sections.e2e.ts e2e/ruleset-wound-sheet.e2e.ts e2e/game-combat-director.e2e.ts --project=desktop-chromium --workers=1 (11/11: the new state picker case in light and dark, the sections and wound sheets, and the ruleset fights, including the positioned Ember Roads case #6678 was about). Mobile projects were not run locally. Local CodeRabbit, two completed passes: two findings, both fixed (the published schema now says an enum table's one source and row count, and that a word in a rest step's to belongs only to a state); the second pass was clean.

  • New lane scripts/regressions/game-ruleset-live-states.regression.ts covers:

    • every import refusal, and a layer on a field a table keys on;
    • reading a state (default, stale, hidden) and the tables on both kinds of key;
    • adjust reaching a real check;
    • the command (by id, label and value label; sparse storage; both refusals; the tag round trip; a whole turn);
    • rests;
    • the sheet block and the reminder;
    • the stored blob's bounds and the 1.42 gate.

    Thirty-one deliberate breaks were each caught.

  • scripts/regressions/ruleset-combat-director.regression.ts gains a hand-drawn ridge between two fighters, with a route round to the south. It checks that no straight-line-closer square is reachable, then plays the fight to the end. Without the fix it still stands after 200 rounds.

  • New browser case e2e/ruleset-live-states.e2e.ts picks Reckless on the game's sheet in light and dark mode. It checks that exactly { states: { stance: "reckless" } } is stored, then that Make camp puts it back to Steady with nothing stored.

  • game-ruleset-json-schema pins the two new schema rules. Older-gate lanes strip the 1.42 keys, and the lifecycle lane follows the new version.

  • Not executed: validating the examples against the published JSON Schema with a real validator, because none is installed here. I checked by hand that every rest step and table in both examples satisfies the two new rules.

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

  • In a Game Mode game on Ember Roads, open the ruleset sheet: confirm Stance shows Steady, set it to Reckless, and confirm a Brawn check's dice card shows the +2. Then use Make camp and confirm Stance is back to Steady. Check light and dark mode and mobile width.
  • Have the Game Master write [sheet: op="state" state="Stance" value="Guarded"]: confirm the Stance picker follows. Then have it write value="Frantic" and confirm the refusal notice says that state has no such value.
  • On Gravewatch, set Light to Out and confirm a Listen check throws two fewer dice. Make a warden on the dawn watch and confirm their Resolve maximum is one higher.
  • Start a positioned Ember Roads fight on a board with impassable ground between the sides, hand both sides to the AI, and confirm they walk round and the fight ends.

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 [docs-i18n] issue after the last ruleset slice, by the maintainer's standing decision, so no per-PR issue is opened here.

UI evidence (if applicable)

None attached. The new browser case saves a full-page screenshot of the sheet with the Stance picker set to Reckless, in each theme. The manual steps above cover mobile width.

Summary by CodeRabbit

  • New Features
    • Added live ruleset states that can affect calculations, display in sheet selectors, and reset during rests.
    • Rulesets can derive numeric values from enum fields or live states.
    • Updated sample rulesets to demonstrate state-based modifiers and restoration.
  • Improvements
    • Engine-controlled fighters now route by reachable walking paths when obstacles block a direct route.
    • Untrained-check refusals retain their reason through later dice processing.
  • Compatibility
    • Capability API 1.42 supports live states, enum-derived values, and state-based rest restoration.

🔄 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/6706 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/26/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-live-states` --- ### 📝 Commits (1) - [`3854dd4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3854dd48ef333f38151c579c35043c69f0de5416) feat(game): live states and the numbers that follow them; the combat picker walks round a wall ### 📊 Changes **33 files changed** (+1722 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+49 -4) 📝 `docs/examples/rulesets/ember-roads.json` (+25 -2) 📝 `docs/examples/rulesets/gravewatch.json` (+32 -2) 📝 `docs/extending/ruleset.schema.json` (+339 -1) 📝 `docs/extending/writing-rulesets.md` (+50 -5) 📝 `docs/game/party-and-npcs.md` (+3 -2) ➕ `e2e/ruleset-live-states.e2e.ts` (+97 -0) 📝 `packages/client/src/components/game/GameRulesetSheet.tsx` (+25 -0) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+22 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+14 -0) 📝 `packages/server/src/services/game/ruleset-combat-director.service.ts` (+7 -4) 📝 `packages/shared/src/features/ruleset-combat/grid.ts` (+50 -0) 📝 `packages/shared/src/features/ruleset-combat/index.ts` (+1 -0) 📝 `packages/shared/src/features/rulesets/live-state.ts` (+81 -1) 📝 `packages/shared/src/features/rulesets/sheet-math.ts` (+18 -5) 📝 `packages/shared/src/features/rulesets/sheet-prompt.ts` (+4 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+6 -1) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+130 -6) _...and 13 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 #6656 Closes #6678 ## Why this change **#6656.** The author of [Marinara-RPG-Extension](https://github.com/Kenhito/Marinara-RPG-Extension) wrote two of their shipped tabletop systems as `ruleset.json` files. An enum field is chosen when a character is made and no sheet command changes it, and a condition is only on or off. So a shapeshifter's form, a frenzy, a stance or how lit a lantern is could not be said: each is one value out of a closed set that changes in play, and numbers hang off it (one form adds to Strength). This is slice 6, the last of the series in the plan doc (§ Gaps a ruleset author found). Slices 1 to 5 were #6663, #6669, #6682, #6689 and #6704. **#6678**, folded in on the maintainer's request. The browser case for a positioned Ember Roads fight sometimes ended without an outcome after 80 AI turns, on staging and on unrelated PRs. Replaying that fight in node across 2000 seeds showed it was a stall rather than a long fight. About one seed in seventy-five froze for good: the two fighters stood two squares apart with mountains and water between them. The AI's closing move only walked to a square that was closer in a straight line, and every such square was impassable, so neither ever moved, although a route round existed. ## What changed Capability API **1.42** (file keys: `states` in the live section, the `enumTable` derived op, and a rest step's `state`). None of it names one game's words. - **Live states.** `sheet.live.states`: up to twelve, each with two to forty `values`, optional `valueLabels`, a `default` (else the first value) and `hideWhen`. Values follow the rule every label follows and never hold a double quote, because the command quotes them. Stored sparse (only when away from the default); a stored value the state no longer offers reads as the default; a hidden state is not on the sheet. - **The command.** `[sheet: who="Name" op="state" state="Form" value="Crinos"]`, naming the state by id or label and the value by itself or its label, refused with the new reasons `unknown-state` and `unknown-value`. The tag's `state=` names the state on this op and still means on or off on a condition. The Game Master's sheet block always says each state's value, its default included, because a form is a fact the narration needs every turn. The reminder adds the command and a `States:` line listing every value, only when the ruleset has a state. The game's sheet screen shows a picker per state. New strings are localized in `en.json`. - **Numbers that follow.** A derived value `enumTable` gives a number for each value of an enum field or a live state, with a `default` for the rest. **Differs from the issue on purpose:** the issue keyed it `{ "state": … }`; it is `{ "liveState": … }`, because every read of the live state is named `live` (`liveTrack`, `livePool`), which is how an author and the import tell what a maximum cannot use. A field's table is build-only and may feed a maximum. A state's table is a live read, refused wherever a live read is, directly or through another derived value. It reaches the dice through slice 2's `adjust`, limited to an ability. A layer may remove a field value a table has a row for; the row is just never read while the layer is on. - **Rests.** A restore step may name a `state`, with `to` set to `"default"` or one of its values. `to` on any other step is still `"max"`, `"min"` or a number. - **Install gate:** each new key needs 1.42. **Published schema:** the generator now also says an enum table has exactly one source and one to forty rows, and that a word in a rest step's `to` belongs only to a state. - **#6678, the combat picker.** The closing move now measures "closer" by walking distance: `rulesetWalkingDistances` in the shared grid module, using the same steps, terrain costs and corner rule a walk pays. Reach and range stay straight-line, and on open ground the choice is the same as before. Across the same 2000 seeds every fight now ends, the longest in seven turns. - **Docs:** author guide (`docs/extending/writing-rulesets.md`, a new "Live states" section plus the sheet, modifiers, rests and Game Master text parts), player page (`docs/game/party-and-npcs.md`), the regenerated JSON Schema, the plan doc's slice 6 notes (and a correction to slice 5's, which still described the settled-ask guard as living in `isEngineRollableSkillCheckTag`), CHANGELOG. **Ember Roads** gains a Stance (Guarded, Steady, Reckless) that adds -1 or +2 to Brawn rolls and that making camp settles. **Gravewatch** gains a Light (Lit, Shuttered, Out) that costs one or two Nerve dice and that standing down from the vigil relights, plus a table on its `watch` field that gives a dawn warden one more Resolve. Both defaults read 0, so no existing number moves. ## 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 3854dd48e (this branch's one commit on staging d427f4a67), all exit 0: `pnpm check`, `pnpm localization:check`, `pnpm version:check`, `pnpm regression:node` (400/400), `pnpm ruleset:schema` (no diff after regeneration), `pnpm smoke:ui` (7/7), and `pnpm regression:ui e2e/ruleset-live-states.e2e.ts e2e/ruleset-sheet-sections.e2e.ts e2e/ruleset-wound-sheet.e2e.ts e2e/game-combat-director.e2e.ts --project=desktop-chromium --workers=1` (11/11: the new state picker case in light and dark, the sections and wound sheets, and the ruleset fights, including the positioned Ember Roads case #6678 was about). Mobile projects were not run locally. Local CodeRabbit, two completed passes: two findings, both fixed (the published schema now says an enum table's one source and row count, and that a word in a rest step's `to` belongs only to a state); the second pass was clean. - New lane `scripts/regressions/game-ruleset-live-states.regression.ts` covers: - every import refusal, and a layer on a field a table keys on; - reading a state (default, stale, hidden) and the tables on both kinds of key; - `adjust` reaching a real check; - the command (by id, label and value label; sparse storage; both refusals; the tag round trip; a whole turn); - rests; - the sheet block and the reminder; - the stored blob's bounds and the 1.42 gate. Thirty-one deliberate breaks were each caught. - `scripts/regressions/ruleset-combat-director.regression.ts` gains a hand-drawn ridge between two fighters, with a route round to the south. It checks that no straight-line-closer square is reachable, then plays the fight to the end. Without the fix it still stands after 200 rounds. - New browser case `e2e/ruleset-live-states.e2e.ts` picks Reckless on the game's sheet in light and dark mode. It checks that exactly `{ states: { stance: "reckless" } }` is stored, then that Make camp puts it back to Steady with nothing stored. - `game-ruleset-json-schema` pins the two new schema rules. Older-gate lanes strip the 1.42 keys, and the lifecycle lane follows the new version. - Not executed: validating the examples against the published JSON Schema with a real validator, because none is installed here. I checked by hand that every rest step and table in both examples satisfies the two new rules. Still to verify by hand (not done by the agent): - In a Game Mode game on Ember Roads, open the ruleset sheet: confirm Stance shows Steady, set it to Reckless, and confirm a Brawn check's dice card shows the +2. Then use Make camp and confirm Stance is back to Steady. Check light and dark mode and mobile width. - Have the Game Master write `[sheet: op="state" state="Stance" value="Guarded"]`: confirm the Stance picker follows. Then have it write `value="Frantic"` and confirm the refusal notice says that state has no such value. - On Gravewatch, set Light to Out and confirm a Listen check throws two fewer dice. Make a warden on the dawn watch and confirm their Resolve maximum is one higher. - Start a positioned Ember Roads fight on a board with impassable ground between the sides, hand both sides to the AI, and confirm they walk round and the fight ends. ## 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 `[docs-i18n]` issue after the last ruleset slice, by the maintainer's standing decision, so no per-PR issue is opened here. ## UI evidence (if applicable) None attached. The new browser case saves a full-page screenshot of the sheet with the Stance picker set to Reckless, in each theme. The manual steps above cover mobile width. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added live ruleset states that can affect calculations, display in sheet selectors, and reset during rests. * Rulesets can derive numeric values from enum fields or live states. * Updated sample rulesets to demonstrate state-based modifiers and restoration. * **Improvements** * Engine-controlled fighters now route by reachable walking paths when obstacles block a direct route. * Untrained-check refusals retain their reason through later dice processing. * **Compatibility** * Capability API 1.42 supports live states, enum-derived values, and state-based rest restoration. <!-- 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:21 +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#7294
No description provided.