[PR #6910] [MERGED] feat(rulesets): charged and gated ruleset items in Classic and Tactical battles #7377

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-items-classic-charges


📝 Commits (2)

  • 1733815 feat(rulesets): charged and gated ruleset items in Classic and Tactical battles (#6909)
  • 0df29ba fix(rulesets): a companion without a card rolls an item's check on a blank sheet, and one wear rule serves the Use button, the fight menu and its spends (#6909)

📊 Changes

23 files changed (+1193 additions, -120 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+37 -4)
📝 docs/extending/writing-rulesets.md (+4 -1)
📝 docs/game/combat.md (+1 -1)
📝 e2e/game-ruleset-classic-items.e2e.ts (+178 -0)
📝 packages/client/src/components/game/GameCombatUI.tsx (+4 -2)
📝 packages/client/src/components/game/GameSurface.tsx (+23 -16)
📝 packages/server/src/routes/combat-director.routes.ts (+43 -9)
📝 packages/server/src/routes/game-inventory.routes.ts (+3 -1)
📝 packages/server/src/routes/game.routes.ts (+12 -1)
📝 packages/server/src/services/game/combat-director.service.ts (+35 -23)
📝 packages/server/src/services/game/combat.service.ts (+21 -0)
📝 packages/server/src/services/game/game-inventory.service.ts (+4 -4)
📝 packages/server/src/services/game/game-item-use.service.ts (+54 -1)
📝 packages/shared/src/features/rulesets/item-book.ts (+12 -1)
📝 packages/shared/src/features/rulesets/item-fight.ts (+78 -24)
📝 packages/shared/src/features/rulesets/item-use.ts (+39 -13)
📝 packages/shared/src/types/combat-encounter.ts (+9 -0)
📝 packages/shared/src/types/game.ts (+2 -0)
📝 packages/shared/src/utils/game-inventory-ops.ts (+62 -2)

...and 3 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 #6909

Why this change

  • #6908 lets a ruleset's own items work in Classic and Tactical battles by their use, but leaves out any item that spends charges (a wand, Gravewatch's dawn bell) or asks a check first (gate: a scroll, the page of the vigil litany), because those battles could not count charges or roll a check. Outside a fight the Use button already handles both, so the same item worked in the bag and vanished from the battle menu. This is slice I8-2 of the ruleset items plan.
  • An item that takes a slot or binds was also offered in a battle while it sat unworn in the bag, although the Use button refuses that.

What changed

  • Charged items are offered by their uses (gameFightOffers, shared by the server and the screen): a charged line counts floor(charges left / cost) over its stacks (a stack without a count is full, and none holds more than its item's most), and is offered only while a use is left. The menu says "spends 1 of 3 charges".
  • Worn and bound where the item asks it. An effect carries wear: a line counts only stacks worn where the item takes slots and bound where it binds, as the Use button and a ruleset fight already do.
  • A new charge inventory op spends them: count uses by own name, each off the first usable stack with enough, the player's own first (or one bag with from). A stack emptied rolls the item's breaksOn with the Engine's own dice and is gone when it breaks; the journal says it was used, and lost where it broke. The screen sends it after a Classic round; the director turns a charged line's spends into it when it saves a step.
  • A used-up item is spent from a worn stack. The take op gains worn (via the new gameInventoryUsableStack, which charge shares), and a fight's spends set it. Without it the fight would count the worn tonic but drink a spare from the bag, and a worn cursed ring would use spare rings up in its place.
  • Gates are rolled on the server with the user's sheet, live state and worn items: rollRulesetItemGate is extracted from the Use button's path, and rollGameFightItemGate finds the user's card by the unit's name: only the player's own unit falls back on the player's card, and a companion with no card rolls on a blank sheet. The Classic round route rolls it for the unit using the item; the director rolls it before a player's classic or tactical item command. unless skips it.
  • A failed gate spends the item (or its charges) and does nothing: the action is a miss with a note, and the log shows it in place of the usual line: "Ada rolls Ward to use Page of the vigil litany: 0 against 2, failed, and it is used up for nothing."
  • Left out, as the Use button leaves it out: a charge count read off a stat the item does not give, or a gate difficulty it cannot say.
  • Docs: the "Items in Classic and Tactical battles" bullets in docs/extending/writing-rulesets.md, the Items line in docs/game/combat.md, the I8-2 record in docs/development/game-rulesets-and-sheets-implementation.md, and a CHANGELOG entry. No Capability API change: every key read here shipped with 1.59.

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

Local run on this branch, rebased onto staging with #6908 (Fedora):

  • pnpm check, pnpm localization:check and prettier: clean.
  • pnpm regression: 480 of 480.
  • pnpm smoke:ui: 7 passed.
  • Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 53 passed. Mobile e2e (every ruleset spec): 28 passed.

Lanes:

  • game-ruleset-classic-items.regression.ts gains the charges-and-gates sections: the effect (charges and the check said, a charge count read off a stat the bell does not give left out, and likewise a page whose check reads one, wear); the offers (counted in uses, a stack without a count full and capped at the most, not bound or not worn not offered, a worn tonic counting only the worn one); the charge op (the player's own first, then the party, one bag, none left, not bound, as many as there are, the last charge rolling its die and breaking on a 1, no dice no break); the take op's worn (the worn tonic drunk, never the spare before it); the gate (skipped by unless, failed for two ones, rolled for whoever uses it); the Classic round route (a page doing what it does when unless holds, a failed page spent for nothing, a bell with no use left refused, the check rolled for Bram rather than Ada); the inventory route's charge (a charge spent, and the Engine's dice breaking a bell on its last); and the director (the bell offered by its uses and spending a charge, a worn page counted alone and spent before the spare, a failed page logged).
  • combat-director-route.regression.ts: the cursed ring is now worn and bound, as a ring that binds is used; a spare in the bag is no longer spent in its place, and a ring taken off since is refused as a changed inventory, not as the curse.
  • e2e/game-ruleset-classic-items.e2e.ts gains a Classic battle whose menu offers the dawn bell as "spends 1 of 3 charges" with two uses, spends one charge on the rat, and whose worn page Ada fails the check for: it is spent for nothing, the log says so, and the spare page stays in the bag.

40 deliberate breaks, each caught by these lanes and the e2e. One slipped past on the first run: counting any stack rather than only worn ones in the director's check went unseen, since it only changed which refusal was given; the ring taken off now pins it.

Local CodeRabbit raised five findings over three passes:

  • Real: rollGameFightItemGate parsed the chat's metadata with a bare JSON.parse, so corrupt metadata could throw mid-round. Fixed: it uses the inventory service's tolerant readMetadata (now exported).
  • Real: the director gathered a step's spends by own name alone, so a charged ruleset item and a plain item of the same own name would have been merged under one kind. Fixed: they are kept apart by kind. (Declined the rest of that finding, to put charge spends through the curse check: spending charges does not part the player from the item, and the charge op refuses a shortfall itself.)
  • Declined, three times over two passes: spending or counting charges on a stack of several items. An item that holds charges must be one to a stack (ruleset.schema.ts, "An item that holds charges is one to a stack"), and every add and merge holds stacks to that limit, so such a stack cannot be made; the Use button and ruleset fights write charges the same way.

The first full gate run caught one more thing: combat-director-route's cursed ring was held bound but not worn, so the new wear rule stopped offering it. Fixing that test showed the real gap above: the fight counted only worn stacks but spent any stack. The worn take closes it.

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, docs/game/combat.md and docs/development/game-rulesets-and-sheets-implementation.md (all carried by docs-i18n), and CHANGELOG.md. Translations: #6813 is the items arc's follow-up; this PR is added to it there.

UI evidence (if applicable)

A Classic battle's Items menu offers the dawn bell with two uses, saying "spends 1 of 3 charges", and the log reads the failed check for the worn page (captured by e2e/game-ruleset-classic-items.e2e.ts as classic-charges.png and classic-failed-gate.png).

Summary by CodeRabbit

  • New Features
    • Classic and Tactical battles now offer supported items that use charges or require a check.
    • Charged items spend uses when activated and may break when their last charge is spent.
    • Items that must be worn or bound can only be used in that state; using them consumes the equipped or bound item, not a spare.
    • Failed checks consume the item or charge without applying its effect.
  • Documentation
    • Updated ruleset and combat guides with item availability, charge, wear, and check 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/6910 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/30/2026 **Status:** ✅ Merged **Merged:** 9/30/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-items-classic-charges` --- ### 📝 Commits (2) - [`1733815`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1733815a3352788569ac494b01fef4aaeed13c9e) feat(rulesets): charged and gated ruleset items in Classic and Tactical battles (#6909) - [`0df29ba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0df29babad2ff166582d73225fe2d61dd94d7314) fix(rulesets): a companion without a card rolls an item's check on a blank sheet, and one wear rule serves the Use button, the fight menu and its spends (#6909) ### 📊 Changes **23 files changed** (+1193 additions, -120 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+37 -4) 📝 `docs/extending/writing-rulesets.md` (+4 -1) 📝 `docs/game/combat.md` (+1 -1) 📝 `e2e/game-ruleset-classic-items.e2e.ts` (+178 -0) 📝 `packages/client/src/components/game/GameCombatUI.tsx` (+4 -2) 📝 `packages/client/src/components/game/GameSurface.tsx` (+23 -16) 📝 `packages/server/src/routes/combat-director.routes.ts` (+43 -9) 📝 `packages/server/src/routes/game-inventory.routes.ts` (+3 -1) 📝 `packages/server/src/routes/game.routes.ts` (+12 -1) 📝 `packages/server/src/services/game/combat-director.service.ts` (+35 -23) 📝 `packages/server/src/services/game/combat.service.ts` (+21 -0) 📝 `packages/server/src/services/game/game-inventory.service.ts` (+4 -4) 📝 `packages/server/src/services/game/game-item-use.service.ts` (+54 -1) 📝 `packages/shared/src/features/rulesets/item-book.ts` (+12 -1) 📝 `packages/shared/src/features/rulesets/item-fight.ts` (+78 -24) 📝 `packages/shared/src/features/rulesets/item-use.ts` (+39 -13) 📝 `packages/shared/src/types/combat-encounter.ts` (+9 -0) 📝 `packages/shared/src/types/game.ts` (+2 -0) 📝 `packages/shared/src/utils/game-inventory-ops.ts` (+62 -2) _...and 3 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 #6909 ## Why this change - #6908 lets a ruleset's own items work in Classic and Tactical battles by their `use`, but leaves out any item that spends charges (a wand, Gravewatch's dawn bell) or asks a check first (`gate`: a scroll, the page of the vigil litany), because those battles could not count charges or roll a check. Outside a fight the Use button already handles both, so the same item worked in the bag and vanished from the battle menu. This is slice I8-2 of the ruleset items plan. - An item that takes a slot or binds was also offered in a battle while it sat unworn in the bag, although the Use button refuses that. ## What changed - **Charged items are offered by their uses** (`gameFightOffers`, shared by the server and the screen): a charged line counts `floor(charges left / cost)` over its stacks (a stack without a count is full, and none holds more than its item's most), and is offered only while a use is left. The menu says "spends 1 of 3 charges". - **Worn and bound where the item asks it.** An effect carries `wear`: a line counts only stacks worn where the item takes slots and bound where it binds, as the Use button and a ruleset fight already do. - **A new `charge` inventory op spends them**: `count` uses by own name, each off the first usable stack with enough, the player's own first (or one bag with `from`). A stack emptied rolls the item's `breaksOn` with the Engine's own dice and is gone when it breaks; the journal says it was used, and lost where it broke. The screen sends it after a Classic round; the director turns a charged line's spends into it when it saves a step. - **A used-up item is spent from a worn stack.** The `take` op gains `worn` (via the new `gameInventoryUsableStack`, which `charge` shares), and a fight's spends set it. Without it the fight would count the worn tonic but drink a spare from the bag, and a worn cursed ring would use spare rings up in its place. - **Gates are rolled on the server** with the user's sheet, live state and worn items: `rollRulesetItemGate` is extracted from the Use button's path, and `rollGameFightItemGate` finds the user's card by the unit's name: only the player's own unit falls back on the player's card, and a companion with no card rolls on a blank sheet. The Classic round route rolls it for the unit using the item; the director rolls it before a player's classic or tactical item command. `unless` skips it. - **A failed gate spends the item (or its charges) and does nothing**: the action is a miss with a `note`, and the log shows it in place of the usual line: "Ada rolls Ward to use Page of the vigil litany: 0 against 2, failed, and it is used up for nothing." - **Left out, as the Use button leaves it out:** a charge count read off a stat the item does not give, or a gate difficulty it cannot say. - **Docs:** the "Items in Classic and Tactical battles" bullets in `docs/extending/writing-rulesets.md`, the Items line in `docs/game/combat.md`, the I8-2 record in `docs/development/game-rulesets-and-sheets-implementation.md`, and a CHANGELOG entry. No Capability API change: every key read here shipped with 1.59. ## 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 Local run on this branch, rebased onto staging with #6908 (Fedora): - `pnpm check`, `pnpm localization:check` and prettier: clean. - `pnpm regression`: 480 of 480. - `pnpm smoke:ui`: 7 passed. - Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 53 passed. Mobile e2e (every ruleset spec): 28 passed. Lanes: - `game-ruleset-classic-items.regression.ts` gains the charges-and-gates sections: the effect (charges and the check said, a charge count read off a stat the bell does not give left out, and likewise a page whose check reads one, `wear`); the offers (counted in uses, a stack without a count full and capped at the most, not bound or not worn not offered, a worn tonic counting only the worn one); the `charge` op (the player's own first, then the party, one bag, none left, not bound, as many as there are, the last charge rolling its die and breaking on a 1, no dice no break); the `take` op's `worn` (the worn tonic drunk, never the spare before it); the gate (skipped by `unless`, failed for two ones, rolled for whoever uses it); the Classic round route (a page doing what it does when `unless` holds, a failed page spent for nothing, a bell with no use left refused, the check rolled for Bram rather than Ada); the inventory route's `charge` (a charge spent, and the Engine's dice breaking a bell on its last); and the director (the bell offered by its uses and spending a charge, a worn page counted alone and spent before the spare, a failed page logged). - `combat-director-route.regression.ts`: the cursed ring is now worn and bound, as a ring that binds is used; a spare in the bag is no longer spent in its place, and a ring taken off since is refused as a changed inventory, not as the curse. - `e2e/game-ruleset-classic-items.e2e.ts` gains a Classic battle whose menu offers the dawn bell as "spends 1 of 3 charges" with two uses, spends one charge on the rat, and whose worn page Ada fails the check for: it is spent for nothing, the log says so, and the spare page stays in the bag. 40 deliberate breaks, each caught by these lanes and the e2e. One slipped past on the first run: counting any stack rather than only worn ones in the director's check went unseen, since it only changed which refusal was given; the ring taken off now pins it. Local CodeRabbit raised five findings over three passes: - Real: `rollGameFightItemGate` parsed the chat's metadata with a bare `JSON.parse`, so corrupt metadata could throw mid-round. Fixed: it uses the inventory service's tolerant `readMetadata` (now exported). - Real: the director gathered a step's spends by own name alone, so a charged ruleset item and a plain item of the same own name would have been merged under one kind. Fixed: they are kept apart by kind. (Declined the rest of that finding, to put charge spends through the curse check: spending charges does not part the player from the item, and the `charge` op refuses a shortfall itself.) - Declined, three times over two passes: spending or counting charges on a stack of several items. An item that holds charges must be one to a stack (`ruleset.schema.ts`, "An item that holds charges is one to a stack"), and every add and merge holds stacks to that limit, so such a stack cannot be made; the Use button and ruleset fights write charges the same way. The first full gate run caught one more thing: `combat-director-route`'s cursed ring was held bound but not worn, so the new wear rule stopped offering it. Fixing that test showed the real gap above: the fight counted only worn stacks but spent any stack. The `worn` take closes it. ## 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`, `docs/game/combat.md` and `docs/development/game-rulesets-and-sheets-implementation.md` (all carried by `docs-i18n`), and `CHANGELOG.md`. Translations: #6813 is the items arc's follow-up; this PR is added to it there. ## UI evidence (if applicable) A Classic battle's Items menu offers the dawn bell with two uses, saying "spends 1 of 3 charges", and the log reads the failed check for the worn page (captured by `e2e/game-ruleset-classic-items.e2e.ts` as `classic-charges.png` and `classic-failed-gate.png`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Classic and Tactical battles now offer supported items that use charges or require a check. * Charged items spend uses when activated and may break when their last charge is spent. * Items that must be worn or bound can only be used in that state; using them consumes the equipped or bound item, not a spare. * Failed checks consume the item or charge without applying its effect. * **Documentation** * Updated ruleset and combat guides with item availability, charge, wear, and check 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:19:10 +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#7377
No description provided.