M2: Block attribution (generated / absorbed / wasted) #6
Labels
No labels
4-29
bug
documentation
duplicate
enhancement
flow improvement
good first issue
help wanted
invalid
investigating
issue-agent
issue-agent-blocked
issue-agent-complete
issue-agent-pr-open
issue-agent-runner-nelsonlaptop
issue-agent-runner-nelsonpc
issue-agent-runner-nelsonpc-user
issue-agent-running
needs-verification
next to do
question
queue
recon
relics-stats-onboarding
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens#6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Attribute each block card's generated block to what it actually did this run.
M2a already covered direct block-gained attribution. This issue tracks the remaining work to determine how much of each card's block actually absorbed damage vs. was effectively unnecessary.
This issue supersedes #1 and #14 so block attribution lives in one place.
Semantics
Use grant-order attribution with oldest block consumed first.
This is the intended behavior for the feature, not just a fallback heuristic:
Example:
Attribution should be:
This is the signal we want: "was this later block card actually needed, or was it mostly redundant?"
Data model
Maintain a runtime provenance ledger for the player's current block pool.
State on combat history / run tracker side:
Event handling
1. On block gain
Whenever the player gains block from a
BlockGainedEntry:TotalBlockGeneratedif the source is a cardBlockChunkto_playerBlockLedgerSequencePseudo-code:
Non-card block sources should still create chunks, but with
CardInstanceId = null, so they participate in consumption order without polluting card stats.2. On damage that consumes block
Whenever the player takes damage and some amount is blocked:
BlockedDamage_playerBlockLedgerfrom oldest to newestTotalBlockEffectiveRemainingreaches zeroPseudo-code:
This must run whenever damage happens, not only on enemy turns, because some rare effects can cause block consumption during the player's own turn.
3. On block expiration / removal without preventing HP loss
At the point where block is removed because it expired or otherwise ceased to exist without absorbing damage:
For this feature, unused block should be blamed on the most recently added surviving chunks first.
Why:
So the final rule is:
Pseudo-code:
This gives the intuitive result that the "extra" block card played later is the one that gets marked wasted first.
Required hook points
Need reliable hooks for:
BlockedDamageIf there is no single clean "block expired" event, the fallback is to compare:
Then attribute the difference via
AttributeUnusedBlock(diff).Aggregate fields
TotalBlockGenerated? raw block the card producedTotalBlockEffective? block that actually absorbed incoming damageTotalBlockWasted? block that disappeared unusedThese should stay integer-valued throughout; no fractional math is needed with this model.
Display
Tooltip block section target:
Definitions:
Absorbed % = TotalBlockEffective / TotalBlockGeneratedWasted % = TotalBlockWasted / TotalBlockGeneratedPercentages may not sum to 100% if there are edge cases like retained block or unresolved removal categories that need their own handling.
Edge cases / design questions
Wastedor needs a separate future bucket such asRemoved.DamageReceivedEntry.Result.BlockedDamagein all relevant paths.Definition of done
BlockGainedEntryappends chunks and incrementsTotalBlockGeneratedDamageReceivedEntryattributes blocked damage FIFO intoTotalBlockEffectiveTotalBlockWastedShipped in
3da6037.This lands the main M2 block-attribution pass:
Verification: