refactor(fight): 重构战斗流程实现并完善效果处理机制

This commit is contained in:
1
2025-08-27 03:59:46 +00:00
parent 5ba6f1b8ef
commit 79cff5d85b
11 changed files with 112 additions and 75 deletions

View File

@@ -4,10 +4,13 @@ import (
"context"
)
const Input_ctx = "player"
type BattleInputSourceEntity struct {
FightUserInfo
ctx context.Context //输入源的上下文
effects NodeManager //挂载effect
FightUserInfo //用户信息
PetEntities []*BattlePetEntity //宠物信息
ctx context.Context //输入源的上下文
}
// 新建一个宠物
@@ -17,7 +20,7 @@ func (u *BattleInputSourceEntity) NewBattlePetEntity(ctx context.Context) {
ret.UnitAttributes = make(map[EnumAttrType]*Attribute)
//todo 待实现精灵特性+加成的封装
ctx = context.WithValue(ctx, "player", &ret) //添加用户到上下文
ctx = context.WithValue(ctx, Input_ctx, &ret) //添加用户到上下文
ret.ctx = ctx
}
@@ -26,7 +29,7 @@ func (u *BattleInputSourceEntity) NewBattleAction(ctx context.Context, actiontyp
ret := BattleAction{
Priority: actiontype,
}
ctx = context.WithValue(ctx, "player", &ret) //添加用户到上下文
ctx = context.WithValue(ctx, Input_ctx, &ret) //添加用户到上下文
ret.ctx = ctx
}