Files
bl/logic/service/fight/effect/effect_117.go
昔念 c4d0119129 ```
refactor(fight): 重构击败触发效果机制,优化代码结构

将 EffectDefeatTrigger 中的回调函数模式改为基于 effectID 的 switch-case 实现,
移除冗余的 defeatTriggerFunc 类型定义。统一通过 triggerByID 方法根据 ID 分发执行具体行为,
提高可维护性和扩展性。

同时更新 AddEffect 方法签名以支持传入主动方输入上下文,增强效果添加时的控制逻辑。
修复部分效果在添加状态时未正确传递施加者信息的问题。

此外,清理了部分注释和无用代码,使逻辑更清晰。
```
2025-11-14 03:21:00 +08:00

57 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
/**
* n回合若自己先手则m%几率让对手害怕1到3回合
*/
func init() {
t := &Effect117{
EffectNode: node.EffectNode{},
}
// t.Duration(-1) //设置成无限回合,到回合数就停止
input.InitEffect(input.EffectType.Skill, 117, t)
}
type Effect117 struct {
node.EffectNode
}
// 默认添加回合
func (e *Effect117) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
}
func (e *Effect117) OnSkill() bool {
if !e.Hit() {
return true
}
if e.Input.FightC.IsFirst(e.Input.Player) {
// 概率判定
ok, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100)
if !ok {
return true
}
// 获取状态效果
eff := input.Geteffect(input.EffectType.Status, int(info.PetStatus.Fear))
if eff == nil {
return true
}
duration := int(e.Input.FightC.GetRand().Int31n(3)) // 默认随机 1~3 回合
eff.Duration(duration)
e.Ctx().Opp.AddEffect(e.Ctx().Our, eff)
}
return true
}