[PR #6903] [MERGED] feat(rulesets): money: coins in the bags, paying and earning, coin layers and loot (#6901) #7375

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

📋 Pull Request Information

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

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


📝 Commits (2)

  • 7dda27c feat(rulesets): money: coins in the bags, paying and earning, coin layers and loot (#6901)
  • d2fb52f test(rulesets): the money turn's retelling is checked to succeed and pay again (#6901)

📊 Changes

39 files changed (+1541 additions, -72 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+39 -0)
📝 docs/examples/rulesets/gravewatch.json (+5 -3)
📝 docs/extending/ruleset.schema.json (+32 -0)
📝 docs/extending/writing-rulesets.md (+26 -7)
📝 docs/game/party-and-npcs.md (+10 -0)
📝 e2e/game-ruleset-fight-fixture.ts (+8 -1)
➕ e2e/game-ruleset-money.e2e.ts (+196 -0)
📝 packages/client/src/components/game/GameInventory.tsx (+55 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+10 -1)
📝 packages/client/src/components/game/RulesetItemPicker.tsx (+18 -6)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/server/src/routes/generate.routes.ts (+22 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+18 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+37 -1)
📝 packages/shared/src/features/rulesets/item-book.ts (+109 -9)
📝 packages/shared/src/features/rulesets/layers.ts (+19 -0)
📝 packages/shared/src/features/rulesets/loot.ts (+3 -1)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+6 -1)

...and 19 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 #6901

Why this change

  • A Game Mode ruleset could declare currencies and price its items since Capability API 1.49, but nothing held money: nobody had a purse, the Game Master could not charge anyone or pay them, and coins weighed nothing even where the ruleset said they did. This is slice I7-2 of the ruleset items plan, after loot (#6900).
  • Building it turned up a bug from the loot slice: in the browser, a ruleset with loot tables silently lost its layers (Gravewatch's long night), because the listing the browser gets sends catalogs without their entries and the loot table's item check then failed. The Game Master still played by the layer; the sheet and pickers did not.

What changed

  • Coins are items in the bags. A coin is a stack whose item is coin:<unit id>, named for its unit, so it gets everything a stack already has: each character's bag, giving, splitting, merging, carry-over and a turn's restart. It weighs one unit of the carry stat per perWeight of its family and counts toward its bearer's load.
  • The purse line. Above the inventory's stacks, each family's coins in view and what they come to in the family's smallest coin, such as "Coin: crowns x1, pennies x12 (worth 72 pennies)": one bag's in a member's tab, the party's in All. The "From the ruleset" picker has a Coins list.
  • Paying and earning. [inventory: action="pay" amount="3 shillings" who="Ada"] and action="earn". A payment comes out of one bag (the player's without who=), inside the coin's family only: the largest coins that fit go first, then the smallest coin left that covers the rest is broken and the change comes back in smaller coins. The answer says what was paid and what came back ("Paid with crowns ×1; shillings ×2 back."), and a payment the purse cannot meet, a coin the ruleset does not have, or any payment in a ruleset without currencies is refused. An earning is an add of the coin. The journal lists both, and the screen announces each ("You paid shillings x3.").
  • What the Game Master sees. Each bag's worth beside it ("Coin worth 54 pennies"), an item's price in its facts ("costs 15 shillings"), and the pay and earn line only where the ruleset has coins.
  • Layers take coins out (Capability API 1.64): a layer's currencies names removeUnits or removeFamilies; a family's smallest coin goes only with its family. Like a catalog entry a layer hides, the ruleset keeps the coin: the purse, the picker, paying, earning and loot leave it out, coins already held stay in the bag, and a price named in it is said at the same worth in the largest coin left that pays it exactly. Taking the coins out of the layered definition instead made its validation fail wherever an item is priced in them, which silently dropped the whole layer.
  • Loot drops coins (Capability API 1.64): a loot line may name coins (a unit id) instead of an item or a filter.
  • The install gate asks for 1.64 for either key, after the 1.63 check.
  • The browser keeps a layer over loot tables. A layered definition no longer re-checks a loot line's item against the catalog's entries, which the listing does not carry; the file was checked at import.
  • Examples: Gravewatch's grave goods drop a few shillings, and its long night takes the crown out.
  • Docs: the Money section, the coin loot line, the layer's currencies and the capability list in docs/extending/writing-rulesets.md, a Money section in docs/game/party-and-npcs.md, the 1.64 record in docs/development/game-rulesets-and-sheets-implementation.md, the regenerated JSON schema and CHANGELOG entries.

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: 479 of 479.
  • pnpm smoke:ui: 7 passed.
  • Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 51 passed. Mobile e2e (every ruleset spec): 26 passed.

Lanes:

  • New game-ruleset-money.regression.ts: every import refusal; the 1.64 gate (the example, a coin loot line alone, a layer's coins alone, neither); coin refs; the book's coins (weights from perWeight, the load, found by id or label, one or many, the family largest first, a name finding a coin, salt as its own family); paying (largest first, breaking the smallest coin that covers the rest, change in smaller coins, one bag only, change into the payer's bag, never across families); the Game Master's pay and earn (answers, notes, now, a bare pay, an item and a count as an amount, the journal, every refusal, amounts by the thousand, an earning into the player's bag); the purse text and an item's price for the Game Master; the pay and earn line with and without coins; the long night (the layer still applies, the ruleset keeps its coins, the book hides the crown but reads a held one, prices at the same worth, a price no coin pays exactly, a family gone taking its prices, the purse and a payment ignoring hidden coins, the Game Master taught only the coins left); loot dropping coins, and not a hidden one.
  • game-inventory-turn.regression.ts gains a real turn under the long night: the prompt carries the purse and a price in shillings and never names crowns, the saved reply pays largest first, and a regenerated reply pays once.
  • game-ruleset-loot.regression.ts pins the browser's listing keeping the long night.
  • Lanes that pin the 1.63 gate, the supported API, or an item's facts for the Game Master were brought up to date.
  • e2e/game-ruleset-money.e2e.ts: the purse line, the picker's Coins list, and a real turn against a local model fixture whose Game Master charges 3 shillings and gives 2 pennies (both announced, the bag and the purse line changed); and a long night game whose purse and Coins list leave the crown out while a held crown stays, and whose picker prices the watch pistol at 15 shillings.

57 deliberate breaks. 50 were caught on the first run. Five slipped past, and four new cases now catch them: a coin found by its id and by its name in the singular when those differ (Gravewatch's pence written as d), a family that lists its coins largest first, the same coin in two bags, and an earning of 50,000 coins. The other two showed conditions in the payment that could never change its result (every coin still held after the first pass is worth more than what is left, and change is always worth less than the coin broken), so they were deleted. All 55 that remain are caught.

Local CodeRabbit raised two findings. One was real: the implementation record still had a placeholder for the break count, now filled in. One was declined: it asked to drop currency families left with no coins before the Game Master's pay line reads a family's first and last coin, but no family can be left empty. The import refuses a layer that takes a family's smallest coin without the whole family (pinned by the money lane), so every family left keeps its coin worth 1.

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)

The purse line above the stacks reads "Coin: crowns x1, shillings x1, pennies x12 (worth 84 pennies)" after a shilling is picked from the Coins list (captured by e2e/game-ruleset-money.e2e.ts as money-purse.png).

Summary by CodeRabbit

  • New Features
    • Rulesets can define coin denominations, currency families, and loot that awards coins. Coins appear in inventory, contribute configured weight, and can be split, given, or merged.
    • The item picker includes available coins, and inventory displays purse totals by currency family.
    • Game Masters can charge or award money. Payments use one currency family, make change when possible, and are refused when funds are insufficient.
    • Ruleset variants can hide coins or currency families while displaying item prices in equivalent available denominations. Layers remain visible in Game Mode for rulesets with loot tables.
  • Compatibility
    • Currency rules and coin loot require Capability API 1.64.

🔄 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/6903 **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-money` --- ### 📝 Commits (2) - [`7dda27c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7dda27cd787d6497b1fb41c9a867765a97a197d6) feat(rulesets): money: coins in the bags, paying and earning, coin layers and loot (#6901) - [`d2fb52f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d2fb52f007c0b45c797b70c256c88de3853224aa) test(rulesets): the money turn's retelling is checked to succeed and pay again (#6901) ### 📊 Changes **39 files changed** (+1541 additions, -72 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+39 -0) 📝 `docs/examples/rulesets/gravewatch.json` (+5 -3) 📝 `docs/extending/ruleset.schema.json` (+32 -0) 📝 `docs/extending/writing-rulesets.md` (+26 -7) 📝 `docs/game/party-and-npcs.md` (+10 -0) 📝 `e2e/game-ruleset-fight-fixture.ts` (+8 -1) ➕ `e2e/game-ruleset-money.e2e.ts` (+196 -0) 📝 `packages/client/src/components/game/GameInventory.tsx` (+55 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+10 -1) 📝 `packages/client/src/components/game/RulesetItemPicker.tsx` (+18 -6) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+22 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+18 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+37 -1) 📝 `packages/shared/src/features/rulesets/item-book.ts` (+109 -9) 📝 `packages/shared/src/features/rulesets/layers.ts` (+19 -0) 📝 `packages/shared/src/features/rulesets/loot.ts` (+3 -1) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+6 -1) _...and 19 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 #6901 ## Why this change - A Game Mode ruleset could declare currencies and price its items since Capability API 1.49, but nothing held money: nobody had a purse, the Game Master could not charge anyone or pay them, and coins weighed nothing even where the ruleset said they did. This is slice I7-2 of the ruleset items plan, after loot (#6900). - Building it turned up a bug from the loot slice: in the browser, a ruleset with loot tables silently lost its layers (Gravewatch's long night), because the listing the browser gets sends catalogs without their entries and the loot table's item check then failed. The Game Master still played by the layer; the sheet and pickers did not. ## What changed - **Coins are items in the bags.** A coin is a stack whose item is `coin:<unit id>`, named for its unit, so it gets everything a stack already has: each character's bag, giving, splitting, merging, carry-over and a turn's restart. It weighs one unit of the carry stat per `perWeight` of its family and counts toward its bearer's load. - **The purse line.** Above the inventory's stacks, each family's coins in view and what they come to in the family's smallest coin, such as "Coin: crowns x1, pennies x12 (worth 72 pennies)": one bag's in a member's tab, the party's in **All**. The "From the ruleset" picker has a **Coins** list. - **Paying and earning.** `[inventory: action="pay" amount="3 shillings" who="Ada"]` and `action="earn"`. A payment comes out of one bag (the player's without `who=`), inside the coin's family only: the largest coins that fit go first, then the smallest coin left that covers the rest is broken and the change comes back in smaller coins. The answer says what was paid and what came back ("Paid with crowns ×1; shillings ×2 back."), and a payment the purse cannot meet, a coin the ruleset does not have, or any payment in a ruleset without currencies is refused. An earning is an add of the coin. The journal lists both, and the screen announces each ("You paid shillings x3."). - **What the Game Master sees.** Each bag's worth beside it ("Coin worth 54 pennies"), an item's price in its facts ("costs 15 shillings"), and the pay and earn line only where the ruleset has coins. - **Layers take coins out** (Capability API 1.64): a layer's `currencies` names `removeUnits` or `removeFamilies`; a family's smallest coin goes only with its family. Like a catalog entry a layer hides, the ruleset keeps the coin: the purse, the picker, paying, earning and loot leave it out, coins already held stay in the bag, and a price named in it is said at the same worth in the largest coin left that pays it exactly. Taking the coins out of the layered definition instead made its validation fail wherever an item is priced in them, which silently dropped the whole layer. - **Loot drops coins** (Capability API 1.64): a loot line may name `coins` (a unit id) instead of an item or a filter. - **The install gate** asks for 1.64 for either key, after the 1.63 check. - **The browser keeps a layer over loot tables.** A layered definition no longer re-checks a loot line's item against the catalog's entries, which the listing does not carry; the file was checked at import. - **Examples:** Gravewatch's grave goods drop a few shillings, and its long night takes the crown out. - **Docs:** the Money section, the coin loot line, the layer's `currencies` and the capability list in `docs/extending/writing-rulesets.md`, a Money section in `docs/game/party-and-npcs.md`, the 1.64 record in `docs/development/game-rulesets-and-sheets-implementation.md`, the regenerated JSON schema and CHANGELOG entries. ## 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`: 479 of 479. - `pnpm smoke:ui`: 7 passed. - Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 51 passed. Mobile e2e (every ruleset spec): 26 passed. Lanes: - New `game-ruleset-money.regression.ts`: every import refusal; the 1.64 gate (the example, a coin loot line alone, a layer's coins alone, neither); coin refs; the book's coins (weights from `perWeight`, the load, found by id or label, one or many, the family largest first, a name finding a coin, salt as its own family); paying (largest first, breaking the smallest coin that covers the rest, change in smaller coins, one bag only, change into the payer's bag, never across families); the Game Master's pay and earn (answers, notes, `now`, a bare pay, an item and a count as an amount, the journal, every refusal, amounts by the thousand, an earning into the player's bag); the purse text and an item's price for the Game Master; the pay and earn line with and without coins; the long night (the layer still applies, the ruleset keeps its coins, the book hides the crown but reads a held one, prices at the same worth, a price no coin pays exactly, a family gone taking its prices, the purse and a payment ignoring hidden coins, the Game Master taught only the coins left); loot dropping coins, and not a hidden one. - `game-inventory-turn.regression.ts` gains a real turn under the long night: the prompt carries the purse and a price in shillings and never names crowns, the saved reply pays largest first, and a regenerated reply pays once. - `game-ruleset-loot.regression.ts` pins the browser's listing keeping the long night. - Lanes that pin the 1.63 gate, the supported API, or an item's facts for the Game Master were brought up to date. - `e2e/game-ruleset-money.e2e.ts`: the purse line, the picker's Coins list, and a real turn against a local model fixture whose Game Master charges 3 shillings and gives 2 pennies (both announced, the bag and the purse line changed); and a long night game whose purse and Coins list leave the crown out while a held crown stays, and whose picker prices the watch pistol at 15 shillings. 57 deliberate breaks. 50 were caught on the first run. Five slipped past, and four new cases now catch them: a coin found by its id and by its name in the singular when those differ (Gravewatch's pence written as `d`), a family that lists its coins largest first, the same coin in two bags, and an earning of 50,000 coins. The other two showed conditions in the payment that could never change its result (every coin still held after the first pass is worth more than what is left, and change is always worth less than the coin broken), so they were deleted. All 55 that remain are caught. Local CodeRabbit raised two findings. One was real: the implementation record still had a placeholder for the break count, now filled in. One was declined: it asked to drop currency families left with no coins before the Game Master's pay line reads a family's first and last coin, but no family can be left empty. The import refuses a layer that takes a family's smallest coin without the whole family (pinned by the money lane), so every family left keeps its coin worth 1. ## 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) The purse line above the stacks reads "Coin: crowns x1, shillings x1, pennies x12 (worth 84 pennies)" after a shilling is picked from the Coins list (captured by `e2e/game-ruleset-money.e2e.ts` as `money-purse.png`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Rulesets can define coin denominations, currency families, and loot that awards coins. Coins appear in inventory, contribute configured weight, and can be split, given, or merged. * The item picker includes available coins, and inventory displays purse totals by currency family. * Game Masters can charge or award money. Payments use one currency family, make change when possible, and are refused when funds are insufficient. * Ruleset variants can hide coins or currency families while displaying item prices in equivalent available denominations. Layers remain visible in Game Mode for rulesets with loot tables. * **Compatibility** * Currency rules and coin loot require Capability API 1.64. <!-- 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:08 +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#7375
No description provided.