[PR #6613] [MERGED] feat(game): a creature written in the ruleset's own terms #7254

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-creature-sheets


📝 Commits (3)

  • 40be7de feat(game): a creature written in the ruleset's own terms
  • 1d0e301 fix(game): hold a creature's sheet to the ranges and tiers its ruleset declares
  • cb092f1 Merge remote-tracking branch 'origin/staging' into feat/ruleset-creature-sheets

📊 Changes

31 files changed (+2167 additions, -185 deletions)

View changed files

📝 CHANGELOG.md (+3 -1)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+51 -0)
📝 docs/development/optional-agent-packages.md (+22 -0)
📝 docs/development/ruleset-5e-2014.example.json (+73 -2)
📝 docs/examples/rulesets/ember-roads.json (+51 -0)
📝 docs/extending/ruleset.schema.json (+163 -8)
📝 docs/extending/writing-rulesets.md (+84 -12)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/server/src/routes/combat-director.routes.ts (+15 -1)
📝 packages/server/src/routes/encounter.routes.ts (+2 -2)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+16 -0)
📝 packages/server/src/services/game/ruleset-combat-director.service.ts (+27 -13)
📝 packages/shared/src/features/ruleset-combat/creatures.ts (+56 -7)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+121 -50)
📝 packages/shared/src/features/ruleset-combat/index.ts (+6 -1)
📝 packages/shared/src/features/ruleset-combat/options.ts (+2 -3)
📝 packages/shared/src/features/ruleset-combat/resolve.ts (+5 -5)
📝 packages/shared/src/features/ruleset-combat/types.ts (+22 -4)
📝 packages/shared/src/schemas/capability-package.schema.ts (+10 -1)
📝 packages/shared/src/schemas/ruleset.schema.ts (+236 -59)

...and 11 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 #6610

Why this change

  • A bestiary creature could only be written as a fixed set of plain numbers: health, defense, initiative, and actions with their own to-hit. Rulesets don't all use the same stats, skills and lists, so a creature in a non-5e ruleset had to be squeezed into numbers its own rules never mention.
  • An opponent had no pools, so it could never pay for anything, and so it could never cast bigger out of a higher pool. #6608 could only give that to party members the Engine plays, for exactly this reason.
  • On a ruleset whose health is a wound track, an opponent still lost plain points, and its resistances could not soften a blow before it marked one. The docs listed this as a limit.
  • Also fixes a leftover from #6525/#6608: writing-rulesets.md still said signature actions were "stored, priced and spent today; see Not yet below", but the window that offers them shipped in C5b. Three more places said the same thing.

What changed

  • A creature may carry a sheet, in the same shape as a character's sheet and with every part optional. A fight builds it with the same function it uses for a party member (sheetCombatant), so its health (a pool or a track), defense, saves, initiative, speed and the attacks and abilities on its lists all come from the ruleset's own formulas. What the entry adds beside the sheet (tier, traits, block actions, signature points, riders, resist/vulnerable/immune, condition immunities) is kept.
  • One place for each number. With a sheet, health, defense, initiativeModifier, speed, abilities and saves are refused beside it, and it may have no block actions. Without one, the first three and an action are still required. The published JSON Schema enforces both halves, pinned by the JSON Schema lane.
  • Checked as authored data. Every id must be declared. Skills and saves must use tiers the ruleset offers for them. Scores and bonuses must be whole numbers in their ranges. Fields and row cells go through the shared rulesetListRowIssues, now also run over fields. Rows must stay within each list's maxItems. _catalog must name a catalog that feeds the list, and, when that catalog is inline, an entry it holds.
  • The route loads the catalogs a bestiary's sheets read (rulesetBestiarySheetCatalogIds), after the bestiaries themselves and only when a sheet names one.
  • It pays out of its own pools, bigger ones included. The candidate builder was never gated by side, and the Game Master's decision already carried payWith. Both are now proven for a sheet-backed opponent.
  • Wound tracks: the hide is read first, then the creature's own track is marked. The "Not yet" limit is rewritten to the part that remains: a creature written in plain numbers still loses points.
  • Still an opponent. It is defeated at zero (by side) and never gets a death track. The live write-back is now keyed by side as well: before, a sheet-backed opponent sharing a party member's name would have overwritten that member's stored sheet. The screen view carries none of its sheet.
  • A Game Master's invention stays a plain block. rulesetProposedCreatureSchema has no sheet, because the clamp holds an invention to its tier by its numbers. A proposal that carries one is not read, and the tier is used.
  • no-health refusal: a sheet that adds up to no health is left out at fight time with its own reason.
  • Refusal text drift guard: every RulesetCombatRefusal reason must now have a sentence in en.json and in the server's rulesetRefusalMessage. C5b's window-open and stale-window had neither; C4a's four positioned reasons had no server sentence.
  • Capability API 1.34 gate, inline and in catalog files.
  • Examples: the 5e draft ships a Toll Sergeant, whose AC, HP, saves and attacks come from its fields and attacks list. Ember Roads ships a Toll Warden, whose Grit and Guard come from its sheet and whose Hold the Line costs its own Luck.
  • Docs: a new "A creature written in your ruleset's own terms" section in writing-rulesets.md, a Capability API 1.34 section, implementation notes, and a CHANGELOG entry. Removed the stale "later release" claims about signature windows (writing-rulesets, the 5e example's Hollow Sentinel comment, options.ts, resolve.ts) and the "opponent has no sheet" comments this makes untrue.

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

Commands the agent ran, on the rebased branch:

  • pnpm check, pnpm localization:check, pnpm version:check
  • pnpm regression (full suite)
  • New lane: scripts/regressions/game-ruleset-combat-creature-sheets.regression.ts. Each behaviour was mutation-tested: 19 deliberate breakages, each confirmed to fail the lane.
  • Local CodeRabbit sweep. The first run had one finding (hold scores and bonuses to whole numbers in range, and lists to maxItems). It was valid and is fixed, including the same gap for offered proficiency tiers. The second run had zero findings.

Manual verification notes

Needs doing by a human:

  • Manually verify in the app: start a Game Mode fight on the 5e example against the Toll Sergeant and confirm its AC shows 17 and its HP 52, and that it swings twice per action with the halberd.
  • Manually verify on Ember Roads: fight two Toll Wardens and confirm one can use Hold the Line on the other, and that nothing about the wardens is written to any character's sheet afterwards.
  • Manually verify that a refusal while a moment is held open ("waiting on somebody else's answer") reads as a sentence, not a code.

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)

