[PR #6669] [MERGED] feat(game): re-throws, spend limits off the sheet, and sheet modifiers on checks #7280

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-rerolls-spends


📝 Commits (4)

  • 3dc8ffc feat(game): re-throws, spend limits off the sheet, and sheet modifiers on checks
  • 268d4c2 fix(game): read a saved check's re-throw back into its result
  • dc4b2a6 Merge remote-tracking branch 'origin/staging' into feat/ruleset-rerolls-spends
  • 3d28541 Merge remote-tracking branch 'origin/staging' into feat/ruleset-rerolls-spends

📊 Changes

37 files changed (+1435 additions, -52 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+36 -0)
📝 docs/examples/rulesets/ember-roads.json (+19 -0)
📝 docs/examples/rulesets/gravewatch.json (+2 -1)
📝 docs/extending/ruleset.schema.json (+257 -4)
📝 docs/extending/writing-rulesets.md (+26 -6)
📝 docs/game/dice-and-skill-checks.md (+3 -1)
📝 packages/client/src/components/dice/AnimatedSkillCheckResult.tsx (+14 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+1 -0)
📝 packages/client/src/hooks/use-game.ts (+1 -0)
📝 packages/client/src/lib/ruleset-resolution.ts (+8 -0)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/server/src/routes/game.routes.ts (+3 -1)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+15 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+45 -1)
📝 packages/server/src/services/game/one-request-dice.ts (+1 -0)
📝 packages/server/src/services/game/skill-check-resolution.service.ts (+105 -7)
📝 packages/shared/src/features/rulesets/sheet-math.ts (+30 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+8 -1)
📝 packages/shared/src/schemas/ruleset.schema.ts (+73 -9)

...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

Closes #6652

Why this change

The author of Marinara-RPG-Extension wrote two of their shipped tabletop systems as ruleset.json files. Three everyday rules about what a check may buy still had to be left to the Game Master, who forgets them or gets the numbers wrong:

  • No free re-throw, and none a player could buy. Many systems throw failed dice again, either as a standing rule the situation grants (a careful, unhurried action) or bought with a point. Only a catalog entry the character picked could do it.
  • A spend's limit was a fixed number, and there were at most two spends. A rule that caps a purchase at "attribute plus skill" changes on every check, and a system with three pools to spend from could not say so.
  • Nothing on the sheet reached the dice by itself. An armour penalty on every agility roll, encumbrance, a blanket curse: each relied on the Game Master remembering bonus= on every check.

This is slice 2 of the series in the plan doc (§ Gaps a ruleset author found). Slice 1 was #6663.

What changed

