Files
bl/logic/service/fight/input/input.go
昔念 93ae004683 refactor(fight): 重构战斗逻辑和数据结构
- 重构了 Input 结构体和相关方法,新增 NewInput 函数
- 优化了 NodeManager 结构体和 Exec 方法的实现
- 调整了 FightC 结构体和 enterturn 方法的逻辑
- 修改了 BattleSkillEntity 结构体,移除了冗余字段
- 更新了 EffectNode 中的相关方法,使其适应新的逻辑
2025-09-14 04:48:38 +08:00

58 lines
1.3 KiB
Go

package input
import (
"blazing/logic/service/common"
"blazing/logic/service/fight/info"
"github.com/jinzhu/copier"
"github.com/mohae/deepcopy"
"github.com/shopspring/decimal"
)
type Input struct {
CanChange bool //是否可以死亡切换CanChange
CurrentPet *info.BattlePetEntity //当前精灵
AllPet []*info.BattlePetEntity
Player common.PlayerI
Finished bool //是否加载完成
*info.AttackValue
FightC common.FightI
// info.BattleActionI
Effect NodeManager //effects容器OurEffect node.NodeManager //effects容器
Damage decimal.Decimal //造成伤害
First bool
}
func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
t, _ := NodeM[0]
ret.Effect.AddEffect(deepcopy.Copy(t).(Effect)) //添加默认基类,实现继承
p.SetFightC(c) //给玩家设置战斗容器
return ret
}
func (i *Input) GetPetInfo() *info.BattlePetEntity {
return i.CurrentPet
}
// 这个每回合都会调用
func (i *Input) InitAttackValue() {
i.AttackValue = info.NewAttackValue(i.Player.ID())
}
func (i *Input) GetPet(id uint32) (ii *info.BattlePetEntity, Reason info.ChangePetInfo) {
for _, v := range i.AllPet {
if v.Info.CatchTime == uint32(id) {
copier.Copy(&Reason, &v.Info)
Reason.UserId = i.Player.ID()
ii = v
}
}
return
}