- 优化了数据结构和类型定义,提高了代码的可读性和可维护性 - 移除了未使用的代码和冗余的结构体字段 - 重新组织了代码文件,提高了模块化程度 - 为后续的战斗逻辑实现和优化奠定了坚实的基础
30 lines
674 B
Go
30 lines
674 B
Go
package info
|
|
|
|
import "context"
|
|
|
|
type BattleInputSourceEntity struct {
|
|
FightUserInfo
|
|
ctx context.Context
|
|
}
|
|
|
|
// 新建一个宠物
|
|
func (u *BattleInputSourceEntity) NewBattlePetEntity(ctx context.Context) {
|
|
|
|
ret := BattlePetEntity{}
|
|
|
|
ret.UnitAttributes = make(map[EnumAttrType]*Attribute)
|
|
//todo 待实现精灵特性+加成的封装
|
|
ctx = context.WithValue(ctx, "player", &ret) //添加用户到上下文
|
|
ret.ctx = ctx
|
|
|
|
}
|
|
func (u *BattleInputSourceEntity) NewBattleAction(ctx context.Context, actiontype EnumPlayerOperation) {
|
|
|
|
ret := BattleAction{
|
|
Priority: actiontype,
|
|
}
|
|
ctx = context.WithValue(ctx, "player", &ret) //添加用户到上下文
|
|
ret.ctx = ctx
|
|
|
|
}
|