113 lines
2.8 KiB
Go
113 lines
2.8 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) SkillHit() bool {
|
|
if f := statusFuncRegistry.Get(e.StatusID); f != nil && f(e.Ctx().Our, e.Ctx().Opp) {
|
|
e.Ctx().SkillEntity.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(info.PetStatus.Burned) {
|
|
return true
|
|
}
|
|
if i.StatEffect_Exist(info.PetStatus.Frozen) {
|
|
return true
|
|
}
|
|
if i.StatEffect_Exist(info.PetStatus.Poisoned) {
|
|
return true
|
|
}
|
|
return false
|
|
})
|
|
registerStatusFunc(96, func(i, o *input.Input) bool {
|
|
return o.StatEffect_Exist(info.PetStatus.Burned)
|
|
})
|
|
registerStatusFunc(97, func(i, o *input.Input) bool {
|
|
return o.StatEffect_Exist(info.PetStatus.Frozen)
|
|
})
|
|
registerStatusFunc(102, func(i, o *input.Input) bool {
|
|
return o.StatEffect_Exist(info.PetStatus.Paralysis)
|
|
})
|
|
initskill(129, &Effect129{})
|
|
registerStatusFunc(132, func(i, o *input.Input) bool {
|
|
return i.CurrentPet.Info.Hp < o.CurrentPet.Info.Hp
|
|
})
|
|
registerStatusFunc(168, func(i, o *input.Input) bool {
|
|
return o.StatEffect_Exist(info.PetStatus.Sleep)
|
|
})
|
|
registerStatusFunc(401, func(i, o *input.Input) bool {
|
|
return i.CurrentPet.PetInfo.Type == o.CurrentPet.PetInfo.Type
|
|
})
|
|
registerStatusFunc(431, func(i, o *input.Input) bool {
|
|
|
|
for _, v := range o.Prop[:] {
|
|
|
|
if v < 0 {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
})
|
|
}
|
|
|
|
type Effect129 struct {
|
|
node.EffectNode
|
|
StatusID int
|
|
}
|
|
|
|
func (e *Effect129) SkillHit() bool {
|
|
if e.Ctx().Opp.CurrentPet.Info.Gender != e.SideEffectArgs[0] {
|
|
return true
|
|
}
|
|
e.Ctx().SkillEntity.Power *= 2
|
|
return true
|
|
}
|
|
|
|
// 小助手函数,让注册看起来更自然
|
|
func registerStatusFunc(id int, fn func(*input.Input, *input.Input) bool) {
|
|
statusFuncRegistry.Register(id, fn)
|
|
input.InitEffect(input.EffectType.Skill, id, &Effect96{StatusID: id})
|
|
}
|