feat(item): 添加 NatureProbs 字段并优化宠物道具使用逻辑
- 在 `Item` 结构体中新增 `NatureProbs` 字段,用于支持性格概率配置 - 重构 `ItemUsePet` 控制器方法,引入处理器注册机制统一管理道具效果 - 修复神经元相关道具的特殊处理逻辑,增强代码可维护性 - 调整 `S2C_USE_PET_ITEM_OUT_OF_FIGHT` 响应结构体,增加技能列表长度字段 - 修改 `ResetNature` 方法命名及判断条件,提升语义清晰度与健壮性 - 新增 `PetInfo_One_Unscoped` 查询方法以支持软删除数据访问 - 实
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
@@ -89,7 +90,7 @@ type PetInfo struct {
|
||||
// 捕获等级默认0(@UInt long → uint32)
|
||||
CatchLevel uint32 `fieldDesc:"捕获等级 默认为0" `
|
||||
EffectInfoLen uint16 `struc:"sizeof=EffectInfo"`
|
||||
// 特性列表:长度用UShort存储(变长List → []PetEffectInfo + 长度前缀规则)
|
||||
// 特性列表:长度用UShort存储(变长List → []PetEffectInfo + 长度前缀规则) 第一个一定是特性
|
||||
EffectInfo []PetEffectInfo `fieldDesc:"特性列表, 长度在头部以UShort存储" serialize:"lengthFirst,lengthType=uint16,type=structArray"`
|
||||
|
||||
// 皮肤ID默认0(@UInt long → uint32)
|
||||
@@ -196,6 +197,42 @@ func (pet *PetInfo) Cure() {
|
||||
}
|
||||
}
|
||||
|
||||
// 随机特性
|
||||
func (pet *PetInfo) RnadAN() {
|
||||
// 随机特性
|
||||
randomIndex := rand.Intn(len(xmlres.PlayerEffectMAP))
|
||||
|
||||
var i int
|
||||
for _, v := range xmlres.PlayerEffectMAP {
|
||||
|
||||
if i == randomIndex {
|
||||
ret := &PetEffectInfo{
|
||||
Idx: uint16(gconv.Int16(v.Idx)),
|
||||
Status: 1,
|
||||
EID: uint16(gconv.Int16(v.Eid)),
|
||||
Args: v.ArgsS,
|
||||
}
|
||||
_, eff1, ok := utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool {
|
||||
return uint16(item.Type) == 1
|
||||
})
|
||||
if ok {
|
||||
copier.Copy(eff1, ret)
|
||||
}
|
||||
pet.EffectInfo = append(pet.EffectInfo, *ret)
|
||||
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func (pet *PetInfo) HaveAN() bool {
|
||||
|
||||
_, _, ok := utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool {
|
||||
return uint16(item.Type) == 1
|
||||
})
|
||||
return ok
|
||||
}
|
||||
func (pet *PetInfo) Downgrade(level uint32) {
|
||||
|
||||
for pet.Level > uint32(level) {
|
||||
|
||||
Reference in New Issue
Block a user