Track the damage Buffer's charges actually prevented #308

Merged
nelsong6 merged 1 commit from claude/buffer-damage-prevented into main 2026-08-08 17:09:51 -07:00
nelsong6 commented 2026-08-08 17:09:44 -07:00 (Migrated from github.com)

Buffer is a Counter power with no per-application identity: every application merges into one BufferPower with an integer Amount, so charges from the Buffer card and Lucky Tonic are indistinguishable at the power. Outcomes therefore go to the pooled PowerAggregate, matching Feel No Pain, Rupture, Free Attack, and Free Skill.

What it records

  • BufferChargesGranted — positive applications to the tracked player. Sits ahead of the card-source requirement in RecordPowerReceived, because Lucky Tonic also grants Buffer with a null card source.
  • BufferChargesUsed — only spends the power's own follow-up callback confirmed.
  • BufferDamagePrevented — the drop across BufferPower.ModifyHpLostAfterOstyLate, which returns 0 for its owner. That is post-Block unblocked HP loss, not the attack's printed or intended damage.

Charges that never fired are granted - used; Buffer does not survive a combat, so that difference is exact at run level and needs no separate persisted field.

Why the hook pair

Arm on the modifier, commit on AfterModifyingHpLostAfterOsty. The arm is gated on the same decimal.Truncate(before) != decimal.Truncate(after) test Hook.ModifyHpLost uses to decide which modifiers get the follow-up call, so every armed prevention pairs with exactly one confirmed charge and a fully blocked or zero-damage hit burns none.

The commit runs on the prefix, ahead of PowerCmd.Decrement, which early-returns while CombatManager.IsEnding. Waiting for the decrement would discard preventions that genuinely stopped HP loss in the killing-blow window.

Hook.ModifyHpLost is called from exactly one place, CreatureCmd.Damage, so Buffer never touches card-cost or curse HP loss.

Notes

  • Registered as POWER.BUFFER_POWER, the canonical runtime id, because TryGetByPower matches on power.Id.
  • Schema fixture and SchemaLoadingTests assertions added for the new persisted fields; NotInDeckViewTests registry list updated.
  • Behavioral verification not run, per the repo's user-owned verification rule. The two new Harmony targets are newly introduced into a running process, so they need one full game restart before the numbers appear.
Buffer is a Counter power with no per-application identity: every application merges into one `BufferPower` with an integer `Amount`, so charges from the Buffer card and Lucky Tonic are indistinguishable at the power. Outcomes therefore go to the pooled `PowerAggregate`, matching Feel No Pain, Rupture, Free Attack, and Free Skill. ## What it records - `BufferChargesGranted` — positive applications to the tracked player. Sits ahead of the card-source requirement in `RecordPowerReceived`, because **Lucky Tonic also grants Buffer** with a null card source. - `BufferChargesUsed` — only spends the power's own follow-up callback confirmed. - `BufferDamagePrevented` — the drop across `BufferPower.ModifyHpLostAfterOstyLate`, which returns 0 for its owner. That is post-Block unblocked HP loss, not the attack's printed or intended damage. Charges that never fired are `granted - used`; Buffer does not survive a combat, so that difference is exact at run level and needs no separate persisted field. ## Why the hook pair Arm on the modifier, commit on `AfterModifyingHpLostAfterOsty`. The arm is gated on the same `decimal.Truncate(before) != decimal.Truncate(after)` test `Hook.ModifyHpLost` uses to decide which modifiers get the follow-up call, so every armed prevention pairs with exactly one confirmed charge and a fully blocked or zero-damage hit burns none. The commit runs on the prefix, ahead of `PowerCmd.Decrement`, which early-returns while `CombatManager.IsEnding`. Waiting for the decrement would discard preventions that genuinely stopped HP loss in the killing-blow window. `Hook.ModifyHpLost` is called from exactly one place, `CreatureCmd.Damage`, so Buffer never touches card-cost or curse HP loss. ## Notes - Registered as `POWER.BUFFER_POWER`, the canonical runtime id, because `TryGetByPower` matches on `power.Id`. - Schema fixture and `SchemaLoadingTests` assertions added for the new persisted fields; `NotInDeckViewTests` registry list updated. - Behavioral verification not run, per the repo's user-owned verification rule. The two new Harmony targets are newly introduced into a running process, so they need one full game restart before the numbers appear.
Sign in to join this conversation.
No reviewers
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
romaine-life/spirelens!308
No description provided.