[PR #6623] [MERGED] feat(game): a Game Master's invented opponent may be a sheet, held to its class and tier #7258

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

📋 Pull Request Information

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

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


📝 Commits (10+)

  • 6d2376f feat(game): a Game Master's invented opponent may be a sheet, held to its tier
  • 3959cb0 feat(game): an invented enemy keeps its class's own entries and fills the rest by temperament
  • 2a52f26 docs(game): say how an invented enemy is held to its class, filled in, and left alone as a boss
  • 0c221f2 fix(game): read each catalog once for the sheet brief, and name the fill limits
  • 270acd9 fix(game): load every list an invented sheet may choose from, and share the creature key lists with the schema generator
  • 92adaca fix(game): measure a striking round with strikes in hand going to the heaviest row, and file the Toll Sergeant under its own tier
  • 01c8dd1 fix(game): bring an entry's other rows with it on an invented sheet, and show text fields in the sheet brief
  • 947d30b fix(game): measure a bigger payment per part, and let a layer keep only the values it took out
  • bc05ce6 fix(game): shave the rider a held round counts, as the plain clamp does
  • 0d06a36 Merge remote-tracking branch 'origin/staging' into feat/ruleset-invented-sheets

📊 Changes

18 files changed (+1906 additions, -140 deletions)

View changed files

📝 CHANGELOG.md (+1 -1)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+37 -3)
📝 docs/development/ruleset-5e-2014.example.json (+3 -3)
📝 docs/extending/writing-rulesets.md (+42 -3)
📝 packages/client/src/lib/ruleset-catalog.ts (+4 -14)
📝 packages/server/src/routes/combat-director.routes.ts (+36 -5)
📝 packages/server/src/routes/encounter.routes.ts (+118 -0)
📝 packages/server/src/services/game/ruleset-catalog.service.ts (+2 -1)
📝 packages/server/src/services/game/ruleset-combat-director.service.ts (+84 -2)
📝 packages/shared/src/features/ruleset-combat/creatures.ts (+3 -2)
➕ packages/shared/src/features/ruleset-combat/hold.ts (+707 -0)
📝 packages/shared/src/features/ruleset-combat/index.ts (+7 -0)
📝 packages/shared/src/features/rulesets/scaled-rows.ts (+17 -0)
📝 packages/shared/src/schemas/ruleset.schema.ts (+97 -15)
📝 scripts/generate-ruleset-schema.mjs (+8 -3)
📝 scripts/regressions/game-ruleset-combat-creature-sheets.regression.ts (+581 -69)
📝 scripts/regressions/game-ruleset-json-schema.regression.ts (+9 -7)
📝 scripts/regressions/ruleset-combat-director-route.regression.ts (+150 -12)

📄 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 #6622

Why this change

  • #6613 let a bestiary creature carry a sheet in the ruleset's own terms, but a creature the Game Master invents still had to be plain numbers, so an invented mage had no spell slots and no spells. Raised in the #6613 review.
  • Also from that review: an invented enemy must follow the ruleset's own class resources (a Sorcerer does not get the whole spell list), the spells it was not given are filled by the competence and temperament system rather than by another model call, and a boss is written in full by the Game Master because it may be an exception.
  • This is the work that was still local when #6613 merged.

