refactor(fight): 重构效果节点继承体系并完善Effect1实现
This commit is contained in:
@@ -2,12 +2,9 @@ package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"blazing/logic/service/fight/info"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
type Effect interface {
|
||||
PreBattleStart() bool //战斗开始前
|
||||
OnBattleStart() bool //战斗开始
|
||||
@@ -88,15 +85,16 @@ type Effect interface {
|
||||
|
||||
// 检查,激活,延后
|
||||
// /基础节点
|
||||
type Node struct {
|
||||
type EffectNode struct {
|
||||
//Turn int // 当前回合数 ,回合数其实从战斗的上下文中获取
|
||||
//本质上ctx还要传入战斗双方数据来判断是否是本精灵切换
|
||||
ctx context.Context //节点上下文
|
||||
duration int // 持续回合/次(0 = 即时生效,>0 = 回合数 ,负数是永久)
|
||||
duration int // 默认为1 持续回合/次(0 = 即时生效,>0 = 回合数 ,负数是永久)
|
||||
stacks int // 当前层数
|
||||
paramSize int
|
||||
maxStack int // 最大叠加层数 ,正常都是不允许叠加的,除了衰弱特殊效果
|
||||
SideEffectArgs []int // 附加效果参数
|
||||
|
||||
//LifeType EnumLifeType //回合效果 是否可持续 继承到下一直精灵 ,这个用重写事件来实现
|
||||
|
||||
// Parent string // 上下文来源(比如 "Skill"、"Buff"、"Passive")
|
||||
@@ -108,12 +106,12 @@ type Node struct {
|
||||
// Done bool // 是否中止后续执行
|
||||
}
|
||||
|
||||
func (this *Node) ID() int {
|
||||
func (this *EffectNode) ID() int {
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
func (this *Node) Stack(t int) int {
|
||||
func (this *EffectNode) Stack(t int) int {
|
||||
if t != 0 {
|
||||
this.stacks = t
|
||||
}
|
||||
@@ -121,22 +119,22 @@ func (this *Node) Stack(t int) int {
|
||||
return this.stacks
|
||||
|
||||
}
|
||||
func (this *Node) MaxStack() int {
|
||||
func (this *EffectNode) MaxStack() int {
|
||||
|
||||
return this.maxStack
|
||||
|
||||
}
|
||||
func (this *Node) Duration(t int) int {
|
||||
func (this *EffectNode) Duration(t int) int {
|
||||
|
||||
return this.duration
|
||||
|
||||
}
|
||||
func (this *Node) SetArgs(args []int) {
|
||||
func (this *EffectNode) SetArgs(args []int) {
|
||||
|
||||
this.SideEffectArgs = args
|
||||
|
||||
}
|
||||
func (this *Node) ParamSize(t int) int {
|
||||
func (this *EffectNode) ParamSize(t int) int {
|
||||
if t != 0 {
|
||||
this.paramSize = t
|
||||
}
|
||||
@@ -144,3 +142,9 @@ func (this *Node) ParamSize(t int) int {
|
||||
return this.paramSize
|
||||
|
||||
}
|
||||
func (this *EffectNode) GetSkill(t int) *info.BattleSkillEntity {
|
||||
pet, _ := this.ctx.Value(info.BattleSkillEntityCtx).(*info.BattleSkillEntity)
|
||||
|
||||
return pet
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user