refactor(fight): 统一战斗系统方法命名规范并优化逻辑 - 将所有下划线命名的方法统一为驼峰命名,如 Turn_Start 改为 TurnStart, Action_end_ex 改为 ActionEndEx,Turn_End 改为 TurnEnd - 新增 IsOwner() 方法用于判断当前精灵是否为场上的当前宠物 - 将硬编码的 CatchTime 比较逻辑替换为 IsOwner() 方法调用 - 在 NewSel408 中实现消除对手能力强化效果的具体逻辑 - 修复 effect_74 中衰弱状态的数值引用,使用枚举类型代替硬编码 - 优化 input/fight.go 中的技能选择逻辑,使用伤害值比较代替权重比较 - 移除 shiny.go 中未使用的 utils 导入和相关逻辑 - 修正 NewSel77 从 Turn_End 重命名为 TurnStart 的方法 - 在 input/fight.go 中添加 Damage 方法的注释说明 ```
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// 81. 体力低于n%时,每次受到伤害都会使自身进入山神守护状态,接下来m回合受到伤害减免90%(a1: n, a2: m)
|
||
type NewSel81 struct {
|
||
NewSel0
|
||
damageReduceTurns int
|
||
}
|
||
|
||
func (e *NewSel81) DamageDivEx(t *info.DamageZone) bool {
|
||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||
return true
|
||
}
|
||
|
||
// 检查当前是否处于山神守护状态
|
||
if e.damageReduceTurns > 0 {
|
||
// 减免90%伤害
|
||
reduction := t.Damage.Mul(alpacadecimal.NewFromInt(90)).Div(alpacadecimal.NewFromInt(100))
|
||
t.Damage = t.Damage.Sub(reduction)
|
||
return true
|
||
}
|
||
|
||
// 计算当前体力百分比
|
||
currentHP := e.Ctx().Our.CurrentPet.GetHP()
|
||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
hpPercent := currentHP.Mul(alpacadecimal.NewFromInt(100)).Div(maxHP)
|
||
|
||
// 检查是否低于阈值
|
||
if hpPercent.Cmp(e.Args()[0]) == -1 {
|
||
// 进入山神守护状态,持续m回合
|
||
e.damageReduceTurns = int(e.Args()[1].IntPart())
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func (e *NewSel81) TurnEnd() {
|
||
// 魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||
return
|
||
}
|
||
|
||
// 减少山神守护状态回合数
|
||
if e.damageReduceTurns > 0 {
|
||
e.damageReduceTurns--
|
||
}
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.NewSel, 81, &NewSel81{})
|
||
}
|