refactor: 重构战斗属性和特效应用逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-04-06 03:11:38 +08:00
committed by cnb
parent a16a06e389
commit 40ec827342
9 changed files with 166 additions and 39 deletions

View File

@@ -383,6 +383,13 @@ func (pet *PetInfo) RnadEffect() {
// 7 :繁殖加成
// 8 :体力提升加成
const (
maxHPUpEffectIdx uint16 = 60000
maxHPUpEffectStatus byte = 8
maxHPUpEffectEID uint16 = 26
maxHPUpEffectCap = 20
)
// 繁殖加成,体力提升加成 ,这里是防止和其他重复所以定义不同类别,但是实际上,能量珠那些事调用不同id的effect实现
// <!-- Stat: 精灵特效Stat: 0: 无效(默认值), 1: 永久, 2: 有`有效次数'的特效 3: 爆发特效 4: 异能精灵特质5特训6魂印-->
func (pet *PetInfo) GetEffect(ptype int) (int, *PetEffectInfo, bool) {
@@ -393,6 +400,47 @@ func (pet *PetInfo) GetEffect(ptype int) (int, *PetEffectInfo, bool) {
}
func (pet *PetInfo) AddMaxHPUpEffect(itemID uint32, value int) bool {
if pet == nil || value <= 0 {
return false
}
if _, eff, ok := pet.GetEffect(int(maxHPUpEffectStatus)); ok {
current := 0
if len(eff.Args) >= 2 && eff.Args[0] == 0 && eff.Args[1] > 0 {
current = eff.Args[1]
}
if current >= maxHPUpEffectCap {
return false
}
next := current + value
if next > maxHPUpEffectCap {
next = maxHPUpEffectCap
}
eff.ItemID = itemID
eff.Idx = maxHPUpEffectIdx
eff.Status = maxHPUpEffectStatus
eff.EID = maxHPUpEffectEID
eff.Args = []int{0, next}
return next > current
}
if value > maxHPUpEffectCap {
value = maxHPUpEffectCap
}
pet.EffectInfo = append(pet.EffectInfo, PetEffectInfo{
ItemID: itemID,
Idx: maxHPUpEffectIdx,
Status: maxHPUpEffectStatus,
EID: maxHPUpEffectEID,
Args: []int{0, value},
})
return true
}
func (pet *PetInfo) Downgrade(level uint32) {
for pet.Level > uint32(level) {