[PR #6608] [MERGED] feat(game): let a ruleset reaction name the moment it waits for #7253

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

📋 Pull Request Information

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

Base: staging ← Head: feat/ruleset-combat-triggers


📝 Commits (2)

  • d2d0ed1 feat(game): a reaction says which moment it waits for
  • 5fe475d docs(game): say who can really pay out of a bigger pool

📊 Changes

27 files changed (+1467 additions, -97 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 docs/development/game-combat-rulesets-implementation.md (+6 -2)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+60 -0)
📝 docs/development/optional-agent-packages.md (+25 -0)
📝 docs/extending/ruleset.schema.json (+54 -1)
📝 docs/extending/writing-rulesets.md (+48 -7)
📝 packages/client/src/components/game/RulesetCombatMenu.tsx (+14 -3)
📝 packages/client/src/lib/ruleset-combat-log.ts (+18 -2)
📝 packages/client/src/localization/locales/en.json (+5 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+18 -0)
📝 packages/server/src/services/game/ruleset-combat-director.service.ts (+139 -29)
📝 packages/shared/src/features/combat-director.ts (+6 -0)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+22 -6)
📝 packages/shared/src/features/ruleset-combat/index.ts (+15 -3)
📝 packages/shared/src/features/ruleset-combat/options.ts (+83 -21)
📝 packages/shared/src/features/ruleset-combat/resolve.ts (+239 -13)
📝 packages/shared/src/features/ruleset-combat/types.ts (+47 -3)
📝 packages/shared/src/schemas/capability-package.schema.ts (+9 -1)
📝 packages/shared/src/schemas/ruleset.schema.ts (+37 -1)
📝 scripts/generate-ruleset-schema.mjs (+15 -0)

...and 7 more files

📄 Description

Linked issue

Closes #6607
Closes #6528

Why this change

A catalog entry marked reaction: true said only that it is not taken on a turn. It never said what it waits for, so the Engine had nowhere to offer it, and every entry marked that way sat on no menu. The 5e package ships Counterspell, Hellish Rebuke, Shield and Feather Fall as reactions, and none of them could ever be cast.

#6525 built the window a reaction is answered in. This lets an entry say which window it belongs in.

It also folds in #6528, because it is the same seam: a player could pay an ability out of a higher pool than it names, but the Engine's own picker only ever saw the base cost, so a party member handed to the Engine never cast a spell that grows any bigger, on a turn or in a window. Opponents are not part of it: a stat block's actions cost nothing off any pool, so an opponent, and so a Game Master's boss, has nothing to climb. (#6528 said otherwise; that premise was wrong, and the issue has a comment saying so.)