Capability API 1.38 (file keys: resolution.reroll, resolution.adjust, a spend's reroll, a perCheck that is a value reference or "pool", and up to four spends). None of it names one game's words.

  • Standing re-throws. resolution.reroll lists up to six, each { id, upTo, mode } on a pool ruleset. The Game Master names one with reroll="id" (matched without case; an unknown name is ignored), and none is thrown unasked. upTo is held below the die's sides, and until stops at the Engine's existing hundred re-throws per check. The record says reroll="id" only when that re-throw was the one thrown and it threw something.
  • A spend may buy a re-throw, beside successes and dice. It is bought once however many purchases the check makes, since a die thrown again twice is still one re-throw.
  • One re-throw per roll. Where a standing re-throw and one bought (by a spend or an entry) would both apply, the one that reaches more faces is thrown, and until beats once where they reach the same. The issue did not say what happens when two apply. Throwing the same dice again twice over is not a rule the format needs, and the wider one is never worse for the player.
  • A spend's limit off the sheet. perCheck may be a number, a value reference, or "pool": the check's own dice, meaning the sheet's number for it before a wound, bonus dice or a modifier. So a hurt character may still buy as many as their rating gives. It is worked out for whoever rolls, rounded down and held between 0 and 100, and a limit of nothing buys and pays nothing. Up to four spends, still one per pool.
  • Modifiers off the sheet. resolution.adjust (up to eight, both kinds) adds a value off the sheet to every check that rolls with one of its abilities, or to every check when it names none: a skill or save through its own ability or with=, an ability check, or a pair that includes it. It goes where the wound penalty goes (dice on a pool under the same floor, a flat number inside a sum's modifier). The record writes adjust="-2" and reads it back, the dice card has a line for it, and a summed record the Game Master wrote itself is only kept when its modifier includes it. A stranger gets none, the same way they get no modifier.
  • Reminder. reroll= is offered, with each id and its faces, only where the ruleset has one. A spend's line says a re-throw it buys and where its limit comes from ("as many times per check as the check has dice", "as the sheet's Nerve"). Differs from the issue on purpose: the issue asked for the resolved cap, but one reminder serves every character a check may name with who=, and each has their own number, so the line says where it comes from instead.
  • Every path carries reroll=: the generated-turn resolver, the sparse rewrite of an ask it could not roll, the sighted pool's bound request, the one-request branch arm, the skill-check endpoint and the client fallback that calls it.
  • Client: the dice card's modifier line (reusing the wound-penalty line's skill-check-roll-meta style) and a rules-summary line per standing re-throw in the import review and sheet screens. New strings are localized in en.json.
  • Install gate: each new key needs 1.38, and two spends with a number for a limit (everything a file could say before) still need nothing new.
  • Docs: author guide (docs/extending/writing-rulesets.md, including its out-of-scope paragraph, which said a spend could never buy a re-roll), player page (docs/game/dice-and-skill-checks.md), the regenerated JSON Schema (its spend refinement now accepts a re-throw), the plan doc's slice 2 notes, CHANGELOG. Gravewatch ships a careful re-throw (six or less, once); Ember Roads ships a burden field, turned negative by a derived value and taken off every Brawn roll.

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

Run by the agent on the branch (based on current staging), all exit 0: pnpm check, pnpm localization:check, pnpm regression:node (378/378), pnpm ruleset:schema (no diff after regeneration). Local CodeRabbit, two passes: the first found two, both fixed (the reminder fell back to "a number on the sheet" for a limit read through a field that names an ability; the standing re-throw repeated the bought one's shape instead of reusing it), and the second pass on the full branch found nothing.

  • New lane scripts/regressions/game-ruleset-rerolls-spends.regression.ts covers the report's own numbers through the roller (1, 1, 9, 3 with sevens and under thrown again), every rule through the resolver, the sparse rewrite, the sighted pool, the branch arm and the real /api/game/skill-check route, the reminder, every import refusal and the 1.38 gate. Twenty-seven deliberate breaks of the new code were each caught; one more (dropping the "a limit of nothing buys nothing" guard) is equivalent, because the sheet op already refuses a spend of zero.
  • Existing lanes that test an older gate on the shipped examples now also strip the 1.38 keys, the JSON Schema lane pins the spend refinement, and the client lane expects Gravewatch's new re-throw line.

Still to verify by hand (not done by the agent):

  • In a Game Mode game on Gravewatch, have the Game Master write [skill_check: skill="Ward" dc="2" reroll="careful"]: confirm the dice card and the saved check show rerolled= and reroll="careful" when a die was thrown again, and neither when none was.
  • In a game on Ember Roads, set a character's Burden to 2 and roll Scrap: confirm the dice card shows "From the sheet: -2 to this roll", in light and dark mode and at mobile width; roll Sway and confirm the line is absent.
  • Open the ruleset import review for Gravewatch: confirm the rules summary lists the careful re-throw.
  • In a game on Gravewatch, confirm the reminder in the prompt inspector offers reroll="id": careful (dice showing 6 or less, once).
  • Import a pool ruleset with "spend": [{ "pool": "...", "amount": 1, "successes": 1, "perCheck": "pool" }] and spend more than the check has dice: confirm only as many successes as dice are bought and paid for.

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: docs/extending/writing-rulesets.md (not carried by docs-i18n), docs/game/dice-and-skill-checks.md (carried by docs-i18n), docs/extending/ruleset.schema.json, docs/examples/rulesets/gravewatch.json, docs/examples/rulesets/ember-roads.json, docs/development/game-rulesets-and-sheets-implementation.md (internal plan), CHANGELOG.md. Translations are batched into one later pass by the maintainer's standing decision, so no per-PR [docs-i18n] issue is opened here.

UI evidence (if applicable)

None captured. The client changes are one optional line on the dice card, reusing the wound-penalty line's existing style, and new lines in the rules summary; see the manual steps above.

Summary by CodeRabbit

  • New Features

    • Rulesets can define free or resource-funded rerolls, rerolling qualifying dice once or repeatedly until they exceed a threshold. When multiple reroll options apply, only one is used.
    • Checks can offer up to four resource-spending options, with purchase limits based on a fixed amount, the dice pool, or a character-sheet value.
    • Character-sheet values can adjust applicable rolls, and adjustments appear in dice results.
    • Skill-check tags can specify a reroll option.
  • Documentation

    • Added ruleset guidance and examples for rerolls, spending limits, and sheet-based roll adjustments.
    • Capability API 1.38 is required to use these features.

🔄 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/6669 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/25/2026 **Status:** ✅ Merged **Merged:** 9/25/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-rerolls-spends` --- ### 📝 Commits (4) - [`3dc8ffc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3dc8ffc3a91edde911cca8573eb4263762347e5f) feat(game): re-throws, spend limits off the sheet, and sheet modifiers on checks - [`268d4c2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/268d4c26693f0f53316ec5d66c356310d592dbdc) fix(game): read a saved check's re-throw back into its result - [`dc4b2a6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dc4b2a61751e07973803329e6d143bf0b5e854c0) Merge remote-tracking branch 'origin/staging' into feat/ruleset-rerolls-spends - [`3d28541`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d2854134626aead9cbb342781f77c53c36cb6c6) Merge remote-tracking branch 'origin/staging' into feat/ruleset-rerolls-spends ### 📊 Changes **37 files changed** (+1435 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+36 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+19 -0) 📝 `docs/examples/rulesets/gravewatch.json` (+2 -1) 📝 `docs/extending/ruleset.schema.json` (+257 -4) 📝 `docs/extending/writing-rulesets.md` (+26 -6) 📝 `docs/game/dice-and-skill-checks.md` (+3 -1) 📝 `packages/client/src/components/dice/AnimatedSkillCheckResult.tsx` (+14 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+1 -0) 📝 `packages/client/src/hooks/use-game.ts` (+1 -0) 📝 `packages/client/src/lib/ruleset-resolution.ts` (+8 -0) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/server/src/routes/game.routes.ts` (+3 -1) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+15 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+45 -1) 📝 `packages/server/src/services/game/one-request-dice.ts` (+1 -0) 📝 `packages/server/src/services/game/skill-check-resolution.service.ts` (+105 -7) 📝 `packages/shared/src/features/rulesets/sheet-math.ts` (+30 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+8 -1) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+73 -9) _...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 Closes #6652 ## Why this change The author of [Marinara-RPG-Extension](https://github.com/Kenhito/Marinara-RPG-Extension) wrote two of their shipped tabletop systems as `ruleset.json` files. Three everyday rules about what a check may buy still had to be left to the Game Master, who forgets them or gets the numbers wrong: - **No free re-throw, and none a player could buy.** Many systems throw failed dice again, either as a standing rule the situation grants (a careful, unhurried action) or bought with a point. Only a catalog entry the character picked could do it. - **A spend's limit was a fixed number, and there were at most two spends.** A rule that caps a purchase at "attribute plus skill" changes on every check, and a system with three pools to spend from could not say so. - **Nothing on the sheet reached the dice by itself.** An armour penalty on every agility roll, encumbrance, a blanket curse: each relied on the Game Master remembering `bonus=` on every check. This is slice 2 of the series in the plan doc (§ Gaps a ruleset author found). Slice 1 was #6663. ## What changed Capability API **1.38** (file keys: `resolution.reroll`, `resolution.adjust`, a spend's `reroll`, a `perCheck` that is a value reference or `"pool"`, and up to four spends). None of it names one game's words. - **Standing re-throws.** `resolution.reroll` lists up to six, each `{ id, upTo, mode }` on a pool ruleset. The Game Master names one with `reroll="id"` (matched without case; an unknown name is ignored), and none is thrown unasked. `upTo` is held below the die's sides, and `until` stops at the Engine's existing hundred re-throws per check. The record says `reroll="id"` only when that re-throw was the one thrown and it threw something. - **A spend may buy a re-throw**, beside successes and dice. It is bought once however many purchases the check makes, since a die thrown again twice is still one re-throw. - **One re-throw per roll.** Where a standing re-throw and one bought (by a spend or an entry) would both apply, the one that reaches more faces is thrown, and `until` beats `once` where they reach the same. The issue did not say what happens when two apply. Throwing the same dice again twice over is not a rule the format needs, and the wider one is never worse for the player. - **A spend's limit off the sheet.** `perCheck` may be a number, a value reference, or `"pool"`: the check's own dice, meaning the sheet's number for it before a wound, bonus dice or a modifier. So a hurt character may still buy as many as their rating gives. It is worked out for whoever rolls, rounded down and held between 0 and 100, and a limit of nothing buys and pays nothing. Up to four spends, still one per pool. - **Modifiers off the sheet.** `resolution.adjust` (up to eight, both kinds) adds a value off the sheet to every check that rolls with one of its `abilities`, or to every check when it names none: a skill or save through its own ability or `with=`, an ability check, or a pair that includes it. It goes where the wound penalty goes (dice on a pool under the same floor, a flat number inside a sum's modifier). The record writes `adjust="-2"` and reads it back, the dice card has a line for it, and a summed record the Game Master wrote itself is only kept when its modifier includes it. A stranger gets none, the same way they get no modifier. - **Reminder.** `reroll=` is offered, with each id and its faces, only where the ruleset has one. A spend's line says a re-throw it buys and where its limit comes from ("as many times per check as the check has dice", "as the sheet's Nerve"). **Differs from the issue on purpose:** the issue asked for the resolved cap, but one reminder serves every character a check may name with `who=`, and each has their own number, so the line says where it comes from instead. - **Every path carries `reroll=`:** the generated-turn resolver, the sparse rewrite of an ask it could not roll, the sighted pool's bound request, the one-request branch arm, the skill-check endpoint and the client fallback that calls it. - **Client:** the dice card's modifier line (reusing the wound-penalty line's `skill-check-roll-meta` style) and a rules-summary line per standing re-throw in the import review and sheet screens. New strings are localized in `en.json`. - **Install gate:** each new key needs 1.38, and two spends with a number for a limit (everything a file could say before) still need nothing new. - **Docs:** author guide (`docs/extending/writing-rulesets.md`, including its out-of-scope paragraph, which said a spend could never buy a re-roll), player page (`docs/game/dice-and-skill-checks.md`), the regenerated JSON Schema (its spend refinement now accepts a re-throw), the plan doc's slice 2 notes, CHANGELOG. **Gravewatch** ships a `careful` re-throw (six or less, once); **Ember Roads** ships a `burden` field, turned negative by a derived value and taken off every Brawn roll. ## 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 Run by the agent on the branch (based on current `staging`), all exit 0: `pnpm check`, `pnpm localization:check`, `pnpm regression:node` (378/378), `pnpm ruleset:schema` (no diff after regeneration). Local CodeRabbit, two passes: the first found two, both fixed (the reminder fell back to "a number on the sheet" for a limit read through a field that names an ability; the standing re-throw repeated the bought one's shape instead of reusing it), and the second pass on the full branch found nothing. - New lane `scripts/regressions/game-ruleset-rerolls-spends.regression.ts` covers the report's own numbers through the roller (1, 1, 9, 3 with sevens and under thrown again), every rule through the resolver, the sparse rewrite, the sighted pool, the branch arm and the real `/api/game/skill-check` route, the reminder, every import refusal and the 1.38 gate. Twenty-seven deliberate breaks of the new code were each caught; one more (dropping the "a limit of nothing buys nothing" guard) is equivalent, because the sheet op already refuses a spend of zero. - Existing lanes that test an older gate on the shipped examples now also strip the 1.38 keys, the JSON Schema lane pins the spend refinement, and the client lane expects Gravewatch's new re-throw line. Still to verify by hand (not done by the agent): - In a Game Mode game on Gravewatch, have the Game Master write `[skill_check: skill="Ward" dc="2" reroll="careful"]`: confirm the dice card and the saved check show `rerolled=` and `reroll="careful"` when a die was thrown again, and neither when none was. - In a game on Ember Roads, set a character's Burden to 2 and roll Scrap: confirm the dice card shows "From the sheet: -2 to this roll", in light and dark mode and at mobile width; roll Sway and confirm the line is absent. - Open the ruleset import review for Gravewatch: confirm the rules summary lists the `careful` re-throw. - In a game on Gravewatch, confirm the reminder in the prompt inspector offers `reroll="id": careful (dice showing 6 or less, once)`. - Import a pool ruleset with `"spend": [{ "pool": "...", "amount": 1, "successes": 1, "perCheck": "pool" }]` and spend more than the check has dice: confirm only as many successes as dice are bought and paid for. ## 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: `docs/extending/writing-rulesets.md` (not carried by `docs-i18n`), `docs/game/dice-and-skill-checks.md` (carried by `docs-i18n`), `docs/extending/ruleset.schema.json`, `docs/examples/rulesets/gravewatch.json`, `docs/examples/rulesets/ember-roads.json`, `docs/development/game-rulesets-and-sheets-implementation.md` (internal plan), `CHANGELOG.md`. Translations are batched into one later pass by the maintainer's standing decision, so no per-PR `[docs-i18n]` issue is opened here. ## UI evidence (if applicable) None captured. The client changes are one optional line on the dice card, reusing the wound-penalty line's existing style, and new lines in the rules summary; see the manual steps above. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Rulesets can define free or resource-funded rerolls, rerolling qualifying dice once or repeatedly until they exceed a threshold. When multiple reroll options apply, only one is used. * Checks can offer up to four resource-spending options, with purchase limits based on a fixed amount, the dice pool, or a character-sheet value. * Character-sheet values can adjust applicable rolls, and adjustments appear in dice results. * Skill-check tags can specify a reroll option. * **Documentation** * Added ruleset guidance and examples for rerolls, spending limits, and sheet-based roll adjustments. * Capability API 1.38 is required to use these features. <!-- 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:12 +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#7280
No description provided.