Files
bl/logic/service/fight/effect/effect_power_doblue.go
昔念 4b34445dfc ```
refactor(fight): 重构战斗逻辑中技能实体传递方式

将战斗逻辑中使用的 action.SelectSkillAction 替换为 info.SkillEntity,
以统一技能数据结构。同时更新相关函数签名和字段引用。

此外,移除了未使用的 Attack 字段,并调整了部分逻辑实现以提高代码清晰度。
还修复了 effect_power_doblue.go 中对输入参数的错误引用问题。

最后,修改了通道命名规范(ActionChan -> actionChan, GetActionChan -> GetOverChan),
并引入 overchan 用于战斗结束通知,提升并发安全性与语义明确性。
```
2025-11-10 02:29:00 +08:00

86 lines
2.3 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 o.StatEffect_Exist(int(info.PetStatus.Burned))
})
registerStatusFunc(97, func(i, o *input.Input) bool {
return o.StatEffect_Exist(int(info.PetStatus.Frozen))
})
registerStatusFunc(102, func(i, o *input.Input) bool {
return o.StatEffect_Exist(int(info.PetStatus.Paralysis))
})
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(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})
}