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] } // Effect 96: 对手处于烧伤状态时,威力翻倍 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.XML.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 { return o.HasPropSub() }) initskill(609, &Effect609{}) } // Effect 129: 对方为{0}则技能威力翻倍 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.XML.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}) } // Effect 609: 若对手{0},技能威力翻倍 type Effect609 struct { node.EffectNode StatusID int } func (e *Effect609) SkillHit() bool { if e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.SideEffectArgs[0])) { return true } e.Ctx().SkillEntity.XML.Power *= 2 return true }