``` refactor(pet): 重构宠物效果检查逻辑,使用GetEffect替代HaveAN并优化效果复制
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
@@ -222,10 +223,10 @@ func (pet *PetInfo) RnadAN() {
|
||||
EID: uint16(gconv.Int16(v.Eid)),
|
||||
Args: v.ArgsS,
|
||||
}
|
||||
_, eff, ok := pet.GetEffect(1)
|
||||
if ok {
|
||||
|
||||
if pet.HaveAN() {
|
||||
pet.EffectInfo[0] = *ret
|
||||
//copier.Copy(pet.EffectInfo[0], ret)
|
||||
copier.Copy(eff, ret)
|
||||
} else {
|
||||
pet.EffectInfo = append(pet.EffectInfo, *ret)
|
||||
}
|
||||
@@ -236,13 +237,14 @@ func (pet *PetInfo) RnadAN() {
|
||||
}
|
||||
}
|
||||
|
||||
func (pet *PetInfo) HaveAN() bool {
|
||||
func (pet *PetInfo) GetEffect(ptype int) (int, *PetEffectInfo, bool) {
|
||||
|
||||
_, _, ok := utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool {
|
||||
return utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool {
|
||||
return gconv.Int(xmlres.EffectMAP[int(item.Idx)].Stat) == 1
|
||||
})
|
||||
return ok
|
||||
|
||||
}
|
||||
|
||||
func (pet *PetInfo) Downgrade(level uint32) {
|
||||
|
||||
for pet.Level > uint32(level) {
|
||||
|
||||
Reference in New Issue
Block a user