M1: Attack damage attribution #5
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#5
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
First real code. Hook card-played and enemy-took-damage events. For every attack card played, record 4 numbers:
Done when
Out of scope
Hook discovery needed
Will require ILSpy exploration of `sts2.dll`.
M1 done and verified live.
Implementation: Single Harmony postfix on `CombatHistory.Add` routes every `CardPlayFinishedEntry` and `DamageReceivedEntry` (with non-null `CardSource`) into `RunTracker`. The game's own `DamageResult` struct already exposes `BlockedDamage` / `UnblockedDamage` / `OverkillDamage` / `WasTargetKilled` — no need to reverse-engineer the damage pipeline.
Combat boundary behavior (per project requirement): events accumulate in an in-memory pending-combat buffer during combat; commit to the run file only on `CombatManager.CombatEnded`. Mid-combat crashes/aborts don't corrupt the persistent record.
Run metadata: captured on `RunManager.RunStarted` — character, ascension, starting floor. Floor updated on each combat end.
Test (Necrobinder, attack vs. Thieving Hopper):
```json
"STRIKE_NECROBINDER": {
"plays": 1,
"total_intended": 6,
"total_blocked": 0,
"total_overkill": 0,
"total_effective": 6,
"kills": 0
}
```
Strike dealt 6 damage to a full-HP Thieving Hopper. All four attribution numbers correct. File written to `%APPDATA%/SlayTheSpire2/CardStats/runs/.json`.
Commits:
7ca5f63— initial M1 implb8b417e— combat-boundary + metadata refactorDeferred to follow-up issues: M2 block (#1 heuristic), M3 utility closure, M4 UI, run outcome detection.