refactor(fight): 重构效果节点继承体系并完善Effect1实现
This commit is contained in:
@@ -2,8 +2,11 @@ package effect
|
||||
|
||||
import "blazing/logic/service/fight/battle/node"
|
||||
|
||||
/**
|
||||
* 给予对象损伤一半,会回复自己的体力
|
||||
*/
|
||||
type Effect1 struct {
|
||||
node.Node
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -13,6 +16,14 @@ func init() {
|
||||
|
||||
// 重写EFFectID
|
||||
func (this *Effect1) ID() int {
|
||||
this.Node.ParamSize(0) //设置参数个数
|
||||
this.EffectNode.ParamSize(0) //设置参数个数
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
// 重写EFFectID
|
||||
func (this *Effect1) PostDamage() bool {
|
||||
this.EffectNode.ParamSize(0) //设置参数个数
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package node
|
||||
|
||||
// 技能效果前
|
||||
func (this *Node) PreActive() bool {
|
||||
func (this *EffectNode) PreActive() bool {
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
func (f *Node) OnActive() bool {
|
||||
func (f *EffectNode) OnActive() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package node
|
||||
|
||||
// 返回false阻止继续运行
|
||||
// 回合开始
|
||||
func (this *Node) PreBattleStart() bool {
|
||||
func (this *EffectNode) PreBattleStart() bool {
|
||||
|
||||
return true
|
||||
|
||||
@@ -10,7 +10,7 @@ func (this *Node) PreBattleStart() bool {
|
||||
|
||||
// 返回false阻止继续运行
|
||||
// 回合开始
|
||||
func (this *Node) OnBattleStart() bool {
|
||||
func (this *EffectNode) OnBattleStart() bool {
|
||||
|
||||
return true
|
||||
|
||||
@@ -18,14 +18,14 @@ func (this *Node) OnBattleStart() bool {
|
||||
|
||||
//回合结束前
|
||||
|
||||
func (this *Node) PreBattleEnd() bool {
|
||||
func (this *EffectNode) PreBattleEnd() bool {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
//回合结束
|
||||
|
||||
func (this *Node) OnBattleEnd() bool {
|
||||
func (this *EffectNode) OnBattleEnd() bool {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package node
|
||||
|
||||
// 治疗相关触发
|
||||
func (this *Node) OnBeforeHeal() bool {
|
||||
func (this *EffectNode) OnBeforeHeal() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnHeal() bool {
|
||||
func (this *EffectNode) OnHeal() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package node
|
||||
|
||||
// 精灵切换相关触发
|
||||
func (this *Node) OnSwitchIn() bool {
|
||||
func (this *EffectNode) OnSwitchIn() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnSwitchOut() bool {
|
||||
func (this *EffectNode) OnSwitchOut() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnOwnerSwitchIn() bool {
|
||||
func (this *EffectNode) OnOwnerSwitchIn() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnOwnerSwitchOut() bool {
|
||||
func (this *EffectNode) OnOwnerSwitchOut() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package node
|
||||
|
||||
// 先手选择前
|
||||
func (this *Node) BeforeSort() bool {
|
||||
func (this *EffectNode) BeforeSort() bool {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
func (this *Node) OnSort() bool {
|
||||
func (this *EffectNode) OnSort() bool {
|
||||
|
||||
//todo 这里待实现对action先手的判断
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package node
|
||||
|
||||
// 堆叠(Stack)相关触发
|
||||
func (this *Node) OnStackBefore() bool {
|
||||
func (this *EffectNode) OnStackBefore() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnStack() bool {
|
||||
func (this *EffectNode) OnStack() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnBeforeConsumeStack() bool {
|
||||
func (this *EffectNode) OnBeforeConsumeStack() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnConsumeStack() bool {
|
||||
func (this *EffectNode) OnConsumeStack() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package node
|
||||
|
||||
// 回合开始前
|
||||
func (this *Node) PreTurnStart() bool {
|
||||
func (this *EffectNode) PreTurnStart() bool {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
// 回合开始
|
||||
func (this *Node) OnTurnStart() bool {
|
||||
func (this *EffectNode) OnTurnStart() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Node) PreTurnEnd() bool {
|
||||
func (this *EffectNode) PreTurnEnd() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) TurnEnd() bool {
|
||||
// 回合结束一次性effect清楚掉
|
||||
func (this *EffectNode) TurnEnd() bool {
|
||||
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
package node
|
||||
|
||||
func (this *Node) BeforeUseSkillCheck() bool {
|
||||
func (this *EffectNode) BeforeUseSkillCheck() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) AfterUseSkillCheck() bool {
|
||||
func (this *EffectNode) AfterUseSkillCheck() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) SkillUseEnd() bool {
|
||||
func (this *EffectNode) SkillUseEnd() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) BeforeMultiHit() bool {
|
||||
func (this *EffectNode) BeforeMultiHit() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) BeforeHit() bool {
|
||||
func (this *EffectNode) BeforeHit() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnCritPreDamage() bool {
|
||||
func (this *EffectNode) OnCritPreDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) PreDamage() bool {
|
||||
func (this *EffectNode) PreDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnBeforeCalculateDamage() bool {
|
||||
func (this *EffectNode) OnBeforeCalculateDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnDamage() bool {
|
||||
func (this *EffectNode) OnDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) Shield() bool {
|
||||
func (this *EffectNode) Shield() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) PostDamage() bool {
|
||||
func (this *EffectNode) PostDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnCritPostDamage() bool {
|
||||
func (this *EffectNode) OnCritPostDamage() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnHit() bool {
|
||||
func (this *EffectNode) OnHit() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnMiss() bool {
|
||||
func (this *EffectNode) OnMiss() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) AfterAttacked() bool {
|
||||
func (this *EffectNode) AfterAttacked() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnDefeat() bool {
|
||||
func (this *EffectNode) OnDefeat() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package node
|
||||
|
||||
// 印记(Mark)相关触发 状态类
|
||||
func (this *Node) OnBeforeAddMark() bool {
|
||||
func (this *EffectNode) OnBeforeAddMark() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnAnyMarkAdded() bool {
|
||||
func (this *EffectNode) OnAnyMarkAdded() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnMarkCreated() bool {
|
||||
func (this *EffectNode) OnMarkCreated() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnMarkDurationEnd() bool {
|
||||
func (this *EffectNode) OnMarkDurationEnd() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnRemoveMark() bool {
|
||||
func (this *EffectNode) OnRemoveMark() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
func (this *Node) OnMarkDestroy() bool {
|
||||
func (this *EffectNode) OnMarkDestroy() bool {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +128,14 @@ func (u *BattleSkillEntity) NewBattleAction(ctx context.Context) {
|
||||
ret.ctx = ctx
|
||||
|
||||
}
|
||||
// // 技能产生effect
|
||||
// func (u *BattleSkillEntity) NewEffect(ctx context.Context)*node.EffectNode {
|
||||
|
||||
// ret := node.EffectNode{}
|
||||
// ctx = context.WithValue(ctx, BattleSkillEntityCtx, &ret) //添加用户到上下文
|
||||
// ret.ctx = ctx
|
||||
|
||||
// }
|
||||
// 解析副作用参数字符串为整数列表
|
||||
func parseSideEffectArgs(argsStr string) []int {
|
||||
if argsStr == "" {
|
||||
|
||||
Reference in New Issue
Block a user