Repository navigation
A hazard's damage that an AI GM rolls and then sends for a creature lands on it, where the call was answered "already applied" and the creature lost nothing - #1074
Open
Smoebo wants to merge 1 commit into
Conversation
…ands on it, where the call was answered "already applied" and the creature lost nothing On an AI GM's turn the tools offer two calls for harm no creature's attack deals: request_roll of kind damage, then apply_damage with that total. Sent for a creature by its id, the second call answered ok with "That damage was already applied when the roll resolved" and took no hit points. The number gate (ai-gate.ts) stamped the roll that paid for a bare number with whatever the number was sent for, in the column that says which enemy the server landed a blow on. The double-apply guard in damage_enemy reads that column, so it took the roll the gate had just stamped for this very call as a blow already landed. The after-fight card reads it too, and counted any total stamped this way as damage dealt by the character the roll was made for: poison a hero took read as damage that hero dealt. A roll that pays for what an AI GM sends is now stamped with markRollPaid, which names no target: the total behind a bare number, and the check behind a trap's hold lifted. The target column is written only where the server lands a blow itself, so its readers read what they were written for. The guard is unchanged: harm the server rolls that comes to the same total as a blow already landed on that creature this turn is still answered "already applied". Tests (test-enforce-ai-gates): the two-call path lands once and the same number again is refused by the number gate; a rolled total sent for a character counts nothing as dealt on the fight's card; and, pinned as it was, a landed blow's number sent bare is refused and dice that come to the same total are answered "already applied". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 22, 2026
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.
This is the small pull request #1073 says will follow. It is on
main, apart from the roll-record door (#915), and does not build what #1073 proposes.What a table sees
On an AI GM's turn the tools offer two calls for harm no creature's attack deals:
request_rollof kinddamage, thenapply_damagewith that total. Run onmainand on this commit:source: "hazard"So the damage was lost when the model named the creature by its id and landed when it used the name.
The cause
rolls.appliedwithrolls.target_enemy_idsays "the server landed this roll's damage on that enemy". The engine writes it as a blow's dice resolve (landRoll). The double-apply guard indamage_enemy(encounter-tools.ts) reads it, and answers "already applied" for a number equal to a blow landed on that creature this turn. The after-fight card (encounter-summary.ts) reads it as damage dealt by the character the roll was made for.The number gate (
ai-gate.tsnumber) used the same stamp for something else: "this total has paid for a bare number". It wrote whatever the number was sent for into the target column: the text sent asenemyId, a character's id, or "split". Sent for a creature by its id, the roll the gate had just stamped for this very call was what the guard then found. And the card counted any total stamped this way as a blow landed on an enemy.The fix
A roll that pays for what an AI GM sends is stamped with
markRollPaid(src/lib/db/rolls.ts), which marks it spent and names no target. Both of the gate's stamps use it: the total behind a bare number, and the check behind a trap's hold lifted (escapeRolled, which wroteescape:<trap>into the same column; nothing read that text). The target column is now written only where the server lands a blow itself (landRoll, and the opportunity attack's own stamp), so its readers read what they were written for. The guard's code is not touched.What else changes
All of it follows from a paid total no longer naming a target:
request_rolland then sent. Before, a total rolled with acharacterIdand sent for a creature by name, or shared out throughtargets, was counted on that character's line. By the tools' own rule this is harm no creature's attack deals, and a fall's or a trap's dice are on nobody's line already. The party's total is not lower for it: it never reads less than the enemies lost. Thetargetscase was run before and after (5 on the line, then 0, the total 5 both times); the by-name case is read in the code.ask.ts) tagged such a total ", applied", also when the guard had swallowed it. It now carries no tag, as a fall's dice carry none. Read in the code, not run.Not covered
dice: "1d8+3") and with a rolled total alike: run onmainand on this commit, a 7 after a blow of 7 did nothing and a 6 landed. The guard cannot tell a repeat from a second harm of the same size.mainand on this commit:apply_damageon a creature with nosourceis refused, and the same call sent again withsource: "hazard"is refused by the number gate, because the first call spent the roll. As it was.ai-gate.ts: a trial merge with each stops on that one line and nowhere else. An opportunity attack and a death save show their dice in the chronicle on the line they post, and a rest's hit dice and a fight's opening dice are on the turn that rolled them: three more families move onto the roll-record door (#915, part four) #1063 and 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 merge clean in a trial merge. I did not run the suites on any merged tree. Whichever merges second I will rebase.Tests
scripts/test-enforce-ai-gates.mjs, three new cases.pc_attacklands a blow, its number sent bare is refused by the number gate, and dice for the same creature that come to the same total are answered "already applied".scripts/test-ai-gate-in-turn.mjs(the net's hold lifted after a rolled check),test-encounter-summary,test-enforce-roll-record,test-name-lookupsandtest-text-comparisonspass on this commit.npm teston Windows, on this commit: 1,263 of 1,268 files passed. Four of the five 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). The fifth,test-enforce-narrator, failed one case ("An agent program's narration is checked against the live encounter", 201 where it expects 409). Run alone it failed 1 time in 3 on this commit and 3 times in 8 on the source as it was, so it comes and goes onmaintoo; I did not look for its cause.npx tsc --noEmit -p .,npm run dead-code, lint on the changed files andnpm run buildpass on this commit.main. It corrected the wording of two comments, the third test's title and the commit message, and found the two other readers of the stamp (ask.ts,authored-spend-more.tsswarmDieBack) now listed above and in the code. The corrected version was not read cold again.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