refactor(fight): 重构战斗系统
- 移除 Player 结构中的 IsFighting 字段,使用 FightID 替代 - 优化 Move 结构,重新排序字段并添加注释 - 修改 EffectNode 和相关结构,统一使用 Ctx 字段名称 - 重构 Battle 和 BattlePetEntity 结构,简化属性并优化布局 - 更新战斗逻辑,调整效果应用和回合处理机制
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
// /基础节点
|
||||
type EffectNode struct {
|
||||
//Turn int // 当前回合数 ,回合数其实从战斗的上下文中获取
|
||||
//本质上ctx还要传入战斗双方数据来判断是否是本精灵切换
|
||||
ctx context.Context //节点上下文
|
||||
//本质上Ctx还要传入战斗双方数据来判断是否是本精灵切换
|
||||
Ctx context.Context //节点上下文
|
||||
duration int // 默认为-1 持续回合/次(0 = 即时生效,>0 = 回合数 ,负数是永久) 次数相当于重写回合
|
||||
|
||||
stacks int // 当前层数
|
||||
@@ -59,7 +59,7 @@ func (this *EffectNode) ParamSize(t int) int {
|
||||
|
||||
}
|
||||
func (this *EffectNode) GetSkill() *info.BattleSkillEntity {
|
||||
pet, ok := this.ctx.Value(info.BattleSkillEntityCtx).(*info.BattleSkillEntity)
|
||||
pet, ok := this.Ctx.Value(info.BattleSkillEntityCtx).(*info.BattleSkillEntity)
|
||||
|
||||
if !ok { //effect不一定来自技能,也有特性 能量珠 boss effect
|
||||
return nil
|
||||
@@ -70,7 +70,15 @@ func (this *EffectNode) GetSkill() *info.BattleSkillEntity {
|
||||
|
||||
// 获取对方精灵
|
||||
func (this *EffectNode) GetBattle() *info.Battle1V1 {
|
||||
pet, _ := this.ctx.Value(info.BattleContainerCtx).(*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
|
||||
|
||||
@@ -78,14 +86,14 @@ func (this *EffectNode) GetBattle() *info.Battle1V1 {
|
||||
|
||||
// 获取自身精灵
|
||||
func (this *EffectNode) GetOwnerPet() *info.BattlePetEntity {
|
||||
pet, _ := this.ctx.Value(info.Pet_O_Ctx).(*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)
|
||||
pet, _ := this.Ctx.Value(info.Pet_T_Ctx).(*info.BattlePetEntity)
|
||||
|
||||
return pet
|
||||
|
||||
|
||||
Reference in New Issue
Block a user