diff --git a/logic/service/item/petuse.go b/logic/service/item/petuse.go index 433ee71d..780df970 100644 --- a/logic/service/item/petuse.go +++ b/logic/service/item/petuse.go @@ -199,8 +199,8 @@ func init() { return true }) PetItemRegistry.RegisterExact(300053, func(itemid uint32, onpet *model.PetInfo) bool { - - if !onpet.HaveAN() { + _, _, ok := onpet.GetEffect(1) + if !ok { onpet.RnadAN() return true } @@ -208,8 +208,8 @@ func init() { return false }) PetItemRegistry.RegisterExact(300054, func(itemid uint32, onpet *model.PetInfo) bool { - - if onpet.HaveAN() { + _, _, ok := onpet.GetEffect(1) + if ok { onpet.RnadAN() return true } diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 465bc22c..88e20a08 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -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) {