What changed

  • mechanics.reaction may name the moment. An object instead of true: on is aimed (before something lands on the holder) or harmed (after something has hurt them); at is source (whoever caused the moment, filled in) or chosen (the entry's own targets, the holder picks); cancels stops what the window was holding. Only aimed may cancel. true and false behave exactly as before.
  • aimed holds the action before it resolves, and asks everybody on the other side it is pointed at who holds something waiting for that moment. What it cost is already spent, so cancelling stops it from happening rather than from having been bought. A friend's action, such as a heal, opens no window.
  • harmed opens after the action resolves, read off the damage the action itself wrote, so the resolver knows nothing about windows. One blow that hurts three people opens one window listing all three.
  • Rules settled along the way: a window asks in the fight's own order; a reaction aimed back at a source an earlier answer took out is no longer offered; cancelling withdraws the question from everybody still waiting instead of working through the queue; a self-targeting reaction fills in its own holder; a free reaction needs no budget; a pool the window did not offer is refused as bad-pool; a utility entry that cancels counts as doing something; a fight saved mid-walk by #6525, whose resume carries no kind, is finished as the walk it can only be.
  • The Engine may let a moment go by. A window's menu carries letting it go as a candidate, weighed the way ending a turn is, so a combatant the Engine plays no longer spends every reaction it can. That includes #6525's strike at somebody walking away. An option that asks for nobody but lands on somebody (the one walking away, or the source of a moment) is weighed by what it would do to them. A picker answer the rules refuse inside a window is logged before the moment is let go, because a refusal is never recorded and would otherwise look like a choice.
  • Upcasting for a party member the Engine plays (#6528). The director's candidate builder emits one candidate per way of paying, each with the forecast the extra rungs buy, a label naming the pool, and a price that counts the rungs climbed so the bigger version is not mistaken for a free one. Only somebody with a sheet has pools; an opponent's actions cost nothing off any pool, and a regression pins that none of them can be paid out of one.
  • Capability API 1.33, gated on the catalog asset's own bytes. The published docs/extending/ruleset.schema.json carries the "only aimed may cancel" rule, which the generator patches in by shape because it cannot see a refinement.
  • Client: the log and the window prompt name the two new moments, and say when something was called off.
  • Docs: the authoring guide's Windows section explains how to name a moment and whom each moment asks; its Not yet list says what still cannot be expressed; both implementation handoffs record what C5c settled; optional-agent-packages.md gains a Capability API 1.33 section.

Still not expressible, and said so in the docs: a chain of windows (a counter cannot itself be countered), a reaction that changes a number on what it answers rather than stopping it, and any refund of what a cancelled action cost.

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

For the reviewer's information rather than in place of the boxes: pnpm check exits 0 and the full pnpm regression lane passes 369/369, on this branch rebased onto staging at d1c5fee55. Local CodeRabbit sweeps were run until three consecutive rounds came back with no findings. Every finding before that was fixed except two, declined with reasons: a ponytail: marker CodeRabbit read as stray is this repository's convention for a named ceiling, and extending the upcast coverage to a Game Master's boss is impossible because a stat block action carries no pool cost. Among the fixes: a backward-compatibility break (reaction: false has been legal since the key existed and would have been refused), a reaction that could be aimed at a source already taken out, a friend's heal that an ally played by the Engine could have cancelled, and a fight saved mid-walk that would have been left standing.

Each behaviour above has a regression, and each regression was mutation-tested: the fix was switched off, with the replaced text asserted to exist first, and the test was seen to fail.

Manual verification notes

Needs a real fight in a browser with a ruleset whose catalog names a moment. The shipped 5e package does not yet; it will once its next release adopts 1.33. Until then, an edited catalog entry is enough.

  • Manually verify that an entry with "reaction": { "on": "aimed", "cancels": true } is not on its holder's turn menu.
  • Manually verify that when an opponent aims something at that holder, the fight stops and the prompt names who is aiming what at whom, with the reaction and a Pass on the menu.
  • Manually verify that taking it logs the action as called off, spends the holder's reaction, and that the opponent's action never lands while its cost stays spent.
  • Manually verify that passing lets the action through and, if it hurt the holder, that a second prompt opens for an entry with "on": "harmed".
  • Manually verify that a harmed reaction pointed at the source shows no target picker and lands on whoever dealt the damage.
  • Manually verify that a party member healing an ally who holds a cancelling reaction opens no prompt.
  • Manually verify that with two party members asked in one window, they are asked in initiative order, and that the second is not asked at all once the first calls the action off.
  • Manually verify that a party member handed to the Engine sometimes casts a scaling spell out of a higher slot, and that the log names that slot.
  • Manually verify the prompts at a phone width and in both light and dark mode.

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/extending/writing-rulesets.md and docs/development/optional-agent-packages.md changed, so both belong in the batched [docs-i18n] follow-up rather than an issue of their own.

UI evidence (if applicable)

None yet. The only new UI is two wordings of the existing window prompt and one new log line, and both want a real fight rather than a screenshot of a fixture.

Summary by CodeRabbit

  • New Features

    • Combatants can react when an action is aimed at them or after they’re harmed. Some reactions can cancel an incoming action; their costs are paid even if the action is cancelled.
    • Reaction windows offer a pass option and resolve one at a time. Combat menus and logs describe reaction moments and cancellations.
    • Engine-controlled party members can choose to pay abilities from higher-cost pools for additional effects; opponents’ payment options are unchanged.
    • Ruleset packages can define timed reactions with targeting and cancellation rules.
  • Compatibility

    • Support for capability API 1.33 is available for ruleset packages using timed reactions.

🔄 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/6608 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/24/2026 **Status:** ✅ Merged **Merged:** 9/24/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-combat-triggers` --- ### 📝 Commits (2) - [`d2d0ed1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d2d0ed14eb712e5d343e9e9b5486158c37f89bc1) feat(game): a reaction says which moment it waits for - [`5fe475d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5fe475d2e9896aac316f1b3f928d5edf3338e90c) docs(game): say who can really pay out of a bigger pool ### 📊 Changes **27 files changed** (+1467 additions, -97 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `docs/development/game-combat-rulesets-implementation.md` (+6 -2) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+60 -0) 📝 `docs/development/optional-agent-packages.md` (+25 -0) 📝 `docs/extending/ruleset.schema.json` (+54 -1) 📝 `docs/extending/writing-rulesets.md` (+48 -7) 📝 `packages/client/src/components/game/RulesetCombatMenu.tsx` (+14 -3) 📝 `packages/client/src/lib/ruleset-combat-log.ts` (+18 -2) 📝 `packages/client/src/localization/locales/en.json` (+5 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+18 -0) 📝 `packages/server/src/services/game/ruleset-combat-director.service.ts` (+139 -29) 📝 `packages/shared/src/features/combat-director.ts` (+6 -0) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+22 -6) 📝 `packages/shared/src/features/ruleset-combat/index.ts` (+15 -3) 📝 `packages/shared/src/features/ruleset-combat/options.ts` (+83 -21) 📝 `packages/shared/src/features/ruleset-combat/resolve.ts` (+239 -13) 📝 `packages/shared/src/features/ruleset-combat/types.ts` (+47 -3) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+9 -1) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+37 -1) 📝 `scripts/generate-ruleset-schema.mjs` (+15 -0) _...and 7 more files_ </details> ### 📄 Description ## Linked issue Closes #6607 Closes #6528 ## Why this change A catalog entry marked `reaction: true` said only that it is not taken on a turn. It never said what it waits for, so the Engine had nowhere to offer it, and every entry marked that way sat on no menu. The 5e package ships Counterspell, Hellish Rebuke, Shield and Feather Fall as reactions, and none of them could ever be cast. [#6525](https://github.com/Pasta-Devs/Marinara-Engine/pull/6525) built the window a reaction is answered in. This lets an entry say which window it belongs in. It also folds in [#6528](https://github.com/Pasta-Devs/Marinara-Engine/issues/6528), because it is the same seam: a player could pay an ability out of a higher pool than it names, but the Engine's own picker only ever saw the base cost, so a party member handed to the Engine never cast a spell that grows any bigger, on a turn or in a window. Opponents are not part of it: a stat block's actions cost nothing off any pool, so an opponent, and so a Game Master's boss, has nothing to climb. (#6528 said otherwise; that premise was wrong, and the issue has a comment saying so.) ## What changed - **`mechanics.reaction` may name the moment.** An object instead of `true`: `on` is `aimed` (before something lands on the holder) or `harmed` (after something has hurt them); `at` is `source` (whoever caused the moment, filled in) or `chosen` (the entry's own targets, the holder picks); `cancels` stops what the window was holding. Only `aimed` may cancel. `true` and `false` behave exactly as before. - **`aimed` holds the action before it resolves**, and asks everybody on the other side it is pointed at who holds something waiting for that moment. What it cost is already spent, so cancelling stops it from happening rather than from having been bought. A friend's action, such as a heal, opens no window. - **`harmed` opens after the action resolves**, read off the damage the action itself wrote, so the resolver knows nothing about windows. One blow that hurts three people opens one window listing all three. - **Rules settled along the way:** a window asks in the fight's own order; a reaction aimed back at a source an earlier answer took out is no longer offered; cancelling withdraws the question from everybody still waiting instead of working through the queue; a self-targeting reaction fills in its own holder; a `free` reaction needs no budget; a pool the window did not offer is refused as `bad-pool`; a `utility` entry that cancels counts as doing something; a fight saved mid-walk by #6525, whose resume carries no `kind`, is finished as the walk it can only be. - **The Engine may let a moment go by.** A window's menu carries letting it go as a candidate, weighed the way ending a turn is, so a combatant the Engine plays no longer spends every reaction it can. That includes #6525's strike at somebody walking away. An option that asks for nobody but lands on somebody (the one walking away, or the source of a moment) is weighed by what it would do to them. A picker answer the rules refuse inside a window is logged before the moment is let go, because a refusal is never recorded and would otherwise look like a choice. - **Upcasting for a party member the Engine plays (#6528).** The director's candidate builder emits one candidate per way of paying, each with the forecast the extra rungs buy, a label naming the pool, and a price that counts the rungs climbed so the bigger version is not mistaken for a free one. Only somebody with a sheet has pools; an opponent's actions cost nothing off any pool, and a regression pins that none of them can be paid out of one. - **Capability API 1.33**, gated on the catalog asset's own bytes. The published `docs/extending/ruleset.schema.json` carries the "only aimed may cancel" rule, which the generator patches in by shape because it cannot see a refinement. - Client: the log and the window prompt name the two new moments, and say when something was called off. - Docs: the authoring guide's Windows section explains how to name a moment and whom each moment asks; its Not yet list says what still cannot be expressed; both implementation handoffs record what C5c settled; `optional-agent-packages.md` gains a Capability API 1.33 section. Still not expressible, and said so in the docs: a chain of windows (a counter cannot itself be countered), a reaction that changes a number on what it answers rather than stopping it, and any refund of what a cancelled action cost. ## 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` For the reviewer's information rather than in place of the boxes: `pnpm check` exits 0 and the full `pnpm regression` lane passes 369/369, on this branch rebased onto `staging` at `d1c5fee55`. Local CodeRabbit sweeps were run until three consecutive rounds came back with no findings. Every finding before that was fixed except two, declined with reasons: a `ponytail:` marker CodeRabbit read as stray is this repository's convention for a named ceiling, and extending the upcast coverage to a Game Master's boss is impossible because a stat block action carries no pool cost. Among the fixes: a backward-compatibility break (`reaction: false` has been legal since the key existed and would have been refused), a reaction that could be aimed at a source already taken out, a friend's heal that an ally played by the Engine could have cancelled, and a fight saved mid-walk that would have been left standing. Each behaviour above has a regression, and each regression was mutation-tested: the fix was switched off, with the replaced text asserted to exist first, and the test was seen to fail. ### Manual verification notes Needs a real fight in a browser with a ruleset whose catalog names a moment. The shipped 5e package does not yet; it will once its next release adopts 1.33. Until then, an edited catalog entry is enough. - Manually verify that an entry with `"reaction": { "on": "aimed", "cancels": true }` is not on its holder's turn menu. - Manually verify that when an opponent aims something at that holder, the fight stops and the prompt names who is aiming what at whom, with the reaction and a Pass on the menu. - Manually verify that taking it logs the action as called off, spends the holder's reaction, and that the opponent's action never lands while its cost stays spent. - Manually verify that passing lets the action through and, if it hurt the holder, that a second prompt opens for an entry with `"on": "harmed"`. - Manually verify that a `harmed` reaction pointed at the source shows no target picker and lands on whoever dealt the damage. - Manually verify that a party member healing an ally who holds a cancelling reaction opens no prompt. - Manually verify that with two party members asked in one window, they are asked in initiative order, and that the second is not asked at all once the first calls the action off. - Manually verify that a party member handed to the Engine sometimes casts a scaling spell out of a higher slot, and that the log names that slot. - Manually verify the prompts at a phone width and in both light and dark mode. ## 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/extending/writing-rulesets.md` and `docs/development/optional-agent-packages.md` changed, so both belong in the batched `[docs-i18n]` follow-up rather than an issue of their own. ## UI evidence (if applicable) None yet. The only new UI is two wordings of the existing window prompt and one new log line, and both want a real fight rather than a screenshot of a fixture. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Combatants can react when an action is aimed at them or after they’re harmed. Some reactions can cancel an incoming action; their costs are paid even if the action is cancelled. * Reaction windows offer a pass option and resolve one at a time. Combat menus and logs describe reaction moments and cancellations. * Engine-controlled party members can choose to pay abilities from higher-cost pools for additional effects; opponents’ payment options are unchanged. * Ruleset packages can define timed reactions with targeting and cancellation rules. * **Compatibility** * Support for capability API 1.33 is available for ruleset packages using timed reactions. <!-- 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:17:57 +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#7253
No description provided.