Repository navigation
Conversation
…n the server plays, are one hit for a reaction to answer, where the Hand showed two and a ward could spend a second die for nothing A hit's record is kept by the door that deals it: the save's door for a save's damage (cast-at-player.ts, openEffect), the attack's for an attack and the damage it prints beside its blow (openLastHit). Where such a door lands damage through apply_damage, that tool must keep no record of its own, and it decided so by how many calls were running one inside another. A call is counted only where withActor runs. apply_hazard, a trap a hero walks onto or an opportunity attack they draw through the board's move route, and an enemy's turn the backstop plays reach those doors with none counted, so the apply_damage inside read as called on its own and wrote a second record of the same hit. The door now says so itself (acting-party.ts asPartOfAHit), so the answer no longer depends on what called it. Three calls use it: a save's damage and a spell's darts in cast-at-player.ts, and an attack's rider damage in enemy-hit.ts resolveOnHit. The darts, and a rider on a steed, are not reached outside a counted call today. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while reading for #1068, and separate from it: this is on
mainand touches nothing of the roll-record door.What a table sees
Some damage was kept as two hits where it is one:
apply_hazardwith a save (a named trap, or a hazard of the GM's own)cast_at_playerandenemy_attacksent as tool calls left one record all along, with the same numbers.The narrator's GAME STATE reads the same list (
turn.tsopenHitsForState), so it was told of the damage twice. I read that in the code and did not run it.Hit points were right before and are unchanged: the damage landed once. Absorb Elements gave back the same amount against a doubled record as against a single one.
The cause
A hit's record is kept by the door that deals it: the save's door for a save's damage (
cast-at-player.ts,openEffect), the attack's for an attack and the damage it prints beside its blow (openLastHit). Those doors land some of their damage throughapply_damage, which keeps a record of its own only whencalledOnItsOwn(), and that reads how many calls are running one inside another. A call is counted only wherewithActorruns. Three ways in reach a door with none counted, so theapply_damageinside read as called on its own and wrote a second record:apply_hazard, dispatched outsideapplyEncounterCallandapplyDmMutation(invoke-dispatch.ts);zonesAfterMove);playSkippedEnemyNowcallshandleEnemyAttackdirectly), and an opportunity attack from the move route.The fix
The door says so itself:
asPartOfAHitinacting-party.ts, andcalledOnItsOwn()is false inside it. The answer no longer depends on what called the door. Three calls use it:cast-at-player.ts;cast-at-player.ts. No caller reaches these outside a counted call today (a hazard and a trap always send a save), but they double the same way when one does, and a test calls the handler directly to hold it;enemy-hit.tsresolveOnHit. Its third caller, a blow on a steed that is a sheet (mount-combat.ts), keeps no record and is reached only throughenemy_attack, so nothing changes there.I did not make every dispatched tool count as a call, which would be the other way to fix it. Shared damage (
split_damage) is dispatched at no depth too, and each share is on record today only because itsapply_damagereads as called on its own: counting its handler would take those records away. A test pins them.Not covered
enemy_attack: a rider's damage is in no swing of the attack's record. I read that in the code and did not run it. Whether a rider's damage should be reducible at all is a ruling I have not asked for here.ar-ws-bastion.ts's header still says the ward answers a record "of attacks and falls". It has answered damage from no attack since that record was added; I left the comment.apply_damageinside a counted call and keep no record at all. That is as it was, read in the code and not run; whether a reaction should answer them is a separate question.cast-at-player.ts. Whichever merges second I will rebase.Tests
scripts/test-reaction-hits.mjs: eleven new cases.cast_at_playeras a tool call leaves its one record, and each share of shared damage keeps its record.npm teston Windows, on this commit: 1,264 of 1,268 files passed. The four that failed fail onmainon my machine for its own setup:test-backup-in-appandtest-backup-restore(Git Bash'starreadsC:as a host),test-enforce-last-combatandtest-enforce-monster-blocks(nosqlite3command).tsc,npm run dead-code, lint on the changed files andnpm run buildpass on this commit. The build ran against the Next.js my checkout has installed (16.4.1), not the 16.4.6 the repository pins.Checks
npm run lint,npm testandnpm run buildpass, and the change has a test that fails without it. (Lint on the changed files.npm test: see Tests.).envfiles or players' names in the code, the tests or this description.Settings, options and controls
🤖 Generated with Claude Code