[PR #6882] [MERGED] feat(rulesets): using items in ruleset fights, used up or spending charges (#6880) #7367

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-items-use-in-fights


📝 Commits (5)

  • 4296cc3 feat(rulesets): using items in ruleset fights, used up or spending charges (#6880)
  • c819e3d docs(rulesets): charges regained on a rest come in a later release (#6880)
  • e514cb2 fix(rulesets): an item's use says its pool target to hit, as a weapon does (#6880)
  • d9b2abc fix(rulesets): charges read off a stat are held to the most a written count may be (#6880)
  • 7800103 fix(rulesets): an item that gives its charges stat as less than one is refused (#6880)

📊 Changes

38 files changed (+2599 additions, -172 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+48 -0)
📝 docs/examples/rulesets/ember-roads.json (+21 -0)
📝 docs/examples/rulesets/gravewatch.json (+27 -2)
📝 docs/extending/ruleset.schema.json (+625 -0)
📝 docs/extending/writing-rulesets.md (+40 -3)
📝 e2e/game-ruleset-fight-fixture.ts (+1 -1)
➕ e2e/game-ruleset-item-use.e2e.ts (+149 -0)
📝 packages/client/src/components/game/GameInventory.tsx (+14 -0)
📝 packages/client/src/components/game/RulesetItemPicker.tsx (+50 -0)
📝 packages/client/src/lib/ruleset-combat-board.ts (+5 -1)
📝 packages/client/src/lib/ruleset-combat-menu.ts (+1 -0)
📝 packages/client/src/localization/locales/en.json (+17 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+16 -0)
📝 packages/shared/src/features/ruleset-combat/ammo.ts (+45 -5)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+156 -33)
📝 packages/shared/src/features/ruleset-combat/grid.ts (+2 -0)
📝 packages/shared/src/features/ruleset-combat/options.ts (+11 -1)
📝 packages/shared/src/features/ruleset-combat/types.ts (+9 -3)
📝 packages/shared/src/features/rulesets/invented-items.ts (+3 -0)

...and 18 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 #6880

Why this change

  • A ruleset's items can be worn, carried, change checks and fight as weapons (#6855, #6871, #6875), but nothing could be used. A healing potion, a poultice or a wand with charges did nothing in a ruleset fight: its effect had to be written as a sheet row and cast, a potion was never used up, and a wand's charges were nowhere. This is slice I6-1 of the ruleset items plan, using items in a fight. Using them outside a fight (the Use button, the Game Master's tag, restoring a pool) follows as I6-2 (#6881), and charges regained on rests, items that break and scroll gates as I6-3.

What changed

  • An item's use (Capability API 1.59): what using it does, in the words a catalog entry's mechanics already has (kind heal, attack, buff or debuff, amount, damageType, plus, attackRoll, save, applies, temporary, range, area, targets, targetCount, friendlyFire), with the budget it spends or free, a weapon-style toHit where it rolls, and its own saveDifficulty where it asks a save (an item has no catalog source to read one off). What only a sheet row can mean (a pool cost, check, reaction, rider and the rest) is refused on a use: an item pays with itself.
  • Used up, or charges: consumes: true takes one off the stack; charges spends that many of the item's own charges (max, written down or read off a number stat), kept on its inventory stack, so a bell rung in one fight has fewer in the next. Charges are one item's, so an item that holds them is one to a stack.
  • In a fight: each usable item is on the menu in a new Items group, one carried from the bag, or one worn (and bound, where it binds). The menu says how many are left, one with nothing left is not offered, and a use is never a strike at somebody walking away. A party member the Engine plays uses a heal only on somebody hurt. What a fight uses up and the charges it leaves are written to the inventory by stack id as each step is taken, in the same transaction as the party's sheets.
  • Checked at import: a use with neither a budget nor free (or both), used up and spending charges, charges on an item without any or an item's charges nothing spends, charges on a stack of several, a save with no number, an unknown save, condition, damage type or budget, a to-hit on a use that rolls none, a pool fight's harm dice off its die, temporary points on a wound track, and a stat read as the wrong kind. The install gate asks for 1.59 in the ruleset file and in catalog files.
  • Seen and said: the item's details say "Use (Action): heals 1d4 + 1, range 0 paces, used up" and "2 of 3 charges left", the Game Master's line ends with use (Act): Steel 7 save negates it, Rattled, 1 of 3 charges, and the log says "Poultice: 1 of 2 left.". An item the Game Master invents like= one of these is used as that one is.
  • Examples: Ember Roads gains a poultice (a heal on the Action, used up). Gravewatch's warming tonic heals a box of harm on the quick budget, and its dawn bell, worn and bound, spends one of three charges to rattle what fails a Steel save against 7.
  • Docs: a "Using items in a fight" section, the item keys and the capability list in docs/extending/writing-rulesets.md (whose line saying items are not used by their own rules yet now says that of using them outside a fight), the 1.59 record in docs/development/game-rulesets-and-sheets-implementation.md, the regenerated JSON schema and a CHANGELOG entry.

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 this branch at 4296cc3f9 (one commit on staging 9b313a48a; the second commit only rewords one docs line):

  • pnpm check exits 0, pnpm localization:check exits 0, pnpm regression passes 471/471, and pnpm smoke:ui passes 7/7.
  • On --project=desktop-chromium, the ruleset, inventory, game dice and combat director specs (e2e/game-ruleset-*.e2e.ts, e2e/ruleset-*.e2e.ts, e2e/game-inventory-*.e2e.ts, e2e/game-native-dice.e2e.ts, e2e/game-one-request-dice.e2e.ts, e2e/game-combat-director.e2e.ts) pass 33/33, and the game ruleset specs pass 14/14 on --project=mobile-chromium.

Lanes:

  • New game-ruleset-item-use.regression.ts: every import refusal; the 1.59 gate (the examples, charges alone, and a catalog file); a poultice on its holder and on a friend and never on a foe, spending the Action, used up and then refused; the Items group; a tonic on the quick budget beside a blow; a bell only while worn, its charges spent and kept between fights, a use that spends two, charges and a save's number read off a stat (and off one the item lacks); a use's own to-hit and a pool target; never a strike in passing; the write-back by stack id and a stack gone or given away refused; charges on a stack of one; the Engine's own party member healing whoever is hurt; item facts, the Game Master's lines and invented items.
  • Lanes that pin the 1.58 gate, the supported API, the examples' items or the menu's groups were brought up to date.
  • e2e/game-ruleset-item-use.e2e.ts: in Ember Roads, a poultice's details say what using it does, the Items group offers it with "2 left", pressing it on Juno is logged and the saved stack drops to one; in Gravewatch, a bound dawn bell's details show its use and "2 of 3 charges left", ringing it at the rats is logged and the saved stack keeps one charge.

Sixty-nine deliberate breaks, across the import checks, the gate, building the actions, what is left, spending, the write-back, charges on a stack, invented items, the menu, the board and the facts, were each caught by the lanes.

Local CodeRabbit (coderabbit review --agent --base staging, with the new files included): no findings.

No Game Master turn was run on a local model for this slice: what the model sees differently is one more part of an item's inventory line, and the Engine's own picker (not the model) decides when a party member it plays uses an item, which a lane covers.

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

UI evidence (if applicable)

In an Ember Roads fight, the Items group offers "Poultice · Spends Action · 2 left · about 4 healed", and after it is pressed on Juno the log reads "Poultice: 1 of 2 left." then "Juno recovers 3, and is on 5 of 11."; in Gravewatch, ringing the dawn bell logs "Dawn bell: 1 of 3 left." (captured by e2e/game-ruleset-item-use.e2e.ts as ruleset-item-use-menu.png, ruleset-item-used.png and ruleset-item-charges.png).

Summary by CodeRabbit

  • New Features

    • Use ruleset-defined items during fights for healing, attacks, and other configured effects, targeting holders, allies, or opponents.
    • Consumables and charges are tracked after use and saved to inventory. Engine-controlled party members can use healing items on injured characters.
    • Item details show combat effects and remaining charges.
  • Documentation

    • Added guidance and examples for configuring combat item use. These rules require Capability API 1.59.

🔄 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/6882 **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-use-in-fights` --- ### 📝 Commits (5) - [`4296cc3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4296cc3f914adf3ebf55330548f4d8a41893a086) feat(rulesets): using items in ruleset fights, used up or spending charges (#6880) - [`c819e3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c819e3d843a1d6f5621d045d9c8211a04c25fd4e) docs(rulesets): charges regained on a rest come in a later release (#6880) - [`e514cb2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e514cb22333c598bbaf52fa3bc42e313c3e75b3c) fix(rulesets): an item's use says its pool target to hit, as a weapon does (#6880) - [`d9b2abc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d9b2abc8797092a69aa0e41e2703ed0e1004c6b5) fix(rulesets): charges read off a stat are held to the most a written count may be (#6880) - [`7800103`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7800103b3e4a72159e79a392d75b073d50f48d45) fix(rulesets): an item that gives its charges stat as less than one is refused (#6880) ### 📊 Changes **38 files changed** (+2599 additions, -172 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+48 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+21 -0) 📝 `docs/examples/rulesets/gravewatch.json` (+27 -2) 📝 `docs/extending/ruleset.schema.json` (+625 -0) 📝 `docs/extending/writing-rulesets.md` (+40 -3) 📝 `e2e/game-ruleset-fight-fixture.ts` (+1 -1) ➕ `e2e/game-ruleset-item-use.e2e.ts` (+149 -0) 📝 `packages/client/src/components/game/GameInventory.tsx` (+14 -0) 📝 `packages/client/src/components/game/RulesetItemPicker.tsx` (+50 -0) 📝 `packages/client/src/lib/ruleset-combat-board.ts` (+5 -1) 📝 `packages/client/src/lib/ruleset-combat-menu.ts` (+1 -0) 📝 `packages/client/src/localization/locales/en.json` (+17 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+16 -0) 📝 `packages/shared/src/features/ruleset-combat/ammo.ts` (+45 -5) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+156 -33) 📝 `packages/shared/src/features/ruleset-combat/grid.ts` (+2 -0) 📝 `packages/shared/src/features/ruleset-combat/options.ts` (+11 -1) 📝 `packages/shared/src/features/ruleset-combat/types.ts` (+9 -3) 📝 `packages/shared/src/features/rulesets/invented-items.ts` (+3 -0) _...and 18 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 #6880 ## Why this change - A ruleset's items can be worn, carried, change checks and fight as weapons (#6855, #6871, #6875), but nothing could be used. A healing potion, a poultice or a wand with charges did nothing in a ruleset fight: its effect had to be written as a sheet row and cast, a potion was never used up, and a wand's charges were nowhere. This is slice I6-1 of the ruleset items plan, using items in a fight. Using them outside a fight (the Use button, the Game Master's tag, restoring a pool) follows as I6-2 (#6881), and charges regained on rests, items that break and scroll gates as I6-3. ## What changed - **An item's `use`** (Capability API 1.59): what using it does, in the words a catalog entry's `mechanics` already has (`kind` heal, attack, buff or debuff, `amount`, `damageType`, `plus`, `attackRoll`, `save`, `applies`, `temporary`, `range`, `area`, `targets`, `targetCount`, `friendlyFire`), with the `budget` it spends or `free`, a weapon-style `toHit` where it rolls, and its own `saveDifficulty` where it asks a save (an item has no catalog source to read one off). What only a sheet row can mean (a pool `cost`, `check`, `reaction`, `rider` and the rest) is refused on a use: an item pays with itself. - **Used up, or charges**: `consumes: true` takes one off the stack; `charges` spends that many of the item's own `charges` (`max`, written down or read off a number stat), kept on its inventory stack, so a bell rung in one fight has fewer in the next. Charges are one item's, so an item that holds them is one to a stack. - **In a fight**: each usable item is on the menu in a new **Items** group, one carried from the bag, or one worn (and bound, where it binds). The menu says how many are left, one with nothing left is not offered, and a use is never a strike at somebody walking away. A party member the Engine plays uses a heal only on somebody hurt. What a fight uses up and the charges it leaves are written to the inventory by stack id as each step is taken, in the same transaction as the party's sheets. - **Checked at import**: a use with neither a budget nor `free` (or both), used up and spending charges, charges on an item without any or an item's charges nothing spends, charges on a stack of several, a save with no number, an unknown save, condition, damage type or budget, a to-hit on a use that rolls none, a pool fight's harm dice off its die, temporary points on a wound track, and a stat read as the wrong kind. The install gate asks for 1.59 in the ruleset file and in catalog files. - **Seen and said**: the item's details say "Use (Action): heals 1d4 + 1, range 0 paces, used up" and "2 of 3 charges left", the Game Master's line ends with `use (Act): Steel 7 save negates it, Rattled, 1 of 3 charges`, and the log says "Poultice: 1 of 2 left.". An item the Game Master invents `like=` one of these is used as that one is. - **Examples**: Ember Roads gains a poultice (a heal on the Action, used up). Gravewatch's warming tonic heals a box of harm on the quick budget, and its dawn bell, worn and bound, spends one of three charges to rattle what fails a Steel save against 7. - **Docs**: a "Using items in a fight" section, the item keys and the capability list in `docs/extending/writing-rulesets.md` (whose line saying items are not used by their own rules yet now says that of using them outside a fight), the 1.59 record in `docs/development/game-rulesets-and-sheets-implementation.md`, the regenerated JSON schema and a CHANGELOG entry. ## 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 this branch at 4296cc3f9 (one commit on staging 9b313a48a; the second commit only rewords one docs line): - `pnpm check` exits 0, `pnpm localization:check` exits 0, `pnpm regression` passes 471/471, and `pnpm smoke:ui` passes 7/7. - On `--project=desktop-chromium`, the ruleset, inventory, game dice and combat director specs (`e2e/game-ruleset-*.e2e.ts`, `e2e/ruleset-*.e2e.ts`, `e2e/game-inventory-*.e2e.ts`, `e2e/game-native-dice.e2e.ts`, `e2e/game-one-request-dice.e2e.ts`, `e2e/game-combat-director.e2e.ts`) pass 33/33, and the game ruleset specs pass 14/14 on `--project=mobile-chromium`. Lanes: - New `game-ruleset-item-use.regression.ts`: every import refusal; the 1.59 gate (the examples, charges alone, and a catalog file); a poultice on its holder and on a friend and never on a foe, spending the Action, used up and then refused; the Items group; a tonic on the quick budget beside a blow; a bell only while worn, its charges spent and kept between fights, a use that spends two, charges and a save's number read off a stat (and off one the item lacks); a use's own to-hit and a pool target; never a strike in passing; the write-back by stack id and a stack gone or given away refused; charges on a stack of one; the Engine's own party member healing whoever is hurt; item facts, the Game Master's lines and invented items. - Lanes that pin the 1.58 gate, the supported API, the examples' items or the menu's groups were brought up to date. - `e2e/game-ruleset-item-use.e2e.ts`: in Ember Roads, a poultice's details say what using it does, the Items group offers it with "2 left", pressing it on Juno is logged and the saved stack drops to one; in Gravewatch, a bound dawn bell's details show its use and "2 of 3 charges left", ringing it at the rats is logged and the saved stack keeps one charge. Sixty-nine deliberate breaks, across the import checks, the gate, building the actions, what is left, spending, the write-back, charges on a stack, invented items, the menu, the board and the facts, were each caught by the lanes. Local CodeRabbit (`coderabbit review --agent --base staging`, with the new files included): no findings. No Game Master turn was run on a local model for this slice: what the model sees differently is one more part of an item's inventory line, and the Engine's own picker (not the model) decides when a party member it plays uses an item, which a lane covers. ## 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` and `docs/development/game-rulesets-and-sheets-implementation.md` (both carried by `docs-i18n`), `CHANGELOG.md`, the generated `docs/extending/ruleset.schema.json` and the two example rulesets. Translations: #6813 is the items arc's follow-up; this PR is added to it there. ## UI evidence (if applicable) In an Ember Roads fight, the Items group offers "Poultice · Spends Action · 2 left · about 4 healed", and after it is pressed on Juno the log reads "Poultice: 1 of 2 left." then "Juno recovers 3, and is on 5 of 11."; in Gravewatch, ringing the dawn bell logs "Dawn bell: 1 of 3 left." (captured by `e2e/game-ruleset-item-use.e2e.ts` as `ruleset-item-use-menu.png`, `ruleset-item-used.png` and `ruleset-item-charges.png`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Use ruleset-defined items during fights for healing, attacks, and other configured effects, targeting holders, allies, or opponents. * Consumables and charges are tracked after use and saved to inventory. Engine-controlled party members can use healing items on injured characters. * Item details show combat effects and remaining charges. * **Documentation** * Added guidance and examples for configuring combat item use. These rules require Capability API 1.59. <!-- 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:04 +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#7367
No description provided.