Skip to content

A trap's or a hazard's save damage, and the poison of a bite on a turn 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 - #1070

Open
Smoebo wants to merge 1 commit into
Lebbitheplow:mainfrom
Smoebo:fix/hazard-damage-one-record

Conversation

@Smoebo

@Smoebo Smoebo commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Found while reading for #1068, and separate from it: this is on main and touches nothing of the roll-record door.

What a table sees

Some damage was kept as two hits where it is one:

Before Now
apply_hazard with a save (a named trap, or a hazard of the GM's own) two hits for the Hand one
A trap set on a square, sprung by the hero who walks onto it on the board two one
A bite with poison, on an enemy turn the server plays ("Play the rest", the AI table's backstop) two: the bite, and its poison as a hit of its own one
Bastion of Law, a second die spent on the same hazard's damage taken: the die is gone and 0 hit points come back refused, and the ward keeps the die

cast_at_player and enemy_attack sent as tool calls left one record all along, with the same numbers.

The narrator's GAME STATE reads the same list (turn.ts openHitsForState), 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 through apply_damage, which keeps a record of its own only when calledOnItsOwn(), and that reads how many calls are running one inside another. A call is counted only where withActor runs. Three ways in reach a door with none counted, so the apply_damage inside read as called on its own and wrote a second record:

  • apply_hazard, dispatched outside applyEncounterCall and applyDmMutation (invoke-dispatch.ts);
  • a trap a hero walks onto, through the board's move route (zonesAfterMove);
  • an enemy's turn the server plays (playSkippedEnemyNow calls handleEnemyAttack directly), and an opportunity attack from the move route.

The fix

The door says so itself: asPartOfAHit in acting-party.ts, and calledOnItsOwn() is false inside it. The answer no longer depends on what called the door. Three calls use it:

  • a save's damage, in cast-at-player.ts;
  • a spell's darts that need no roll, in 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;
  • an attack's rider damage, in enemy-hit.ts resolveOnHit. Its third caller, a blow on a steed that is a sheet (mount-combat.ts), keeps no record and is reached only through enemy_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 its apply_damage reads as called on its own: counting its handler would take those records away. A test pins them.

Not covered

  • An opportunity attack's rider, struck as a hero walks away on the board, wrote the second record too. No GM turn is running there, so the bite's record, written after it, closed it unless the two were stamped in the same millisecond: stored, and as good as never offered. The fix stops it being stored, and a test reads the stored row.
  • On a turn the server plays, a ward's die could be spent on a bite's poison alone, since the poison had a record of its own. It no longer can, as it never could when the same bite came as 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.
  • An area's damage to characters and Prismatic Spray's rays go through apply_damage inside 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.
  • Records already written twice in a fight under way are not cleaned up. They close as any hit does.
  • No screenshots, and I did not look at the Hand in a browser or the app shell. No screen changes: the Hand lists one hit where it listed two.
  • No run against a real model.
  • A trap, a fall and a poison name themselves on their roll card, where their dice read as the roll of the character they landed on, and every attack or damage roll says who or what made it (#915, ruling 2) #1068 changes lines next to these in cast-at-player.ts. Whichever merges second I will rebase.

Tests

  • scripts/test-reaction-hits.mjs: eleven new cases.
    • Nine fail on the source as it was (run three times, the same nine each time): a hazard's save leaves one record and the Hand one hit; a named trap's save; a trap set on a square, sprung through the move route; Bastion of Law's second spend is refused and keeps its die; the helper itself, at each depth and after a throw; Magic Missile sent through the handler with no call counted (needs the content pack, skipped without it); a bite's poison on the AI table's backstop turn; the same on "Play the rest" at a table a person runs, where the Hand is shown one hit; and the same on an opportunity attack from the move route.
    • Two pass before and after, to pin what must not change: cast_at_player as a tool call leaves its one record, and each share of shared damage keeps its record.
  • Three of them read the stored row and not only the hits still open. With no GM turn running, a later record closes an earlier one once their times differ, so the open hits alone showed the second record on some runs and not on others.
  • npm test on Windows, on this commit: 1,264 of 1,268 files passed. The four that failed fail on main on my machine for its own setup: test-backup-in-app and test-backup-restore (Git Bash's tar reads C: as a host), test-enforce-last-combat and test-enforce-monster-blocks (no sqlite3 command).
  • tsc, npm run dead-code, lint on the changed files and npm run build pass 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.
  • A reader went through the first version cold and found the bite's poison, which I had ruled out too early. The same reader read this version and found no defect; the wording it corrected is corrected. It had read the first version, so the second reading was not cold.

Checks

  • npm run lint, npm test and npm run build pass, and the change has a test that fails without it. (Lint on the changed files. npm test: see Tests.)
  • Anything a player sees has screenshots below: the website and the app, day and night themes, phone width. (None. No screen changes; the Hand lists one hit where it listed two.)
  • No hostnames, IP addresses, logs, keys, .env files or players' names in the code, the tests or this description.

Settings, options and controls

  • This adds no new setting, toggle, option or other control.

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant