refactor(fight): 重构战斗模块
- 优化了数据结构和类型定义,提高了代码的可读性和可维护性 - 移除了未使用的代码和冗余的结构体字段 - 重新组织了代码文件,提高了模块化程度 - 为后续的战斗逻辑实现和优化奠定了坚实的基础
This commit is contained in:
@@ -1,10 +1,29 @@
|
||||
package info
|
||||
|
||||
type FightUserInfo struct {
|
||||
// 用户ID(野怪为0),对应Java的@UInt long
|
||||
UserID uint32 `fieldDesc:"userID 如果为野怪则为0" `
|
||||
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
|
||||
|
||||
// 玩家名称(野怪为UTF-8的'-',固定16字节)
|
||||
// 使用[16]byte存储固定长度的字节数组
|
||||
Nickname [16]byte ` `
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user