feat(item): 优化宠物道具使用逻辑与个体值处理

- 在获取用户物品列表时,过滤掉数量为0的物品
- 调整部分宠物道具ID判断条件,并修复神经元道具特殊处理逻辑
- 使用 DeepCopy 方式拷贝宠物数据,避免引用问题
- 移除冗余 copier 包引用,统一在需要处进行深拷贝操作
- 增加对宠物个体值(Dv)的操作边界检查,防止溢出
- 重构基因重组道具逻辑,调用封装
This commit is contained in:
2025-12-07 02:50:35 +08:00
parent 004eec219c
commit 3817fc1861
3 changed files with 52 additions and 28 deletions

View File

@@ -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
}