Files
bl/logic/service/fight/battle/node/node.go
昔念 7d48e9ab64 refactor(fight): 重构战斗系统
- 优化了技能解析和存储逻辑
- 重构了战斗流程和回合结算机制
- 调整了数据结构以提高性能
- 移除了未使用的代码和注释
2025-09-04 23:57:22 +08:00

103 lines
2.2 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 node
import (
"blazing/logic/service/fight/info"
"context"
)
// 检查,激活,延后
// /基础节点
type EffectNode struct {
//Turn int // 当前回合数 ,回合数其实从战斗的上下文中获取
//本质上Ctx还要传入战斗双方数据来判断是否是本精灵切换
Ctx context.Context //节点上下文
duration int // 默认为-1 持续回合/次0 = 即时生效,>0 = 回合数 ,负数是永久) 次数相当于重写回合
stacks int // 当前层数
paramSize int
maxStack int // 最大叠加层数 ,正常都是不允许叠加的,除了衰弱特殊效果 ,异常和能力的叠层
SideEffectArgs []int // 附加效果参数
Success bool // 是否执行成功 成功XXX失败XXX
efftype int // 传出作用对象,默认0是自身,1是作用于对面
}
func (this *EffectNode) ID() int {
return 0
}
// 传出作用对象,默认0是自身,1是作用于对面
func (this *EffectNode) Type() int {
return this.efftype
}
func (this *EffectNode) Stack(t int) int {
if t != 0 {
this.stacks = t
}
return this.stacks
}
func (this *EffectNode) MaxStack() int {
return this.maxStack
}
func (this *EffectNode) Duration(t int) int {
return this.duration
}
func (this *EffectNode) SetArgs(args []int) {
this.SideEffectArgs = args
}
func (this *EffectNode) ParamSize(t int) int {
if t != 0 {
this.paramSize = t
}
return this.paramSize
}
func (this *EffectNode) GetSkill() *info.BattleSkillEntity {
pet, ok := this.Ctx.Value(info.BattleSkillEntityCtx).(*info.BattleSkillEntity)
if !ok { //effect不一定来自技能,也有特性 能量珠 boss effect
return nil
}
return pet
}
// 获取对方精灵
// // 获取我方输入源
// func (this *EffectNode) GetInput() *info.BattleInputSourceEntity {
// pet, _ := this.Ctx.Value(info.Input_ctx).(*info.BattleInputSourceEntity)
// return pet
// }
// 获取自身精灵
func (this *EffectNode) GetOwnerPet() *info.BattlePetEntity {
pet, _ := this.Ctx.Value(info.Pet_O_Ctx).(*info.BattlePetEntity)
return pet
}
func (this *EffectNode) GetTargetPet() *info.BattlePetEntity {
pet, _ := this.Ctx.Value(info.Pet_T_Ctx).(*info.BattlePetEntity)
return pet
}