[PR #6851] [MERGED] feat(rulesets): item requirements, abilities from items, and levels off a derived value (#6846) #7357

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

📋 Pull Request Information

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

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


📝 Commits (2)

  • 021a74b feat(rulesets): item requirements, abilities from items, and levels off a derived value (#6846)
  • 7a13603 fix(rulesets): name every requirement value, and keep derived levels apart from tracks (#6846)

📊 Changes

39 files changed (+2123 additions, -120 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+42 -0)
📝 docs/examples/rulesets/ember-roads.json (+31 -1)
📝 docs/examples/rulesets/gravewatch.json (+8 -1)
📝 docs/extending/ruleset.schema.json (+692 -1)
📝 docs/extending/writing-rulesets.md (+41 -7)
📝 e2e/game-ruleset-wearing.e2e.ts (+118 -1)
📝 packages/client/src/components/game/RulesetItemPicker.tsx (+31 -9)
📝 packages/client/src/lib/ruleset-combat-log.ts (+10 -3)
📝 packages/client/src/localization/locales/en.json (+6 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+29 -0)
📝 packages/server/src/services/game/gm-prompts.ts (+2 -1)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+19 -9)
📝 packages/shared/src/features/ruleset-combat/options.ts (+2 -1)
📝 packages/shared/src/features/ruleset-combat/resolve.ts (+8 -2)
📝 packages/shared/src/features/ruleset-combat/types.ts (+4 -3)
📝 packages/shared/src/features/rulesets/check-effects.ts (+34 -10)
📝 packages/shared/src/features/rulesets/invented-items.ts (+70 -7)
📝 packages/shared/src/features/rulesets/item-book.ts (+90 -7)
📝 packages/shared/src/features/rulesets/sheet-math.ts (+32 -10)

...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 #6846

Why this change

  • Since #6832 a ruleset's items can change checks while worn or carried, but three things tabletop systems need were still left for the Game Master to remember: armor or a weapon that asks for a minimum ability and costs its wearer something until they meet it, an item that sets or raises an ability ("Strength 19 while you wear these", "+2 Constitution"), and encumbrance that follows what a character carries without anyone ticking a track by hand. This is slice I4-3 of the ruleset items plan.

What changed

  • Requirements (Capability API 1.54): an item may list requires, each a value off the wearer's sheet (any value reference, live ones too), the least it must be, and otherwise: what applies on their checks while it is worn and they fall short, in the worn-effect vocabulary. An unmet requirement cannot change an ability, so a requirement can never feed itself.
  • Abilities from items: a worn or carried effect may set an ability to at least a number or add to it (up to 12 per effect). The highest set and the sum of the adds apply before the sheet is worked out, inside the ability's own range, so the sheet, derived values, checks, the Game Master's sheet block and fights all read the changed ability. Each item applies once, however many stacks.
  • Levels off a derived value: a condition level may read derived instead of track (one of them), so a ruleset can say "carrying 10 bulk or more slows you" with a derived value that sums an item stat. It counts on checks outside a fight and in fights, and the fight log names it.
  • Seen and said. Item details and the picker say "While worn: Brawn at least 2", "+1 Heart" and "Needs Sinew 3, otherwise: -1 on checks (Dig)", in localized words; the Game Master's inventory line says the same.
  • Invented items take +N or -N on an ability's name in worn= or carried=, held to the rarity's bonus; a set copied from like= is left out at a capped rarity, and like= brings its requirements. A small local model often wrote the bonus as Brawn +1, inside stats=, or beside tags="none", so a proposal now reads a number after the name, lifts worn=, carried= and summary= out of stats= when the ruleset has no stat of that name and the part was not also given on its own, and reads none as an empty list of tags, stats or slots.
  • Gate and schema: 1.54 at install for requires, an effect's abilities (in the ruleset file and in catalog files) and a level's derived; the published JSON schema mirrors the one-of level, abilities as an item effect's content, and no abilities in an unmet requirement. rulesetReadsItems is now simply "the ruleset has an items block", since abilities and requirements can come from any item.
  • Examples. Ember Roads: ox-hide gauntlets set Brawn to at least 2 while worn, and a derived "Bulk carried" (the sum of what is carried) slows anyone at 10 or more and costs them 1 on Sneak. Gravewatch: the grave spade needs Sinew 3, otherwise -1 on Dig.
  • Docs: the new keys, "Checks outside a fight" and invented items in docs/extending/writing-rulesets.md, the 1.54 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 021a74b1b (one commit on staging 0cad58d35):

  • pnpm check exits 0 and pnpm localization:check exits 0; Prettier passes on the changed source and lanes.
  • pnpm regression passes 446/446, and pnpm smoke:ui passes 7/7.
  • On --project=desktop-chromium, the ruleset, inventory and game dice 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) pass 20/20; the game ruleset specs pass 6/6 on --project=mobile-chromium.

Lanes:

  • New game-ruleset-requirements.regression.ts: every import refusal and the 1.54 gate (ruleset file, catalog file, each key on its own); abilities from items on the sheet, in a derived value, in the Game Master's sheet block and in a fight's initiative; requirements on checks, including one met by an item; derived levels on checks and in a fight, and their names in the fight log; item facts; invented items with ability bonuses held to the rarity; and each of a proposal's slips above, including through the Game Master's item book.
  • game-ruleset-invented-items.regression.ts: a tag's tags, stats and slots written as none read as given and empty.
  • game-inventory-turn.regression.ts: a real Game Master turn's Sneak check in Ember Roads now carries effects="-2" from="Bulk carried 10; Leather coat".
  • e2e/game-ruleset-wearing.e2e.ts: the gauntlets make the in-game sheet's Brawn +2, their details say "While worn: Brawn at least 2", and the Gravewatch spade's say "Needs Sinew 3, otherwise: -1 on checks (Dig)".
  • Lanes that pin the prompt text, the 1.53 gate or the examples were brought up to date.

Forty-one deliberate breaks, across the format, the gate, ability changes, requirements, derived levels on checks and in fights, item facts, the screen and the invented-item slips, were each caught.

Local CodeRabbit (coderabbit review --agent --base staging): two passes. The first had no findings. The second, after the proposal fixes and a rebase onto current staging, had one trivial finding, declined: it asked for a fixed numeric bound on an ability change's set. An ability's own min and max have no fixed bound, and a set outside the ability's range is already refused at import (the lane's "a set out of range" case), so a fixed number would be arbitrary and could refuse a valid ruleset.

