fix: recover battle damage from statistics
This commit is contained in:
1 parent
1ed0fb73f9
commit
5120219ae2
2 files changed
+82
-3
No files matched your search
@@ -101,3 +101,47 @@ func TestBattleReportSerialization(t *testing.T) {
|
||||
t.Fatal("expected error after clearing report, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBattleReportUsesAvatarDamageEventsWhenAvatarTotalsAreZero(t *testing.T) {
|
||||
stt := &goproto.BattleStatistics{
|
||||
BattleAvatarList: []*goproto.AvatarBattleInfo{
|
||||
{Id: 1503},
|
||||
{Id: 1511},
|
||||
},
|
||||
OKFALMGFHMA: []*goproto.HDKEPPDIDIH{
|
||||
{AvatarId: 1503, Damage: 720},
|
||||
{AvatarId: 1503, Damage: 180},
|
||||
{AvatarId: 1511, Damage: 100},
|
||||
},
|
||||
MonsterList: []*goproto.MonsterBattleInfo{{TotalDamageTaken: 1000}},
|
||||
}
|
||||
|
||||
report := BattleReportFromStatistics(stt, 1, 1052106, "WIN")
|
||||
if report.TeamTotalDamage != 1000 {
|
||||
t.Fatalf("expected event-derived team damage 1000, got %f", report.TeamTotalDamage)
|
||||
}
|
||||
if report.Avatars[0].TotalDamage != 900 || report.Avatars[0].DamagePercent != 90 {
|
||||
t.Fatalf("unexpected avatar 1503 report: %+v", report.Avatars[0])
|
||||
}
|
||||
if report.Avatars[1].TotalDamage != 100 || report.Avatars[1].DamagePercent != 10 {
|
||||
t.Fatalf("unexpected avatar 1511 report: %+v", report.Avatars[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestBattleReportFallsBackToMonsterDamageTakenForTeamTotal(t *testing.T) {
|
||||
stt := &goproto.BattleStatistics{
|
||||
BattleAvatarList: []*goproto.AvatarBattleInfo{{Id: 1503}},
|
||||
MonsterList: []*goproto.MonsterBattleInfo{
|
||||
{TotalDamageTaken: 250},
|
||||
{TotalDamageTaken: 750},
|
||||
},
|
||||
}
|
||||
|
||||
report := BattleReportFromStatistics(stt, 1, 1052106, "WIN")
|
||||
if report.TeamTotalDamage != 1000 {
|
||||
t.Fatalf("expected monster-derived team damage 1000, got %f", report.TeamTotalDamage)
|
||||
}
|
||||
if report.Avatars[0].DamagePercent != 0 {
|
||||
t.Fatalf("cannot infer avatar share from monster totals, got %f", report.Avatars[0].DamagePercent)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user