[PR #6377] [MERGED] feat(game): ruleset bestiaries, creature actions and the threat clamp (real combat C2) #7155

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-combat-creatures


📝 Commits (10+)

  • 2cd8b2d feat(rulesets): a catalog may hold creatures instead of rows
  • 6ff0cce feat(game): a fight reads a bestiary, sequences, uses, recharge and signature points
  • f04d92d feat(packages): capability api 1.27 for ruleset bestiaries
  • bc14668 feat(rulesets): a bestiary in both example rulesets
  • 35c8114 test(game): pin bestiaries, sequences, uses, recharge, points and the clamp
  • 8d798a3 docs(rulesets): bestiary catalogs, the creature format and the threat clamp
  • e885508 fix(game): the use command is offered for catalogs of rows, not for a bestiary
  • e299945 refactor(game): drop a redundant guard in the threat clamp
  • f36188a test(game): a bestiary is never fetched for a character sheet
  • fa03b77 fix(game): the clamp shrinks a die along real dice, and the client regressions read the optional feeds and rows

📊 Changes

34 files changed (+3946 additions, -192 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+50 -2)
📝 docs/development/optional-agent-packages.md (+28 -0)
📝 docs/development/ruleset-5e-2014.example.json (+216 -0)
📝 docs/examples/rulesets/ember-roads.json (+168 -1)
📝 docs/extending/ruleset.schema.json (+515 -9)
📝 docs/extending/writing-rulesets.md (+120 -9)
📝 packages/client/src/components/rulesets/RulesetCatalogPicker.tsx (+1 -1)
📝 packages/client/src/components/rulesets/RulesetSheetEditor.tsx (+3 -2)
📝 packages/client/src/lib/ruleset-catalog.ts (+2 -2)
📝 packages/client/src/lib/ruleset-combat-bridge.ts (+1 -1)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+20 -1)
📝 packages/server/src/services/game/gm-prompts.ts (+4 -3)
➕ packages/shared/src/features/ruleset-combat/creatures.ts (+437 -0)
➕ packages/shared/src/features/ruleset-combat/dice.ts (+65 -0)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+68 -60)
📝 packages/shared/src/features/ruleset-combat/index.ts (+17 -7)
📝 packages/shared/src/features/ruleset-combat/options.ts (+128 -19)
📝 packages/shared/src/features/ruleset-combat/resolve.ts (+186 -24)
📝 packages/shared/src/features/ruleset-combat/types.ts (+84 -6)

...and 14 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 #6361 (real ruleset combat, slice C2 of 5; it does not close the issue) and of #6314. Builds on #6372 (combat core, merged).

Why this change

  • Slice C1 gave a ruleset a combat block and a resolver, but a fight's opponents were stat blocks somebody had to hand in. A real system comes with its own creatures, and they do things C1 could not say: strike several times in one action, breathe fire and wait for it to come back, use something a few times a day, act between other turns.
  • When the Game Master invents an opponent the ruleset does not ship, its numbers have to land on the ruleset's own scale, not on whatever the model felt like. C1 stored a threat tier table for exactly this; this slice is what reads it.
  • Nothing is playable yet. Like C1, this is format, resolver and proof. No session, no route and no screen ship here, so no existing battle changes.