Game Master turns on a real local model (Gemma 4 E4B, Q8, through llama.cpp) on an isolated Engine from this branch, in Ember Roads with Ada (Brawn 0) wearing the ox-hide gauntlets:

  • Heaving a cart out of the mud, 3 tellings: all 3 called for Scrap and each was rolled with modifier 2, the gauntlets' Brawn.
  • "The drover thanks me with an iron ring; he swears wearing it gives +1 Brawn": before the proposal fixes above, the model sometimes put the bonus in stats= or wrote Brawn +1, and the ring came out with no effect. After them, 3 of 3 tellings invented the ring with +1 Brawn (twice worn, once carried); one of the three had written stats="worn=+1 Brawn", which is now lifted out.

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 and docs/development/game-rulesets-and-sheets-implementation.md (both carried by docs-i18n), CHANGELOG.md, the generated docs/extending/ruleset.schema.json and the two example rulesets. 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 where Ada wears the ox-hide gauntlets, the in-game sheet's Brawn card shows +2 and the gauntlets' details say "While worn: Brawn at least 2"; in Gravewatch the grave spade's details say "Needs Sinew 3, otherwise: -1 on checks (Dig)" (checked by e2e/game-ruleset-wearing.e2e.ts, desktop and phone).

Summary by CodeRabbit

  • New Features
    • Worn or carried items can raise or set abilities, and impose requirements with fallback effects when unmet. Item details show these effects and requirements.
    • Combat conditions can be based on derived sheet values, such as carried bulk, and affect movement and checks.
    • Game Masters can assign ability changes when inventing items.
    • Rulesets using these features require Capability API 1.54.
  • Documentation
    • Updated ruleset guides and examples to cover item requirements, ability changes, and derived combat levels.