What changed

  • A proposal may carry a sheet, read leniently in packages/shared/src/features/ruleset-combat/hold.ts (readProposedRulesetSheet):
    • names the ruleset lacks are dropped and said in the log;
    • values are fitted to their field or column;
    • numbers written beside a sheet are dropped instead of failing the whole proposal;
    • a row that names a catalog entry, in any case, becomes that entry under its own name, with the entry's other rows (a feature's counter) alongside;
    • a named row in a chosen-from list counts as chosen.
  • Held to the class (not bosses). restrictRulesetSheetEntries keeps only the entries a catalog filter with startFrom opens to the sheet's own value, matched by sheetFieldMatchTexts, which moved to shared so the picker and the fight agree. No format change.
  • Open choices filled by temperament (not bosses). fillRulesetSheetChoices works on every list a creature chooses from (an ability source with onlyWhen):
    • it draws only entries open to the creature and payable from its own pools;
    • each pool rung, and what it can use at will, is filled up to a small count by competence;
    • each entry's nature (harm, support, control, or bends-the-turn) is weighted against the combat AI's temperament, and competence raises the bends-the-turn weight;
    • the draw is seeded, so the same fight always fills the same way.
      The route assigns tactics up front from the same unit and seed the picker would use, so the creature fills and fights with one temperament.
  • Held to the tier. holdRulesetSheetHealth moves health into the band through the one field the health pool reads, or a sum with one field in it, and otherwise leaves it as written with a log line; a wound track is never changed. holdRulesetCombatant then works on the built combatant:
    • defense, to-hit and save difficulties are capped at two above the tier;
    • the best round is scaled down, counting the biggest affordable payment, with the bigger payment's extra damage shaved first;
    • a striking round counts strikes in hand going to the heaviest striking row.
  • Blueprint prompt. An EncounterSheetBrief gives the Game Master the sheet's ids and what each holds (text fields included), the lists a fight reads, the field that opens each list, up to 60 catalog names per list, and the boss rule. Each catalog is read once.
  • Catalogs for invented sheets. The route loads every catalog feeding a list an invented sheet names or may choose from.
  • Layers never cost a creature. Creature-sheet enum values are not held to values a layer removed (narrowedByLayers), so a layer is never silently skipped and a bestiary file never refused over one.
  • 5e example. The Toll Sergeant is filed under CR 5, which its numbers match, and its HP goes to 80.
  • Shared key lists. The creature key lists are exported and shared with the schema generator and its regression.
  • Docs. writing-rulesets.md (Opponents nobody wrote, creature sheets), implementation notes and the CHANGELOG, whose #6613 line is updated.

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 branch: pnpm check, pnpm regression (full suite), and pnpm localization:check.

The new cases are in scripts/regressions/game-ruleset-combat-creature-sheets.regression.ts and the route lane, and every behaviour was mutation-tested. The temperament tests assert margins, not a bare "more": without any weighting, protective and reckless come out level. Local CodeRabbit sweeps over this work raised ten findings across six rounds, and nine were fixed:

  • a layer that narrows an enum invalidating creatures;
  • the doc naming its fill limits;
  • one read per catalog in the brief;
  • shared creature key lists;
  • loading the lists an invented sheet may choose from;
  • strikes in hand;
  • the Toll Sergeant's tier;
  • an entry's companion rows;
  • text fields in the brief.

The last round raised one trivial suggestion, which was declined: caching the brief's catalog names across encounter starts. The catalog loader is uncached by design, so a package update never serves stale entries, and the fight route itself reads the same catalogs on every start.

Manual verification notes

Needs doing by a human:

  • Manually verify in the app: on the 5e package, let the Game Master invent a spellcasting enemy (not a boss) and confirm it only has spells from its own class, and that the combat log's adjustments say what was filled in and why.
  • Manually verify that an invented boss keeps exactly the spells the Game Master gave it, with nothing filled in.
  • Manually verify that an overdone invention (very high AC or HP) is pulled onto its tier, with the log saying so.

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: none of the pages this changes are carried on the docs-i18n branch (writing-rulesets.md and the implementation notes are not translated).

UI evidence (if applicable)

No UI changes.

Summary by CodeRabbit

  • New Features
    • Game Masters can create invented enemies as ruleset-based character sheets, including abilities, skills, saves, fields, and catalog-backed choices.
    • Non-boss sheets receive eligible unspecified choices based on their ruleset and creature traits; boss sheets remain fully authored by the Game Master.
    • Sheet-based enemies are balanced to their threat tier, including health, defense, accuracy, saves, and damage. Wound-track damage is supported.
    • Sheet-based enemies remain opponents: they are defeated at zero health and do not roll against death. They do not replace characters with the same name, and each number appears only once.
  • Bug Fixes
    • Creatures using enum values narrowed by an active ruleset layer now use the field’s default instead of being rejected.

