fix(engine): add combat_deaths array to replay JSON top level

Per plan §7.1, the replay format should include combat_deaths array
at the top level for easy access. Previously this field only existed
inside the Result object, causing all replays to show combat_deaths: null
at the top level despite having combat_death events in the turns array.

Changes:
- Add CombatDeaths []int field to Replay struct with json tag
- Populate CombatDeaths in Finalize() from result.CombatDeaths

Closes: bf-36tko

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-05-26 13:54:37 -04:00
parent 3f0ece8508
commit f3a7a5e0d9

View file

@ -20,6 +20,7 @@ type Replay struct {
Turns []ReplayTurn `json:"turns"`
WinProb []WinProbEntry `json:"win_prob,omitempty"`
CriticalMoments []CriticalMoment `json:"critical_moments,omitempty"`
CombatDeaths []int `json:"combat_deaths,omitempty"` // bots killed in combat per player (focus-fire)
}
// ReplayPlayer represents player info in a replay.
@ -204,6 +205,10 @@ func (rw *ReplayWriter) Finalize(result *MatchResult) {
rw.replay.EndTime = time.Now().UTC()
rw.replay.Result = result
rw.replay.Turns = rw.turns
// Copy combat_deaths to top level for easy access (plan §7.1)
if result != nil {
rw.replay.CombatDeaths = result.CombatDeaths
}
}
// GetReplay returns the completed replay.