35 lines
1.8 KiB
Go
35 lines
1.8 KiB
Go
package common
|
|
|
|
import (
|
|
pb "gac-hkrpg-go/protocol/proto"
|
|
"testing"
|
|
)
|
|
|
|
func TestBattleReportAttributesServantDamageByOwner(t *testing.T) {
|
|
servant := &pb.BattleAvatarServantInfo{AvatarId: 20, EntityId: 200, TotalDamage: 900, TotalHeal: 30,
|
|
AttackTypeDamage: []*pb.AttackDamageProperty{{AttackType: "BPSkill", Damage: 900}},
|
|
AttackTypeMaxDamage: []*pb.AttackDamageProperty{{AttackType: "BPSkill", Damage: 300}}}
|
|
stats := &pb.BattleStatistics{BattleAvatarList: []*pb.AvatarBattleInfo{
|
|
{Id: 10, TotalDamage: 100}, {Id: 20, TotalDamage: 0}},
|
|
IAGKLJEKAOL: &pb.OHDHNDMJFAP{GFOAHHHNBJC: []*pb.BattleAvatarServantInfo{servant, servant,
|
|
{AvatarId: 999, TotalDamage: 999999}}}}
|
|
report := BattleReportFromStatistics(stats, 1, 2, "LIVE")
|
|
owner := report.Avatars[1]
|
|
if report.TeamTotalDamage != 1000 || owner.TotalDamage != 900 || owner.MemospriteDamage != 900 || owner.DamagePercent != 90 ||
|
|
owner.AttackTypeDamage["BPSkill"] != 900 || owner.AttackTypeMaxDamage["BPSkill"] != 300 || report.TeamTotalHeal != 30 {
|
|
t.Fatalf("servant owner attribution incorrect: report=%+v owner=%+v", report, owner)
|
|
}
|
|
if stats.BattleAvatarList[1].TotalDamage != 0 || servant.TotalDamage != 900 {
|
|
t.Fatal("conversion modified native source statistics")
|
|
}
|
|
}
|
|
|
|
func TestBattleReportServantDoesNotDoubleMonsterFallback(t *testing.T) {
|
|
stats := &pb.BattleStatistics{BattleAvatarList: []*pb.AvatarBattleInfo{{Id: 10}},
|
|
MonsterList: []*pb.MonsterBattleInfo{{TotalDamageTaken: 1000}},
|
|
IAGKLJEKAOL: &pb.OHDHNDMJFAP{GFOAHHHNBJC: []*pb.BattleAvatarServantInfo{{AvatarId: 10, TotalDamage: 1000}}}}
|
|
if report := BattleReportFromStatistics(stats, 1, 2, "WIN"); report.TeamTotalDamage != 1000 || report.Avatars[0].DamagePercent != 100 {
|
|
t.Fatalf("servant was added to a team-wide fallback twice: %+v", report)
|
|
}
|
|
}
|