What changed

  • Bestiary catalogs. A catalog declares "holds": "creatures" (default "rows"), and each of its entries carries a creature stat block instead of rows: never both, never neither, never mixed in one catalog. A bestiary needs no feeds (and may not declare one, which is what keeps it out of the sheet editor's picker by construction), keeps filters, and may live in an asset file under the same 1 MB and 2000 entry caps. It is only legal in a ruleset that has a combat block.
  • The creature format, in neutral words: health (a number, or dice rolled when the fight is built, with the average used for forecasts), defense, speed, initiativeModifier, abilities and saves keyed by the sheet's own ids, resist / vulnerable / immune, conditionImmunities, a tier from the ruleset's threat table, traits (short name and text pairs the Game Master is shown, never resolved), signaturePoints, and up to 12 actions.
  • Actions take everything a C1 stat block action had, plus uses (per encounter or per day), recharge (the creature rolls at the start of its turn and the action comes back on from or higher; it starts available), sequence (other actions of the same block, each a number of times, for ONE budget: this is how a creature that attacks several times in one action is written, and a sequence may not name a sequence), and signature (bought from a per-round pool that refills at the start of the creature's own turn and is never spendable on its own turn).
  • Cross-checks, shared by inline and asset catalogs: budgets, saves, conditions and tiers exist, damage types are declared when the ruleset declares any, a sequence names real non-sequence actions of the same creature.
  • Resolver. createRulesetEncounter takes an enemy as { creature: { catalogId, entryId } } from handed-in catalogs as well as an inline block, and rolls health dice with the encounter's roller. Sequences are one option on the menu (forecast: the sum of its parts) and resolve each strike with its own roll and its own target. uses and recharge are tracked on the combatant and emit events carrying the dice. rulesetSignatureOptions lists and prices signature actions and applyRulesetCombatChoice resolves one for points instead of a budget; the WINDOW that offers them is slice C5.
  • Lookup and clamp. findRulesetCreature finds what a Game Master named: the exact catalog/entry, then a label or id ignoring case and punctuation, then nothing, never fuzzier. clampRulesetStatBlock pulls a proposed block into a tier: health into the band, defense, to-hit and save difficulties to at most the tier's number plus 2, damage scaled down (dice count, then the flat part, then a strike off a sequence, then the die size along real dice) until the best round fits, unknown names dropped, at most 6 actions, and every change returned in plain words for a log line. Shipped bestiaries are never clamped.
  • Game Master prompt. The [sheet: op="use"] line is offered only when the ruleset has a catalog of rows, so a bestiary-only ruleset does not advertise a command that always refuses.
  • Examples. Ember Roads gets three original creatures (a two-strike sequence, a recharge). The 5e example gets four hand-written creatures with original names and numbers covering a sequence, a recharge, a save with a condition, and resist and immune lists. The real SRD creatures belong to the downloadable 5e package, not to this repo.
  • Capability API 1.27 gates bestiaries for packages, inline and in catalog files.
  • Docs: the authoring guide (Creatures, the clamp, what is stored and not yet resolved), the plan, docs/development/optional-agent-packages.md, the generated schema (which learns the rows-or-creature rule).
  • Regression game-ruleset-combat-creatures: schema refusals, health dice, lookup, a sequence spending one budget, uses running out, recharge on the right face and not below it, signature pricing and refusals, the clamp on each tier and on a block already in scale, the LISTED form of a ruleset, the 1.27 gate, and the sheet editor's catalog list ignoring a bestiary.

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, 328 of 328), and the new regression. One complete local CodeRabbit sweep over all 33 changed files was run before opening and came back with no findings. The agent's own review before that changed one thing: when the clamp has to shrink a damage die it steps along dice a table owns (d12, d10, d8 ...) instead of answering with a d7, and the regression pins it.

There is no UI and no route in this slice, so there is nothing to click and no e2e surface. The four client files it touches only gain a ?. because feeds became optional in the type.

Still to verify by hand:

  • Manually import the Ember Roads example and the 5e example through Import ruleset and confirm both are accepted with their bestiaries.
  • Manually open the sheet editor of a game on either example and confirm the catalog picker offers the same catalogs as before and never the bestiary.
  • Manually read the four 5e example creatures against the SRD's way of writing a stat block (they are original creatures, the point is the shape).
  • Manually confirm a battle in a game on a ruleset still runs exactly as before (the bridge), since nothing calls the resolver yet.

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, the plan, docs/development/optional-agent-packages.md, both example rulesets and the generated schema. The [docs-i18n] follow-up for the combat slices is batched into one issue at the end of the arc, as #6371 says.

UI evidence (if applicable)

None: this slice has no UI.

Summary by CodeRabbit

  • New Features

    • Rulesets can include bestiaries with creature statistics, traits, defenses, resistances, and combat actions.
    • Combat supports limited-use actions, recharge rolls, action sequences, and signature actions.
    • Opponents can be scaled to declared threat tiers, with adjustments explained to the Game Master.
    • Example rulesets now include sample bestiaries.
  • Compatibility

    • Bestiary support requires Capability API 1.27.
    • Rulesets without bestiaries remain unchanged.
    • Bestiaries are not yet playable through a user interface.

🔄 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/6377 **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/ruleset-combat-creatures` --- ### 📝 Commits (10+) - [`2cd8b2d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2cd8b2d9c3f1beecba95d3dee707738ab313c698) feat(rulesets): a catalog may hold creatures instead of rows - [`6ff0cce`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6ff0cce810783965f232635a81e0dd7f9aaf6863) feat(game): a fight reads a bestiary, sequences, uses, recharge and signature points - [`f04d92d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f04d92d7830caa1b8f873ddce94407a4610c4c8f) feat(packages): capability api 1.27 for ruleset bestiaries - [`bc14668`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bc14668e8b694e2b69381f5d90c32120b894f2d0) feat(rulesets): a bestiary in both example rulesets - [`35c8114`](https://github.com/Pasta-Devs/Marinara-Engine/commit/35c81140698865f4957f1e9f8305c1200d213fa6) test(game): pin bestiaries, sequences, uses, recharge, points and the clamp - [`8d798a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8d798a3e5695ab095d61a813836e62d900373862) docs(rulesets): bestiary catalogs, the creature format and the threat clamp - [`e885508`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e8855089ea3ae68bb1977c7966c081270bcf5f04) fix(game): the use command is offered for catalogs of rows, not for a bestiary - [`e299945`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e299945facf9712eebd084c75da9713b65baeea7) refactor(game): drop a redundant guard in the threat clamp - [`f36188a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f36188a8f84a7355b42d279ba2aa95a3f009c4fd) test(game): a bestiary is never fetched for a character sheet - [`fa03b77`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fa03b771c8558ee4d0222eddaf1f7239ad225ed7) fix(game): the clamp shrinks a die along real dice, and the client regressions read the optional feeds and rows ### 📊 Changes **34 files changed** (+3946 additions, -192 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+50 -2) 📝 `docs/development/optional-agent-packages.md` (+28 -0) 📝 `docs/development/ruleset-5e-2014.example.json` (+216 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+168 -1) 📝 `docs/extending/ruleset.schema.json` (+515 -9) 📝 `docs/extending/writing-rulesets.md` (+120 -9) 📝 `packages/client/src/components/rulesets/RulesetCatalogPicker.tsx` (+1 -1) 📝 `packages/client/src/components/rulesets/RulesetSheetEditor.tsx` (+3 -2) 📝 `packages/client/src/lib/ruleset-catalog.ts` (+2 -2) 📝 `packages/client/src/lib/ruleset-combat-bridge.ts` (+1 -1) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+20 -1) 📝 `packages/server/src/services/game/gm-prompts.ts` (+4 -3) ➕ `packages/shared/src/features/ruleset-combat/creatures.ts` (+437 -0) ➕ `packages/shared/src/features/ruleset-combat/dice.ts` (+65 -0) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+68 -60) 📝 `packages/shared/src/features/ruleset-combat/index.ts` (+17 -7) 📝 `packages/shared/src/features/ruleset-combat/options.ts` (+128 -19) 📝 `packages/shared/src/features/ruleset-combat/resolve.ts` (+186 -24) 📝 `packages/shared/src/features/ruleset-combat/types.ts` (+84 -6) _...and 14 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 #6361 (real ruleset combat, slice C2 of 5; it does not close the issue) and of #6314. Builds on #6372 (combat core, merged). ## Why this change - Slice C1 gave a ruleset a `combat` block and a resolver, but a fight's opponents were stat blocks somebody had to hand in. A real system comes with its own creatures, and they do things C1 could not say: strike several times in one action, breathe fire and wait for it to come back, use something a few times a day, act between other turns. - When the Game Master invents an opponent the ruleset does not ship, its numbers have to land on the ruleset's own scale, not on whatever the model felt like. C1 stored a threat tier table for exactly this; this slice is what reads it. - **Nothing is playable yet.** Like C1, this is format, resolver and proof. No session, no route and no screen ship here, so no existing battle changes. ## What changed - **Bestiary catalogs.** A catalog declares `"holds": "creatures"` (default `"rows"`), and each of its entries carries a `creature` stat block instead of `rows`: never both, never neither, never mixed in one catalog. A bestiary needs no `feeds` (and may not declare one, which is what keeps it out of the sheet editor's picker by construction), keeps `filters`, and may live in an asset file under the same 1 MB and 2000 entry caps. It is only legal in a ruleset that has a `combat` block. - **The creature format**, in neutral words: `health` (a number, or dice rolled when the fight is built, with the average used for forecasts), `defense`, `speed`, `initiativeModifier`, `abilities` and `saves` keyed by the sheet's own ids, `resist` / `vulnerable` / `immune`, `conditionImmunities`, a `tier` from the ruleset's threat table, `traits` (short name and text pairs the Game Master is shown, never resolved), `signaturePoints`, and up to 12 `actions`. - **Actions** take everything a C1 stat block action had, plus `uses` (per encounter or per day), `recharge` (the creature rolls at the start of its turn and the action comes back on `from` or higher; it starts available), `sequence` (other actions of the same block, each a number of times, for ONE budget: this is how a creature that attacks several times in one action is written, and a sequence may not name a sequence), and `signature` (bought from a per-round pool that refills at the start of the creature's own turn and is never spendable on its own turn). - **Cross-checks**, shared by inline and asset catalogs: budgets, saves, conditions and tiers exist, damage types are declared when the ruleset declares any, a sequence names real non-sequence actions of the same creature. - **Resolver.** `createRulesetEncounter` takes an enemy as `{ creature: { catalogId, entryId } }` from handed-in catalogs as well as an inline block, and rolls health dice with the encounter's roller. Sequences are one option on the menu (forecast: the sum of its parts) and resolve each strike with its own roll and its own target. `uses` and `recharge` are tracked on the combatant and emit events carrying the dice. `rulesetSignatureOptions` lists and prices signature actions and `applyRulesetCombatChoice` resolves one for points instead of a budget; the WINDOW that offers them is slice C5. - **Lookup and clamp.** `findRulesetCreature` finds what a Game Master named: the exact `catalog/entry`, then a label or id ignoring case and punctuation, then nothing, never fuzzier. `clampRulesetStatBlock` pulls a proposed block into a tier: health into the band, defense, to-hit and save difficulties to at most the tier's number plus 2, damage scaled down (dice count, then the flat part, then a strike off a sequence, then the die size along real dice) until the best round fits, unknown names dropped, at most 6 actions, and every change returned in plain words for a log line. Shipped bestiaries are never clamped. - **Game Master prompt.** The `[sheet: op="use"]` line is offered only when the ruleset has a catalog of rows, so a bestiary-only ruleset does not advertise a command that always refuses. - **Examples.** Ember Roads gets three original creatures (a two-strike sequence, a recharge). The 5e example gets four hand-written creatures with original names and numbers covering a sequence, a recharge, a save with a condition, and resist and immune lists. The real SRD creatures belong to the downloadable 5e package, not to this repo. - **Capability API 1.27** gates bestiaries for packages, inline and in catalog files. - Docs: the authoring guide (Creatures, the clamp, what is stored and not yet resolved), the plan, `docs/development/optional-agent-packages.md`, the generated schema (which learns the rows-or-creature rule). - Regression `game-ruleset-combat-creatures`: schema refusals, health dice, lookup, a sequence spending one budget, uses running out, recharge on the right face and not below it, signature pricing and refusals, the clamp on each tier and on a block already in scale, the LISTED form of a ruleset, the 1.27 gate, and the sheet editor's catalog list ignoring a bestiary. ## 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`, 328 of 328), and the new regression. One complete local CodeRabbit sweep over all 33 changed files was run before opening and came back with no findings. The agent's own review before that changed one thing: when the clamp has to shrink a damage die it steps along dice a table owns (d12, d10, d8 ...) instead of answering with a d7, and the regression pins it. There is no UI and no route in this slice, so there is nothing to click and no e2e surface. The four client files it touches only gain a `?.` because `feeds` became optional in the type. Still to verify by hand: - Manually import the Ember Roads example and the 5e example through **Import ruleset** and confirm both are accepted with their bestiaries. - Manually open the sheet editor of a game on either example and confirm the catalog picker offers the same catalogs as before and never the bestiary. - Manually read the four 5e example creatures against the SRD's way of writing a stat block (they are original creatures, the point is the shape). - Manually confirm a battle in a game on a ruleset still runs exactly as before (the bridge), since nothing calls the resolver yet. ## 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`, the plan, `docs/development/optional-agent-packages.md`, both example rulesets and the generated schema. The `[docs-i18n]` follow-up for the combat slices is batched into one issue at the end of the arc, as #6371 says. ## UI evidence (if applicable) None: this slice has no UI. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Rulesets can include bestiaries with creature statistics, traits, defenses, resistances, and combat actions. - Combat supports limited-use actions, recharge rolls, action sequences, and signature actions. - Opponents can be scaled to declared threat tiers, with adjustments explained to the Game Master. - Example rulesets now include sample bestiaries. - **Compatibility** - Bestiary support requires Capability API 1.27. - Rulesets without bestiaries remain unchanged. - Bestiaries are not yet playable through a user interface. <!-- 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:01 +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#7155
No description provided.