refactor(fight): 重构战斗系统

- 重构了 BattleSkillEntity 结构,改名为 SkillEntity
- 优化了 Input 结构,移除了冗余的 Effect 容器
- 调整了 Effect 接口,增加了 SetInput 和 Alive 方法
- 重构了战斗逻辑中的技能使用和效果处理流程
- 优化了代码结构,提高了可读性和可维护性
This commit is contained in:
2025-09-15 00:40:19 +08:00
parent 906bad9e21
commit d9f09aa96a
10 changed files with 108 additions and 94 deletions

View File

@@ -2,7 +2,6 @@ package node
import (
"blazing/logic/service/fight/input"
"context"
)
// 检查,激活,延后
@@ -10,9 +9,11 @@ import (
type EffectNode struct {
//Turn int // 当前回合数 ,回合数其实从战斗的上下文中获取
//本质上Ctx还要传入战斗双方数据来判断是否是本精灵切换
Ctx context.Context //节点上下文
duration int // 默认为-1 持续回合/次0 = 即时生效,>0 = 回合数 ,负数是永久) 次数相当于重写回合
//Ctx context.Context //节点上下文
//次数相当于重写回合
duration int // 默认为-1 持续回合/次0 = 即时生效,>0 = 回合数 ,负数是永久) \
Input *input.Input
stacks int // 当前层数
ArgSize int
maxStack int // 最大叠加层数 ,正常都是不允许叠加的,除了衰弱特殊效果 ,异常和能力的叠层
@@ -21,10 +22,15 @@ type EffectNode struct {
Success bool // 是否执行成功 成功XXX失败XXX
arget bool // 传出作用对象,默认0是自身,1是作用于对面
Flag int //过滤掉的战斗类型 pvp pve boss战斗,野怪全部生效
Alive bool // 是否失效 effect返回值是否被取消是否被删除
NotAlive bool // 是否失效 effect返回值是否被取消是否被删除
//增加owner target如果owner target都为自身就回合效果结束后再使用回合效果
}
func (this *EffectNode) Alive() bool {
return !this.NotAlive
}
func (this *EffectNode) ID() int {
return 0
@@ -58,10 +64,16 @@ func (this *EffectNode) Duration(t int) int {
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) GetArgSize() int {