[PR #6729] [MERGED] feat(game): a moment after an attack hits in ruleset combat, and creatures that react #7303

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

📋 Pull Request Information

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

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


📝 Commits (1)

  • bd2dd20 feat(game): a moment after an attack hits, and creatures that react

📊 Changes

29 files changed (+1525 additions, -98 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+40 -1)
📝 docs/development/ruleset-5e-2014.example.json (+18 -1)
📝 docs/extending/ruleset.schema.json (+177 -1)
📝 docs/extending/writing-rulesets.md (+63 -15)
📝 docs/game/combat.md (+1 -1)
📝 packages/client/src/components/game/DirectedCombatUI.tsx (+5 -0)
📝 packages/client/src/components/game/GameCombatUI.tsx (+3 -0)
📝 packages/client/src/components/game/RulesetCombatBoard.tsx (+4 -0)
📝 packages/client/src/components/game/RulesetCombatMenu.tsx (+12 -0)
📝 packages/client/src/lib/ruleset-combat-log.ts (+29 -1)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+21 -0)
📝 packages/server/src/services/game/ruleset-combat-director.service.ts (+20 -1)
📝 packages/shared/src/features/combat-director.ts (+4 -1)
📝 packages/shared/src/features/ruleset-combat/encounter.ts (+25 -12)
📝 packages/shared/src/features/ruleset-combat/index.ts (+5 -4)
📝 packages/shared/src/features/ruleset-combat/options.ts (+31 -1)
📝 packages/shared/src/features/ruleset-combat/resolve.ts (+139 -25)
📝 packages/shared/src/features/ruleset-combat/types.ts (+65 -3)

...and 9 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 #6728

Why this change

