Files
bl/logic/service/fight/effect/effect_62.go
昔念 da9286d3d8 ```
feat(fight): 调整技能效果命中逻辑与回合开始处理

- 修改了技能效果命中的判定顺序,确保暴击计算在效果添加之前执行
- 修复了回合开始时敌我双方状态结算的上下文错误
- 优化了效果缓存初始化逻辑,避免重复添加相同效果
- 增加了效果去重判断,防止完全相同的效果被重复添加
- 调整了战斗循环中结束逻辑的位置,确保广播和通道关闭正确执行
- 更新了部分日志提示信息,使其更符合实际业务含义
- 移除了部分无用代码和注释,提高
2025-11-11 01:10:26 +08:00

114 lines
2.8 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"
"sync"
"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(ctx input.Ctx) bool {
//defer e.Alive(false)
if e.bindpet == e.bind.CurrentPet { //说明对方没有切换精灵
//直接扣除所有血量OnSkill
ctx.DamageZone.Type = info.DamageType.Fixed
ctx.DamageZone.Damage = decimal.NewFromInt(int64(e.bind.CurrentPet.Info.MaxHp))
e.bind.Damage(ctx)
}
return true
}
func init() {
t := &Effect62{
EffectNode: node.EffectNode{},
}
input.InitEffect(input.EffectType.Skill, 62, t)
}
func (e *Effect62) Turn_Start(ctx input.Ctx) {
//如果对面还是我方放技能时候的玩家
// 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(ctx input.Ctx) bool {
if !e.Hit() {
//e.Alive(false)
return true
}
e.l.Do(func() {
//e.Duration(1) //必须保持到下一回合,这样才会被复制
e.opp = ctx.Input
e.e = &Effect62_sub{
EffectNode: node.EffectNode{},
bindpet: ctx.CurrentPet,
bind: ctx.Input,
}
e.e.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID
//e.e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
//给对方添加我方施加的buff
e.e.SetArgs(e.Input, e.SideEffectArgs...)
})
return true
}
func (e *Effect62) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0])
}
// // 因为对方切精灵,这个效果也要无效掉
// func (this *Effect62) OnSwitchIn(input.Ctx) bool {
// if this.Hide { //如果还在隐藏,就直接返回
// return true
// }
// //this.GetBattle().Effects[this.GetInput().UserID].RemoveEffect(this)
// //否则触发秒杀 在对面使用技能后
// return true
// }