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 方法的注释说明 ```
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/input"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// 46. 若自身5回合内体力被降到0会余下1点体力,并且体力全恢复,恢复后回合数重新计算。
|
||
// TODO: 需要了解如何实现体力归零时的保命和恢复效果
|
||
type NewSel46 struct {
|
||
NewSel0
|
||
|
||
// 记录上次恢复后的回合数
|
||
lastRecoveryRound uint32
|
||
}
|
||
|
||
func (e *NewSel46) ActionEndEx() bool {
|
||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||
return true
|
||
}
|
||
|
||
// 获取当前回合数
|
||
r := e.Ctx().Our.FightC.GetOverInfo()
|
||
|
||
// 检查是否在5回合内
|
||
if r.Round-e.lastRecoveryRound <= 5 {
|
||
// 检查体力是否被降到0
|
||
if e.Ctx().Our.CurrentPet.Info.Hp <= 0 {
|
||
// 体力降到0,保留1点体力,恢复满
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, alpacadecimal.NewFromInt(1))
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, e.Ctx().Our.CurrentPet.GetMaxHP().Sub(alpacadecimal.NewFromInt(1)))
|
||
|
||
// 更新恢复后的回合数
|
||
e.lastRecoveryRound = r.Round
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.NewSel, 46, &NewSel46{})
|
||
}
|