From f91b88e90ffbccb36983828ec16486fa584d2b27 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Tue, 30 Dec 2025 02:15:33 +0000 Subject: [PATCH] =?UTF-8?q?```=20refactor(pet):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E7=89=B9=E6=80=A7=E9=9A=8F=E6=9C=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=AE=A0=E7=89=A9=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=95=B0=E7=BB=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{pet_COLLECT.go => pet_collect.go} | 0 logic/service/item/petuse.go | 4 +-- logic/service/player/base.go | 4 +-- modules/blazing/model/pet.go | 28 ++++++++----------- modules/config/service/pet_fusion_service.go | 2 +- 5 files changed, 17 insertions(+), 21 deletions(-) rename logic/controller/{pet_COLLECT.go => pet_collect.go} (100%) diff --git a/logic/controller/pet_COLLECT.go b/logic/controller/pet_collect.go similarity index 100% rename from logic/controller/pet_COLLECT.go rename to logic/controller/pet_collect.go diff --git a/logic/service/item/petuse.go b/logic/service/item/petuse.go index 8d795f220..d62a47500 100644 --- a/logic/service/item/petuse.go +++ b/logic/service/item/petuse.go @@ -201,7 +201,7 @@ func init() { PetItemRegistry.RegisterExact(300053, func(itemid uint32, onpet *model.PetInfo) bool { _, _, ok := onpet.GetEffect(1) if !ok { - onpet.RnadAN() + onpet.RnadEffect() return true } @@ -210,7 +210,7 @@ func init() { PetItemRegistry.RegisterExact(300054, func(itemid uint32, onpet *model.PetInfo) bool { _, _, ok := onpet.GetEffect(1) if ok { - onpet.RnadAN() + onpet.RnadEffect() return true } return false diff --git a/logic/service/player/base.go b/logic/service/player/base.go index ada662cce..f6f75d1d3 100644 --- a/logic/service/player/base.go +++ b/logic/service/player/base.go @@ -68,8 +68,8 @@ func (f *baseplayer) FindPet(catchTime uint32) (int, *model.PetInfo, bool) { func (f *Player) PetDel(catchTime uint32) { index, olpet, ok := f.FindPet(catchTime) if ok { - copy(f.Info.PetList[index:], f.Info.PetList[index+1:]) - f.Info.PetList = f.Info.PetList[:len(f.Info.PetList)-1] + f.Info.PetList = append(f.Info.PetList[:index], f.Info.PetList[index+1:]...) + //先将背包更新 f.Service.Pet.PetInfo_One_exec(catchTime, func(petData *model.PetEX) { petData.Data = *olpet diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 711b149e1..ea512e940 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "math" - "math/rand" "time" "github.com/gogf/gf/v2/util/gconv" @@ -240,14 +239,10 @@ func (pet *PetInfo) IsShiny() bool { } // 随机特性 -func (pet *PetInfo) RnadAN() { - // 随机特性 - randomIndex := rand.Intn(len(xmlres.PlayerEffectMAP)) +func (pet *PetInfo) RnadEffect() { - var i int for _, v := range xmlres.PlayerEffectMAP { - - if i == randomIndex { + if gconv.Int(v.StarLevel) == 0 { ret := &PetEffectInfo{ Idx: uint16(gconv.Int16(v.Idx)), Status: 1, @@ -264,7 +259,7 @@ func (pet *PetInfo) RnadAN() { break } - i++ + } } @@ -475,14 +470,15 @@ func GenPetInfo( case abilityTypeEnum == -1: for _, v := range xmlres.PlayerEffectMAP { - - p.EffectInfo = append(p.EffectInfo, PetEffectInfo{ - Idx: uint16(gconv.Int16(v.Idx)), - Status: 1, - EID: uint16(gconv.Int16(v.Eid)), - Args: v.ArgsS, - }) - break + if gconv.Int(v.StarLevel) == 0 { + p.EffectInfo = append(p.EffectInfo, PetEffectInfo{ + Idx: uint16(gconv.Int16(v.Idx)), + Status: 1, + EID: uint16(gconv.Int16(v.Eid)), + Args: v.ArgsS, + }) + break + } } } diff --git a/modules/config/service/pet_fusion_service.go b/modules/config/service/pet_fusion_service.go index bfe925a91..6436c51c7 100644 --- a/modules/config/service/pet_fusion_service.go +++ b/modules/config/service/pet_fusion_service.go @@ -46,7 +46,7 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 { return 0 } pets := s.def() - res := pets[grand.Intn(len(pets)-1)] + res := pets[grand.Intn(len(pets))] rr := grand.Intn(100) if rr < int(res.Probability+int32(rand)) { return uint32(res.ResultPetID)