Translated docs: the new Capability API 1.34 section in docs/development/optional-agent-packages.md is added to the batched follow-up #6458.

The 5e package in Marinara-Agents adopts this in its own release later. Nothing here changes the package.

UI evidence (if applicable)

No UI changes. The only client change is three new refusal sentences in en.json.

Summary by CodeRabbit

  • New Features
    • Bestiary creatures can use ruleset-defined character sheets for combat stats, attacks, abilities, and resource pools. They can take wound-track marks, and their abilities draw from their own pools.
    • Creature sheets can reference abilities and other entries in ruleset catalogs.
    • Combat can offer between-turn reaction windows, including aiming and responding to harm.
  • Improvements
    • Ability costs can draw from higher available pools when needed.
    • Combat refusals now include clearer messages for additional invalid or unavailable actions.
  • Compatibility
    • Ruleset packages that use creature sheets must declare Capability API 1.34 or newer.

🔄 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/6613 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/24/2026 **Status:** ✅ Merged **Merged:** 9/24/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-creature-sheets` --- ### 📝 Commits (3) - [`40be7de`](https://github.com/Pasta-Devs/Marinara-Engine/commit/40be7def5ec299517db248e8f2f10d13d6f2fbcf) feat(game): a creature written in the ruleset's own terms - [`1d0e301`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1d0e3010965d5ff3ca717e34be2eb665f93b2961) fix(game): hold a creature's sheet to the ranges and tiers its ruleset declares - [`cb092f1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cb092f1f384f20d4ec5de787871ff91f032b8e44) Merge remote-tracking branch 'origin/staging' into feat/ruleset-creature-sheets ### 📊 Changes **31 files changed** (+2167 additions, -185 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -1) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+51 -0) 📝 `docs/development/optional-agent-packages.md` (+22 -0) 📝 `docs/development/ruleset-5e-2014.example.json` (+73 -2) 📝 `docs/examples/rulesets/ember-roads.json` (+51 -0) 📝 `docs/extending/ruleset.schema.json` (+163 -8) 📝 `docs/extending/writing-rulesets.md` (+84 -12) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/server/src/routes/combat-director.routes.ts` (+15 -1) 📝 `packages/server/src/routes/encounter.routes.ts` (+2 -2) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+16 -0) 📝 `packages/server/src/services/game/ruleset-combat-director.service.ts` (+27 -13) 📝 `packages/shared/src/features/ruleset-combat/creatures.ts` (+56 -7) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+121 -50) 📝 `packages/shared/src/features/ruleset-combat/index.ts` (+6 -1) 📝 `packages/shared/src/features/ruleset-combat/options.ts` (+2 -3) 📝 `packages/shared/src/features/ruleset-combat/resolve.ts` (+5 -5) 📝 `packages/shared/src/features/ruleset-combat/types.ts` (+22 -4) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+10 -1) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+236 -59) _...and 11 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 #6610 ## Why this change - A bestiary creature could only be written as a fixed set of plain numbers: health, defense, initiative, and actions with their own to-hit. Rulesets don't all use the same stats, skills and lists, so a creature in a non-5e ruleset had to be squeezed into numbers its own rules never mention. - An opponent had no pools, so it could never pay for anything, and so it could never cast bigger out of a higher pool. #6608 could only give that to party members the Engine plays, for exactly this reason. - On a ruleset whose health is a wound track, an opponent still lost plain points, and its resistances could not soften a blow before it marked one. The docs listed this as a limit. - Also fixes a leftover from #6525/#6608: `writing-rulesets.md` still said signature actions were "stored, priced and spent today; see Not yet below", but the window that offers them shipped in C5b. Three more places said the same thing. ## What changed - **A creature may carry a `sheet`**, in the same shape as a character's sheet and with every part optional. A fight builds it with the same function it uses for a party member (`sheetCombatant`), so its health (a pool or a track), defense, saves, initiative, speed and the attacks and abilities on its lists all come from the ruleset's own formulas. What the entry adds beside the sheet (tier, traits, block actions, signature points, riders, resist/vulnerable/immune, condition immunities) is kept. - **One place for each number.** With a sheet, `health`, `defense`, `initiativeModifier`, `speed`, `abilities` and `saves` are refused beside it, and it may have no block actions. Without one, the first three and an action are still required. The published JSON Schema enforces both halves, pinned by the JSON Schema lane. - **Checked as authored data.** Every id must be declared. Skills and saves must use tiers the ruleset offers for them. Scores and bonuses must be whole numbers in their ranges. Fields and row cells go through the shared `rulesetListRowIssues`, now also run over fields. Rows must stay within each list's `maxItems`. `_catalog` must name a catalog that feeds the list, and, when that catalog is inline, an entry it holds. - **The route loads the catalogs a bestiary's sheets read** (`rulesetBestiarySheetCatalogIds`), after the bestiaries themselves and only when a sheet names one. - **It pays out of its own pools, bigger ones included.** The candidate builder was never gated by side, and the Game Master's decision already carried `payWith`. Both are now proven for a sheet-backed opponent. - **Wound tracks:** the hide is read first, then the creature's own track is marked. The "Not yet" limit is rewritten to the part that remains: a creature written in plain numbers still loses points. - **Still an opponent.** It is defeated at zero (by side) and never gets a death track. The live write-back is now keyed by side as well: before, a sheet-backed opponent sharing a party member's name would have overwritten that member's stored sheet. The screen view carries none of its sheet. - **A Game Master's invention stays a plain block.** `rulesetProposedCreatureSchema` has no `sheet`, because the clamp holds an invention to its tier by its numbers. A proposal that carries one is not read, and the tier is used. - **`no-health` refusal:** a sheet that adds up to no health is left out at fight time with its own reason. - **Refusal text drift guard:** every `RulesetCombatRefusal` reason must now have a sentence in `en.json` and in the server's `rulesetRefusalMessage`. C5b's `window-open` and `stale-window` had neither; C4a's four positioned reasons had no server sentence. - **Capability API 1.34** gate, inline and in catalog files. - **Examples:** the 5e draft ships a Toll Sergeant, whose AC, HP, saves and attacks come from its fields and attacks list. Ember Roads ships a Toll Warden, whose Grit and Guard come from its sheet and whose Hold the Line costs its own Luck. - **Docs:** a new "A creature written in your ruleset's own terms" section in `writing-rulesets.md`, a Capability API 1.34 section, implementation notes, and a CHANGELOG entry. Removed the stale "later release" claims about signature windows (writing-rulesets, the 5e example's Hollow Sentinel comment, `options.ts`, `resolve.ts`) and the "opponent has no sheet" comments this makes untrue. ## 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` Commands the agent ran, on the rebased branch: - `pnpm check`, `pnpm localization:check`, `pnpm version:check` - `pnpm regression` (full suite) - New lane: `scripts/regressions/game-ruleset-combat-creature-sheets.regression.ts`. Each behaviour was mutation-tested: 19 deliberate breakages, each confirmed to fail the lane. - Local CodeRabbit sweep. The first run had one finding (hold scores and bonuses to whole numbers in range, and lists to `maxItems`). It was valid and is fixed, including the same gap for offered proficiency tiers. The second run had zero findings. ### Manual verification notes Needs doing by a human: - Manually verify in the app: start a Game Mode fight on the 5e example against the Toll Sergeant and confirm its AC shows 17 and its HP 52, and that it swings twice per action with the halberd. - Manually verify on Ember Roads: fight two Toll Wardens and confirm one can use Hold the Line on the other, and that nothing about the wardens is written to any character's sheet afterwards. - Manually verify that a refusal while a moment is held open ("waiting on somebody else's answer") reads as a sentence, not a code. ## 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) Translated docs: the new Capability API 1.34 section in `docs/development/optional-agent-packages.md` is added to the batched follow-up #6458. The 5e package in Marinara-Agents adopts this in its own release later. Nothing here changes the package. ## UI evidence (if applicable) No UI changes. The only client change is three new refusal sentences in `en.json`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Bestiary creatures can use ruleset-defined character sheets for combat stats, attacks, abilities, and resource pools. They can take wound-track marks, and their abilities draw from their own pools. * Creature sheets can reference abilities and other entries in ruleset catalogs. * Combat can offer between-turn reaction windows, including aiming and responding to harm. * **Improvements** * Ability costs can draw from higher available pools when needed. * Combat refusals now include clearer messages for additional invalid or unavailable actions. * **Compatibility** * Ruleset packages that use creature sheets must declare Capability API 1.34 or newer. <!-- 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:17:58 +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#7254
No description provided.