Shield, a Parry and Uncanny Dodge are all taken after an attack has hit and before its damage lands, and a ruleset fight had no such moment. An answer taken when an attack is aimed has to be spent before anyone knows whether it will hit, so a Shield written that way is wasted on every attack that would have missed. And a creature written in plain numbers could not hold a reaction at all, so the 5e package keeps every printed Parry as a trait. The conditions slice (#6719) gave conditions the numbers these answers need; this is the moment to take them in. This is C5g of real ruleset combat (plan doc, § Real ruleset combat).

What changed

Capability API 1.46 (file keys: on: "hit" in a reaction, and reaction and self on a creature's action). None of it names one game's words.

  • The moment after a hit. A reaction on hit is offered to the one an attack roll has just hit, before its damage, when they hold one. What they take counts for that attack: the roll is not made again but checked again against their defense as it now stands, so a guard can turn the hit into a miss, and a natural face that always hits still hits. A one-attack condition put on as the answer covers that attack's damage too and is spent by it, which is how "halve that attack's damage" is said. It cannot cancel.
  • Held, then picked up exactly there. The attack is held after its roll with everything it needs: which target, the targets after it, the roll, and, for a creature's action made of other actions, which part. It then carries on with the same roll, the rest of its targets and the rest of its parts, and nothing before the hold is done again. Being hurt is asked about once the whole action is over, including whoever it hurt before it was held. A fight saved while the window is open comes back the same way. An attack made inside a window (a strike at somebody walking away, a signature action, an answer) is never held.
  • Creatures that react. A creature's action may carry the same reaction object a catalog entry does, and self: true for one that lands on the creature itself. A sequence may not carry either or make a reaction, and a reaction is not also a signature action.
  • Opponents the Engine plays take a guard on a held hit only when it turns the hit into a miss, and let other blows land. A Game Master's opponent picks from the same menu.
  • Log and screen. "Snag hits Brenna with Scimitar: 20 against Armor Class 18. Brenna may answer." and, when the answer changed the defense, "Against Armor Class 23 (Shielded + 5), Snag's Scimitar now misses Brenna." New strings are localized in en.json.
  • Install gate for every new key, inline, in a catalog file or on a creature. Published schema: regenerated, with hand patches for the creature-action rules (a sequence carries nothing of its own, self takes no other target, a reaction is not a signature action).
  • Example. The 5e reference's Toll Sergeant parries, with a Parrying condition that adds 2 to defense for one attack. Ember Roads has only one action a turn, so a reaction there would never have a budget to spend, and it gains none. The 5e package's next release adopts Shield, Parry and Uncanny Dodge with everything #6712 and #6719 added.
  • Docs:
    • Author guide (docs/extending/writing-rulesets.md): Windows gains the moment and "The moment after a hit", and the creature keys gain reaction and self. Not yet is updated: the stale bullet saying a number can only change before the roll is replaced by what is still missing (being hit without an attack roll, damage reduced by an amount, telling a swing from a shot).
    • Player page (docs/game/combat.md), the plan doc's C5g notes, the shared resolver's comments (two still said a creature could not react and that there was no moment after a hit) and the CHANGELOG.

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 bd2dd2068 (this branch's one commit on staging c7bfc9e71), all exit 0: pnpm check, pnpm localization:check, pnpm version:check, pnpm regression:node (406/406), pnpm ruleset:schema (no diff after regeneration), pnpm smoke:ui (7/7), and pnpm regression:ui e2e/game-combat-director.e2e.ts e2e/ruleset-wound-sheet.e2e.ts e2e/ruleset-live-states.e2e.ts --project=desktop-chromium --workers=1 (9/9, including both ruleset fights). Mobile projects were not run locally. Local CodeRabbit (CLI 0.8.1), two passes on this slice's changes: two findings, both fixed (the held hit's menu prompt now names the defense as the log does, and the set of catalog ids is built once per creature), then clean.

  • New lane scripts/regressions/game-ruleset-combat-hit.regression.ts covers:

    • Shield: a hit turned into a miss, a roll that beats it, a natural 20, and letting it go;
    • Uncanny Dodge halving one attack;
    • a creature's Parry, spent by the attack it answered;
    • a two-part action held at each part with nothing rolled twice;
    • several targets, with the rest rolled after the answer and being hurt asked about at the end;
    • a save and reload while the window is open;
    • nothing held inside a window;
    • the refusals, the log lines and the 1.46 gate.

    Twenty-six deliberate breaks were each caught, among them: never holding, holding inside a window, re-checking against the old defense, ignoring the natural face, losing the rest of the targets, losing the part of an action made of others, starting a held action's concentration again, forgetting who was already hurt, not spending the guard, the picker spending a guard that cannot turn the hit, and each half of the 1.46 gate. Two first slipped through (a natural 20 whose total also beat the raised defense, and no held attack that starts concentration), and both tests were tightened until they caught them.

  • scripts/regressions/ruleset-combat-director.regression.ts plays forty seeded fights with a Shield holder the Engine plays: hits are held, Shield is raised only when the recheck then misses, and blows it could not stop are let through. Writing this case found a real bug before the PR: a guard aimed at its own holder was scored as help for a friend and taken even when it could not turn the hit.

  • Older lanes are adjusted:

    • The lifecycle lane follows the new version.
    • The registry and creature-sheet lanes count the reference's new condition and the Toll Sergeant's Parry.
    • The screen lane gives the new event a line.

Still to verify by hand (not done by the agent):

  • In a Game Mode game on the 5e reference with a ruleset fight against a Toll Sergeant: hit it with an attack that beats its Armor Class by 1 or 2, and confirm the log says it parries and the blow now misses. Hit it by more, and confirm it lets the blow land.
  • Give a party member a Shield-shaped reaction (as in the author guide's example). When an opponent hits them, confirm the fight pauses with the roll and the Armor Class it was made against, that taking Shield says whether the blow now misses, and that it lasts until their next turn begins.
  • Check light and dark mode and mobile width on the window prompt.

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 (not carried by docs-i18n)
  • docs/game/combat.md (carried by docs-i18n)
  • docs/extending/ruleset.schema.json
  • docs/development/ruleset-5e-2014.example.json and docs/development/game-rulesets-and-sheets-implementation.md (internal)
  • CHANGELOG.md

Translations are batched into one [docs-i18n] issue after the last ruleset slice, by the maintainer's standing decision, so no per-PR issue is opened here.

UI evidence (if applicable)

None attached. The window prompt and log lines reuse the existing reaction window; the manual steps above cover what is new on screen.

Summary by CodeRabbit

  • New Features
    • Added a post-hit reaction window before damage resolves. Reactions can raise defense and recheck the original attack roll, potentially turning a hit into a miss; some reactions can also halve the attack’s damage.
    • Creature opponents can use self-targeted reactions, such as parrying, when the response can deflect a hit.
    • Combat menus and logs now show ruleset-specific defense labels and report hit rechecks and their outcomes.
    • Ruleset packages can use these capabilities with Capability API 1.46 or later.

🔄 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/6729 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/26/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/ruleset-combat-hit` --- ### 📝 Commits (1) - [`bd2dd20`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bd2dd2068e0a4841b1ecb2dbcb204fc456aa2266) feat(game): a moment after an attack hits, and creatures that react ### 📊 Changes **29 files changed** (+1525 additions, -98 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+40 -1) 📝 `docs/development/ruleset-5e-2014.example.json` (+18 -1) 📝 `docs/extending/ruleset.schema.json` (+177 -1) 📝 `docs/extending/writing-rulesets.md` (+63 -15) 📝 `docs/game/combat.md` (+1 -1) 📝 `packages/client/src/components/game/DirectedCombatUI.tsx` (+5 -0) 📝 `packages/client/src/components/game/GameCombatUI.tsx` (+3 -0) 📝 `packages/client/src/components/game/RulesetCombatBoard.tsx` (+4 -0) 📝 `packages/client/src/components/game/RulesetCombatMenu.tsx` (+12 -0) 📝 `packages/client/src/lib/ruleset-combat-log.ts` (+29 -1) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+21 -0) 📝 `packages/server/src/services/game/ruleset-combat-director.service.ts` (+20 -1) 📝 `packages/shared/src/features/combat-director.ts` (+4 -1) 📝 `packages/shared/src/features/ruleset-combat/encounter.ts` (+25 -12) 📝 `packages/shared/src/features/ruleset-combat/index.ts` (+5 -4) 📝 `packages/shared/src/features/ruleset-combat/options.ts` (+31 -1) 📝 `packages/shared/src/features/ruleset-combat/resolve.ts` (+139 -25) 📝 `packages/shared/src/features/ruleset-combat/types.ts` (+65 -3) _...and 9 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 #6728 ## Why this change Shield, a Parry and Uncanny Dodge are all taken after an attack has hit and before its damage lands, and a ruleset fight had no such moment. An answer taken when an attack is aimed has to be spent before anyone knows whether it will hit, so a Shield written that way is wasted on every attack that would have missed. And a creature written in plain numbers could not hold a reaction at all, so the 5e package keeps every printed Parry as a trait. The conditions slice (#6719) gave conditions the numbers these answers need; this is the moment to take them in. This is C5g of real ruleset combat (plan doc, § Real ruleset combat). ## What changed Capability API **1.46** (file keys: `on: "hit"` in a reaction, and `reaction` and `self` on a creature's action). None of it names one game's words. - **The moment after a hit.** A reaction on `hit` is offered to the one an attack roll has just hit, before its damage, when they hold one. What they take counts for that attack: the roll is not made again but checked again against their defense as it now stands, so a guard can turn the hit into a miss, and a natural face that always hits still hits. A one-attack condition put on as the answer covers that attack's damage too and is spent by it, which is how "halve that attack's damage" is said. It cannot cancel. - **Held, then picked up exactly there.** The attack is held after its roll with everything it needs: which target, the targets after it, the roll, and, for a creature's action made of other actions, which part. It then carries on with the same roll, the rest of its targets and the rest of its parts, and nothing before the hold is done again. Being hurt is asked about once the whole action is over, including whoever it hurt before it was held. A fight saved while the window is open comes back the same way. An attack made inside a window (a strike at somebody walking away, a signature action, an answer) is never held. - **Creatures that react.** A creature's action may carry the same `reaction` object a catalog entry does, and `self: true` for one that lands on the creature itself. A sequence may not carry either or make a reaction, and a reaction is not also a signature action. - **Opponents the Engine plays** take a guard on a held hit only when it turns the hit into a miss, and let other blows land. A Game Master's opponent picks from the same menu. - **Log and screen.** "Snag hits Brenna with Scimitar: 20 against Armor Class 18. Brenna may answer." and, when the answer changed the defense, "Against Armor Class 23 (Shielded + 5), Snag's Scimitar now misses Brenna." New strings are localized in `en.json`. - **Install gate** for every new key, inline, in a catalog file or on a creature. **Published schema:** regenerated, with hand patches for the creature-action rules (a sequence carries nothing of its own, `self` takes no other target, a reaction is not a signature action). - **Example.** The 5e reference's Toll Sergeant parries, with a Parrying condition that adds 2 to defense for one attack. Ember Roads has only one action a turn, so a reaction there would never have a budget to spend, and it gains none. The 5e package's next release adopts Shield, Parry and Uncanny Dodge with everything #6712 and #6719 added. - **Docs:** - Author guide (`docs/extending/writing-rulesets.md`): Windows gains the moment and "The moment after a hit", and the creature keys gain `reaction` and `self`. Not yet is updated: the stale bullet saying a number can only change before the roll is replaced by what is still missing (being hit without an attack roll, damage reduced by an amount, telling a swing from a shot). - Player page (`docs/game/combat.md`), the plan doc's C5g notes, the shared resolver's comments (two still said a creature could not react and that there was no moment after a hit) and the CHANGELOG. ## 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 bd2dd2068 (this branch's one commit on staging c7bfc9e71), all exit 0: `pnpm check`, `pnpm localization:check`, `pnpm version:check`, `pnpm regression:node` (406/406), `pnpm ruleset:schema` (no diff after regeneration), `pnpm smoke:ui` (7/7), and `pnpm regression:ui e2e/game-combat-director.e2e.ts e2e/ruleset-wound-sheet.e2e.ts e2e/ruleset-live-states.e2e.ts --project=desktop-chromium --workers=1` (9/9, including both ruleset fights). Mobile projects were not run locally. Local CodeRabbit (CLI 0.8.1), two passes on this slice's changes: two findings, both fixed (the held hit's menu prompt now names the defense as the log does, and the set of catalog ids is built once per creature), then clean. - New lane `scripts/regressions/game-ruleset-combat-hit.regression.ts` covers: - Shield: a hit turned into a miss, a roll that beats it, a natural 20, and letting it go; - Uncanny Dodge halving one attack; - a creature's Parry, spent by the attack it answered; - a two-part action held at each part with nothing rolled twice; - several targets, with the rest rolled after the answer and being hurt asked about at the end; - a save and reload while the window is open; - nothing held inside a window; - the refusals, the log lines and the 1.46 gate. Twenty-six deliberate breaks were each caught, among them: never holding, holding inside a window, re-checking against the old defense, ignoring the natural face, losing the rest of the targets, losing the part of an action made of others, starting a held action's concentration again, forgetting who was already hurt, not spending the guard, the picker spending a guard that cannot turn the hit, and each half of the 1.46 gate. Two first slipped through (a natural 20 whose total also beat the raised defense, and no held attack that starts concentration), and both tests were tightened until they caught them. - `scripts/regressions/ruleset-combat-director.regression.ts` plays forty seeded fights with a Shield holder the Engine plays: hits are held, Shield is raised only when the recheck then misses, and blows it could not stop are let through. Writing this case found a real bug before the PR: a guard aimed at its own holder was scored as help for a friend and taken even when it could not turn the hit. - Older lanes are adjusted: - The lifecycle lane follows the new version. - The registry and creature-sheet lanes count the reference's new condition and the Toll Sergeant's Parry. - The screen lane gives the new event a line. Still to verify by hand (not done by the agent): - In a Game Mode game on the 5e reference with a ruleset fight against a Toll Sergeant: hit it with an attack that beats its Armor Class by 1 or 2, and confirm the log says it parries and the blow now misses. Hit it by more, and confirm it lets the blow land. - Give a party member a Shield-shaped reaction (as in the author guide's example). When an opponent hits them, confirm the fight pauses with the roll and the Armor Class it was made against, that taking Shield says whether the blow now misses, and that it lasts until their next turn begins. - Check light and dark mode and mobile width on the window prompt. ## 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` (not carried by `docs-i18n`) - `docs/game/combat.md` (carried by `docs-i18n`) - `docs/extending/ruleset.schema.json` - `docs/development/ruleset-5e-2014.example.json` and `docs/development/game-rulesets-and-sheets-implementation.md` (internal) - `CHANGELOG.md` Translations are batched into one `[docs-i18n]` issue after the last ruleset slice, by the maintainer's standing decision, so no per-PR issue is opened here. ## UI evidence (if applicable) None attached. The window prompt and log lines reuse the existing reaction window; the manual steps above cover what is new on screen. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a post-hit reaction window before damage resolves. Reactions can raise defense and recheck the original attack roll, potentially turning a hit into a miss; some reactions can also halve the attack’s damage. * Creature opponents can use self-targeted reactions, such as parrying, when the response can deflect a hit. * Combat menus and logs now show ruleset-specific defense labels and report hit rechecks and their outcomes. * Ruleset packages can use these capabilities with Capability API 1.46 or later. <!-- 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:26 +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#7303
No description provided.