[PR #6323] [MERGED] feat(game): roll checks through a pinned ruleset (rulesets slice 2) #7138

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

📋 Pull Request Information

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

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


📝 Commits (3)

  • e431112 feat(game): roll checks through a pinned ruleset's dice-sum kind
  • f6abd7a fix(game): address ruleset check review findings
  • b0505c1 docs(game): say that the player keeps a name they share with a party member

📊 Changes

16 files changed (+1383 additions, -51 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+13 -2)
📝 docs/game/dice-and-skill-checks.md (+26 -11)
📝 packages/client/src/components/game/GameSurface.tsx (+1 -0)
📝 packages/client/src/hooks/use-game.ts (+1 -0)
📝 packages/server/src/routes/game.routes.ts (+7 -0)
📝 packages/server/src/routes/generate.routes.ts (+19 -1)
📝 packages/server/src/services/game/gm-prompts.ts (+48 -5)
📝 packages/server/src/services/game/one-request-dice.ts (+36 -0)
📝 packages/server/src/services/game/skill-check-resolution.service.ts (+309 -31)
➕ packages/shared/src/features/rulesets/sheet-math.ts (+316 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/game.ts (+8 -0)
📝 packages/shared/src/utils/skill-check-format.ts (+4 -1)
📝 packages/shared/src/utils/skill-check-tag.ts (+8 -0)
➕ scripts/regressions/game-ruleset-checks.regression.ts (+585 -0)

📄 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 2 of 7; it does not close the issue). Builds on #6315, which is merged.

Why this change

  • A game that pinned a ruleset still rolled every check with Marinara's own d20 arithmetic. This makes the pin mean something: checks, saves and ability checks come from the ruleset's dice and the party's ruleset sheets.
  • It is testable with no UI at all, which is the cheapest place to find out the resolver is wrong.

What changed

  • Resolver behind the existing context. SkillCheckModifierContext gains an optional ruleset. Every caller already goes through resolveSkillCheckWithContext, so the endpoint, generation post-processing, one-request dice and the sighted pool all reach it with no new call sites.
  • Shared sheet arithmetic (packages/shared/src/features/rulesets/sheet-math.ts): tolerant sheet evaluation, name matching for skills, saves and abilities ("Dexterity save", dex_save, "DEX saving throw"), and the dice-sum roll with advantage, disadvantage and the ruleset's natural-result policy. Nothing in it throws.
  • who= on [skill_check:] checks a party member. It rides SkillCheckResult.who, set only by the ruleset resolver, so legacy records keep their bytes. A name with no sheet rolls unmodified dice.
  • Finished-looking tags are audited against the sheet in ruleset games: a modifier, die count, kept die or natural result the ruleset would not have produced sends the tag back to be rolled. A rulesetPinned hint from the generate route means a legacy game still never loads the context for a finished tag.
  • A pin the install cannot honour fails closed: the context refuses to load and the existing failure path saves the checks sparse.
  • GM reminder: the ruleset's check guidance and difficulty ladder replace the built-in check lines, the line teaching other notations is dropped, and roll_dice is no longer offered as a way to record a check. With no ruleset the reminder is byte-identical.
  • Roll placeholders resolve ruleset abilities, skills, saves and PROF; unknown names stay refused.
  • The sighted pool serves a ruleset's checks only when the ruleset rolls a single d20. It spends one value when the ruleset has no advantage, keeps who= on an overflowed check, and is skipped for other dice so no pool value is recorded against a roll it did not decide.
  • A turn never fails on an unavailable ruleset: the prompt-time sheet-name lookup for one-request dice is guarded, and a finished-looking check that can be neither vouched for nor rolled is saved without its claimed numbers.
  • Regression: scripts/regressions/game-ruleset-checks.regression.ts.

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) and the regressions game-ruleset-checks, gm-skill-check-resolution, the four one-request-dice-* lanes and prompt (all pass).

Local CodeRabbit review ran until it returned no findings. Declined along the way, with reasons: gating rulesetPinned on the pin resolving (an unavailable pin must fail closed, not fall back to the built-in arithmetic), and wrapping loadRulesetRegistry() at the call site (it already never throws).

Still to verify by hand:

  • Manually verify a legacy game still rolls a check with a natural 20 as a critical success.
  • Manually hand-enter a rulesetSheet and a gameRuleset pin through Edit Spoilers JSON and watch a real check banner use the sheet modifier.

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/game/dice-and-skill-checks.md, the plan. The [docs-i18n] follow-up is batched for the ruleset slices.

UI evidence (if applicable)

None. No UI in this slice.

Summary by CodeRabbit

  • New Features

    • Game Mode skill checks support pinned rulesets with custom dice, difficulty ladders, character sheets, advantage/disadvantage, and natural-roll rules.
    • Game Masters can target checks to a specific party member using who="Name".
    • Ruleset-aware placeholders support skills, saving throws, abilities, and proficiency bonuses.
    • Results preserve the selected party member and validate reported rolls against the applicable ruleset.
    • Game Masters receive ruleset-specific guidance and supported check formats.
  • Bug Fixes

    • Invalid or unavailable rulesets now fail safely without interrupting the game turn.
    • Games without a pinned ruleset retain their existing behavior.

