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

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

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

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

112 lines
2.9 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"
"fmt"
"github.com/shopspring/decimal"
)
/**
* n回合内没有击败则对方死亡
*/
type Effect62 struct {
node.EffectNode
// Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用
// opp *input.Input
// e *Effect62_sub
//l sync.Once
}
type Effect62_sub struct {
node.EffectNode
//bindpet *info.BattlePetEntity
//bind *input.Input
// Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用
}
// 这个实际上在对方回合执行的
func (e *Effect62_sub) OnSkill() bool {
fmt.Println("镇魂歌剩余回合", e.Duration())
//defer e.Alive(false)
if e.Duration() == 0 { //说明对方没有切换精灵
//直接扣除所有血量OnSkill
//相当于对方给自己的伤害
e.Ctx().Our.Damage(e.Ctx().Opp, &info.DamageZone{
Type: info.DamageType.Fixed,
Damage: decimal.NewFromInt(int64(e.Ctx().Our.CurrentPet.Info.MaxHp)),
})
}
return true
}
func init() {
t := &Effect62{
EffectNode: node.EffectNode{},
}
input.InitEffect(input.EffectType.Skill, 62, t)
}
// func (e *Effect62) Turn_Start() {
// //如果对面还是我方放技能时候的玩家
// // if ctx.Player != e.opp.Player {
// // return
// // }
// fmt.Println(e.Duration(), "镇魂歌剩余回合")
// if e.Duration() != 0 { //说明还没到生效节点
// e.Hide = true //隐藏效果
// } else {
// e.opp.AddEffect(e.e)
// }
// // if !e.Hide { //说明是自身回合//如果还在隐藏,就直接返回
// // //t.Duration(e.SideEffectArgs[0])
// // e.opp.AddEffect(e.e)
// // //defer e.EffectNode.NotALive() //失效
// // //应该是对方固定伤害等于自身血量
// // //e.Input.Death() //本只死亡
// // //否则触发秒杀 在对面使用技能后
// // //return true
// // }
// }
// 魂印开局添加,然后切精灵不消失
func (e *Effect62) OnSkill() bool {
if !e.Hit() {
//e.Alive(false)
return true
}
//e.Duration(1) //必须保持到下一回合,这样才会被复制
// e.opp = ctx.Input
ee := &Effect62_sub{
// bindpet: ctx.CurrentPet,
// bind: ctx.Input,
}
ee.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) //给对方挂3回合子buff
ee.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID
//e.e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
//给对方添加我方施加的buff
ee.SetArgs(e.Ctx().Our, e.SideEffectArgs...)
e.Ctx().Opp.AddEffect(e.Ctx().Our, ee)
return true
}
// // 因为对方切精灵,这个效果也要无效掉
// func (this *Effect62) OnSwitchIn(input.Ctx) bool {
// if this.Hide { //如果还在隐藏,就直接返回
// return true
// }
// //this.GetBattle().Effects[this.GetInput().UserID].RemoveEffect(this)
// //否则触发秒杀 在对面使用技能后
// return true
// }