🔄 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/6623 **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-invented-sheets` --- ### 📝 Commits (10+) - [`6d2376f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d2376fa8620d726f2b50886c2460ca9500ba010) feat(game): a Game Master's invented opponent may be a sheet, held to its tier - [`3959cb0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3959cb01b1e57d7a162d875261b0a00761ca326c) feat(game): an invented enemy keeps its class's own entries and fills the rest by temperament - [`2a52f26`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2a52f26b7e5a98ca2bcbb1d55bda502143eefbc9) docs(game): say how an invented enemy is held to its class, filled in, and left alone as a boss - [`0c221f2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0c221f2061a8fe2d945a87862503c629e00dc34b) fix(game): read each catalog once for the sheet brief, and name the fill limits - [`270acd9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/270acd94805e32bb5fe4263345c530016d528209) fix(game): load every list an invented sheet may choose from, and share the creature key lists with the schema generator - [`92adaca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/92adaca4b35a0919895f1bd1a6b63cb5c4209a28) fix(game): measure a striking round with strikes in hand going to the heaviest row, and file the Toll Sergeant under its own tier - [`01c8dd1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/01c8dd1c15e5ce7a5021ecdff8a9ab5eb3de2c07) fix(game): bring an entry's other rows with it on an invented sheet, and show text fields in the sheet brief - [`947d30b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/947d30b81328d6db052bd4fa9791d16e63ee82f2) fix(game): measure a bigger payment per part, and let a layer keep only the values it took out - [`bc05ce6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bc05ce60de203bca269ef04343e7ed2c3f93d6e3) fix(game): shave the rider a held round counts, as the plain clamp does - [`0d06a36`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0d06a36f36c9267fae12b22198677d500b316a6e) Merge remote-tracking branch 'origin/staging' into feat/ruleset-invented-sheets ### 📊 Changes **18 files changed** (+1906 additions, -140 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -1) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+37 -3) 📝 `docs/development/ruleset-5e-2014.example.json` (+3 -3) 📝 `docs/extending/writing-rulesets.md` (+42 -3) 📝 `packages/client/src/lib/ruleset-catalog.ts` (+4 -14) 📝 `packages/server/src/routes/combat-director.routes.ts` (+36 -5) 📝 `packages/server/src/routes/encounter.routes.ts` (+118 -0) 📝 `packages/server/src/services/game/ruleset-catalog.service.ts` (+2 -1) 📝 `packages/server/src/services/game/ruleset-combat-director.service.ts` (+84 -2) 📝 `packages/shared/src/features/ruleset-combat/creatures.ts` (+3 -2) ➕ `packages/shared/src/features/ruleset-combat/hold.ts` (+707 -0) 📝 `packages/shared/src/features/ruleset-combat/index.ts` (+7 -0) 📝 `packages/shared/src/features/rulesets/scaled-rows.ts` (+17 -0) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+97 -15) 📝 `scripts/generate-ruleset-schema.mjs` (+8 -3) 📝 `scripts/regressions/game-ruleset-combat-creature-sheets.regression.ts` (+581 -69) 📝 `scripts/regressions/game-ruleset-json-schema.regression.ts` (+9 -7) 📝 `scripts/regressions/ruleset-combat-director-route.regression.ts` (+150 -12) </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 #6622 ## Why this change - #6613 let a bestiary creature carry a sheet in the ruleset's own terms, but a creature the Game Master invents still had to be plain numbers, so an invented mage had no spell slots and no spells. Raised in the #6613 review. - Also from that review: an invented enemy must follow the ruleset's own class resources (a Sorcerer does not get the whole spell list), the spells it was not given are filled by the competence and temperament system rather than by another model call, and a boss is written in full by the Game Master because it may be an exception. - This is the work that was still local when #6613 merged. ## What changed - **A proposal may carry a `sheet`**, read leniently in `packages/shared/src/features/ruleset-combat/hold.ts` (`readProposedRulesetSheet`): - names the ruleset lacks are dropped and said in the log; - values are fitted to their field or column; - numbers written beside a sheet are dropped instead of failing the whole proposal; - a row that names a catalog entry, in any case, becomes that entry under its own name, with the entry's other rows (a feature's counter) alongside; - a named row in a chosen-from list counts as chosen. - **Held to the class (not bosses).** `restrictRulesetSheetEntries` keeps only the entries a catalog filter with `startFrom` opens to the sheet's own value, matched by `sheetFieldMatchTexts`, which moved to shared so the picker and the fight agree. No format change. - **Open choices filled by temperament (not bosses).** `fillRulesetSheetChoices` works on every list a creature chooses from (an ability source with `onlyWhen`): - it draws only entries open to the creature and payable from its own pools; - each pool rung, and what it can use at will, is filled up to a small count by competence; - each entry's nature (harm, support, control, or bends-the-turn) is weighted against the combat AI's temperament, and competence raises the bends-the-turn weight; - the draw is seeded, so the same fight always fills the same way. The route assigns tactics up front from the same unit and seed the picker would use, so the creature fills and fights with one temperament. - **Held to the tier.** `holdRulesetSheetHealth` moves health into the band through the one field the health pool reads, or a `sum` with one field in it, and otherwise leaves it as written with a log line; a wound track is never changed. `holdRulesetCombatant` then works on the built combatant: - defense, to-hit and save difficulties are capped at two above the tier; - the best round is scaled down, counting the biggest affordable payment, with the bigger payment's extra damage shaved first; - a striking round counts strikes in hand going to the heaviest striking row. - **Blueprint prompt.** An `EncounterSheetBrief` gives the Game Master the sheet's ids and what each holds (text fields included), the lists a fight reads, the field that opens each list, up to 60 catalog names per list, and the boss rule. Each catalog is read once. - **Catalogs for invented sheets.** The route loads every catalog feeding a list an invented sheet names or may choose from. - **Layers never cost a creature.** Creature-sheet enum values are not held to values a layer removed (`narrowedByLayers`), so a layer is never silently skipped and a bestiary file never refused over one. - **5e example.** The Toll Sergeant is filed under CR 5, which its numbers match, and its HP goes to 80. - **Shared key lists.** The creature key lists are exported and shared with the schema generator and its regression. - **Docs.** `writing-rulesets.md` (Opponents nobody wrote, creature sheets), implementation notes and the CHANGELOG, whose #6613 line is updated. ## 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 branch: `pnpm check`, `pnpm regression` (full suite), and `pnpm localization:check`. The new cases are in `scripts/regressions/game-ruleset-combat-creature-sheets.regression.ts` and the route lane, and every behaviour was mutation-tested. The temperament tests assert margins, not a bare "more": without any weighting, protective and reckless come out level. Local CodeRabbit sweeps over this work raised ten findings across six rounds, and nine were fixed: - a layer that narrows an enum invalidating creatures; - the doc naming its fill limits; - one read per catalog in the brief; - shared creature key lists; - loading the lists an invented sheet may choose from; - strikes in hand; - the Toll Sergeant's tier; - an entry's companion rows; - text fields in the brief. The last round raised one trivial suggestion, which was declined: caching the brief's catalog names across encounter starts. The catalog loader is uncached by design, so a package update never serves stale entries, and the fight route itself reads the same catalogs on every start. ### Manual verification notes Needs doing by a human: - Manually verify in the app: on the 5e package, let the Game Master invent a spellcasting enemy (not a boss) and confirm it only has spells from its own class, and that the combat log's adjustments say what was filled in and why. - Manually verify that an invented boss keeps exactly the spells the Game Master gave it, with nothing filled in. - Manually verify that an overdone invention (very high AC or HP) is pulled onto its tier, with the log saying so. ## 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: none of the pages this changes are carried on the `docs-i18n` branch (`writing-rulesets.md` and the implementation notes are not translated). ## UI evidence (if applicable) No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Game Masters can create invented enemies as ruleset-based character sheets, including abilities, skills, saves, fields, and catalog-backed choices. * Non-boss sheets receive eligible unspecified choices based on their ruleset and creature traits; boss sheets remain fully authored by the Game Master. * Sheet-based enemies are balanced to their threat tier, including health, defense, accuracy, saves, and damage. Wound-track damage is supported. * Sheet-based enemies remain opponents: they are defeated at zero health and do not roll against death. They do not replace characters with the same name, and each number appears only once. * **Bug Fixes** * Creatures using enum values narrowed by an active ruleset layer now use the field’s default instead of being rejected. <!-- 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:00 +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#7258
No description provided.