[PR #6889] [MERGED] feat(rulesets): using items outside a fight, and restoring a pool (#6881) #7368

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

📋 Pull Request Information

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

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


📝 Commits (5)

  • ffd30d6 feat(rulesets): using items outside a fight, and restoring a pool (#6881)
  • 100859c Merge remote-tracking branch 'origin/staging' into feat/ruleset-items-use-outside-fights
  • 32b2a37 fix(rulesets): Use asks the Engine about an item the screen cannot tell yet, and the e2e looks for the line as JSON writes it (#6881)
  • 29fce87 fix(rulesets): only the latest Use answer writes the sheet, as only it writes the bag (#6881)
  • 60fb1aa fix(rulesets): a Use answer overtaken only by a plain inventory save still shows its sheet (#6881)

📊 Changes

38 files changed (+1968 additions, -59 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+35 -0)
📝 docs/examples/rulesets/gravewatch.json (+2 -1)
📝 docs/extending/ruleset.schema.json (+31 -0)
📝 docs/extending/writing-rulesets.md (+15 -4)
📝 docs/game/party-and-npcs.md (+2 -1)
➕ e2e/game-ruleset-item-use-outside.e2e.ts (+284 -0)
📝 packages/client/src/components/game/GameInventory.tsx (+4 -3)
📝 packages/client/src/components/game/GameSurface.tsx (+104 -14)
📝 packages/client/src/components/game/RulesetItemPicker.tsx (+1 -0)
📝 packages/client/src/components/game/game-narration-format.ts (+8 -0)
📝 packages/client/src/lib/ruleset-combat-log.ts (+8 -0)
📝 packages/client/src/localization/locales/en.json (+8 -0)
📝 packages/server/src/routes/game-inventory.routes.ts (+25 -0)
📝 packages/server/src/routes/generate.routes.ts (+47 -4)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+13 -0)
➕ packages/server/src/services/game/game-item-use.service.ts (+171 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+5 -0)
📝 packages/server/src/services/game/ruleset-combat-director.service.ts (+21 -3)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+2 -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 #6881

Why this change

  • With #6882 a ruleset's items can be used in a ruleset fight, but not outside one. The inventory's Use button only said "I use my Poultice." to the Game Master: nothing was healed, the poultice stayed in the bag, and a bell's charges were not spent unless the Game Master remembered to remove or change them by hand. The Game Master's own inventory tag had no way to use an item, and an item could not give back a pool (a blood bag, a tonic that restores Resolve) anywhere. This is slice I6-2 of the ruleset items plan; charges regained on rests, items that break when emptied and scroll gates follow as I6-3.

What changed

  • restore (Capability API 1.60): an item's use may give back some of a pool of each sheet it lands on ({ "pool": "resolve", "amount": { "flat": 1 } }), in a fight and outside one. In a fight it is written after temporary points and logged ("Ada gets back 1 Resolve, and is on 2 of 4."), and a party member the Engine plays leaves a full pool alone. Checked at import: a pool the sheet has, never the health pool, an amount, and only on a heal or a buff. The install gate asks for 1.60 in the ruleset file and in catalog files.
  • The Use button: on one of the ruleset's items with a use, the Engine uses it first, after any sheet edit still waiting to be saved has landed. It rolls with the Engine's dice and applies to whoever carries it what lands on them: a heal (the amount on a health pool, one mark cleared on a wound track, as in a fight), temporary points, a restore and the conditions it puts on. It takes one off the stack or spends a charge, and a new route (POST /api/game/inventory/use) writes the bag, the journal and the carrier's sheet in one transaction. The message then sent is "I use my Poultice." with an [item_used] block holding what happened ("Juno uses Poultice: heals 4 (Grit 6/11). 1 left."), shown as a badge in the chat. The player's own bag is the player's card, or the first card when none is named for them, as the inventory and checks read it. An item with nothing left, or one that has to be worn and is not, is refused with a toast and changes nothing. Any other item is simply said, as before.
  • Aimed at somebody else: a use that harms or is aimed at the other side lands on nobody outside a fight. The item is still used, and the Game Master is told what it does to narrate.
  • The Game Master's use: [inventory: action="use" item="Poultice" who="Juno"] does the same, answered with what happened. Its dice come from one seed per turn, so the answer worked out before the reply is saved and the one saved agree, and what it heals is saved with the turn's sheets. A regenerated reply starts again from the turn's start, so an item is never used twice. The prompt offers the tag in rulesets with item catalogs and explains the [item_used] block, and the player is told "You used Poultice."
  • Examples: Gravewatch's warming tonic also restores a point of Resolve.
  • Docs: a "Using items outside a fight" section and the restore key in docs/extending/writing-rulesets.md (whose line saying using items outside a fight comes later now says only money does), the Use button in docs/game/party-and-npcs.md, the 1.60 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 ffd30d6bf (one commit on staging 75bffb210):

  • pnpm check exits 0, pnpm localization:check exits 0, pnpm regression passes 472/472, 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 34/34, and the game ruleset specs pass 15/15 on --project=mobile-chromium.

Lanes:

  • New game-ruleset-item-use-outside.regression.ts: every restore refusal; the 1.60 gate (the example, and a catalog file); a restore in a fight, its event and log line; the Engine's picker using smelling salts only when Resolve is spent; a poultice used outside a fight (the heal, the stack, the journal, the words, the last one), temporary points (and none on a pool without a buffer), a condition, a tonic clearing a harm mark and restoring Resolve, a bell aimed at nobody spending a charge; every refusal; the Use route through Fastify (the bag, the journal and the sheet written together, 404, 409 with its reason, 400, no ruleset); the Game Master's tag (its answer, the sheet, the same answer from the same seed, several uses, cannot-use and none-held); the [item_used] block stripped and reserved; the prompt's tag line.
  • game-inventory-turn.regression.ts gains a real turn: the Game Master's use spends one poultice, heals the player's card from the turn's start, saves it on the turn's row, and a regenerated reply uses it once, not twice.
  • Lanes that pin the 1.59 gate, the supported API, the examples' items or the fight log were brought up to date.
  • e2e/game-ruleset-item-use-outside.e2e.ts: in Ember Roads, the Use button on Juno's poultice heals her with the Engine's dice, the message sent carries the [item_used] block with the Engine's line, the saved bag holds one and the saved sheet the healed Grit, and in the Session Logs the message shows the "Item used" badge with the line.

Forty-eight deliberate breaks, across the import checks, the gate, a restore in a fight and the picker, using an item outside a fight (every refusal, what lands, the words, what is spent), the route and whose sheet it is, the Game Master's tag and the turn that saves it, the block and the prompt, were each caught by the lanes.

Local CodeRabbit (coderabbit review --agent --base staging), two rounds:

  • Fixed: an item that binds but takes no slot could not be used outside a fight; a bare [inventory: use ...] was read as an add; a use whose message could not reach the Game Master (another chat opened meanwhile, or the send failed) now says so in a toast instead of being spent in silence; the "has to be worn" toast wording. Each fix has a lane case except the toast, which no lane can reach.
  • Declined: using items when the turn's sheet pass itself failed (its commands stay unapplied and the sheets untouched, and a use is refused the same way rather than written over a state the turn could not read); repeating the pool's name in a restore's words ("restores 1 Resolve (2/4)" already names it).

No Game Master turn was run on a local model for this slice: the tag's behaviour is pinned through a real generate turn with a scripted reply, and what the model is told is one more instruction line and the block's own sentence.

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

UI evidence (if applicable)

In an Ember Roads game, Juno's poultice used from the inventory sends "I use my Poultice." and the Session Logs show it with the "🎒 Item used" badge and "Juno uses Poultice: heals 2 (Grit 2/11). 1 left." (captured by e2e/game-ruleset-item-use-outside.e2e.ts as ruleset-use-outside-before.png and ruleset-use-outside-after.png).

Summary by CodeRabbit

  • New Features
    • Use eligible ruleset items outside combat to apply healing, buffs, conditions, or resource restoration to the bearer. Successful uses consume an item or charge and report the outcome to the Game Master.
    • Restore resource pools with item effects during combat; restoration appears in combat updates.
    • Game Masters can use inventory commands to trigger item effects during generated turns.
  • Compatibility
    • Rulesets using item-based pool restoration or out-of-combat item use require Capability API 1.60.

🔄 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/6889 **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-outside-fights` --- ### 📝 Commits (5) - [`ffd30d6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ffd30d6bfaf2e372d0090b1c5ac62f390c689bba) feat(rulesets): using items outside a fight, and restoring a pool (#6881) - [`100859c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/100859cba5f8302b0388f1b7340afdda92d46d86) Merge remote-tracking branch 'origin/staging' into feat/ruleset-items-use-outside-fights - [`32b2a37`](https://github.com/Pasta-Devs/Marinara-Engine/commit/32b2a37b2d51aa8ae7e51ac7c3856c3aff6ef021) fix(rulesets): Use asks the Engine about an item the screen cannot tell yet, and the e2e looks for the line as JSON writes it (#6881) - [`29fce87`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29fce87dd782290c7cd3145daf0e40f6556943e5) fix(rulesets): only the latest Use answer writes the sheet, as only it writes the bag (#6881) - [`60fb1aa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/60fb1aad737ae6e04d2414a4bd659ebb8f1a4327) fix(rulesets): a Use answer overtaken only by a plain inventory save still shows its sheet (#6881) ### 📊 Changes **38 files changed** (+1968 additions, -59 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+35 -0) 📝 `docs/examples/rulesets/gravewatch.json` (+2 -1) 📝 `docs/extending/ruleset.schema.json` (+31 -0) 📝 `docs/extending/writing-rulesets.md` (+15 -4) 📝 `docs/game/party-and-npcs.md` (+2 -1) ➕ `e2e/game-ruleset-item-use-outside.e2e.ts` (+284 -0) 📝 `packages/client/src/components/game/GameInventory.tsx` (+4 -3) 📝 `packages/client/src/components/game/GameSurface.tsx` (+104 -14) 📝 `packages/client/src/components/game/RulesetItemPicker.tsx` (+1 -0) 📝 `packages/client/src/components/game/game-narration-format.ts` (+8 -0) 📝 `packages/client/src/lib/ruleset-combat-log.ts` (+8 -0) 📝 `packages/client/src/localization/locales/en.json` (+8 -0) 📝 `packages/server/src/routes/game-inventory.routes.ts` (+25 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+47 -4) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+13 -0) ➕ `packages/server/src/services/game/game-item-use.service.ts` (+171 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+5 -0) 📝 `packages/server/src/services/game/ruleset-combat-director.service.ts` (+21 -3) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+2 -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 #6881 ## Why this change - With #6882 a ruleset's items can be used in a ruleset fight, but not outside one. The inventory's Use button only said "I use my Poultice." to the Game Master: nothing was healed, the poultice stayed in the bag, and a bell's charges were not spent unless the Game Master remembered to remove or change them by hand. The Game Master's own inventory tag had no way to use an item, and an item could not give back a pool (a blood bag, a tonic that restores Resolve) anywhere. This is slice I6-2 of the ruleset items plan; charges regained on rests, items that break when emptied and scroll gates follow as I6-3. ## What changed - **`restore`** (Capability API 1.60): an item's `use` may give back some of a pool of each sheet it lands on (`{ "pool": "resolve", "amount": { "flat": 1 } }`), in a fight and outside one. In a fight it is written after temporary points and logged ("Ada gets back 1 Resolve, and is on 2 of 4."), and a party member the Engine plays leaves a full pool alone. Checked at import: a pool the sheet has, never the health pool, an amount, and only on a heal or a buff. The install gate asks for 1.60 in the ruleset file and in catalog files. - **The Use button**: on one of the ruleset's items with a `use`, the Engine uses it first, after any sheet edit still waiting to be saved has landed. It rolls with the Engine's dice and applies to whoever carries it what lands on them: a heal (the amount on a health pool, one mark cleared on a wound track, as in a fight), temporary points, a restore and the conditions it puts on. It takes one off the stack or spends a charge, and a new route (`POST /api/game/inventory/use`) writes the bag, the journal and the carrier's sheet in one transaction. The message then sent is "I use my Poultice." with an `[item_used]` block holding what happened ("Juno uses Poultice: heals 4 (Grit 6/11). 1 left."), shown as a badge in the chat. The player's own bag is the player's card, or the first card when none is named for them, as the inventory and checks read it. An item with nothing left, or one that has to be worn and is not, is refused with a toast and changes nothing. Any other item is simply said, as before. - **Aimed at somebody else**: a use that harms or is aimed at the other side lands on nobody outside a fight. The item is still used, and the Game Master is told what it does to narrate. - **The Game Master's `use`**: `[inventory: action="use" item="Poultice" who="Juno"]` does the same, answered with what happened. Its dice come from one seed per turn, so the answer worked out before the reply is saved and the one saved agree, and what it heals is saved with the turn's sheets. A regenerated reply starts again from the turn's start, so an item is never used twice. The prompt offers the tag in rulesets with item catalogs and explains the `[item_used]` block, and the player is told "You used Poultice." - **Examples**: Gravewatch's warming tonic also restores a point of Resolve. - **Docs**: a "Using items outside a fight" section and the `restore` key in `docs/extending/writing-rulesets.md` (whose line saying using items outside a fight comes later now says only money does), the Use button in `docs/game/party-and-npcs.md`, the 1.60 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 ffd30d6bf (one commit on staging 75bffb210): - `pnpm check` exits 0, `pnpm localization:check` exits 0, `pnpm regression` passes 472/472, 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 34/34, and the game ruleset specs pass 15/15 on `--project=mobile-chromium`. Lanes: - New `game-ruleset-item-use-outside.regression.ts`: every `restore` refusal; the 1.60 gate (the example, and a catalog file); a restore in a fight, its event and log line; the Engine's picker using smelling salts only when Resolve is spent; a poultice used outside a fight (the heal, the stack, the journal, the words, the last one), temporary points (and none on a pool without a buffer), a condition, a tonic clearing a harm mark and restoring Resolve, a bell aimed at nobody spending a charge; every refusal; the Use route through Fastify (the bag, the journal and the sheet written together, 404, 409 with its reason, 400, no ruleset); the Game Master's tag (its answer, the sheet, the same answer from the same seed, several uses, cannot-use and none-held); the `[item_used]` block stripped and reserved; the prompt's tag line. - `game-inventory-turn.regression.ts` gains a real turn: the Game Master's `use` spends one poultice, heals the player's card from the turn's start, saves it on the turn's row, and a regenerated reply uses it once, not twice. - Lanes that pin the 1.59 gate, the supported API, the examples' items or the fight log were brought up to date. - `e2e/game-ruleset-item-use-outside.e2e.ts`: in Ember Roads, the Use button on Juno's poultice heals her with the Engine's dice, the message sent carries the `[item_used]` block with the Engine's line, the saved bag holds one and the saved sheet the healed Grit, and in the Session Logs the message shows the "Item used" badge with the line. Forty-eight deliberate breaks, across the import checks, the gate, a restore in a fight and the picker, using an item outside a fight (every refusal, what lands, the words, what is spent), the route and whose sheet it is, the Game Master's tag and the turn that saves it, the block and the prompt, were each caught by the lanes. Local CodeRabbit (`coderabbit review --agent --base staging`), two rounds: - Fixed: an item that binds but takes no slot could not be used outside a fight; a bare `[inventory: use ...]` was read as an add; a use whose message could not reach the Game Master (another chat opened meanwhile, or the send failed) now says so in a toast instead of being spent in silence; the "has to be worn" toast wording. Each fix has a lane case except the toast, which no lane can reach. - Declined: using items when the turn's sheet pass itself failed (its commands stay unapplied and the sheets untouched, and a use is refused the same way rather than written over a state the turn could not read); repeating the pool's name in a restore's words ("restores 1 Resolve (2/4)" already names it). No Game Master turn was run on a local model for this slice: the tag's behaviour is pinned through a real generate turn with a scripted reply, and what the model is told is one more instruction line and the block's own sentence. ## 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/party-and-npcs.md` and `docs/development/game-rulesets-and-sheets-implementation.md` (all carried by `docs-i18n`), `CHANGELOG.md`, the generated `docs/extending/ruleset.schema.json` and the Gravewatch example. Translations: #6813 is the items arc's follow-up; this PR is added to it there. ## UI evidence (if applicable) In an Ember Roads game, Juno's poultice used from the inventory sends "I use my Poultice." and the Session Logs show it with the "🎒 Item used" badge and "Juno uses Poultice: heals 2 (Grit 2/11). 1 left." (captured by `e2e/game-ruleset-item-use-outside.e2e.ts` as `ruleset-use-outside-before.png` and `ruleset-use-outside-after.png`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Use eligible ruleset items outside combat to apply healing, buffs, conditions, or resource restoration to the bearer. Successful uses consume an item or charge and report the outcome to the Game Master. * Restore resource pools with item effects during combat; restoration appears in combat updates. * Game Masters can use inventory commands to trigger item effects during generated turns. * **Compatibility** * Rulesets using item-based pool restoration or out-of-combat item use require Capability API 1.60. <!-- 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:05 +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#7368
No description provided.