refactor(login): 重构登录功能相关结构体和方法
- 修改了 Login 方法的返回类型,使用新的 PlayerLoginInfo 结构体 - 新增 NewPlayerLoginInfo 函数用于创建并初始化 PlayerLoginInfo 对象 - 重构了 LoginSidInfo 和 LoginUserInfo 文件中的结构体 - 优化了数据初始化和默认值设置的方式
This commit is contained in:
@@ -13,86 +13,84 @@ type Pet struct {
|
||||
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
|
||||
}
|
||||
|
||||
// PetInfo 精灵信息结构,合并了两个版本的字段
|
||||
// PetInfo 精灵信息结构(合并后的优化版本)
|
||||
type PetInfo struct {
|
||||
// 第一个版本中的字段
|
||||
CapturePlayerID uint64 `gorm:"not null;comment:'捕获者ID'" json:"capture_player_id"`
|
||||
CaptureTime int64 `gorm:"not null;comment:'捕获时间(时间戳)'" json:"capture_time"`
|
||||
CaptureMap int32 `gorm:"not null;comment:'捕获地图ID'" json:"capture_map"`
|
||||
CaptureRect int16 `gorm:"not null;default:0;comment:'捕获区域(未知用途,默认为0)'" json:"capture_rect"`
|
||||
CaptureLevel int16 `gorm:"not null;default:0;comment:'捕获时的等级'" json:"capture_level"`
|
||||
PetTypeID int32 `gorm:"not null;comment:'精灵类型ID/精灵图鉴ID'" json:"pet_type_id"`
|
||||
IndividualValue int16 `gorm:"not null;comment:'个体值(DV)'" json:"individual_value"`
|
||||
Nature int16 `gorm:"not null;comment:'性格类型'" json:"nature"`
|
||||
AbilityTypeEnum int16 `gorm:"comment:'特性枚举'" json:"ability_type_enum"`
|
||||
Shiny int32 `gorm:"not null;default:0;comment:'闪光ID(异色!=0,非异色=0)'" json:"shiny"`
|
||||
Level int16 `gorm:"not null;default:1;comment:'当前等级'" json:"level"`
|
||||
CurrentExp int32 `gorm:"not null;default:0;comment:'当前等级已获得经验值'" json:"current_exp"`
|
||||
CurrentHP int32 `gorm:"not null;comment:'当前生命值'" json:"current_hp"`
|
||||
MaxHP int32 `gorm:"not null;comment:'实际最大生命值'" json:"max_hp"`
|
||||
Attack int32 `gorm:"not null;comment:'实际攻击力'" json:"attack"`
|
||||
Defense int32 `gorm:"not null;comment:'实际防御力'" json:"defense"`
|
||||
SpecialAttack int32 `gorm:"not null;comment:'实际特殊攻击力'" json:"special_attack"`
|
||||
SpecialDefense int32 `gorm:"not null;comment:'实际特殊防御力'" json:"special_defense"`
|
||||
Speed int32 `gorm:"not null;comment:'实际速度'" json:"speed"`
|
||||
EvHP int16 `gorm:"not null;default:0;comment:'生命值学习力'" json:"ev_hp"`
|
||||
EvAttack int16 `gorm:"not null;default:0;comment:'攻击学习力'" json:"ev_attack"`
|
||||
EvDefense int16 `gorm:"not null;default:0;comment:'防御学习力'" json:"ev_defense"`
|
||||
EvSpecialAttack int16 `gorm:"not null;default:0;comment:'特殊攻击学习力'" json:"ev_special_attack"`
|
||||
EvSpecialDefense int16 `gorm:"not null;default:0;comment:'特殊防御学习力'" json:"ev_special_defense"`
|
||||
EvSpeed int16 `gorm:"not null;default:0;comment:'速度学习力'" json:"ev_speed"`
|
||||
PetSkill []PetSkillInfo // 技能组
|
||||
ElementalOrbID int32 `gorm:"not null;default:0;comment:'属性能量珠ID'" json:"elemental_orb_id"`
|
||||
SpecialOrbID int32 `gorm:"not null;default:0;comment:'平衡/暴击能量珠ID'" json:"special_orb_id"`
|
||||
ElementalOrbCount int16 `gorm:"not null;default:0;comment:'属性能量珠剩余使用次数'" json:"elemental_orb_count"`
|
||||
SpecialOrbCount int16 `gorm:"not null;default:0;comment:'平衡/暴击能量珠剩余使用次数'" json:"special_orb_count"`
|
||||
IndividualGuarantee int64 `gorm:"not null;default:0;comment:'个体值保底(0=无保底)'" json:"individual_guarantee"`
|
||||
NatureGuarantee int64 `gorm:"not null;default:0;comment:'性格保底(0=无保底)'" json:"nature_guarantee"`
|
||||
Freed bool `gorm:"default:false;not null;comment:'是否已放生(0=未放生,1=已放生)'" json:"freed"`
|
||||
FreedTime string `gorm:"comment:'放生时间'" json:"freed_time"`
|
||||
|
||||
// 第二个版本中的字段
|
||||
ID uint32 `struc:"uint32" gorm:"not null;comment:'精灵编号'" json:"id"`
|
||||
Name [16]byte `struc:"[16]byte" gorm:"type:char(16);comment:'名字'" json:"name"`
|
||||
DV uint32 `struc:"uint32" gorm:"not null;comment:'个体值'" json:"dv"`
|
||||
LvExp uint32 `struc:"uint32" gorm:"not null;comment:'当前等级所需的经验'" json:"lv_exp"`
|
||||
NextLvExp uint32 `struc:"uint32" gorm:"not null;comment:'升到下一级的经验'" json:"next_lv_exp"`
|
||||
Defence uint32 `struc:"uint32" gorm:"not null;comment:'防御'" json:"defence"`
|
||||
//EvSpecialDefense uint32 `struc:"uint32" gorm:"not null;comment:'特防学习力'" json:"ev_special_defense"`
|
||||
SkillSize uint32 `struc:"uint32" gorm:"not null;comment:'技能个数'" json:"skill_size"`
|
||||
SkillList [4]SkillInfo `gorm:"embedded;embeddedPrefix:skill_list_" json:"skill_list"`
|
||||
CatchTime uint32 `struc:"uint32" gorm:"not null;comment:'捕捉时间'" json:"catch_time"`
|
||||
CatchRect uint32 `struc:"uint32" default:"0" gorm:"default:0;comment:'未知(默认0)'" json:"catch_rect"`
|
||||
CatchLevel uint32 `struc:"uint32" default:"0" gorm:"default:0;comment:'捕获等级(默认0)'" json:"catch_level"`
|
||||
SkinID uint32 `struc:"uint32" default:"0" gorm:"default:0;comment:'皮肤id(默认0)'" json:"skin_id"`
|
||||
EffectInfoLen uint16 `struc:"sizeof=EffectInfo" gorm:"comment:'特性列表长度'" json:"effect_info_len"`
|
||||
EffectInfo []PetEffectInfo `gorm:"embedded;embeddedPrefix:effect_info_" json:"effect_info"`
|
||||
// 第一个版本字段
|
||||
CapturePlayerID uint64 `json:"capture_player_id"`
|
||||
CaptureTime int64 `json:"capture_time"`
|
||||
CaptureMap int32 `json:"capture_map"`
|
||||
CaptureRect int16 `json:"capture_rect"`
|
||||
CaptureLevel int16 `json:"capture_level"`
|
||||
PetTypeID int32 `json:"pet_type_id"`
|
||||
IndividualValue int16 `json:"individual_value"`
|
||||
Nature int16 `json:"nature"`
|
||||
AbilityTypeEnum int16 `json:"ability_type_enum"`
|
||||
Shiny int32 `json:"shiny"`
|
||||
Level int16 `json:"level"`
|
||||
CurrentExp int32 `json:"current_exp"`
|
||||
CurrentHP int32 `json:"current_hp"`
|
||||
MaxHP int32 `json:"max_hp"`
|
||||
Attack int32 `json:"attack"`
|
||||
Defense int32 `json:"defense"`
|
||||
SpecialAttack int32 `json:"special_attack"`
|
||||
SpecialDefense int32 `json:"special_defense"`
|
||||
Speed int32 `json:"speed"`
|
||||
EvHP int16 `json:"ev_hp"`
|
||||
EvAttack int16 `json:"ev_attack"`
|
||||
EvDefense int16 `json:"ev_defense"`
|
||||
EvSpecialAttack int16 `json:"ev_special_attack"`
|
||||
EvSpecialDefense int16 `json:"ev_special_defense"`
|
||||
EvSpeed int16 `json:"ev_speed"`
|
||||
PetSkillLen int16 `struc:"sizeof=PetSkill" json:"pet_skill_len"`
|
||||
PetSkill []PetSkillInfo `json:"pet_skill"`
|
||||
ElementalOrbID int32 `json:"elemental_orb_id"`
|
||||
SpecialOrbID int32 `json:"special_orb_id"`
|
||||
ElementalOrbCount int16 `json:"elemental_orb_count"`
|
||||
SpecialOrbCount int16 `json:"special_orb_count"`
|
||||
IndividualGuarantee int64 `json:"individual_guarantee"`
|
||||
NatureGuarantee int64 `json:"nature_guarantee"`
|
||||
Freed bool `json:"freed"`
|
||||
FreedTime string `json:"freed_time"`
|
||||
|
||||
// 第二个版本字段
|
||||
ID uint32 `struc:"uint32" json:"id"`
|
||||
Name [16]byte `struc:"[16]byte" json:"name"`
|
||||
DV uint32 `struc:"uint32" json:"dv"`
|
||||
LvExp uint32 `struc:"uint32" json:"lv_exp"`
|
||||
NextLvExp uint32 `struc:"uint32" json:"next_lv_exp"`
|
||||
Defence uint32 `struc:"uint32" json:"defence"`
|
||||
SkillSize uint32 `struc:"uint32" json:"skill_size"`
|
||||
SkillList [4]SkillInfo `json:"skill_list"`
|
||||
CatchTime uint32 `struc:"uint32" json:"catch_time"`
|
||||
CatchRect uint32 `struc:"uint32" json:"catch_rect"`
|
||||
CatchLevel uint32 `struc:"uint32" json:"catch_level"`
|
||||
SkinID uint32 `struc:"uint32" json:"skin_id"`
|
||||
EffectInfoLen uint16 `struc:"sizeof=EffectInfo" json:"effect_info_len"`
|
||||
EffectInfo []PetEffectInfo `json:"effect_info"`
|
||||
}
|
||||
|
||||
// PetSkillInfo 精灵技能信息结构,合并了两个版本
|
||||
// PetSkillInfo 精灵技能信息结构
|
||||
type PetSkillInfo struct {
|
||||
SkillID1 int32 `gorm:"not null;default:0;comment:'技能1ID'" json:"skill_1_id"`
|
||||
PP1 int16 `gorm:"not null;default:0;comment:'技能1PP'" json:"skill_1_pp"`
|
||||
SkillID2 int32 `gorm:"default:0;comment:'技能2ID'" json:"skill_2_id"`
|
||||
PP2 int16 `gorm:"default:0;comment:'技能2PP'" json:"skill_2_pp"`
|
||||
SkillID3 int32 `gorm:"default:0;comment:'技能3ID'" json:"skill_3_id"`
|
||||
PP3 int16 `gorm:"default:0;comment:'技能3PP'" json:"skill_3_pp"`
|
||||
SkillID4 int32 `gorm:"default:0;comment:'技能4ID'" json:"skill_4_id"`
|
||||
PP4 int16 `gorm:"default:0;comment:'技能4PP'" json:"skill_4_pp"`
|
||||
SkillID1 int32 `json:"skill_1_id"`
|
||||
PP1 int16 `json:"skill_1_pp"`
|
||||
SkillID2 int32 `json:"skill_2_id"`
|
||||
PP2 int16 `json:"skill_2_pp"`
|
||||
SkillID3 int32 `json:"skill_3_id"`
|
||||
PP3 int16 `json:"skill_3_pp"`
|
||||
SkillID4 int32 `json:"skill_4_id"`
|
||||
PP4 int16 `json:"skill_4_pp"`
|
||||
}
|
||||
|
||||
|
||||
|
||||
// PetEffectInfo 精灵特性信息结构(第二个版本中的定义)
|
||||
// PetEffectInfo 精灵特性信息结构
|
||||
type PetEffectInfo struct {
|
||||
ItemID uint32 `struc:"uint32" gorm:"not null;comment:'特性晶片对应的物品id'" json:"item_id"`
|
||||
Status byte `struc:"byte" default:"1" gorm:"default:1;comment:'状态'" json:"status"`
|
||||
LeftCount byte `struc:"byte" gorm:"comment:'未知'" json:"left_count"`
|
||||
EffectID uint16 `struc:"uint16" gorm:"not null;comment:'特性id'" json:"effect_id"`
|
||||
Reserve1 byte `struc:"byte" gorm:"comment:'保留字段1'" json:"reserve1"`
|
||||
Reserve2 byte `struc:"byte" gorm:"comment:'保留字段2'" json:"reserve2"`
|
||||
Reserve3 byte `struc:"byte" gorm:"comment:'保留字段3'" json:"reserve3"`
|
||||
Reserve4 [13]byte `struc:"[13]byte" gorm:"type:char(13);comment:'保留字段4'" json:"reserve4"`
|
||||
ItemID uint32 `struc:"uint32" json:"item_id"`
|
||||
Status byte `struc:"byte" json:"status"`
|
||||
LeftCount byte `struc:"byte" json:"left_count"`
|
||||
EffectID uint16 `struc:"uint16" json:"effect_id"`
|
||||
Reserve1 byte `struc:"byte" json:"reserve1"`
|
||||
Reserve2 byte `struc:"byte" json:"reserve2"`
|
||||
Reserve3 byte `struc:"byte" json:"reserve3"`
|
||||
Reserve4 [13]byte `struc:"[13]byte" json:"reserve4"`
|
||||
}
|
||||
|
||||
// TableName Pet's table name
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package model
|
||||
|
||||
import "blazing/common/socket/handler"
|
||||
|
||||
// TeamInfo 战队信息结构
|
||||
type TeamInfo struct {
|
||||
Head handler.TomeeHeader `cmd:"1001" struc:"[0]pad"` // 命令头
|
||||
ID uint32 `struc:"uint32" default:"0"` // 默认值0
|
||||
Priv uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
SuperCore uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
IsShow uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
AllContribution uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
CanExContribution uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
//Head handler.TomeeHeader `cmd:"1001" struc:"[0]pad"` // 命令头
|
||||
ID uint32 `struc:"uint32" default:"0"` // 默认值0
|
||||
Priv uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
SuperCore uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
IsShow uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
AllContribution uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
CanExContribution uint32 `struc:"uint32" default:"1"` // 默认值1
|
||||
}
|
||||
|
||||
// InitDefaults 初始化默认值
|
||||
|
||||
@@ -6,31 +6,10 @@ import (
|
||||
|
||||
const TableNamePlayerInfo = "player_info"
|
||||
|
||||
// PlayerInfo mapped from table <player_info>
|
||||
type PlayerInfo struct {
|
||||
*cool.Model
|
||||
AccountID uint64 `gorm:"not null;uniqueIndex:idx_player_info_unique_by_account_id;comment:'所属账户ID'" json:"account_id"`
|
||||
Nickname string `gorm:"type:varchar(16);not null;default:'nieo';comment:'昵称'" json:"nickname"`
|
||||
NieoBean int64 `gorm:"not null;default:0;comment:'尼尔豆(基础货币,uint32)'" json:"nieo_bean"`
|
||||
NieoGoldBean string `gorm:"type:decimal(12,2);not null;default:0;comment:'尼尔金豆(特殊货币,uint32)'" json:"nieo_gold_bean"`
|
||||
EquipmentHead int32 `gorm:"not null;default:0;comment:'头部穿戴装备ID(0=未穿戴)'" json:"equipment_head"`
|
||||
EquipmentFace int32 `gorm:"not null;default:0;comment:'脸部穿戴装备ID'" json:"equipment_face"`
|
||||
EquipmentHand int32 `gorm:"not null;default:0;comment:'手部穿戴装备ID'" json:"equipment_hand"`
|
||||
EquipmentWaist int32 `gorm:"not null;default:0;comment:'腰部穿戴装备ID'" json:"equipment_waist"`
|
||||
EquipmentLeg int32 `gorm:"not null;default:0;comment:'腿部穿戴装备ID'" json:"equipment_leg"`
|
||||
EquipmentBackground int32 `gorm:"not null;default:0;comment:'背景穿戴装备ID'" json:"equipment_background"`
|
||||
RobotColor int64 `gorm:"not null;default:0;comment:'RGB颜色值(uint32,实际为3个uint8)'" json:"robot_color"`
|
||||
HasNono bool `gorm:"default:false;not null;comment:'是否拥普通NONO(布尔转TINYINT)'" json:"has_nono"`
|
||||
HasSuperNono bool `gorm:"default:false;not null;comment:'是否拥超能NONO'" json:"has_super_nono"`
|
||||
NonoNickname string `gorm:"type:varchar(16);not null;default:'NONO';comment:'NONO昵称(byte[16])'" json:"nono_nickname"`
|
||||
NonoColor int64 `gorm:"not null;default:0;comment:'NONO颜色值'" json:"nono_color"`
|
||||
ExpPool int64 `gorm:"not null;default:0;comment:'累计经验池'" json:"exp_pool"`
|
||||
Pet1 int64 `gorm:"not null;default:0;comment:'背包精灵1(首发精灵),捕获时间戳'" json:"pet1"`
|
||||
Pet2 int64 `gorm:"not null;default:0;comment:'背包精灵2'" json:"pet2"`
|
||||
Pet3 int64 `gorm:"not null;default:0;comment:'背包精灵3'" json:"pet3"`
|
||||
Pet4 int64 `gorm:"not null;default:0;comment:'背包精灵4'" json:"pet4"`
|
||||
Pet5 int64 `gorm:"not null;default:0;comment:'背包精灵5'" json:"pet5"`
|
||||
Pet6 int64 `gorm:"not null;default:0;comment:'背包精灵6'" json:"pet6"`
|
||||
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
|
||||
}
|
||||
|
||||
// TableName PlayerInfo's table name
|
||||
@@ -44,7 +23,7 @@ func (*PlayerInfo) GroupName() string {
|
||||
}
|
||||
|
||||
// NewPlayerInfo create a new PlayerInfo
|
||||
func NewPlayerInfo() *PlayerInfo {
|
||||
func NewPlayer() *PlayerInfo {
|
||||
return &PlayerInfo{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user