feat(fight): 调整技能与状态效果逻辑,优化战斗流程 - 注释掉状态 ID 13 的注册,暂不启用 DrainedHP 状态 - 为 Effect10 增加输入参数设置,标记目标单位 - 重构 Effect62 实现逻辑,新增子效果 Effect62_1 支持回合触发秒杀机制 - 引入 decimal 包以支持精确伤害计算 - 修改命中判断流程,修复部分技能命中异常问题 - 增加睡眠状态对空技能的防御处理 - 优化战斗死亡判定逻辑,支持同归于尽判定及战斗结束控制
86 lines
2.4 KiB
Go
86 lines
2.4 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
)
|
|
|
|
// ---- 全局函数表自动管理 ----
|
|
var statusFuncRegistry = newStatusFuncRegistry()
|
|
|
|
type statusFuncRegistryType struct {
|
|
funcs map[int]func(*input.Input, *input.Input) bool
|
|
}
|
|
|
|
func newStatusFuncRegistry() *statusFuncRegistryType {
|
|
return &statusFuncRegistryType{funcs: make(map[int]func(*input.Input, *input.Input) bool)}
|
|
}
|
|
|
|
func (r *statusFuncRegistryType) Register(id int, f func(*input.Input, *input.Input) bool) {
|
|
r.funcs[id] = f
|
|
}
|
|
|
|
func (r *statusFuncRegistryType) Get(id int) func(*input.Input, *input.Input) bool {
|
|
return r.funcs[id]
|
|
}
|
|
|
|
// ---- Effect96 ----
|
|
type Effect96 struct {
|
|
node.EffectNode
|
|
StatusID int
|
|
}
|
|
|
|
func (e *Effect96) Skill_Hit(opp input.Ctx) bool {
|
|
if f := statusFuncRegistry.Get(e.StatusID); f != nil && f(e.Input, opp.Input) {
|
|
opp.Power *= 2
|
|
}
|
|
return true
|
|
}
|
|
|
|
// ---- 注册所有效果 ----
|
|
func init() {
|
|
registerStatusFunc(2, func(i, o *input.Input) bool {
|
|
return o.CurrentPet.Info.Hp < (o.CurrentPet.Info.MaxHp / 2)
|
|
})
|
|
registerStatusFunc(30, func(i, o *input.Input) bool {
|
|
return !i.FightC.IsFirst(i.Player)
|
|
})
|
|
registerStatusFunc(40, func(i, o *input.Input) bool {
|
|
return i.FightC.IsFirst(i.Player)
|
|
})
|
|
registerStatusFunc(64, func(i, o *input.Input) bool {
|
|
if i.StatEffect_Exist(int(info.PetStatus.Burned)) {
|
|
return true
|
|
}
|
|
if i.StatEffect_Exist(int(info.PetStatus.Frozen)) {
|
|
return true
|
|
}
|
|
if i.StatEffect_Exist(int(info.PetStatus.Poisoned)) {
|
|
return true
|
|
}
|
|
return false
|
|
})
|
|
registerStatusFunc(96, func(i, o *input.Input) bool {
|
|
return i.StatEffect_Exist(int(info.PetStatus.Burned))
|
|
})
|
|
registerStatusFunc(97, func(i, o *input.Input) bool {
|
|
return i.StatEffect_Exist(int(info.PetStatus.Frozen))
|
|
})
|
|
registerStatusFunc(102, func(i, o *input.Input) bool {
|
|
return i.StatEffect_Exist(int(info.PetStatus.Paralysis))
|
|
})
|
|
registerStatusFunc(132, func(i, o *input.Input) bool {
|
|
return i.CurrentPet.Info.Hp < o.CurrentPet.Info.MaxHp
|
|
})
|
|
registerStatusFunc(168, func(i, o *input.Input) bool {
|
|
return i.StatEffect_Exist(int(info.PetStatus.Sleep))
|
|
})
|
|
}
|
|
|
|
// 小助手函数,让注册看起来更自然
|
|
func registerStatusFunc(id int, fn func(*input.Input, *input.Input) bool) {
|
|
statusFuncRegistry.Register(id, fn)
|
|
input.InitEffect(input.EffectType.Skill, id, &Effect96{StatusID: id})
|
|
}
|