[PR #6900] [MERGED] feat(rulesets): loot on victory, ruleset loot tables and creature loot (#6894, #6758) #7374

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/6900
Author: @kolacheee
Created: 9/30/2026
Status: ✅ Merged
Merged: 9/30/2026
Merged by: @kolacheee

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


📝 Commits (2)

  • ef57869 feat(rulesets): loot on victory, ruleset loot tables and creature loot (#6894, #6758)
  • 1ff4725 fix(game): a fight's recap reaches the chat it ended in, even when the player has left it (#6894)

📊 Changes

42 files changed (+1991 additions, -167 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+40 -0)
📝 docs/examples/rulesets/gravewatch.json (+16 -0)
📝 docs/extending/ruleset.schema.json (+106 -0)
📝 docs/extending/writing-rulesets.md (+31 -1)
📝 docs/game/combat.md (+1 -1)
➕ e2e/game-ruleset-loot.e2e.ts (+344 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+114 -74)
📝 packages/client/src/components/game/game-narration-format.ts (+8 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/db/seed-mari.ts (+1 -1)
📝 packages/server/src/routes/combat-director.routes.ts (+33 -0)
📝 packages/server/src/routes/game-inventory.routes.ts (+20 -0)
📝 packages/server/src/routes/game.routes.ts (+0 -35)
📝 packages/server/src/routes/generate.routes.ts (+14 -1)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+17 -0)
📝 packages/server/src/services/game/combat-director.service.ts (+5 -0)
➕ packages/server/src/services/game/game-loot.service.ts (+193 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+10 -0)
📝 packages/server/src/services/game/loot.service.ts (+21 -13)

...and 22 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 #6894
Closes #6758

Why this change

  • The combat guide and Mari's instructions have long said that a won fight drops loot, but nothing produced it (#6758). The native loot service and its two routes had no caller, and the recap told the Game Master to decide rewards itself. A Game Mode ruleset could declare items and currencies, but had no way to say what its creatures carry or what a treasure table holds. This is slice I7-1 of the ruleset items plan, loot; money (purses, paying and earning) follows as I7-2.
  • On #6758 the user ruled to make the docs true rather than trim them: games without a ruleset get the native drops the guide describes.

What changed

  • A won fight drops loot in every Game Mode game, once, into the party's bags. One rule decides where it comes from:
    • Without a ruleset, or with one that declares no loot tables and leaves native items on, it comes from Game Mode's own tables (loot.service.ts, whose randomness is now injectable): more and rarer drops on a harder game, into the player's bag, as every weightless item goes.
    • A ruleset that declares loot tables drops its own items instead. Each defeated bestiary creature rolls the table it names, into the shared view by the carrying rule, the player's bag asked first.
    • A ruleset that turns native items off and declares no tables drops nothing.
  • Once per fight. A fight the combat director runs (every ruleset fight, and Classic or Tactical with the director) drops its loot on the step that wins it, inside that step's transaction, and its summary carries what dropped (empty when nothing did). The fight state keeps each bestiary opponent's table as the fight is built. A fight the screen plays alone asks the new POST /api/game/inventory/loot when it ends, keyed by the message that started it and remembered beside the stacks, so a win reported twice drops once. A fight with no starting message asks for nothing, and the Game Master decides the reward as before. The unused /api/game/combat/loot and /api/game/loot/generate routes are gone.
  • Said. The recap the Game Master gets says "Loot (already in the party's bags): ..." and what was left behind, so it narrates the loot and never adds it again. The "decide a reward" line stays only when nothing dropped. The journal lists it, and a notification shows it.
  • items.lootTables (Capability API 1.63): rolls (a number or dice), and weighted lines that name an item of the ruleset's catalogs or a filter by rarity, category and tag, each with a count. A bestiary creature's loot names its table. An item a layer takes out drops nothing. Unknown catalogs, items, words and tables are refused at import. The install gate asks for 1.63 in the ruleset file and in bestiary catalog files, last of all its checks, so a package declaring an older minor hears first about what that minor lacks.
  • The Game Master's [loot: table="..." who="..."] rolls a table in the story, measured from where the turn began like its inventory tags, with its own seeded dice, so a regenerated reply drops once. Each item that drops is answered as a resolved inventory add, so the screen announces it and the next turn reads it back like any add. A table that drops nothing, or a refused tag, keeps its place. The tag is reserved, hidden from the narration, shown as a badge in the session log, and taught to the Game Master only where the ruleset has tables.
  • Mari's instructions now describe what really happens on a win.
  • Examples: Gravewatch's grave goods (shot and powder, a tonic, a litany page, or any arm through a filter line), carried by the hollow warden and the grave wight. Ember Roads keeps none, so the lanes that cut it down are unchanged.
  • Docs: the loot section, the lootTables and creature loot keys and the capability list in docs/extending/writing-rulesets.md, the loot paragraph of docs/game/combat.md, the 1.63 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

Local run on this branch (Fedora):

  • pnpm check, pnpm localization:check and prettier: clean.
  • pnpm regression: 478 of 478.
  • pnpm smoke:ui: 7 passed.
  • Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 48 passed. Mobile e2e (every ruleset spec): 23 passed.

Lanes:

  • New game-ruleset-loot.regression.ts: every import refusal; the 1.63 gate (the ruleset file, tables alone, a creature's loot alone, a bestiary in its own file); rolling a table (picks, weights, counts adding up, a filter picking evenly, a filter by tag, an item a layer took out, a filter that finds none, no picks, no such table); the native tables' counts; what nobody can carry, left behind and said; the loot route through Fastify (the native drop into the player's bag, the same fight twice, the next fight, 404 and 400); a ruleset with tables dropping nothing for a fight without bestiary creatures, and planning its tables into the shared view; native items on and off without tables; a directed Ember fight won through the director's routes, whose moth's table drops into the bags and stays said on the next read; and the Game Master's [loot:] (resolved adds, who=, every refusal, nothing dropped, the seeded roll, the narration strip and its instructions).
  • game-inventory-turn.regression.ts gains a real turn: the Game Master's [loot:] drops what the saved reply says, and a regenerated reply holds only its own drop.
  • Lanes that pin the 1.62 gate, the supported API, or cut Gravewatch down were brought up to date.
  • e2e/game-ruleset-loot.e2e.ts: a Classic fight without a ruleset opens on its Victory, and Continue drops the native loot into the player's bag, shows "Loot: ...", and tells the Game Master; a directed ruleset fight won through the director shows Continue story, the recap names the moth's drop, and the screen never asks the loot route again.

40 deliberate breaks, each caught by these lanes and the e2e. Five slipped past on the first run. Four got their own cases: creature loot alone in the ruleset file, a filter by tag, the native tables' random share of drops, and what nobody can carry. The fifth showed that an explicit strip for [loot:] in the narration was dead code, since its catch-all already hides any [word: tag, so that line was deleted.

Local CodeRabbit raised one finding, which was real: when a fight had no starting message, the screen made up a key from the clock, which would defeat the once-per-fight guard. Fixed: without that message the screen does not ask for loot, and the Game Master decides the reward as before. A rerun on the fix found nothing.

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/combat.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)

After a won Classic fight in a game without a ruleset, the notification reads "Loot: Steel Breastplate, Gemstone ×5" (captured by e2e/game-ruleset-loot.e2e.ts as loot-native.png; the red wash in that capture is the fight's own end transition, which fades on its own).

Summary by CodeRabbit

  • New Features
    • Victory loot is added directly to party bags, with a recap showing collected items and anything left behind.
    • Rulesets can define weighted loot tables for creatures. Game Masters can roll these tables with [loot:] during narration, and the results are added to inventory.
    • Ruleset loot features require Capability API 1.63.

🔄 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/6900 **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-loot` --- ### 📝 Commits (2) - [`ef57869`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ef57869e7ab12101582f3ffd145c7fdc57394374) feat(rulesets): loot on victory, ruleset loot tables and creature loot (#6894, #6758) - [`1ff4725`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ff47252b8c3915384ba5e020f73bba91c097f8f) fix(game): a fight's recap reaches the chat it ended in, even when the player has left it (#6894) ### 📊 Changes **42 files changed** (+1991 additions, -167 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+40 -0) 📝 `docs/examples/rulesets/gravewatch.json` (+16 -0) 📝 `docs/extending/ruleset.schema.json` (+106 -0) 📝 `docs/extending/writing-rulesets.md` (+31 -1) 📝 `docs/game/combat.md` (+1 -1) ➕ `e2e/game-ruleset-loot.e2e.ts` (+344 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+114 -74) 📝 `packages/client/src/components/game/game-narration-format.ts` (+8 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/db/seed-mari.ts` (+1 -1) 📝 `packages/server/src/routes/combat-director.routes.ts` (+33 -0) 📝 `packages/server/src/routes/game-inventory.routes.ts` (+20 -0) 📝 `packages/server/src/routes/game.routes.ts` (+0 -35) 📝 `packages/server/src/routes/generate.routes.ts` (+14 -1) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+17 -0) 📝 `packages/server/src/services/game/combat-director.service.ts` (+5 -0) ➕ `packages/server/src/services/game/game-loot.service.ts` (+193 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+10 -0) 📝 `packages/server/src/services/game/loot.service.ts` (+21 -13) _...and 22 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 #6894 Closes #6758 ## Why this change - The combat guide and Mari's instructions have long said that a won fight drops loot, but nothing produced it (#6758). The native loot service and its two routes had no caller, and the recap told the Game Master to decide rewards itself. A Game Mode ruleset could declare items and currencies, but had no way to say what its creatures carry or what a treasure table holds. This is slice I7-1 of the ruleset items plan, loot; money (purses, paying and earning) follows as I7-2. - On #6758 the user ruled to make the docs true rather than trim them: games without a ruleset get the native drops the guide describes. ## What changed - **A won fight drops loot in every Game Mode game, once, into the party's bags.** One rule decides where it comes from: - Without a ruleset, or with one that declares no loot tables and leaves native items on, it comes from Game Mode's own tables (`loot.service.ts`, whose randomness is now injectable): more and rarer drops on a harder game, into the player's bag, as every weightless item goes. - A ruleset that declares loot tables drops its own items instead. Each defeated bestiary creature rolls the table it names, into the shared view by the carrying rule, the player's bag asked first. - A ruleset that turns native items off and declares no tables drops nothing. - **Once per fight.** A fight the combat director runs (every ruleset fight, and Classic or Tactical with the director) drops its loot on the step that wins it, inside that step's transaction, and its summary carries what dropped (empty when nothing did). The fight state keeps each bestiary opponent's table as the fight is built. A fight the screen plays alone asks the new `POST /api/game/inventory/loot` when it ends, keyed by the message that started it and remembered beside the stacks, so a win reported twice drops once. A fight with no starting message asks for nothing, and the Game Master decides the reward as before. The unused `/api/game/combat/loot` and `/api/game/loot/generate` routes are gone. - **Said.** The recap the Game Master gets says "Loot (already in the party's bags): ..." and what was left behind, so it narrates the loot and never adds it again. The "decide a reward" line stays only when nothing dropped. The journal lists it, and a notification shows it. - **`items.lootTables`** (Capability API 1.63): `rolls` (a number or dice), and weighted lines that name an item of the ruleset's catalogs or a `filter` by rarity, category and tag, each with a `count`. A bestiary creature's `loot` names its table. An item a layer takes out drops nothing. Unknown catalogs, items, words and tables are refused at import. The install gate asks for 1.63 in the ruleset file and in bestiary catalog files, last of all its checks, so a package declaring an older minor hears first about what that minor lacks. - **The Game Master's `[loot: table="..." who="..."]`** rolls a table in the story, measured from where the turn began like its inventory tags, with its own seeded dice, so a regenerated reply drops once. Each item that drops is answered as a resolved inventory add, so the screen announces it and the next turn reads it back like any add. A table that drops nothing, or a refused tag, keeps its place. The tag is reserved, hidden from the narration, shown as a badge in the session log, and taught to the Game Master only where the ruleset has tables. - **Mari's instructions** now describe what really happens on a win. - **Examples:** Gravewatch's grave goods (shot and powder, a tonic, a litany page, or any arm through a filter line), carried by the hollow warden and the grave wight. Ember Roads keeps none, so the lanes that cut it down are unchanged. - **Docs:** the loot section, the `lootTables` and creature `loot` keys and the capability list in `docs/extending/writing-rulesets.md`, the loot paragraph of `docs/game/combat.md`, the 1.63 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 Local run on this branch (Fedora): - `pnpm check`, `pnpm localization:check` and prettier: clean. - `pnpm regression`: 478 of 478. - `pnpm smoke:ui`: 7 passed. - Desktop e2e (every ruleset, inventory, combat and Game Mode dice spec): 48 passed. Mobile e2e (every ruleset spec): 23 passed. Lanes: - New `game-ruleset-loot.regression.ts`: every import refusal; the 1.63 gate (the ruleset file, tables alone, a creature's loot alone, a bestiary in its own file); rolling a table (picks, weights, counts adding up, a filter picking evenly, a filter by tag, an item a layer took out, a filter that finds none, no picks, no such table); the native tables' counts; what nobody can carry, left behind and said; the loot route through Fastify (the native drop into the player's bag, the same fight twice, the next fight, 404 and 400); a ruleset with tables dropping nothing for a fight without bestiary creatures, and planning its tables into the shared view; native items on and off without tables; a directed Ember fight won through the director's routes, whose moth's table drops into the bags and stays said on the next read; and the Game Master's `[loot:]` (resolved adds, `who=`, every refusal, nothing dropped, the seeded roll, the narration strip and its instructions). - `game-inventory-turn.regression.ts` gains a real turn: the Game Master's `[loot:]` drops what the saved reply says, and a regenerated reply holds only its own drop. - Lanes that pin the 1.62 gate, the supported API, or cut Gravewatch down were brought up to date. - `e2e/game-ruleset-loot.e2e.ts`: a Classic fight without a ruleset opens on its Victory, and Continue drops the native loot into the player's bag, shows "Loot: ...", and tells the Game Master; a directed ruleset fight won through the director shows Continue story, the recap names the moth's drop, and the screen never asks the loot route again. 40 deliberate breaks, each caught by these lanes and the e2e. Five slipped past on the first run. Four got their own cases: creature loot alone in the ruleset file, a filter by tag, the native tables' random share of drops, and what nobody can carry. The fifth showed that an explicit strip for `[loot:]` in the narration was dead code, since its catch-all already hides any `[word:` tag, so that line was deleted. Local CodeRabbit raised one finding, which was real: when a fight had no starting message, the screen made up a key from the clock, which would defeat the once-per-fight guard. Fixed: without that message the screen does not ask for loot, and the Game Master decides the reward as before. A rerun on the fix found nothing. ## 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/combat.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) After a won Classic fight in a game without a ruleset, the notification reads "Loot: Steel Breastplate, Gemstone ×5" (captured by `e2e/game-ruleset-loot.e2e.ts` as `loot-native.png`; the red wash in that capture is the fight's own end transition, which fades on its own). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Victory loot is added directly to party bags, with a recap showing collected items and anything left behind. * Rulesets can define weighted loot tables for creatures. Game Masters can roll these tables with `[loot:]` during narration, and the results are added to inventory. * Ruleset loot features require Capability API 1.63. <!-- 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#7374
No description provided.