pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package sdkserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
pb "gac-hkrpg-go/protocol/proto"
|
||||
"math"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type liveAvatarBreakdown struct {
|
||||
Damage map[string]float64 `json:"attack_type_damage"`
|
||||
BreakDamage map[string]float64 `json:"attack_type_break_damage"`
|
||||
MaxDamage map[string]float64 `json:"attack_type_max_damage"`
|
||||
}
|
||||
|
||||
func liveDamageProperties(values map[string]float64) ([]*pb.AttackDamageProperty, error) {
|
||||
if len(values) > 64 {
|
||||
return nil, fmt.Errorf("too many attack types")
|
||||
}
|
||||
keys := make([]string, 0, len(values))
|
||||
for key, value := range values {
|
||||
if key == "" || len(key) > 128 || math.IsNaN(value) || math.IsInf(value, 0) || value < 0 {
|
||||
return nil, fmt.Errorf("invalid native attack-type statistic")
|
||||
}
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
list := make([]*pb.AttackDamageProperty, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
list = append(list, &pb.AttackDamageProperty{AttackType: key, Damage: values[key]})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func applyLiveAvatarBreakdowns(avatars []*pb.AvatarBattleInfo, values []liveAvatarBreakdown) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(values) != len(avatars) {
|
||||
return fmt.Errorf("native breakdown count does not match avatars")
|
||||
}
|
||||
for i, value := range values {
|
||||
if avatars[i] == nil {
|
||||
return fmt.Errorf("missing native avatar")
|
||||
}
|
||||
for _, pair := range []struct {
|
||||
values map[string]float64
|
||||
target *[]*pb.AttackDamageProperty
|
||||
}{{value.Damage, &avatars[i].AttackTypeDamage}, {value.BreakDamage, &avatars[i].AttackTypeBreakDamage}, {value.MaxDamage, &avatars[i].AttackTypeMaxDamage}} {
|
||||
if pair.values == nil {
|
||||
continue
|
||||
}
|
||||
properties, err := liveDamageProperties(pair.values)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*pair.target = properties
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user