diff --git a/logic/controller/item_use.go b/logic/controller/item_use.go index 651892a2c..634882fde 100644 --- a/logic/controller/item_use.go +++ b/logic/controller/item_use.go @@ -20,7 +20,10 @@ func (h Controller) UserItemList(data *item.ItemListInboundInfo, c *player.Playe vv.ItemId = v.ItemId vv.ItemCnt = v.ItemCnt vv.LeftTime = 360000 - result.ItemList = append(result.ItemList, vv) + if vv.ItemCnt != 0 { + result.ItemList = append(result.ItemList, vv) + } + } return result, 0 @@ -35,11 +38,8 @@ func (h Controller) ItemUsePet(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGHT, c *play if c.Service.Item.CheakItem(data.ItemID) == 0 { return nil, errorcode.ErrorCodes.ErrSystemError } - hd := item.PetItemRegistry.GetHandler(data.ItemID) - if hd == nil { - return nil, errorcode.ErrorCodes.ErrSystemError - } - if data.ItemID == 300025 { + + if data.ItemID == 300036 { //神经元需要特殊处理 if onpet.OldCatchTime == 0 { @@ -48,9 +48,13 @@ func (h Controller) ItemUsePet(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGHT, c *play oldpetc := onpet.CatchTime oldpet := c.Service.Pet.PetInfo_One_Unscoped(onpet.OldCatchTime) - copier.Copy(onpet, oldpet.Data) + copier.CopyWithOption(onpet, oldpet.Data, copier.Option{DeepCopy: true}) onpet.CatchTime = oldpetc } else { + hd := item.PetItemRegistry.GetHandler(data.ItemID) + if hd == nil { + return nil, errorcode.ErrorCodes.ErrSystemError + } r := hd(data.ItemID, onpet) if !r { return nil, errorcode.ErrorCodes.ErrSystemError diff --git a/logic/service/item/petuse.go b/logic/service/item/petuse.go index 789acf466..e5cc70fc7 100644 --- a/logic/service/item/petuse.go +++ b/logic/service/item/petuse.go @@ -9,7 +9,6 @@ import ( "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" - "github.com/jinzhu/copier" ) type PetItemHandler func(itemid uint32, ctx *model.PetInfo) bool @@ -148,27 +147,27 @@ func init() { PetItemRegistry.RegisterExact(300790, func(itemid uint32, onpet *model.PetInfo) bool { r := grand.Intn(2) if r == 0 { - onpet.Dv-- + if onpet.Dv > 0 { + onpet.Dv-- + } + } else { - onpet.Dv++ + if onpet.Dv < 31 { + onpet.Dv++ + } + } return true }) //基因重组 PetItemRegistry.RegisterExact(300024, func(itemid uint32, onpet *model.PetInfo) bool { - oldcat := onpet.CatchTime - ab := 0 - for _, v := range onpet.EffectInfo { - if v.Type == 1 { - ab = int(v.Idx) - } - - } - r := model.GenPetInfo(int(onpet.ID), -1, -1, ab, 0, 1) - - copier.Copy(onpet, r) - onpet.CatchTime = oldcat + onpet.Downgrade(1) + onpet.Update_EXP() + onpet.Ev = [6]uint32{} + onpet.Dv = uint32(grand.Intn(32)) + onpet.Nature = (onpet.Nature + uint32(grand.Intn(25))) % 25 + onpet.CalculatePetPane() return true }) @@ -178,13 +177,24 @@ func init() { return true }) PetItemRegistry.RegisterExact(300791, func(itemid uint32, onpet *model.PetInfo) bool { - + if onpet.Dv >= 31 { + onpet.Dv = 31 + return true + } onpet.Dv = 31 return true }) - PetItemRegistry.RegisterExact(300792, func(itemid uint32, onpet *model.PetInfo) bool { + PetItemRegistry.RegisterExact(300702, func(itemid uint32, onpet *model.PetInfo) bool { + if onpet.Dv >= 31 { + onpet.Dv = 31 + return true + } + onpet.Dv = onpet.Dv + uint32(grand.Intn(31-int(onpet.Dv))+1) - onpet.Dv = uint32(grand.Intn(31-int(onpet.Dv)) + 1) + if onpet.Dv >= 31 { + onpet.Dv = 31 + //return true + } return true }) PetItemRegistry.RegisterExact(300053, func(itemid uint32, onpet *model.PetInfo) bool { diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index e536f6576..3ecb64deb 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -34,6 +34,16 @@ type PetEX struct { Data PetInfo `orm:"data" json:"data"` } +type Attr uint32 + +func (r Attr) sub() uint32 { + if r > 0 { + return uint32(r) - 1 + + } + return 0 +} + // PetInfo 精灵信息结构(合并后的优化版本) type PetInfo struct { @@ -44,7 +54,7 @@ type PetInfo struct { Name string `struc:"[16]byte" ` // 个体值(@UInt long → uint32) - Dv uint32 `fieldDesc:"个体值" ` + Dv uint32 `struc:"uint32" ` // 性格(@UInt long → uint32) Nature uint32 `fieldDesc:"性格" ` @@ -213,7 +223,7 @@ func (pet *PetInfo) RnadAN() { Args: v.ArgsS, } _, eff1, ok := utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool { - return uint16(item.Type) == 1 + return gconv.Int(xmlres.EffectMAP[int(item.Idx)].Stat) == 1 }) if ok { copier.Copy(eff1, ret) @@ -229,7 +239,7 @@ func (pet *PetInfo) RnadAN() { func (pet *PetInfo) HaveAN() bool { _, _, ok := utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool { - return uint16(item.Type) == 1 + return gconv.Int(xmlres.EffectMAP[int(item.Idx)].Stat) == 1 }) return ok }