test: player base report

This commit is contained in:
Ilia Denisov
2026-02-06 19:53:28 +02:00
parent 93baafe2a0
commit ec8b494a5b
3 changed files with 44 additions and 4 deletions
+1 -3
View File
@@ -109,19 +109,17 @@ func (c *Cache) ReportRace(ri int, rep *mr.Report, battles []*mr.BattleReport, b
rep.RaceID = r.ID
// votes based on population
// TODO: check vote values was previously calculated
rep.Votes = mr.F(r.Votes.F())
// relations
for i := range r.Relations {
rii := slices.IndexFunc(rep.Player, func(v mr.Player) bool { return v.ID == r.Relations[i].RaceID })
if rii < 0 {
panic(fmt.Sprintf("relation race not found, id=%v", r.Relations[i].RaceID))
panic(fmt.Sprintf("opponent race for relation not found, id=%v", r.Relations[i].RaceID))
}
rep.Player[rii].Relation = r.Relations[i].Relation.String()
}
// self-relation is undefined
if i := slices.IndexFunc(rep.Player, func(v mr.Player) bool { return v.ID == r.ID }); i < 0 {
panic(fmt.Sprintf("race not found in report, id=%v", r.ID))
} else {