Files
bl/logic/service/fight/input/input.go
昔念 906bad9e21 refactor(fight): 重构战斗效果和技能初始化逻辑
- 将 InitEffect 重命名为 InitSkillEffect,用于初始化技能效果
- 修改技能效果的 ID,避免和普通效果 ID 冲突
- 优化战斗循环逻辑,增加战斗结束的判断条件
- 调整输入结构,移除未使用的属性和状态容器
- 重构技能解析和攻击处理逻辑,提高代码可读性和维护性
2025-09-14 19:59:58 +08:00

61 lines
1.5 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容器 技能的
// Prop NodeManager //属性容器
// Status NodeManager //状态容器
//NewSeIdx NodeManager //全局容器
Damage decimal.Decimal //造成伤害
First bool //是否先手
}
func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
t := NodeM[1000000]
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
}