[PR #6368] [MERGED] feat(game): rulesets can resolve checks with a dice pool that counts successes #7152

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

📋 Pull Request Information

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

Base: staging ← Head: feat/rulesets-dice-pool


📝 Commits (10+)

  • 0b569f1 feat(game): add the dice-pool resolution kind to the shared schema and resolver
  • fb332f1 feat(packages): gate a dice-pool ruleset on Capability API 1.24 and ship the Gravewatch example
  • c5d5b15 test(game): pin the dice-pool kind, its tag attributes and the 1.24 install gate
  • 0f912a8 docs(game): document the dice-pool resolution kind for authors, players and packagers
  • 0ef3fad refactor(game): build the empty check result per call and drop a dead read
  • c5ca04e test(game): pin the pool difficulty ceiling on the sighted-pool path
  • 9354a94 feat(game): the client spells a pool ruleset's numbers as dice and says how it rolls
  • 6db5a84 test(game): pin the client's pool wording and its rules summary
  • 341abe7 docs(game): say what a pool result's dice card shows
  • 0f179c3 fix(game): the client's fallback check carries the tag's with, threshold and bonus

📊 Changes

37 files changed (+2470 additions, -132 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+25 -7)
📝 docs/development/optional-agent-packages.md (+22 -0)
➕ docs/examples/rulesets/gravewatch.json (+107 -0)
📝 docs/extending/ruleset.schema.json (+382 -0)
📝 docs/extending/writing-rulesets.md (+89 -8)
📝 docs/game/dice-and-skill-checks.md (+15 -1)
📝 packages/client/src/components/agents/RulesetImportReviewModal.tsx (+8 -5)
📝 packages/client/src/components/dice/AnimatedDiceRoll.tsx (+14 -1)
📝 packages/client/src/components/dice/AnimatedSkillCheckResult.tsx (+16 -8)
📝 packages/client/src/components/dice/dice.css (+13 -2)
📝 packages/client/src/components/game/GameRulesetSheet.tsx (+6 -6)
📝 packages/client/src/components/game/GameSetupRulesChooser.tsx (+10 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+9 -0)
📝 packages/client/src/components/rulesets/RulesetSheetEditor.tsx (+3 -6)
📝 packages/client/src/hooks/use-game.ts (+3 -0)
➕ packages/client/src/lib/ruleset-resolution.ts (+55 -0)
📝 packages/client/src/localization/locales/en.json (+14 -0)
📝 packages/server/src/routes/game.routes.ts (+10 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+10 -1)

...and 17 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 #6314 (slice 7b of the ruleset plan; it does not close the issue). Builds on #6362 (slice 8c, merged).

Why this change

  • A ruleset could only say "roll dice, add the sheet's numbers, meet a difficulty". Systems that throw a handful of dice and count the ones that succeed had no native home, which is a large share of what the community plays: the public Marinara-RPG-Extension runs four such systems today with extra agents and a model call per turn.
  • The plan asked for this kind to be specified with a community author. Nobody answered on #6314, so the vocabulary is taken from what that extension ships for its pool systems plus the plan's own list (pool size from two sheet ratings, target number, ones cancelling, botch, exploding or doubled tens). Review wanted from anyone who runs these systems: the closed vocabulary is cheap to extend now and expensive later.

What changed

  • A second resolution kind, dice-pool. The sheet is unchanged: everything it already computes for a check (ability through abilityModifier, the training tier's bonus, the free bonus) is, under this kind, the number of dice. A rating-based sheet is abilities read with identity and training tiers with flat bonuses, so there is no new sheet vocabulary and no new editor UI.
  • The kind declares the die, the pool's bounds, a per-die target (fixed, or a range the Game Master may set per check), and optional rules: faces that count twice, faces that roll again (chained, capped), faces that cancel a success, a botch (no die succeeded and a botch face shows), an exceptional result, and situational dice the Game Master may add or take. The difficulty ladder is in successes required, with an optional per-die target per step. Everything is cross-checked: faces must exist on the die, cancelling and botch faces sit below the lowest target, and a number of successes no roll could reach is refused.
  • The tag. dc is the successes required. Optional and bounded by the ruleset: threshold=, bonus=, and with="Ability" to roll a skill with another ability than its own. with= works for both kinds. A dice= or resolution= the model wrote from habit is ignored in a pool ruleset, and pool numbers are always the Engine's: nothing the model wrote is vouched for. Because of that, resolveSkillCheckTagsInContent is not idempotent for pool checks; generation only ever hands it a freshly written segment, and the doc comment now says so.
  • The sighted one-request dice pool holds d20s, so in a pool ruleset a check takes the blind branch, no slot is spent, and the roll still applies the tag's own with=, bonus= and threshold=. Roll placeholders resolve no sheet name under a pool ruleset, because a dice count is not a modifier.
  • The client prints "5 dice" where a summed ruleset prints "+5" (sheet editor, in-game sheet), summarises a pool ruleset's rules in the import review and the setup chooser from the definition's own numbers, and the dice card marks the dice that counted and says "3 successes, needed 2". The legacy dice="6d10" resolution="successes" threshold="6" tag (games with no ruleset) rolls exactly as before and gets the same card wording. The client's fallback check call now carries with, threshold and bonus too.
  • Prompt. The ruleset check line branches on the kind: the ladder in successes, "the engine rolls the pool from the character sheet and counts the successes", and one clause each for threshold=, bonus= and with= only where the ruleset declares them.
  • Capability API 1.24 gates the kind for packages.
  • Out of scope, said in the docs: take the highest die, pools compared to a stat, symbol dice, opposed pools, roll-under and open-ended percentile, sum pools with a wild die. Each would be its own kind. Re-rolls bought with a resource and automatic successes are not modelled; bonus= with a sheet command is the documented approximation.
  • Docs: the authoring guide (Resolution kinds), docs/game/dice-and-skill-checks.md, docs/development/optional-agent-packages.md, the plan, the generated schema, and a new original example, docs/examples/rulesets/gravewatch.json (d10 pool, adjustable target, ones cancel, tens roll again).
  • Regressions: game-ruleset-dice-pool (schema refusals, every rule with a scripted die, tag attributes and bounds, with= on both kinds, the prompt line, the sheet block, the 1.24 gate, the legacy successes path unchanged, the sighted pool falling back blind), ruleset-dice-pool-client (the wording and the rules summary on all three examples).

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, 324 of 324), and the new regressions. Four complete local CodeRabbit sweeps were run before opening (4, 3, 2 and 0 findings), and every finding was fixed: a blind roll under the sighted pool now applies the ask its record keeps, a saved record is written from what the roll applied (the clamped bonus dice, the ability only when it was swapped in), one ceiling for a check's difficulty is shared by the schema and the resolver, and a number of successes no roll could reach is refused. The e2e suite was checked by reading it: the only specs that mention skill checks assert the server-side tag text or sum results, none produces a successes result, and none mentions a ruleset. Playwright was not run locally.

The agent drove a scratch server on port 7820 with a fresh data folder and no model connected: imported the Gravewatch example, created a character on it, and opened the sheet editor, which showed "4 dice" on the ability, "7 dice" and "5 dice" on the trained skills, and all six training tiers. Through the check endpoint the client's fallback uses, a check with with, threshold 8 and bonus +2 rolled 7 dice at target 8 and the saved tag kept threshold, who, with and bonus; a plain check rolled 7 dice, one ten rolled again, one 1 cancelled, 3 successes.

Still to verify by hand:

  • Manually play a turn with a real model on a pool ruleset and look at the dice card: counted dice marked, "N successes, needed M", a pool of more than a dozen dice still fits. The agent could not bring the card up without a model, because the client only rolls the tags of a turn that arrives while the game is open.
  • Manually check the in-game sheet and the import review and setup chooser summaries for a pool ruleset.
  • Manually confirm a game with no ruleset still resolves the legacy resolution="successes" tag, and a 5e game is unchanged.
  • Manually verify light mode and a phone-width viewport for the wider "5 dice" wording in the ability tiles.

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, docs/game/dice-and-skill-checks.md, docs/development/optional-agent-packages.md, the plan, the new example and the generated schema. The [docs-i18n] follow-up is batched for the ruleset slices.

UI evidence (if applicable)

To be added by a human: a pool dice card, the sheet editor on a pool ruleset, and the rules summary in the setup chooser.

Summary by CodeRabbit

  • New Features

    • Added dice-pool game rulesets, where sheet values determine dice rolled and difficulty determines required successes.
    • Supports exploding, doubling, cancelling, botches, exceptional successes, and situational dice.
    • Game Masters can adjust thresholds, add or remove dice, and use alternate abilities for checks.
    • Added the Gravewatch example ruleset.
    • Dice results show successes, targets, and applicable rules.
    • Large dice pools now scroll instead of being clipped.
    • Existing games without a ruleset remain unchanged.
  • Documentation

    • Added authoring and gameplay guidance, including import requirements.

🔄 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/6368 **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/rulesets-dice-pool` --- ### 📝 Commits (10+) - [`0b569f1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b569f1c9371c687474973c5533b3f72c7ad8f63) feat(game): add the dice-pool resolution kind to the shared schema and resolver - [`fb332f1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fb332f179bd9f8af549f356b7cc58d44864fa21b) feat(packages): gate a dice-pool ruleset on Capability API 1.24 and ship the Gravewatch example - [`c5d5b15`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c5d5b15f0842f692aba5930839a1cffbf99d4fae) test(game): pin the dice-pool kind, its tag attributes and the 1.24 install gate - [`0f912a8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0f912a89562f78b04f2b0fce481fbccf29c740ba) docs(game): document the dice-pool resolution kind for authors, players and packagers - [`0ef3fad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ef3fadc62a23e862087411fdc0edc250320c787) refactor(game): build the empty check result per call and drop a dead read - [`c5ca04e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c5ca04e201a374bca1e10f84fefc7d2b4f190089) test(game): pin the pool difficulty ceiling on the sighted-pool path - [`9354a94`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9354a94de15f609b6f2c807045c3e5259065ae4f) feat(game): the client spells a pool ruleset's numbers as dice and says how it rolls - [`6db5a84`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6db5a84abe8f75d877fc756b8a0ed37f837b41f4) test(game): pin the client's pool wording and its rules summary - [`341abe7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/341abe717a519010da5a86789e41f3d8b7789a5e) docs(game): say what a pool result's dice card shows - [`0f179c3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0f179c337b19e90b51f793f7e061bdd9a44a722b) fix(game): the client's fallback check carries the tag's with, threshold and bonus ### 📊 Changes **37 files changed** (+2470 additions, -132 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+25 -7) 📝 `docs/development/optional-agent-packages.md` (+22 -0) ➕ `docs/examples/rulesets/gravewatch.json` (+107 -0) 📝 `docs/extending/ruleset.schema.json` (+382 -0) 📝 `docs/extending/writing-rulesets.md` (+89 -8) 📝 `docs/game/dice-and-skill-checks.md` (+15 -1) 📝 `packages/client/src/components/agents/RulesetImportReviewModal.tsx` (+8 -5) 📝 `packages/client/src/components/dice/AnimatedDiceRoll.tsx` (+14 -1) 📝 `packages/client/src/components/dice/AnimatedSkillCheckResult.tsx` (+16 -8) 📝 `packages/client/src/components/dice/dice.css` (+13 -2) 📝 `packages/client/src/components/game/GameRulesetSheet.tsx` (+6 -6) 📝 `packages/client/src/components/game/GameSetupRulesChooser.tsx` (+10 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+9 -0) 📝 `packages/client/src/components/rulesets/RulesetSheetEditor.tsx` (+3 -6) 📝 `packages/client/src/hooks/use-game.ts` (+3 -0) ➕ `packages/client/src/lib/ruleset-resolution.ts` (+55 -0) 📝 `packages/client/src/localization/locales/en.json` (+14 -0) 📝 `packages/server/src/routes/game.routes.ts` (+10 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+10 -1) _...and 17 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 #6314 (slice 7b of the ruleset plan; it does not close the issue). Builds on #6362 (slice 8c, merged). ## Why this change - A ruleset could only say "roll dice, add the sheet's numbers, meet a difficulty". Systems that throw a handful of dice and count the ones that succeed had no native home, which is a large share of what the community plays: the public Marinara-RPG-Extension runs four such systems today with extra agents and a model call per turn. - The plan asked for this kind to be specified with a community author. Nobody answered on #6314, so the vocabulary is taken from what that extension ships for its pool systems plus the plan's own list (pool size from two sheet ratings, target number, ones cancelling, botch, exploding or doubled tens). **Review wanted** from anyone who runs these systems: the closed vocabulary is cheap to extend now and expensive later. ## What changed - **A second resolution kind, `dice-pool`.** The sheet is unchanged: everything it already computes for a check (ability through `abilityModifier`, the training tier's bonus, the free bonus) is, under this kind, the number of dice. A rating-based sheet is abilities read with `identity` and training tiers with `flat` bonuses, so there is no new sheet vocabulary and no new editor UI. - **The kind declares** the die, the pool's bounds, a per-die target (fixed, or a range the Game Master may set per check), and optional rules: faces that count twice, faces that roll again (chained, capped), faces that cancel a success, a botch (no die succeeded and a botch face shows), an exceptional result, and situational dice the Game Master may add or take. The difficulty ladder is in successes required, with an optional per-die target per step. Everything is cross-checked: faces must exist on the die, cancelling and botch faces sit below the lowest target, and a number of successes no roll could reach is refused. - **The tag.** `dc` is the successes required. Optional and bounded by the ruleset: `threshold=`, `bonus=`, and `with="Ability"` to roll a skill with another ability than its own. `with=` works for both kinds. A `dice=` or `resolution=` the model wrote from habit is ignored in a pool ruleset, and pool numbers are always the Engine's: nothing the model wrote is vouched for. Because of that, `resolveSkillCheckTagsInContent` is not idempotent for pool checks; generation only ever hands it a freshly written segment, and the doc comment now says so. - **The sighted one-request dice pool holds d20s**, so in a pool ruleset a check takes the blind branch, no slot is spent, and the roll still applies the tag's own `with=`, `bonus=` and `threshold=`. Roll placeholders resolve no sheet name under a pool ruleset, because a dice count is not a modifier. - **The client** prints "5 dice" where a summed ruleset prints "+5" (sheet editor, in-game sheet), summarises a pool ruleset's rules in the import review and the setup chooser from the definition's own numbers, and the dice card marks the dice that counted and says "3 successes, needed 2". The legacy `dice="6d10" resolution="successes" threshold="6"` tag (games with no ruleset) rolls exactly as before and gets the same card wording. The client's fallback check call now carries `with`, `threshold` and `bonus` too. - **Prompt.** The ruleset check line branches on the kind: the ladder in successes, "the engine rolls the pool from the character sheet and counts the successes", and one clause each for `threshold=`, `bonus=` and `with=` only where the ruleset declares them. - **Capability API 1.24** gates the kind for packages. - **Out of scope, said in the docs:** take the highest die, pools compared to a stat, symbol dice, opposed pools, roll-under and open-ended percentile, sum pools with a wild die. Each would be its own kind. Re-rolls bought with a resource and automatic successes are not modelled; `bonus=` with a sheet command is the documented approximation. - Docs: the authoring guide (Resolution kinds), `docs/game/dice-and-skill-checks.md`, `docs/development/optional-agent-packages.md`, the plan, the generated schema, and a new original example, `docs/examples/rulesets/gravewatch.json` (d10 pool, adjustable target, ones cancel, tens roll again). - Regressions: `game-ruleset-dice-pool` (schema refusals, every rule with a scripted die, tag attributes and bounds, `with=` on both kinds, the prompt line, the sheet block, the 1.24 gate, the legacy successes path unchanged, the sighted pool falling back blind), `ruleset-dice-pool-client` (the wording and the rules summary on all three examples). ## 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`, 324 of 324), and the new regressions. Four complete local CodeRabbit sweeps were run before opening (4, 3, 2 and 0 findings), and every finding was fixed: a blind roll under the sighted pool now applies the ask its record keeps, a saved record is written from what the roll applied (the clamped bonus dice, the ability only when it was swapped in), one ceiling for a check's difficulty is shared by the schema and the resolver, and a number of successes no roll could reach is refused. The e2e suite was checked by reading it: the only specs that mention skill checks assert the server-side tag text or sum results, none produces a successes result, and none mentions a ruleset. Playwright was not run locally. The agent drove a scratch server on port 7820 with a fresh data folder and no model connected: imported the Gravewatch example, created a character on it, and opened the sheet editor, which showed "4 dice" on the ability, "7 dice" and "5 dice" on the trained skills, and all six training tiers. Through the check endpoint the client's fallback uses, a check with `with`, `threshold` 8 and `bonus` +2 rolled 7 dice at target 8 and the saved tag kept `threshold`, `who`, `with` and `bonus`; a plain check rolled 7 dice, one ten rolled again, one 1 cancelled, 3 successes. Still to verify by hand: - Manually play a turn with a real model on a pool ruleset and look at the dice card: counted dice marked, "N successes, needed M", a pool of more than a dozen dice still fits. The agent could not bring the card up without a model, because the client only rolls the tags of a turn that arrives while the game is open. - Manually check the in-game sheet and the import review and setup chooser summaries for a pool ruleset. - Manually confirm a game with no ruleset still resolves the legacy `resolution="successes"` tag, and a 5e game is unchanged. - Manually verify light mode and a phone-width viewport for the wider "5 dice" wording in the ability tiles. ## 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`, `docs/game/dice-and-skill-checks.md`, `docs/development/optional-agent-packages.md`, the plan, the new example and the generated schema. The `[docs-i18n]` follow-up is batched for the ruleset slices. ## UI evidence (if applicable) To be added by a human: a pool dice card, the sheet editor on a pool ruleset, and the rules summary in the setup chooser. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added dice-pool game rulesets, where sheet values determine dice rolled and difficulty determines required successes. - Supports exploding, doubling, cancelling, botches, exceptional successes, and situational dice. - Game Masters can adjust thresholds, add or remove dice, and use alternate abilities for checks. - Added the Gravewatch example ruleset. - Dice results show successes, targets, and applicable rules. - Large dice pools now scroll instead of being clipped. - Existing games without a ruleset remain unchanged. - **Documentation** - Added authoring and gameplay guidance, including import requirements. <!-- 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: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#7152
No description provided.