[PR #6921] [MERGED] feat(rulesets): markets: price levels, place sizes, sellers, services and the Game Master's buy #7385

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-items-markets


📝 Commits (4)

  • ad57a97 feat(rulesets): markets: price levels, place sizes, sellers, services and the Game Master's buy (#6917)
  • e53f064 fix(rulesets): a place a player types never counts, a service is never added to a bag, and a buy that does not fully fit is refused (#6917)
  • 94ca74f Merge remote-tracking branch 'origin/staging' into feat/ruleset-items-markets
  • 2b3aca6 fix(rulesets): a seller's only reads what the buyer carries at that tag, and the market e2e matches its notifications exactly (#6917)

📊 Changes

38 files changed (+2324 additions, -25 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+30 -0)
📝 docs/examples/rulesets/gravewatch.json (+43 -2)
📝 docs/extending/ruleset.schema.json (+358 -0)
📝 docs/extending/writing-rulesets.md (+51 -2)
📝 docs/game/party-and-npcs.md (+2 -0)
➕ e2e/game-ruleset-markets.e2e.ts (+179 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+9 -0)
📝 packages/client/src/components/game/RulesetItemPicker.tsx (+2 -1)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/server/src/routes/generate.routes.ts (+64 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+18 -0)
📝 packages/server/src/services/game/game-inventory.service.ts (+8 -1)
➕ packages/server/src/services/game/game-market.service.ts (+90 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+13 -1)
📝 packages/shared/src/features/rulesets/item-book.ts (+1 -0)
➕ packages/shared/src/features/rulesets/market.ts (+221 -0)
📝 packages/shared/src/index.ts (+2 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+7 -1)
📝 packages/shared/src/schemas/gm-verb-table.schema.ts (+1 -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 #6917

Why this change

  • Since #6901 a Game Mode ruleset's items can have a cost in the ruleset's own coins, but buying is the Game Master's payment and then an add: every shop in the world sells everything at its list price, and nothing but the Game Master's judgement decides what a place has. The user asked (2026-09-30) for what can be bought, and what it costs, to follow the size of the place and the kind of seller, with price levels. This is slice I9-1 of the ruleset items plan.

What changed

  • A market in the items block (Capability API 1.65, new features/rulesets/market.ts):
    • prices: levels, each a multiplier on an item's cost, one the default (cheap, fair and dear at ×0.75, ×1 and ×1.5, say). A price is worked out in the cost family's smallest coin, rounded there (never below one coin for something that costs anything), and said in the largest coin the game's layers leave that pays it exactly.
    • places: a ladder of place sizes in the ruleset's own words, smallest first.
    • sold: rules for the smallest place that sells what a filter picks (filters read as a loot line's are; the first match decides). An item's own sold wins; an item nothing names is sold anywhere.
    • sellers: what each kind of seller sells, the smallest place that has one, and who it sells only to (a value off the buyer's sheet, read as an item's gate.unless is).
    • service: true on an item: bought like one, never carried. Buying it only pays.
  • Where the party is: the Game Master's [place: name="Millbrook" size="market town"], answered in place (an unknown size is refused). The place in force is the last one answered in the messages the player sees, from the latest conversation start and only before the telling a regeneration replaces, then the reply's own; so swipes, deletions and branches need nothing stored. place is now a reserved GM tag name. The worldgen plan will later fill the same seam from a generated world.
  • Buying: [inventory: action="buy" item level seller count who]. The Engine checks the place and the seller sell it, prices it, pays out of the buyer's purse as a payment is (largest coins first, change back), and adds the item to their bag, or refuses and changes nothing (no place, an unknown level, item or seller, no price, too small a place, no seller here, a seller's only, a purse or a bag that cannot take it). The answer carries the price, and a notification says "You bought ... for 12 shillings." The market is built once per turn and kept on the inventory turn, so the preview and the save answer alike.
  • What the Game Master sees, only with a market: the [place:] and buy lines, and a MARKET block naming the place and its size, the levels, and each seller there with a dozen wares at the default level, cheapest first.
  • Gravewatch's example has a market: three levels, four places, rare things from a market town up and arms from a village up, a watch pistol only in a city, a chandler, a smith and a chapel that sells litany pages only to wardens of Nerve 3 or more, and a bed at the watch-house as a service.
  • Docs: a Markets section, sold and service in the item fields, and the version rundown in docs/extending/writing-rulesets.md; the Money section of docs/game/party-and-npcs.md; the I9-1 record in docs/development/game-rulesets-and-sheets-implementation.md; the regenerated docs/extending/ruleset.schema.json; and a CHANGELOG entry.
  • Left for I9-2 (in the plan): a seller's rare stock rolled from a loot table per visit, limited items a place keeps only a few of, and selling back up to a purse per day.

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 (Fedora):

  • pnpm check, pnpm localization:check and prettier: clean.
  • pnpm regression: 481 of 481.
  • pnpm smoke:ui: 7 passed.
  • Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 54 passed. Mobile e2e (every ruleset spec): 29 passed.
  • Rebased onto staging 186cc60f4 afterwards (the CHANGELOG was the only conflict): pnpm check, pnpm localization:check, pnpm regression (481 of 481) and the markets and money e2e (3 passed) again.

Lanes:

  • New game-ruleset-markets.regression.ts: every import check (levels, the one default, places, rules, filters, sellers, only, an item's place with and without a market, a service's cost and what it may not have); places by id or label, the default level, filters by every word, the rank an item is sold from (its own place, the first rule, anywhere), the sellers at each size; prices (dear, cheap, counted, the largest coin that pays, rounding, never below one, free stays free, a layer that takes crowns out); buys (a dear coat paid with change, a service that only pays, a member's purse and bag, every refusal changing nothing, a hidden item, an item nobody can carry costing nothing, a layer's coins); place tags (answered, refused, unreadable, the last in force, only answered ones, no market); the MARKET block (exact lines, no place said, no market, a small place with no seller, a dozen and how many more) and the instructions with and without a market; the 1.65 gate for a market, an item's place and a service each alone; and, on a real database, the place before a reply (and without the telling a regeneration replaces) and a seller's only read off the player's card, a member's, a persona's and a blank sheet.
  • The lanes that prove older Capability API minors against the examples (ammo, armor, item-charges, item-gate, item-use, item-use-outside, loot, money, weapon-modes, weapons) strip the 1.65 keys as they strip the 1.64 ones; capability-package-lifecycle pins 1.65; capability-gm-verbs reserves place.
  • New e2e/game-ruleset-markets.e2e.ts: a real turn against a local model fixture names a market town and buys a dear coat and a bed at the watch-house (paid with change, the coat in the bag, the bed not), a watch pistol is refused as only a city sells it, both notifications show, and the next turn's prompt carries that town's MARKET block.

60 deliberate breaks, each caught by these lanes and the e2e.

GitHub CodeRabbit's first review raised three real findings, all fixed in e53f064a7: a place tag a player types no longer counts (only the Game Master's replies are read); a service is refused by the add operation itself, so nothing puts one in a bag, and the picker leaves services out; and a buy whose items do not all fit is refused whole, so nothing is paid for what is not delivered. Each has a lane case (and the picker an e2e check) and a deliberate break. Local CodeRabbit on that commit: no findings.

Local CodeRabbit raised eight findings over three passes:

  • Real: the place before a regenerated reply skipped the replaced telling but still read the messages after it, and ignored a conversation start. Fixed: it reads only what came before, from the latest conversation start, as the Game Master's own context is scoped (two lane cases, three breaks).
  • Real: a seller's only read live state off the newest stored row, which during a regeneration is the replaced telling's. Fixed: the route hands the market the turn's own live state, the one the reply's items are used with (a lane case where Resolve left decides, one break). The route's choice of that state is the same expression the item uses read, proven by typecheck rather than a regeneration e2e.
  • Declined, three times: treating a place id the market does not know as "sold nowhere". Every place a rule, a seller or an item names is checked at import (items in a catalog file when that file is read), so no unknown id reaches the market.
  • Declined: loading the sheet context only when a seller has only (one chat read per turn, only in games with a market); wrapping the MARKET block's building in its own try/catch (the item facts, purses and carrying status beside it are built from the same calls, unwrapped, and a catalog that cannot be read is already logged and left out by the book loader); and adding service to the chandler in the docs' shortened example (a shortened example; services are described on their own below 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/party-and-npcs.md, docs/development/game-rulesets-and-sheets-implementation.md (all carried by docs-i18n), docs/extending/ruleset.schema.json (generated), and CHANGELOG.md. Translations: #6813 is the items arc's follow-up; this PR is added to it there.

UI evidence (if applicable)

A market town turn: "You bought Lantern-keeper's coat for 12 shillings." and "You bought A bed at the watch-house for 6 pennies." (captured by e2e/game-ruleset-markets.e2e.ts as market-bought.png).

Summary by CodeRabbit

  • New Features
    • Added configurable markets with location-based offerings, price levels, seller restrictions, and services.
    • Purchases charge the buyer, provide change, and add goods to inventory. Services are paid for without being carried. Successful purchases display their price; unavailable or unaffordable purchases are refused.
    • Added market examples to the Gravewatch ruleset.
  • Documentation
    • Updated ruleset authoring and game inventory guides with market and purchasing details.

🔄 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/6921 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/30/2026 **Status:** ✅ Merged **Merged:** 10/1/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-items-markets` --- ### 📝 Commits (4) - [`ad57a97`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad57a9728ec37b51bf5d687b6dffd812f6f82d05) feat(rulesets): markets: price levels, place sizes, sellers, services and the Game Master's buy (#6917) - [`e53f064`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e53f064a7c41e5067fc0b316b212ada1e13cc521) fix(rulesets): a place a player types never counts, a service is never added to a bag, and a buy that does not fully fit is refused (#6917) - [`94ca74f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/94ca74f00f6e106f943a74d7e9e59997d5afff7d) Merge remote-tracking branch 'origin/staging' into feat/ruleset-items-markets - [`2b3aca6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2b3aca64631f925a141e524d524bd8cfbf3d1c4b) fix(rulesets): a seller's only reads what the buyer carries at that tag, and the market e2e matches its notifications exactly (#6917) ### 📊 Changes **38 files changed** (+2324 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+30 -0) 📝 `docs/examples/rulesets/gravewatch.json` (+43 -2) 📝 `docs/extending/ruleset.schema.json` (+358 -0) 📝 `docs/extending/writing-rulesets.md` (+51 -2) 📝 `docs/game/party-and-npcs.md` (+2 -0) ➕ `e2e/game-ruleset-markets.e2e.ts` (+179 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+9 -0) 📝 `packages/client/src/components/game/RulesetItemPicker.tsx` (+2 -1) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+64 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+18 -0) 📝 `packages/server/src/services/game/game-inventory.service.ts` (+8 -1) ➕ `packages/server/src/services/game/game-market.service.ts` (+90 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+13 -1) 📝 `packages/shared/src/features/rulesets/item-book.ts` (+1 -0) ➕ `packages/shared/src/features/rulesets/market.ts` (+221 -0) 📝 `packages/shared/src/index.ts` (+2 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+7 -1) 📝 `packages/shared/src/schemas/gm-verb-table.schema.ts` (+1 -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 #6917 ## Why this change - Since #6901 a Game Mode ruleset's items can have a `cost` in the ruleset's own coins, but buying is the Game Master's payment and then an add: every shop in the world sells everything at its list price, and nothing but the Game Master's judgement decides what a place has. The user asked (2026-09-30) for what can be bought, and what it costs, to follow the size of the place and the kind of seller, with price levels. This is slice I9-1 of the ruleset items plan. ## What changed - **A market in the items block** (Capability API 1.65, new `features/rulesets/market.ts`): - `prices`: levels, each a multiplier on an item's cost, one the default (cheap, fair and dear at ×0.75, ×1 and ×1.5, say). A price is worked out in the cost family's smallest coin, rounded there (never below one coin for something that costs anything), and said in the largest coin the game's layers leave that pays it exactly. - `places`: a ladder of place sizes in the ruleset's own words, smallest first. - `sold`: rules for the smallest place that sells what a filter picks (filters read as a loot line's are; the first match decides). An item's own `sold` wins; an item nothing names is sold anywhere. - `sellers`: what each kind of seller sells, the smallest place that has one, and who it sells `only` to (a value off the buyer's sheet, read as an item's `gate.unless` is). - `service: true` on an item: bought like one, never carried. Buying it only pays. - **Where the party is**: the Game Master's `[place: name="Millbrook" size="market town"]`, answered in place (an unknown size is refused). The place in force is the last one answered in the messages the player sees, from the latest conversation start and only before the telling a regeneration replaces, then the reply's own; so swipes, deletions and branches need nothing stored. `place` is now a reserved GM tag name. The worldgen plan will later fill the same seam from a generated world. - **Buying**: `[inventory: action="buy" item level seller count who]`. The Engine checks the place and the seller sell it, prices it, pays out of the buyer's purse as a payment is (largest coins first, change back), and adds the item to their bag, or refuses and changes nothing (no place, an unknown level, item or seller, no price, too small a place, no seller here, a seller's `only`, a purse or a bag that cannot take it). The answer carries the `price`, and a notification says "You bought ... for 12 shillings." The market is built once per turn and kept on the inventory turn, so the preview and the save answer alike. - **What the Game Master sees**, only with a market: the `[place:]` and `buy` lines, and a MARKET block naming the place and its size, the levels, and each seller there with a dozen wares at the default level, cheapest first. - **Gravewatch's example** has a market: three levels, four places, rare things from a market town up and arms from a village up, a watch pistol only in a city, a chandler, a smith and a chapel that sells litany pages only to wardens of Nerve 3 or more, and a bed at the watch-house as a service. - **Docs**: a Markets section, `sold` and `service` in the item fields, and the version rundown in `docs/extending/writing-rulesets.md`; the Money section of `docs/game/party-and-npcs.md`; the I9-1 record in `docs/development/game-rulesets-and-sheets-implementation.md`; the regenerated `docs/extending/ruleset.schema.json`; and a CHANGELOG entry. - **Left for I9-2** (in the plan): a seller's rare stock rolled from a loot table per visit, `limited` items a place keeps only a few of, and selling back up to a purse per day. ## 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 (Fedora): - `pnpm check`, `pnpm localization:check` and prettier: clean. - `pnpm regression`: 481 of 481. - `pnpm smoke:ui`: 7 passed. - Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 54 passed. Mobile e2e (every ruleset spec): 29 passed. - Rebased onto staging 186cc60f4 afterwards (the CHANGELOG was the only conflict): `pnpm check`, `pnpm localization:check`, `pnpm regression` (481 of 481) and the markets and money e2e (3 passed) again. Lanes: - New `game-ruleset-markets.regression.ts`: every import check (levels, the one default, places, rules, filters, sellers, `only`, an item's place with and without a market, a service's cost and what it may not have); places by id or label, the default level, filters by every word, the rank an item is sold from (its own place, the first rule, anywhere), the sellers at each size; prices (dear, cheap, counted, the largest coin that pays, rounding, never below one, free stays free, a layer that takes crowns out); buys (a dear coat paid with change, a service that only pays, a member's purse and bag, every refusal changing nothing, a hidden item, an item nobody can carry costing nothing, a layer's coins); place tags (answered, refused, unreadable, the last in force, only answered ones, no market); the MARKET block (exact lines, no place said, no market, a small place with no seller, a dozen and how many more) and the instructions with and without a market; the 1.65 gate for a market, an item's place and a service each alone; and, on a real database, the place before a reply (and without the telling a regeneration replaces) and a seller's `only` read off the player's card, a member's, a persona's and a blank sheet. - The lanes that prove older Capability API minors against the examples (`ammo`, `armor`, `item-charges`, `item-gate`, `item-use`, `item-use-outside`, `loot`, `money`, `weapon-modes`, `weapons`) strip the 1.65 keys as they strip the 1.64 ones; `capability-package-lifecycle` pins 1.65; `capability-gm-verbs` reserves `place`. - New `e2e/game-ruleset-markets.e2e.ts`: a real turn against a local model fixture names a market town and buys a dear coat and a bed at the watch-house (paid with change, the coat in the bag, the bed not), a watch pistol is refused as only a city sells it, both notifications show, and the next turn's prompt carries that town's MARKET block. 60 deliberate breaks, each caught by these lanes and the e2e. GitHub CodeRabbit's first review raised three real findings, all fixed in e53f064a7: a place tag a player types no longer counts (only the Game Master's replies are read); a service is refused by the add operation itself, so nothing puts one in a bag, and the picker leaves services out; and a buy whose items do not all fit is refused whole, so nothing is paid for what is not delivered. Each has a lane case (and the picker an e2e check) and a deliberate break. Local CodeRabbit on that commit: no findings. Local CodeRabbit raised eight findings over three passes: - Real: the place before a regenerated reply skipped the replaced telling but still read the messages after it, and ignored a conversation start. Fixed: it reads only what came before, from the latest conversation start, as the Game Master's own context is scoped (two lane cases, three breaks). - Real: a seller's `only` read live state off the newest stored row, which during a regeneration is the replaced telling's. Fixed: the route hands the market the turn's own live state, the one the reply's items are used with (a lane case where Resolve left decides, one break). The route's choice of that state is the same expression the item uses read, proven by typecheck rather than a regeneration e2e. - Declined, three times: treating a place id the market does not know as "sold nowhere". Every place a rule, a seller or an item names is checked at import (items in a catalog file when that file is read), so no unknown id reaches the market. - Declined: loading the sheet context only when a seller has `only` (one chat read per turn, only in games with a market); wrapping the MARKET block's building in its own try/catch (the item facts, purses and carrying status beside it are built from the same calls, unwrapped, and a catalog that cannot be read is already logged and left out by the book loader); and adding `service` to the chandler in the docs' shortened example (a shortened example; services are described on their own below 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/party-and-npcs.md`, `docs/development/game-rulesets-and-sheets-implementation.md` (all carried by `docs-i18n`), `docs/extending/ruleset.schema.json` (generated), and `CHANGELOG.md`. Translations: #6813 is the items arc's follow-up; this PR is added to it there. ## UI evidence (if applicable) A market town turn: "You bought Lantern-keeper's coat for 12 shillings." and "You bought A bed at the watch-house for 6 pennies." (captured by `e2e/game-ruleset-markets.e2e.ts` as `market-bought.png`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added configurable markets with location-based offerings, price levels, seller restrictions, and services. * Purchases charge the buyer, provide change, and add goods to inventory. Services are paid for without being carried. Successful purchases display their price; unavailable or unaffordable purchases are refused. * Added market examples to the Gravewatch ruleset. * **Documentation** * Updated ruleset authoring and game inventory guides with market and purchasing details. <!-- 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:15 +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#7385
No description provided.