feat(item): 优化宠物道具使用逻辑与个体值处理
- 在获取用户物品列表时,过滤掉数量为0的物品 - 调整部分宠物道具ID判断条件,并修复神经元道具特殊处理逻辑 - 使用 DeepCopy 方式拷贝宠物数据,避免引用问题 - 移除冗余 copier 包引用,统一在需要处进行深拷贝操作 - 增加对宠物个体值(Dv)的操作边界检查,防止溢出 - 重构基因重组道具逻辑,调用封装
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user