Files
bl/logic/service/fight/battle/node/node.go
昔念 8e690dacd4 refactor(fight): 重构战斗模块代码
- 优化了 FightC 结构体,将 Info 字段改为指针类型
- 添加了 EffectNode 类型的 Type 方法,用于获取效果类型
- 修改了 BattlePetEntity 中的 Attribute 结构,移除了未使用的枚举类型
- 删除了 info.go 文件中未使用的结构体定义
- 在 effect_1.go 中更新了 Effect1 类的 PostDamage 方法,待重写实现
2025-09-04 02:11:55 +08:00

109 lines
2.3 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) GetBattle() *info.Battle1V1 {
pet, _ := this.Ctx.Value(info.BattleContainerCtx).(*info.Battle1V1)
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
}