M2b: Block absorption attribution (effective / wasted block) #14

Closed
opened 2026-04-20 00:05:45 -07:00 by nelsong6 · 1 comment
nelsong6 commented 2026-04-20 00:05:45 -07:00 (Migrated from github.com)

Context

M2a (block gained) shipped — we track how much block each card contributed using BlockGainedEntry.CardPlay for direct attribution. That's the easy side of block.

This issue tracks the hard side: which card's block actually absorbed incoming damage vs. got wasted at turn end?

Why it's hard

STS2 block is a pooled resource. When Defend adds 5 block and Warcry adds 3, the game just increments a single block counter to 8. When damage hits, it subtracts from the pool — no per-card tag telling us "2 of those 4 absorbed came from Defend".

Same issue for waste: at turn-end block decay, we don't know which card's contributions got zeroed out.

Proposed approach

Maintain a runtime block provenance list during combat: List<(string cardInstanceId, int remainingAmount)>.

  • On BlockGainedEntry with CardPlay: append (instanceId, amount) to the list.
  • On DamageReceivedEntry where receiver is the player: split the BlockedDamage amount across entries proportionally to their remainingAmount, decrement each entry, drop entries that hit zero.
  • On turn end: whatever remains in the list is "wasted"; attribute it to each entry's instanceId.

Why proportional over FIFO/LIFO

The game doesn't actually use an order — the pool is flat. Proportional is the only split that's mathematically fair across cards with different contribution sizes. FIFO would make the first-applied Defend look disproportionately "effective" vs. a later-applied Warcry, which isn't real information.

New CardAggregate fields

  • TotalBlockEffective — block absorbed before expiring (HP actually saved by this card's block)
  • TotalBlockWasted — block that expired at turn end without absorbing anything

Display

Once these are populated, the tooltip's block section becomes:

Block gained    25
Avg block       5.0
Absorbed        18 (72%)
Wasted           7 (28%)

Same "whole number + %" layout as Overkill/Blocked on the damage side. Can share the 3-col table logic.

Open questions

  • Fractional attribution: proportional splits produce fractional shares. Round per-event (accumulates rounding error) or track as floats in memory and only floor on display?
  • Turn end hook: CombatManager must have a per-turn-end signal. Needs investigation.
  • Does DamageReceivedEntry.Result.BlockedDamage fire for fully-blocked hits? (We saw earlier that the game might skip DamageReceivedEntry entirely for some edge cases.)

Definition of done

  • Block provenance list maintained during combat
  • Proportional split on damage receipt
  • Turn-end waste attribution
  • Aggregate fields persisted + resumable after hot reload
  • Tooltip renders Absorbed/Wasted rows
## Context M2a (block gained) shipped — we track how much block each card contributed using `BlockGainedEntry.CardPlay` for direct attribution. That's the easy side of block. This issue tracks the hard side: **which card's block actually absorbed incoming damage vs. got wasted at turn end?** ## Why it's hard STS2 block is a pooled resource. When Defend adds 5 block and Warcry adds 3, the game just increments a single block counter to 8. When damage hits, it subtracts from the pool — no per-card tag telling us "2 of those 4 absorbed came from Defend". Same issue for waste: at turn-end block decay, we don't know which card's contributions got zeroed out. ## Proposed approach Maintain a runtime **block provenance list** during combat: `List<(string cardInstanceId, int remainingAmount)>`. - On `BlockGainedEntry` with `CardPlay`: append `(instanceId, amount)` to the list. - On `DamageReceivedEntry` where receiver is the player: split the `BlockedDamage` amount across entries **proportionally** to their `remainingAmount`, decrement each entry, drop entries that hit zero. - On turn end: whatever remains in the list is "wasted"; attribute it to each entry's instanceId. ### Why proportional over FIFO/LIFO The game doesn't actually use an order — the pool is flat. Proportional is the only split that's mathematically fair across cards with different contribution sizes. FIFO would make the first-applied Defend look disproportionately "effective" vs. a later-applied Warcry, which isn't real information. ## New `CardAggregate` fields - `TotalBlockEffective` — block absorbed before expiring (HP actually saved by this card's block) - `TotalBlockWasted` — block that expired at turn end without absorbing anything ## Display Once these are populated, the tooltip's block section becomes: ``` Block gained 25 Avg block 5.0 Absorbed 18 (72%) Wasted 7 (28%) ``` Same "whole number + %" layout as Overkill/Blocked on the damage side. Can share the 3-col table logic. ## Open questions - Fractional attribution: proportional splits produce fractional shares. Round per-event (accumulates rounding error) or track as floats in memory and only floor on display? - Turn end hook: `CombatManager` must have a per-turn-end signal. Needs investigation. - Does `DamageReceivedEntry.Result.BlockedDamage` fire for fully-blocked hits? (We saw earlier that the game might skip DamageReceivedEntry entirely for some edge cases.) ## Definition of done - [ ] Block provenance list maintained during combat - [ ] Proportional split on damage receipt - [ ] Turn-end waste attribution - [ ] Aggregate fields persisted + resumable after hot reload - [ ] Tooltip renders Absorbed/Wasted rows
nelsong6 commented 2026-04-20 20:36:46 -07:00 (Migrated from github.com)

Consolidating block-attribution tracking into #6 as of April 20, 2026 so the remaining M2 work lives in one place. Closing this as a duplicate/superseded issue after merging the useful implementation detail into #6.

Consolidating block-attribution tracking into #6 as of April 20, 2026 so the remaining M2 work lives in one place. Closing this as a duplicate/superseded issue after merging the useful implementation detail into #6.
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
romaine-life/spirelens#14
No description provided.