2025-09-25 20:34:33 +00:00
|
|
|
package effect
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
"blazing/logic/service/fight/input"
|
|
|
|
|
"blazing/logic/service/fight/node"
|
|
|
|
|
)
|
|
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
// ---- 全局函数表自动管理 ----
|
|
|
|
|
var statusFuncRegistry = newStatusFuncRegistry()
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
type statusFuncRegistryType struct {
|
|
|
|
|
funcs map[int]func(*input.Input, *input.Input) bool
|
|
|
|
|
}
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
func newStatusFuncRegistry() *statusFuncRegistryType {
|
|
|
|
|
return &statusFuncRegistryType{funcs: make(map[int]func(*input.Input, *input.Input) bool)}
|
|
|
|
|
}
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
func (r *statusFuncRegistryType) Register(id int, f func(*input.Input, *input.Input) bool) {
|
|
|
|
|
r.funcs[id] = f
|
|
|
|
|
}
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
func (r *statusFuncRegistryType) Get(id int) func(*input.Input, *input.Input) bool {
|
|
|
|
|
return r.funcs[id]
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
// ---- Effect96 ----
|
2025-09-25 20:34:33 +00:00
|
|
|
type Effect96 struct {
|
|
|
|
|
node.EffectNode
|
2025-11-03 03:59:59 +08:00
|
|
|
StatusID int
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-08 23:20:48 +08:00
|
|
|
func (e *Effect96) Skill_Hit(opp input.Ctx) bool {
|
2025-11-08 19:48:59 +08:00
|
|
|
if f := statusFuncRegistry.Get(e.StatusID); f != nil && f(e.Input, opp.Input) {
|
|
|
|
|
opp.Power *= 2
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|
2025-11-08 19:48:59 +08:00
|
|
|
return true
|
2025-11-03 03:59:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---- 注册所有效果 ----
|
|
|
|
|
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 {
|
2025-11-10 02:29:00 +08:00
|
|
|
return o.StatEffect_Exist(int(info.PetStatus.Burned))
|
2025-11-03 03:59:59 +08:00
|
|
|
})
|
|
|
|
|
registerStatusFunc(97, func(i, o *input.Input) bool {
|
2025-11-10 02:29:00 +08:00
|
|
|
return o.StatEffect_Exist(int(info.PetStatus.Frozen))
|
2025-11-03 03:59:59 +08:00
|
|
|
})
|
|
|
|
|
registerStatusFunc(102, func(i, o *input.Input) bool {
|
2025-11-10 02:29:00 +08:00
|
|
|
return o.StatEffect_Exist(int(info.PetStatus.Paralysis))
|
2025-11-03 03:59:59 +08:00
|
|
|
})
|
2025-11-08 23:20:48 +08:00
|
|
|
registerStatusFunc(132, func(i, o *input.Input) bool {
|
2025-11-10 02:29:00 +08:00
|
|
|
return i.CurrentPet.Info.Hp < o.CurrentPet.Info.Hp
|
2025-11-08 23:20:48 +08:00
|
|
|
})
|
2025-11-03 03:59:59 +08:00
|
|
|
registerStatusFunc(168, func(i, o *input.Input) bool {
|
2025-11-10 02:29:00 +08:00
|
|
|
return o.StatEffect_Exist(int(info.PetStatus.Sleep))
|
2025-11-03 03:59:59 +08:00
|
|
|
})
|
|
|
|
|
}
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
// 小助手函数,让注册看起来更自然
|
|
|
|
|
func registerStatusFunc(id int, fn func(*input.Input, *input.Input) bool) {
|
|
|
|
|
statusFuncRegistry.Register(id, fn)
|
|
|
|
|
input.InitEffect(input.EffectType.Skill, id, &Effect96{StatusID: id})
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|