- 修改 `AddEffect` 方法,使用 `EffectID` 包装技能效果,并避免重复添加 - 将 `Effects` 类型从 `[]Effect` 改为 `*utils.OrderedMap[int, Effect]` 以提升查找和管理效率 - 移除 `Effect` 接口中的 `ID()` 方法,改由 `EffectID` 结构体维护 - 增加 `GetSkillEffect` 和 `GetDamageEffect` 方法返回带 ID 的效果结构 - 更新 `CancelTurn` 和 `Exec` 方法以适配新的数据结构 - 初始化 `Effects` 为 `OrderedMap` 实例,确保容器正确创建
87 lines
2.0 KiB
Go
87 lines
2.0 KiB
Go
package node
|
||
|
||
import (
|
||
"blazing/logic/service/fight/input"
|
||
)
|
||
|
||
// 检查,激活,延后
|
||
// /基础节点
|
||
type EffectNode struct {
|
||
//Turn int // 当前回合数 ,回合数其实从战斗的上下文中获取
|
||
//本质上Ctx还要传入战斗双方数据来判断是否是本精灵切换
|
||
//Ctx context.Context //节点上下文
|
||
//次数相当于重写回合
|
||
duration int // 默认为-1 持续回合/次(0 = 即时生效,>0 = 回合数 ,负数是永久) \
|
||
|
||
Input *input.Input
|
||
stacks int // 当前层数
|
||
|
||
MaxStack int // 最大叠加层数 ,正常都是不允许叠加的,除了衰弱特殊效果 ,异常和能力的叠层
|
||
SideEffectArgs []int // 附加效果参数
|
||
Owner bool //是否作用自身
|
||
Success bool // 是否执行成功 成功XXX,失败XXX
|
||
arget bool // 传出作用对象,默认0是自身,1是作用于对面
|
||
Flag int //过滤掉的战斗类型 pvp pve boss战斗,野怪全部生效
|
||
notAlive bool // 是否失效 effect返回值是否被取消,是否被删除
|
||
//增加owner target,如果owner target都为自身,就回合效果结束后再使用回合效果
|
||
}
|
||
|
||
func (this *EffectNode) Alive() bool {
|
||
|
||
return !this.notAlive
|
||
|
||
}
|
||
|
||
func (this *EffectNode) NotALive() {
|
||
|
||
this.notAlive = true
|
||
|
||
}
|
||
func (this *EffectNode) GetOwner() bool {
|
||
|
||
return this.Owner
|
||
|
||
}
|
||
func (this *EffectNode) SetOwner(b bool) {
|
||
|
||
this.Owner = b
|
||
|
||
}
|
||
func (this *EffectNode) Stack(t ...int) int {
|
||
if len(t) > 0 {
|
||
this.stacks = t[0]
|
||
}
|
||
|
||
return this.stacks
|
||
|
||
}
|
||
func (this *EffectNode) GetMaxStack() int {
|
||
|
||
return this.MaxStack
|
||
|
||
}
|
||
func (this *EffectNode) Duration(t ...int) int {
|
||
if len(t) > 0 {
|
||
this.duration = t[0]
|
||
}
|
||
return this.duration
|
||
|
||
}
|
||
|
||
// 设置参数,加上设置输入源
|
||
func (this *EffectNode) SetArgs(args ...int) {
|
||
|
||
this.SideEffectArgs = args
|
||
|
||
}
|
||
func (this *EffectNode) SetInput(args *input.Input) {
|
||
this.Input = args
|
||
|
||
}
|
||
|
||
func (this *EffectNode) AttackTime(*input.Input, *input.Input) bool {
|
||
|
||
return true
|
||
|
||
}
|