mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6797] [MERGED] feat(game): a ruleset's own items in the inventory #7334
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7334
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6797
Author: @kolacheee
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/28/2026
Merged by: @kolacheee
Base:
staging← Head:feat/ruleset-items-inventory📝 Commits (7)
e4d07cafeat(game): a ruleset's own items in the inventory7434831test(game): spend a ruleset item in a fight2ffdf61fix(game): compare ruleset items in the turn record, and show the add row only when something can be added1c94d44test(game): check the Game Master's streamed answers read the ruleset's items9638ea8fix(game): stack what a new session brings back as its ruleset item allows, and word an item's price for any amount17e8f52fix(game): add by id only what the game's layers leave in, restore only ids the ruleset has, and say fights already spend ruleset items2b6d138fix(game): say when a picked item is no longer one of the ruleset's items📊 Changes
26 files changed (+1968 additions, -140 deletions)
View changed files
📝
CHANGELOG.md(+3 -1)📝
docs/extending/writing-rulesets.md(+9 -1)📝
docs/game/party-and-npcs.md(+4 -1)➕
e2e/game-ruleset-items.e2e.ts(+172 -0)📝
packages/client/src/components/game/GameInventory.tsx(+137 -27)📝
packages/client/src/components/game/GameSurface.tsx(+74 -3)➕
packages/client/src/components/game/RulesetItemPicker.tsx(+248 -0)➕
packages/client/src/hooks/use-ruleset-item-book.ts(+47 -0)📝
packages/client/src/localization/locales/en.json(+13 -0)📝
packages/client/vite.config.ts(+2 -1)📝
packages/server/src/routes/combat-director.routes.ts(+3 -3)📝
packages/server/src/routes/game-inventory.routes.ts(+4 -2)📝
packages/server/src/routes/game.routes.ts(+4 -1)📝
packages/server/src/routes/generate.routes.ts(+39 -3)📝
packages/server/src/services/game/game-inventory.service.ts(+56 -0)📝
packages/server/src/services/game/gm-prompts.ts(+29 -7)➕
packages/shared/src/features/rulesets/item-book.ts(+151 -0)📝
packages/shared/src/index.ts(+1 -0)📝
packages/shared/src/utils/game-inventory-ops.ts(+34 -11)📝
packages/shared/src/utils/game-inventory-stacks.ts(+247 -72)...and 6 more files
📄 Description
Linked issue
Closes #6795
Builds on #6794 (item ids and nicknames), now merged.
Why this change
Capability API 1.49 (#6771) lets a ruleset ship catalogs of its own items, each with a category, rarity, tags, stats, a stack size and a price. Nothing in a game read them: Game Mode's inventory only held plain items typed in by name, so a ruleset's Hand axe was just a name, with none of its details, and the ruleset's
freeformsetting did nothing.This is the second part of slice I2b of the ruleset items plan. I split I2b-2 in two (my call, like the I2 split, recorded in the plan): this PR puts the ruleset's items in the bag, and I2b-3 adds wearing and carrying (equip and bind with slots and the binding maximum, the Game Master's equip and bind commands, placement by carrying capacity, load and encumbrance). It needs no Capability API change.
What changed
item: "<catalog>/<entry>", which is its identity from then on, whatever it is called. Plain stacks are unchanged and still store no id, so saved games read exactly as before.rulesetItemBookinpackages/shared/src/features/rulesets/item-book.ts) reads a game's item catalogs the same way on the server and in the browser: which name is which item (its label, in any case; the first listed wins a shared label), how many one stack holds, and what each item is in the ruleset's own words (category, rarity and tag labels, the stats it gives, its summary and price). A layer that hides an entry takes it out of names and the picker, and an item already held still reads as itself.[inventory: action="add"], that is one of the ruleset's items adds that item. A held item still wins by its own name or a nickname, and a ruleset item wins over a plain item that only has its name.RulesetItemPicker, built like the sheet editor's catalog picker), with the catalogs' search and filters, each item's kind, stats, summary, price ("Price in marks: 4", since a ruleset's unit labels are plural) and stack size. The items ticked go into the bag of the open tab, one of each, in one change.stackis the most one stack holds. Adding fills the bag's stacks of the item in order and starts new ones of at most that size; setting a count past it fills the stack and starts new ones right after it; merging pours in only what fits; giving fills the receiver's stack and starts a new one. One change never starts more than 50 stacks.freeform: "refuse"leaves the player only the ruleset's items: the name field is hidden and the server refuses a typed plain item (not-ruleset-item). The Game Master's untyped items stay allowed; switching those off is slice I3'snative.Hand axe ×2 [Weapon, Common, Thrown; Bulk 1, Damage 1d6, Rolls with brawn, Reach close], only the stats the ruleset leavespromptVisible. The command line adds that a name that is one of the ruleset's items becomes that item. The inventory tags stay on their own server path (I2), with the ruleset's items passed in, rather than moving into the sheet commands as the plan first said; the plan records this.docs/game/party-and-npcs.mdcovers From the ruleset and stack sizes.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Run by the agent on this branch at
2b6d13824(e4d07caedand the follow-up commits7434831f7,2ffdf618b,1c94d4416,9638ea858,17e8f52b0and2b6d13824, on staging50249cee9):pnpm checkexits 0, andpnpm localization:checkexits 0.pnpm regression:nodepasses 421/421.pnpm smoke:uipasses 7/7.pnpm regression:ui e2e/game-ruleset-items.e2e.ts e2e/game-inventory-bags.e2e.ts e2e/game-inventory-stacks.e2e.ts e2e/game-combat-ai.e2e.ts e2e/game-combat-director.e2e.ts --project=desktop-chromium --workers=1passes 14/14.Lanes:
game-inventory-stacks.regression.ts: a stack of a ruleset item is that item whatever it is called; saveditemvalues are read back, and anything that is not a catalog and an entry is dropped; a name finds a ruleset item by its label, a nickname still finds a held one, and a ruleset item wins over a plain item that only has its name; adding by id, and refusing one the ruleset does not have;freeform: "refuse"refuses a new plain item but not one already held; stack sizes when adding (in order across stacks, then new ones), setting, merging and giving (the receiver's stack filled and a new one started); never more than 50 new stacks in one change; taking, counting, splitting, renaming and totals by item; the turn record telling apart stacks that differ only in their item; carry-over bringing a ruleset item back as itself, stacked as its item allows.game-ruleset-items.regression.ts: the item book from both examples (names in any case, ids, stack sizes, labels, stats, prices, value labels, yes-or-no stats, stats hidden from the Game Master, a layer hiding an entry from names but not from what is held, the first of two same-named items winning); the Game Master's inventory with facts in brackets, for the player and per bag, and the command line only when the ruleset has an item catalog.game-inventory-turn.regression.ts, through the real routes: the inventory route adding a ruleset item by typed name and by id and stacking arrows by 20; afreeform: "refuse"ruleset refusing a typed plain item asnot-ruleset-item; a real Game Master turn whose tags add the ruleset's road rations (stacked by 7), a plain lamp, and the ruleset's arrows beside an old plain Arrows stack, with the streamed answers already reading the ruleset; the next turn's prompt showing the facts; a new session bringing thirty arrows back as 20 and 10.combat-director-route.regression.ts: a fight spending a ruleset item.Forty-seven deliberate breaks of these rules, in the shared helpers, the item book, the inventory route, the turn, carry-over, the prompt and the fight route, were each caught. The first full run caught 39 of 40: dropping the ruleset from the turn's first answering pass was missed, because the pass after saving corrects the saved reply. The lane now checks the answers streamed before the save, with an item whose answer differs, and that break is caught.
Local CodeRabbit (
coderabbit review --agent), before opening:2ffdf618b: the turn record compares items, the add row's condition, and the give test now overflows the receiver's stack. Declined: carry-over reading an item's own name back off a plain id in lowercase. That is #6794's code: the id keeps only the case-folded name, so there is no original spelling to recover; the item stays exactly itself, and the nickname the player sees keeps its spelling.9638ea858: carry-over now stacks what it brings back as the ruleset allows. Declined: using the "only takes its own items" message when a picked item is refused. A picked item is refused only when the ruleset no longer has it, whateverfreeformsays, so that message would be wrong; the general "Failed to add" message is the honest one.9638ea858: no findings.2b6d13824: a pick refused because the ruleset no longer offers it (a layer hides it, or its catalog changed since the picker loaded) now says "... is no longer one of this ruleset's items", apart from picks that failed for another reason.GitHub CodeRabbit's first review found five. Four are fixed in
17e8f52b0: an item a layer hides can no longer be added by its id (the item rules gainedoffers, whileitemOfstill reads a hidden item already held); carry-over restores an item id only while the ruleset still has it; the author guide says a fight already spends a ruleset item; and the browser test opens the strict ruleset's game on a page of its own. Its translated-docs note is answered by the batched[docs-i18n]issue.Clicked through by the agent in the browser test, at desktop width and, in a throwaway copy, at phone width (mobile-chromium, 1024 by 2216 screenshots): the picker, the item details, the stack split and a typed ruleset item. At phone width the picker is full screen, the chips wrap, and the item details, the nickname field, the amount row and the Add row (name, Add and From the ruleset) all fit inside the panel. The committed test runs at desktop width only: at phone width the Inventory button's text label is hidden and it has no accessible name, so
getByRole("button", { name: /Inventory/ })cannot find it. That is older than this PR and is filed as #6796.A real model, run by the agent after opening: eight Game Master tellings on a local model (Gemma 4 E4B, Q8, through llama-server), in an isolated Engine on this branch with Ember Roads, a ruleset Hand axe, arrows nicknamed "Quiver" and a plain rope. In one telling of a purchase it wrote
add item="Leather Coat"andadd item="Road Rations" count="2". Both matched the ruleset's items despite the capital letters, were answeredok, and landed asLeather coat <outfitter/leather-coat>andRoad rations <outfitter/road-rations>. It never copied the bracketed facts into a tag or its narration. In the other seven tellings it wrote no inventory tag, as on #6794 (a small local model rarely writes the command), so a real model spending an item it holds was not seen; the lanes cover that with a scripted reply.Nothing is left to verify by hand.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs touched:
docs/game/party-and-npcs.mdanddocs/extending/writing-rulesets.md(both carried bydocs-i18n) andCHANGELOG.md. Translations are batched for the items arc: these sections join the batched[docs-i18n]issue opened after the arc's last slice, so no per-PR issue is opened.UI evidence (if applicable)
The new browser test
e2e/game-ruleset-items.e2e.tspicks a Hand axe and Arrows from the picker, checks what the selected item shows, sets 25 arrows and sees a stack of 20 and one of 5, adds a Hand axe by typing its name, and checks that a ruleset that takes only its own items shows only the picker. It saves screenshots of the picker and the inventory.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.