Files
bl/logic/service/fight/effect/effect_4_5.go
昔念 e2a184b687 feat(rpc): 优化客户端连接管理,使用 sync.Map 替代普通 map
将 `Clientmap` 从普通 map 改为 `sync.Map`,提升并发安全性。新增
`addClient` 和 `getClient` 方法封装存取逻辑,并在多处调用点进行了替换。

fix(fight): 修复战斗逻辑中技能ID与攻击时间字段引用错误

将 `attacker.AttackValue.SkillID` 和
`attacker.AttackValue.AttackTime` 的访问方式修正为正确的字段路径。

refactor(fight): 调整战斗结束信息处理流程

合并 `FightOverInfo` 结构到 `FightC` 中,简化广播发送逻辑,统一通过
`f.FightOverInfo` 发送战斗结果。

refactor(effect): 修改效果叠加判断逻辑并增强健壮性

更新效果节点比较方法,增加参数匹配检查以支持更精确的效果识别;同时添加
`equalInts` 工具函数用于数组内容对比。
2025-11-07 22:50:34 +08:00

85 lines
2.0 KiB
Go

package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// -----------------------------------------------------------
// 注册
// -----------------------------------------------------------
func init() {
// 自身能力变化
input.InitEffect(input.EffectType.Skill, 4, newEffectStat(false))
// 对方能力变化
input.InitEffect(input.EffectType.Skill, 5, newEffectStat(true))
}
// -----------------------------------------------------------
// 构造
// -----------------------------------------------------------
func newEffectStat(targetOpponent bool) input.Effect {
e := &EffectStat{
Etype: targetOpponent,
}
//e.MaxStack(-1) // 无限叠加
return e
}
// -----------------------------------------------------------
// 主体结构
// -----------------------------------------------------------
type EffectStat struct {
node.EffectNode
Etype bool // false: 作用自身, true: 作用对方
}
// -----------------------------------------------------------
// 技能触发时调用
// -----------------------------------------------------------
func (e *EffectStat) OnSkill(ctx input.Ctx) bool {
if !e.Hit() {
return true
}
// 参数解构 (防止 SideEffectArgs 长度不足)
var (
statIndex int // 哪个属性
chance int // 触发概率
level int // 增减值
)
if len(e.SideEffectArgs) > 0 {
statIndex = e.SideEffectArgs[0]
}
if len(e.SideEffectArgs) > 1 {
chance = e.SideEffectArgs[1]
}
if len(e.SideEffectArgs) > 2 {
level = e.SideEffectArgs[2]
}
// 概率判定
ok, _, _ := e.Input.Player.Roll(chance, 100)
if !ok {
return true
}
// 判断加减类型
opType := info.AbilityOpType.ADD
if level < 0 {
opType = info.AbilityOpType.SUB
}
// 执行属性变化
if e.Etype {
// 对方属性变化
ctx.SetProp(e.Input, int8(statIndex), int8(level), opType)
} else {
// 自身属性变化
e.Input.SetProp(e.Input, int8(statIndex), int8(level), opType)
}
return true
}