🔄 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/6851 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/29/2026 **Status:** ✅ Merged **Merged:** 9/29/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-items-requirements` --- ### 📝 Commits (2) - [`021a74b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/021a74b1baedc5f56b21b7851ea415a65b1a97f8) feat(rulesets): item requirements, abilities from items, and levels off a derived value (#6846) - [`7a13603`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7a13603de1f69488035326763e8e29b3a708b9d0) fix(rulesets): name every requirement value, and keep derived levels apart from tracks (#6846) ### 📊 Changes **39 files changed** (+2123 additions, -120 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+42 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+31 -1) 📝 `docs/examples/rulesets/gravewatch.json` (+8 -1) 📝 `docs/extending/ruleset.schema.json` (+692 -1) 📝 `docs/extending/writing-rulesets.md` (+41 -7) 📝 `e2e/game-ruleset-wearing.e2e.ts` (+118 -1) 📝 `packages/client/src/components/game/RulesetItemPicker.tsx` (+31 -9) 📝 `packages/client/src/lib/ruleset-combat-log.ts` (+10 -3) 📝 `packages/client/src/localization/locales/en.json` (+6 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+29 -0) 📝 `packages/server/src/services/game/gm-prompts.ts` (+2 -1) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+19 -9) 📝 `packages/shared/src/features/ruleset-combat/options.ts` (+2 -1) 📝 `packages/shared/src/features/ruleset-combat/resolve.ts` (+8 -2) 📝 `packages/shared/src/features/ruleset-combat/types.ts` (+4 -3) 📝 `packages/shared/src/features/rulesets/check-effects.ts` (+34 -10) 📝 `packages/shared/src/features/rulesets/invented-items.ts` (+70 -7) 📝 `packages/shared/src/features/rulesets/item-book.ts` (+90 -7) 📝 `packages/shared/src/features/rulesets/sheet-math.ts` (+32 -10) _...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 #6846 ## Why this change - Since #6832 a ruleset's items can change checks while worn or carried, but three things tabletop systems need were still left for the Game Master to remember: armor or a weapon that asks for a minimum ability and costs its wearer something until they meet it, an item that sets or raises an ability ("Strength 19 while you wear these", "+2 Constitution"), and encumbrance that follows what a character carries without anyone ticking a track by hand. This is slice I4-3 of the ruleset items plan. ## What changed - **Requirements** (Capability API 1.54): an item may list `requires`, each a value off the wearer's sheet (any value reference, live ones too), the least it must be, and `otherwise`: what applies on their checks while it is worn and they fall short, in the worn-effect vocabulary. An unmet requirement cannot change an ability, so a requirement can never feed itself. - **Abilities from items:** a `worn` or `carried` effect may `set` an ability to at least a number or `add` to it (up to 12 per effect). The highest set and the sum of the adds apply before the sheet is worked out, inside the ability's own range, so the sheet, derived values, checks, the Game Master's sheet block and fights all read the changed ability. Each item applies once, however many stacks. - **Levels off a derived value:** a condition level may read `derived` instead of `track` (one of them), so a ruleset can say "carrying 10 bulk or more slows you" with a derived value that sums an item stat. It counts on checks outside a fight and in fights, and the fight log names it. - **Seen and said.** Item details and the picker say "While worn: Brawn at least 2", "+1 Heart" and "Needs Sinew 3, otherwise: -1 on checks (Dig)", in localized words; the Game Master's inventory line says the same. - **Invented items** take `+N` or `-N` on an ability's name in `worn=` or `carried=`, held to the rarity's `bonus`; a `set` copied from `like=` is left out at a capped rarity, and `like=` brings its requirements. A small local model often wrote the bonus as `Brawn +1`, inside `stats=`, or beside `tags="none"`, so a proposal now reads a number after the name, lifts `worn=`, `carried=` and `summary=` out of `stats=` when the ruleset has no stat of that name and the part was not also given on its own, and reads `none` as an empty list of tags, stats or slots. - **Gate and schema:** 1.54 at install for `requires`, an effect's `abilities` (in the ruleset file and in catalog files) and a level's `derived`; the published JSON schema mirrors the one-of level, abilities as an item effect's content, and no abilities in an unmet requirement. `rulesetReadsItems` is now simply "the ruleset has an `items` block", since abilities and requirements can come from any item. - **Examples.** Ember Roads: ox-hide gauntlets set Brawn to at least 2 while worn, and a derived "Bulk carried" (the sum of what is carried) slows anyone at 10 or more and costs them 1 on Sneak. Gravewatch: the grave spade needs Sinew 3, otherwise -1 on Dig. - **Docs:** the new keys, "Checks outside a fight" and invented items in `docs/extending/writing-rulesets.md`, the 1.54 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 021a74b1b (one commit on staging 0cad58d35): - `pnpm check` exits 0 and `pnpm localization:check` exits 0; Prettier passes on the changed source and lanes. - `pnpm regression` passes 446/446, and `pnpm smoke:ui` passes 7/7. - On `--project=desktop-chromium`, the ruleset, inventory and game dice 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`) pass 20/20; the game ruleset specs pass 6/6 on `--project=mobile-chromium`. Lanes: - New `game-ruleset-requirements.regression.ts`: every import refusal and the 1.54 gate (ruleset file, catalog file, each key on its own); abilities from items on the sheet, in a derived value, in the Game Master's sheet block and in a fight's initiative; requirements on checks, including one met by an item; derived levels on checks and in a fight, and their names in the fight log; item facts; invented items with ability bonuses held to the rarity; and each of a proposal's slips above, including through the Game Master's item book. - `game-ruleset-invented-items.regression.ts`: a tag's `tags`, `stats` and `slots` written as `none` read as given and empty. - `game-inventory-turn.regression.ts`: a real Game Master turn's Sneak check in Ember Roads now carries `effects="-2" from="Bulk carried 10; Leather coat"`. - `e2e/game-ruleset-wearing.e2e.ts`: the gauntlets make the in-game sheet's Brawn +2, their details say "While worn: Brawn at least 2", and the Gravewatch spade's say "Needs Sinew 3, otherwise: -1 on checks (Dig)". - Lanes that pin the prompt text, the 1.53 gate or the examples were brought up to date. Forty-one deliberate breaks, across the format, the gate, ability changes, requirements, derived levels on checks and in fights, item facts, the screen and the invented-item slips, were each caught. Local CodeRabbit (`coderabbit review --agent --base staging`): two passes. The first had no findings. The second, after the proposal fixes and a rebase onto current staging, had one trivial finding, declined: it asked for a fixed numeric bound on an ability change's `set`. An ability's own `min` and `max` have no fixed bound, and a `set` outside the ability's range is already refused at import (the lane's "a set out of range" case), so a fixed number would be arbitrary and could refuse a valid ruleset. Game Master turns on a real local model (Gemma 4 E4B, Q8, through llama.cpp) on an isolated Engine from this branch, in Ember Roads with Ada (Brawn 0) wearing the ox-hide gauntlets: - Heaving a cart out of the mud, 3 tellings: all 3 called for Scrap and each was rolled with modifier 2, the gauntlets' Brawn. - "The drover thanks me with an iron ring; he swears wearing it gives +1 Brawn": before the proposal fixes above, the model sometimes put the bonus in `stats=` or wrote `Brawn +1`, and the ring came out with no effect. After them, 3 of 3 tellings invented the ring with +1 Brawn (twice worn, once carried); one of the three had written `stats="worn=+1 Brawn"`, which is now lifted out. ## 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` and `docs/development/game-rulesets-and-sheets-implementation.md` (both carried by `docs-i18n`), `CHANGELOG.md`, the generated `docs/extending/ruleset.schema.json` and the two example rulesets. 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 where Ada wears the ox-hide gauntlets, the in-game sheet's Brawn card shows +2 and the gauntlets' details say "While worn: Brawn at least 2"; in Gravewatch the grave spade's details say "Needs Sinew 3, otherwise: -1 on checks (Dig)" (checked by `e2e/game-ruleset-wearing.e2e.ts`, desktop and phone). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Worn or carried items can raise or set abilities, and impose requirements with fallback effects when unmet. Item details show these effects and requirements. * Combat conditions can be based on derived sheet values, such as carried bulk, and affect movement and checks. * Game Masters can assign ability changes when inventing items. * Rulesets using these features require Capability API 1.54. * **Documentation** * Updated ruleset guides and examples to cover item requirements, ability changes, and derived combat levels. <!-- 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:18:58 +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#7357
No description provided.