29 lines
1012 B
Go
29 lines
1012 B
Go
package sdkserver
|
|
|
|
import (
|
|
"encoding/base64"
|
|
pb "gac-hkrpg-go/protocol/proto"
|
|
"google.golang.org/protobuf/proto"
|
|
"testing"
|
|
)
|
|
|
|
func TestLiveServantHydratesNativeCategories(t *testing.T) {
|
|
wire, _ := proto.Marshal(&pb.BattleAvatarServantInfo{AvatarId: 20, TotalDamage: 1000})
|
|
encoded := []string{base64.StdEncoding.EncodeToString(wire)}
|
|
stats := &pb.BattleStatistics{}
|
|
err := applyLiveServantStatistics(stats, encoded, []liveAvatarBreakdown{{Damage: map[string]float64{"BPSkill": 800}}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
servant := stats.IAGKLJEKAOL.GFOAHHHNBJC[0]
|
|
if servant.AvatarId != 20 || servant.TotalDamage != 1000 || servant.AttackTypeDamage[0].Damage != 800 {
|
|
t.Fatalf("native servant aggregate/categories lost: %+v", servant)
|
|
}
|
|
if applyLiveServantStatistics(stats, encoded, nil) == nil {
|
|
t.Fatal("accepted two servant statistic sources")
|
|
}
|
|
if applyLiveServantStatistics(&pb.BattleStatistics{}, nil, []liveAvatarBreakdown{{}}) == nil {
|
|
t.Fatal("accepted unmatched breakdowns")
|
|
}
|
|
}
|