refactor(fight): 重构战斗节点模块并添加效果管理

This commit is contained in:
1
2025-08-26 18:02:32 +00:00
parent 5c8f5195cf
commit e3184646e4
8 changed files with 125 additions and 46 deletions

View File

@@ -1,24 +1,25 @@
package node
import "context"
import (
"context"
)
type Effect interface {
OnBattleStart() bool
OnBattleEnd() bool
BeforeEffect() bool
AfterEffect() bool
OnSwitch() bool
OnTurnStart() bool
OnBattleStart() func()
OnBattleEnd() func()
OnActive() func()
OnSwitch() func()
OnTurnStart() func()
Duration(int) int
ID() int
Stack(int) int
MaxStack() int
OnBeforeAddMark() bool
OnAnyMarkAdded() bool
Duration(int) int
}
///基础节点
// 检查,激活,延后
// /基础节点
type Node struct {
//Turn int // 当前回合数 ,回合数其实从战斗的上下文中获取
//本质上ctx还要传入战斗双方数据来判断是否是本精灵切换
@@ -43,7 +44,7 @@ func (this *Node) ID() int {
return 0
}
func (this *Node) Stacks(t int) int {
func (this *Node) Stack(t int) int {
if t != 0 {
this.stacks = t
}
@@ -51,7 +52,7 @@ func (this *Node) Stacks(t int) int {
return this.stacks
}
func (this *Node) MaxStacks() int {
func (this *Node) MaxStack() int {
return this.maxStack
@@ -61,36 +62,3 @@ func (this *Node) Duration(t int) int {
return this.duration
}
//返回false阻止继续运行
//回合开始
func (this *Node) OnBattleStart() bool {
return true
}
//回合结束
func (this *Node) OnBattleEnd() bool {
return true
}
//技能效果前
func (this *Node) BeforeEffect() bool {
return true
}
//技能效果前
func (this *Node) AfterEffect() bool {
return true
}
//精灵切换时
func (this *Node) OnSwitch() bool {
return true
}