feat(fight): 添加新效果类型574并优化现有战斗逻辑 - 重命名NewSel409结构体的Action_end_ex方法为Skill_Use_ex - 将effect/523中HP检查改为Alive()方法调用 - 修复selfkill效果中的代码格式问题 - 新增效果类型574:消耗自身全部体力使下次技能必定先手、命中且暴击 - 实现Effect574的ComparePre和ActionStart方法处理先手、命中和暴击逻辑 ```
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
|
)
|
|
|
|
// {
|
|
// "id": 527,
|
|
// "argsNum": 2,
|
|
// "info": "使用技能时体力低于1/{0},则{1}回合内免疫异常状态"
|
|
// },
|
|
type Effect527 struct {
|
|
node.EffectNode
|
|
can bool
|
|
}
|
|
|
|
func (e *Effect527) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
|
|
|
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
|
if !e.can {
|
|
return true
|
|
}
|
|
|
|
if in != e.Ctx().Opp {
|
|
return true
|
|
}
|
|
if input.IS_Stat(effEffect) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
func (e *Effect527) OnSkill() bool {
|
|
|
|
divisor := e.Args()[0] // 除数
|
|
|
|
// 检查当前体力是否低于最大体力的 1/divisor
|
|
currentHP := alpacadecimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.Hp))
|
|
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
|
threshold := maxHP.Div(divisor)
|
|
|
|
if currentHP.Cmp(threshold) < 0 {
|
|
e.can = true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func (e *Effect527) SetArgs(t *input.Input, a ...int) {
|
|
e.EffectNode.SetArgs(t, a...)
|
|
|
|
e.EffectNode.Duration(a[0]) // 持续m回合
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 527, &Effect527{})
|
|
}
|