🔄 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/6323 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/18/2026 **Status:** ✅ Merged **Merged:** 9/18/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/rulesets-dice-sum` --- ### 📝 Commits (3) - [`e431112`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e431112816ba8983687a50703f91e267ab181728) feat(game): roll checks through a pinned ruleset's dice-sum kind - [`f6abd7a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f6abd7ac7f58103d5ec9a79690f13fb156487f65) fix(game): address ruleset check review findings - [`b0505c1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b0505c161a0c450a7dc45141c189477bee2757c1) docs(game): say that the player keeps a name they share with a party member ### 📊 Changes **16 files changed** (+1383 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+13 -2) 📝 `docs/game/dice-and-skill-checks.md` (+26 -11) 📝 `packages/client/src/components/game/GameSurface.tsx` (+1 -0) 📝 `packages/client/src/hooks/use-game.ts` (+1 -0) 📝 `packages/server/src/routes/game.routes.ts` (+7 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+19 -1) 📝 `packages/server/src/services/game/gm-prompts.ts` (+48 -5) 📝 `packages/server/src/services/game/one-request-dice.ts` (+36 -0) 📝 `packages/server/src/services/game/skill-check-resolution.service.ts` (+309 -31) ➕ `packages/shared/src/features/rulesets/sheet-math.ts` (+316 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/game.ts` (+8 -0) 📝 `packages/shared/src/utils/skill-check-format.ts` (+4 -1) 📝 `packages/shared/src/utils/skill-check-tag.ts` (+8 -0) ➕ `scripts/regressions/game-ruleset-checks.regression.ts` (+585 -0) </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 2 of 7; it does not close the issue). Builds on #6315, which is merged. ## Why this change - A game that pinned a ruleset still rolled every check with Marinara's own d20 arithmetic. This makes the pin mean something: checks, saves and ability checks come from the ruleset's dice and the party's ruleset sheets. - It is testable with no UI at all, which is the cheapest place to find out the resolver is wrong. ## What changed - **Resolver behind the existing context.** `SkillCheckModifierContext` gains an optional `ruleset`. Every caller already goes through `resolveSkillCheckWithContext`, so the endpoint, generation post-processing, one-request dice and the sighted pool all reach it with no new call sites. - **Shared sheet arithmetic** (`packages/shared/src/features/rulesets/sheet-math.ts`): tolerant sheet evaluation, name matching for skills, saves and abilities ("Dexterity save", `dex_save`, "DEX saving throw"), and the `dice-sum` roll with advantage, disadvantage and the ruleset's natural-result policy. Nothing in it throws. - **`who=`** on `[skill_check:]` checks a party member. It rides `SkillCheckResult.who`, set only by the ruleset resolver, so legacy records keep their bytes. A name with no sheet rolls unmodified dice. - **Finished-looking tags are audited against the sheet** in ruleset games: a modifier, die count, kept die or natural result the ruleset would not have produced sends the tag back to be rolled. A `rulesetPinned` hint from the generate route means a legacy game still never loads the context for a finished tag. - **A pin the install cannot honour fails closed**: the context refuses to load and the existing failure path saves the checks sparse. - **GM reminder**: the ruleset's check guidance and difficulty ladder replace the built-in check lines, the line teaching other notations is dropped, and `roll_dice` is no longer offered as a way to record a check. With no ruleset the reminder is byte-identical. - **Roll placeholders** resolve ruleset abilities, skills, saves and `PROF`; unknown names stay refused. - **The sighted pool** serves a ruleset's checks only when the ruleset rolls a single d20. It spends one value when the ruleset has no advantage, keeps `who=` on an overflowed check, and is skipped for other dice so no pool value is recorded against a roll it did not decide. - **A turn never fails on an unavailable ruleset**: the prompt-time sheet-name lookup for one-request dice is guarded, and a finished-looking check that can be neither vouched for nor rolled is saved without its claimed numbers. - **Regression**: `scripts/regressions/game-ruleset-checks.regression.ts`. ## 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) and the regressions `game-ruleset-checks`, `gm-skill-check-resolution`, the four `one-request-dice-*` lanes and `prompt` (all pass). Local CodeRabbit review ran until it returned no findings. Declined along the way, with reasons: gating `rulesetPinned` on the pin resolving (an unavailable pin must fail closed, not fall back to the built-in arithmetic), and wrapping `loadRulesetRegistry()` at the call site (it already never throws). Still to verify by hand: - Manually verify a legacy game still rolls a check with a natural 20 as a critical success. - Manually hand-enter a `rulesetSheet` and a `gameRuleset` pin through **Edit Spoilers** JSON and watch a real check banner use the sheet modifier. ## 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/game/dice-and-skill-checks.md`, the plan. The `[docs-i18n]` follow-up is batched for the ruleset slices. ## UI evidence (if applicable) None. No UI in this slice. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Game Mode skill checks support pinned rulesets with custom dice, difficulty ladders, character sheets, advantage/disadvantage, and natural-roll rules. - Game Masters can target checks to a specific party member using `who="Name"`. - Ruleset-aware placeholders support skills, saving throws, abilities, and proficiency bonuses. - Results preserve the selected party member and validate reported rolls against the applicable ruleset. - Game Masters receive ruleset-specific guidance and supported check formats. - **Bug Fixes** - Invalid or unavailable rulesets now fail safely without interrupting the game turn. - Games without a pinned ruleset retain their existing behavior. <!-- 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:16:52 +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#7138
No description provided.