refactor(model): 重构玩家登录信息结构并优化精灵技能定义
This commit is contained in:
@@ -2,4 +2,4 @@ module github.com/ECUST-XX/xml
|
|||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require github.com/looplab/fsm v1.0.3 // indirect
|
//require github.com/looplab/fsm v1.0.3 // indirect
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import (
|
|||||||
"blazing/common/socket/errorcode"
|
"blazing/common/socket/errorcode"
|
||||||
"blazing/logic/service"
|
"blazing/logic/service"
|
||||||
"blazing/logic/service/login"
|
"blazing/logic/service/login"
|
||||||
|
"blazing/modules/blazing/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 处理命令: 1001
|
// 处理命令: 1001
|
||||||
func (h *Controller) Login(data *login.InInfo, c *entity.Conn) (result *login.PlayerLoginInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
func (h *Controller) Login(data *login.InInfo, c *entity.Conn) (result *model.PlayerLoginInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||||
|
|
||||||
if tt := data.CheakSession(); tt { //说明sid正确
|
if tt := data.CheakSession(); tt { //说明sid正确
|
||||||
h.RPCClient.Kick(data.Head.UserID) //先踢人
|
h.RPCClient.Kick(data.Head.UserID) //先踢人
|
||||||
@@ -20,9 +21,8 @@ func (h *Controller) Login(data *login.InInfo, c *entity.Conn) (result *login.Pl
|
|||||||
share.ShareManager.SetUserOnline(data.Head.UserID, h.Port) //设置用户登录服务器
|
share.ShareManager.SetUserOnline(data.Head.UserID, h.Port) //设置用户登录服务器
|
||||||
t.CompleteLogin() //通知客户端登录成功
|
t.CompleteLogin() //通知客户端登录成功
|
||||||
//c.SendPack(data.Def())
|
//c.SendPack(data.Def())
|
||||||
result = login.NewPlayerLoginInfo() //设置登录消息
|
result = model.NewPlayerLoginInfo() //设置登录消息
|
||||||
//data.Head.UserID = 99942
|
|
||||||
//data.Head.Result = 0
|
|
||||||
return result, 0
|
return result, 0
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
package login
|
|
||||||
|
|
||||||
import (
|
|
||||||
"blazing/modules/blazing/model"
|
|
||||||
|
|
||||||
"github.com/creasty/defaults"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerLoginInfo struct {
|
|
||||||
GoldBean int32 `struc:"skip" json:"nieo_gold_bean"` // 尼尔金豆(特殊货币)
|
|
||||||
EquipmentHead int32 `struc:"skip" json:"equipment_head"` // 头部穿戴装备ID(0=未穿戴)
|
|
||||||
EquipmentFace int32 `struc:"skip" json:"equipment_face"` // 脸部穿戴装备ID
|
|
||||||
EquipmentHand int32 `struc:"skip" json:"equipment_hand"` // 手部穿戴装备ID
|
|
||||||
EquipmentWaist int32 `struc:"skip" json:"equipment_waist"` // 腰部穿戴装备ID
|
|
||||||
EquipmentLeg int32 `struc:"skip" json:"equipment_leg"` // 腿部穿戴装备ID
|
|
||||||
EquipmentBackground int32 `struc:"skip" json:"equipment_background"` // 背景穿戴装备ID
|
|
||||||
RobotColor int64 `struc:"skip" json:"robot_color"` // RGB颜色值(uint32,实际为3个uint8)
|
|
||||||
|
|
||||||
ExpPool int64 `struc:"skip" json:"exp_pool"` // 累计经验池
|
|
||||||
|
|
||||||
// OutInfo 字段
|
|
||||||
UserID uint32 `struc:"uint32" json:"user_id"` // 米米号 通过sid拿到
|
|
||||||
RegisterTime uint32 `struc:"uint32" json:"register_time"` // 注册时间(秒时间戳)
|
|
||||||
Nick string `struc:"[16]byte" default:"seer" json:"nick"` // 16字节昵称
|
|
||||||
Vip uint16 `struc:"uint16" json:"vip"` // 固定0
|
|
||||||
Viped uint16 `struc:"uint16" default:"15" json:"viped"` // 固定15
|
|
||||||
DSFlag uint32 `struc:"uint32" json:"ds_flag"` // 固定0
|
|
||||||
Color uint32 `struc:"uint32" json:"color"` // 机器人颜色,0x00 rgb
|
|
||||||
Texture uint32 `struc:"uint32" json:"texture"` // 固定0
|
|
||||||
Energy uint32 `struc:"uint32" default:"3000" json:"energy"` // 固定3000
|
|
||||||
Coins uint32 `struc:"uint32" json:"coins"` // 赛尔豆
|
|
||||||
FightBadge uint32 `struc:"uint32" json:"fight_badge"` // 固定0
|
|
||||||
MapID uint32 `struc:"uint32" default:"1" json:"map_id"` // 上线地图ID
|
|
||||||
Pos Pos `json:"pos"` // 坐标
|
|
||||||
TimeToday uint32 `struc:"uint32" json:"time_today"` // 已消耗时间(秒)
|
|
||||||
TimeLimit uint32 `struc:"uint32" json:"time_limit"` // 总电池限制(秒)
|
|
||||||
IsClothHalfDay byte `struc:"byte" json:"is_cloth_half_day"` // 活动标志0/1
|
|
||||||
IsRoomHalfDay byte `struc:"byte" json:"is_room_half_day"` // 活动标志0/1
|
|
||||||
IFortressHalfDay byte `struc:"byte" json:"i_fortress_half_day"` // 活动标志0/1
|
|
||||||
IsHQHalfDay byte `struc:"byte" json:"is_hq_half_day"` // 活动标志0/1
|
|
||||||
LoginCount uint32 `struc:"uint32" json:"login_count"` // 固定0
|
|
||||||
Inviter uint32 `struc:"uint32" json:"inviter"` // 固定0
|
|
||||||
NewInviteeCount uint32 `struc:"uint32" json:"new_invitee_count"` // 固定0
|
|
||||||
VipLevel uint32 `struc:"uint32" default:"8" json:"vip_level"` // 固定8
|
|
||||||
VipValue uint32 `struc:"uint32" default:"80000" json:"vip_value"` // 固定80000
|
|
||||||
VipStage uint32 `struc:"uint32" default:"1" json:"vip_stage"` // 固定1
|
|
||||||
AutoCharge uint32 `struc:"uint32" default:"1" json:"auto_charge"` // 固定1
|
|
||||||
VipEndTime uint32 `struc:"uint32" default:"4294967295" json:"vip_end_time"` // 尽可能大值
|
|
||||||
FreshManBonus uint32 `struc:"uint32" json:"fresh_man_bonus"` // 固定0
|
|
||||||
NonoChipList [80]byte `struc:"[80]byte" json:"nono_chip_list"` // 超no芯片列表
|
|
||||||
DailyResArr [50]byte `struc:"[50]byte" default:"3" json:"daily_res_arr"` // 任务状态数组默认3
|
|
||||||
TeacherID uint32 `struc:"uint32" json:"teacher_id"` // 教官id
|
|
||||||
StudentID uint32 `struc:"uint32" json:"student_id"` // 学员id
|
|
||||||
GraduationCount uint32 `struc:"uint32" default:"0" json:"graduation_count"` // 毕业人数
|
|
||||||
MaxPuniLv uint32 `struc:"uint32" default:"0" json:"max_puni_lv"` // 默认0
|
|
||||||
PetMaxLevel uint32 `struc:"uint32" json:"pet_max_level"` // 精灵最高等级
|
|
||||||
AllPetNumber uint32 `struc:"uint32" json:"all_pet_number"` // 精灵数量
|
|
||||||
MonKingWin uint32 `struc:"uint32" json:"mon_king_win"` // 精灵王胜场
|
|
||||||
CurrentStage uint32 `struc:"uint32" json:"current_stage"` // 勇者之塔层数
|
|
||||||
MaxStage uint32 `struc:"uint32" json:"max_stage"` // 试炼之塔最高层
|
|
||||||
CurrentFreshStage uint32 `struc:"uint32" json:"current_fresh_stage"` // 当前试炼层数
|
|
||||||
MaxFreshStage uint32 `struc:"uint32" json:"max_fresh_stage"` // 最高试炼层
|
|
||||||
MaxArenaWins uint32 `struc:"uint32" json:"max_arena_wins"` // 星际擂台连胜
|
|
||||||
TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 默认0
|
|
||||||
ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 默认0
|
|
||||||
AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 默认0
|
|
||||||
AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 默认0
|
|
||||||
EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 默认0
|
|
||||||
LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 默认0
|
|
||||||
MonBattleMedal uint32 `struc:"uint32" default:"0" json:"mon_battle_medal"` // 默认0
|
|
||||||
RecordCount uint32 `struc:"uint32" default:"0" json:"record_count"` // 默认0
|
|
||||||
ObtainTm uint32 `struc:"uint32" default:"0" json:"obtain_tm"` // 默认0
|
|
||||||
SoulBeadItemID uint32 `struc:"uint32" json:"soul_bead_item_id"` // 当前元神珠id
|
|
||||||
ExpireTm uint32 `struc:"uint32" default:"0" json:"expire_tm"` // 默认0
|
|
||||||
FuseTimes uint32 `struc:"uint32" default:"0" json:"fuse_times"` // 默认0
|
|
||||||
HasNono uint32 `struc:"uint32" default:"1" json:"has_nono"` // 玩家是否有nono
|
|
||||||
SuperNono uint32 `struc:"uint32" default:"1" json:"super_nono"` // 玩家是否有超能nono
|
|
||||||
NonoState uint32 `struc:"uint32" default:"4294967295" json:"nono_state"` // 默认-1
|
|
||||||
NonoColor uint32 `struc:"uint32" json:"nono_color"` // nono颜色
|
|
||||||
NonoNick string `struc:"[16]byte" default:"nono" json:"nono_nick"` // nono名字(16字节)
|
|
||||||
TeamInfo model.TeamInfo `struc:"struct" json:"team_info"` // 战队信息24字节
|
|
||||||
TeamPkInfo model.TeamPKInfo `struc:"struct" json:"team_pk_info"` // 8字节
|
|
||||||
Reserved byte `struc:"byte" json:"reserved"` // 1字节无内容
|
|
||||||
Badge uint32 `struc:"uint32" default:"0" json:"badge"` // 默认0
|
|
||||||
Reserved1 [27]byte `struc:"[27]byte" default:"3" json:"reserved1"` // 27字节默认3
|
|
||||||
TaskList [500]byte `struc:"[500]byte" default:"3" json:"task_list"` // 任务状态数组500字节,默认3
|
|
||||||
PetListCount uint32 `struc:"sizeof=PetList" json:"pet_list_count"` // 精灵列表长度
|
|
||||||
PetList []model.PetInfo ` json:"pet_list"` // 精灵背包内信息
|
|
||||||
ClothesCount uint32 `struc:"sizeof=Clothes" json:"clothes_count"` // 穿戴装备数量
|
|
||||||
Clothes []model.PeopleItemInfo ` json:"clothes"` // 穿戴装备
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPlayerLoginInfo() *PlayerLoginInfo {
|
|
||||||
l := &PlayerLoginInfo{
|
|
||||||
Clothes: make([]model.PeopleItemInfo, 0),
|
|
||||||
PetList: make([]model.PetInfo, 0),
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自动填充 struct tag 里的 default 值
|
|
||||||
if err := defaults.Set(l); err != nil {
|
|
||||||
panic(err) // 方便发现 default 设置错误
|
|
||||||
}
|
|
||||||
|
|
||||||
// 填充需要重复值的数组
|
|
||||||
fillBytes(&l.DailyResArr, 3)
|
|
||||||
fillBytes(&l.Reserved1, 3)
|
|
||||||
fillBytes(&l.TaskList, 3)
|
|
||||||
|
|
||||||
return l
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工具函数:给数组/切片批量赋同一个 byte 值
|
|
||||||
func fillBytes(arr any, val byte) {
|
|
||||||
switch a := arr.(type) {
|
|
||||||
case *[50]byte:
|
|
||||||
for i := range a {
|
|
||||||
a[i] = val
|
|
||||||
}
|
|
||||||
case *[27]byte:
|
|
||||||
for i := range a {
|
|
||||||
a[i] = val
|
|
||||||
}
|
|
||||||
case *[500]byte:
|
|
||||||
for i := range a {
|
|
||||||
a[i] = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package login
|
|
||||||
|
|
||||||
type Pos struct {
|
|
||||||
X uint32 `struc:"uint32" default:"0"`
|
|
||||||
Y uint32 `struc:"uint32" default:"0"`
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// PeopleItemInfo 穿戴装备信息结构(对应Java的PeopleItemInfo)
|
|
||||||
type PeopleItemInfo struct {
|
|
||||||
ID uint32 `struc:"uint32"` // 装备id(对应Java的@UInt long)
|
|
||||||
Level uint32 `struc:"uint32" default:"1"` // 未知字段(默认值1,对应Java的@Builder.Default)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitDefaults 初始化默认值(确保默认值正确赋值)
|
|
||||||
func (p *PeopleItemInfo) InitDefaults() {
|
|
||||||
p.Level = 1 // 未知字段默认值1,与Java的@Builder.Default保持一致
|
|
||||||
}
|
|
||||||
@@ -16,41 +16,41 @@ type Pet struct {
|
|||||||
// PetInfo 精灵信息结构(合并后的优化版本)
|
// PetInfo 精灵信息结构(合并后的优化版本)
|
||||||
type PetInfo struct {
|
type PetInfo struct {
|
||||||
// 第一个版本字段
|
// 第一个版本字段
|
||||||
CapturePlayerID uint64 `json:"capture_player_id"`
|
CapturePlayerID uint64 `json:"capture_player_id"`
|
||||||
CaptureTime int64 `json:"capture_time"`
|
CaptureTime int64 `json:"capture_time"`
|
||||||
CaptureMap int32 `json:"capture_map"`
|
CaptureMap int32 `json:"capture_map"`
|
||||||
CaptureRect int16 `json:"capture_rect"`
|
CaptureRect int16 `json:"capture_rect"`
|
||||||
CaptureLevel int16 `json:"capture_level"`
|
CaptureLevel int16 `json:"capture_level"`
|
||||||
PetTypeID int32 `json:"pet_type_id"`
|
PetTypeID int32 `json:"pet_type_id"`
|
||||||
IndividualValue int16 `json:"individual_value"`
|
IndividualValue int16 `json:"individual_value"`
|
||||||
Nature int16 `json:"nature"`
|
Nature int16 `json:"nature"`
|
||||||
AbilityTypeEnum int16 `json:"ability_type_enum"`
|
AbilityTypeEnum int16 `json:"ability_type_enum"`
|
||||||
Shiny int32 `json:"shiny"`
|
Shiny int32 `json:"shiny"`
|
||||||
Level int16 `json:"level"`
|
Level int16 `json:"level"`
|
||||||
CurrentExp int32 `json:"current_exp"`
|
CurrentExp int32 `json:"current_exp"`
|
||||||
CurrentHP int32 `json:"current_hp"`
|
CurrentHP int32 `json:"current_hp"`
|
||||||
MaxHP int32 `json:"max_hp"`
|
MaxHP int32 `json:"max_hp"`
|
||||||
Attack int32 `json:"attack"`
|
Attack int32 `json:"attack"`
|
||||||
Defense int32 `json:"defense"`
|
Defense int32 `json:"defense"`
|
||||||
SpecialAttack int32 `json:"special_attack"`
|
SpecialAttack int32 `json:"special_attack"`
|
||||||
SpecialDefense int32 `json:"special_defense"`
|
SpecialDefense int32 `json:"special_defense"`
|
||||||
Speed int32 `json:"speed"`
|
Speed int32 `json:"speed"`
|
||||||
EvHP int16 `json:"ev_hp"`
|
EvHP int16 `json:"ev_hp"`
|
||||||
EvAttack int16 `json:"ev_attack"`
|
EvAttack int16 `json:"ev_attack"`
|
||||||
EvDefense int16 `json:"ev_defense"`
|
EvDefense int16 `json:"ev_defense"`
|
||||||
EvSpecialAttack int16 `json:"ev_special_attack"`
|
EvSpecialAttack int16 `json:"ev_special_attack"`
|
||||||
EvSpecialDefense int16 `json:"ev_special_defense"`
|
EvSpecialDefense int16 `json:"ev_special_defense"`
|
||||||
EvSpeed int16 `json:"ev_speed"`
|
EvSpeed int16 `json:"ev_speed"`
|
||||||
PetSkillLen int16 `struc:"sizeof=PetSkill" json:"pet_skill_len"`
|
PetSkillLen int16 `struc:"sizeof=PetSkill" json:"pet_skill_len"`
|
||||||
PetSkill []PetSkillInfo `json:"pet_skill"`
|
PetSkill []SkillInfo `json:"pet_skill"`
|
||||||
ElementalOrbID int32 `json:"elemental_orb_id"`
|
ElementalOrbID int32 `json:"elemental_orb_id"`
|
||||||
SpecialOrbID int32 `json:"special_orb_id"`
|
SpecialOrbID int32 `json:"special_orb_id"`
|
||||||
ElementalOrbCount int16 `json:"elemental_orb_count"`
|
ElementalOrbCount int16 `json:"elemental_orb_count"`
|
||||||
SpecialOrbCount int16 `json:"special_orb_count"`
|
SpecialOrbCount int16 `json:"special_orb_count"`
|
||||||
IndividualGuarantee int64 `json:"individual_guarantee"`
|
IndividualGuarantee int64 `json:"individual_guarantee"`
|
||||||
NatureGuarantee int64 `json:"nature_guarantee"`
|
NatureGuarantee int64 `json:"nature_guarantee"`
|
||||||
Freed bool `json:"freed"`
|
Freed bool `json:"freed"`
|
||||||
FreedTime string `json:"freed_time"`
|
FreedTime string `json:"freed_time"`
|
||||||
|
|
||||||
// 第二个版本字段
|
// 第二个版本字段
|
||||||
ID uint32 `struc:"uint32" json:"id"`
|
ID uint32 `struc:"uint32" json:"id"`
|
||||||
@@ -69,18 +69,6 @@ type PetInfo struct {
|
|||||||
EffectInfo []PetEffectInfo `json:"effect_info"`
|
EffectInfo []PetEffectInfo `json:"effect_info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PetSkillInfo 精灵技能信息结构
|
|
||||||
type PetSkillInfo struct {
|
|
||||||
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 {
|
type PetEffectInfo struct {
|
||||||
ItemID uint32 `struc:"uint32" json:"item_id"`
|
ItemID uint32 `struc:"uint32" json:"item_id"`
|
||||||
@@ -93,6 +81,12 @@ type PetEffectInfo struct {
|
|||||||
Reserve4 [13]byte `struc:"[13]byte" json:"reserve4"`
|
Reserve4 [13]byte `struc:"[13]byte" json:"reserve4"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SkillInfo 精灵技能信息结构(对应Java的SkillInfo)
|
||||||
|
type SkillInfo struct {
|
||||||
|
ID uint32 `struc:"uint32"` // 技能id(对应Java的@UInt long)
|
||||||
|
Pp uint32 `struc:"uint32"` // 剩余pp(对应Java的@UInt long)
|
||||||
|
}
|
||||||
|
|
||||||
// TableName Pet's table name
|
// TableName Pet's table name
|
||||||
func (*Pet) TableName() string {
|
func (*Pet) TableName() string {
|
||||||
return TableNamePet
|
return TableNamePet
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// SkillInfo 精灵技能信息结构(对应Java的SkillInfo)
|
|
||||||
type SkillInfo struct {
|
|
||||||
ID uint32 `struc:"uint32"` // 技能id(对应Java的@UInt long)
|
|
||||||
Pp uint32 `struc:"uint32"` // 剩余pp(对应Java的@UInt long)
|
|
||||||
}
|
|
||||||
@@ -20,3 +20,15 @@ func (t *TeamInfo) InitDefaults() {
|
|||||||
t.AllContribution = 1
|
t.AllContribution = 1
|
||||||
t.CanExContribution = 1
|
t.CanExContribution = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TeamPKInfo 战队PK相关信息结构
|
||||||
|
type TeamPKInfo struct {
|
||||||
|
GroupID uint32 `struc:"uint32" default:"1"` // 分组ID,默认值1(对应Java的@UInt long)
|
||||||
|
HomeTeamID uint32 `struc:"uint32" default:"1"` // 主队ID,默认值1(对应Java的@UInt long)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitDefaults 初始化默认值(确保字段默认值正确赋值)
|
||||||
|
func (t *TeamPKInfo) InitDefaults() {
|
||||||
|
t.GroupID = 1
|
||||||
|
t.HomeTeamID = 1
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// TeamPKInfo 战队PK相关信息结构
|
|
||||||
type TeamPKInfo struct {
|
|
||||||
GroupID uint32 `struc:"uint32" default:"1"` // 分组ID,默认值1(对应Java的@UInt long)
|
|
||||||
HomeTeamID uint32 `struc:"uint32" default:"1"` // 主队ID,默认值1(对应Java的@UInt long)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitDefaults 初始化默认值(确保字段默认值正确赋值)
|
|
||||||
func (t *TeamPKInfo) InitDefaults() {
|
|
||||||
t.GroupID = 1
|
|
||||||
t.HomeTeamID = 1
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"blazing/cool"
|
|
||||||
)
|
|
||||||
|
|
||||||
const TableNameChallenge = "challenge"
|
|
||||||
|
|
||||||
// Challenge mapped from table <challenge>
|
|
||||||
type Challenge struct {
|
|
||||||
*cool.Model
|
|
||||||
PlayerID uint64 `gorm:"not null;uniqueIndex:idx_challenge_unique_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
|
||||||
MonKingWin int32 `gorm:"not null;default:0;comment:'精灵王之战胜场数'" json:"mon_king_win"`
|
|
||||||
CurStage int16 `gorm:"not null;default:0;comment:'当期勇者之塔到达的层数'" json:"cur_stage"`
|
|
||||||
MaxStage int16 `gorm:"not null;default:0;comment:'历史勇者之塔到达的最大层数'" json:"max_stage"`
|
|
||||||
MessWin int32 `gorm:"not null;default:0;comment:'精灵大乱斗胜场数'" json:"mess_win"`
|
|
||||||
CurFreshStage int16 `gorm:"not null;default:0;comment:'试炼之塔当前层数'" json:"cur_fresh_stage"`
|
|
||||||
MaxFreshStage int16 `gorm:"not null;default:0;comment:'试炼之塔当前层数'" json:"max_fresh_stage"`
|
|
||||||
MaxArenaWins int32 `gorm:"not null;default:0;comment:'最大星际擂台连胜数'" json:"max_arena_wins"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TableName Challenge's table name
|
|
||||||
func (*Challenge) TableName() string {
|
|
||||||
return TableNameChallenge
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupName Challenge's table group
|
|
||||||
func (*Challenge) GroupName() string {
|
|
||||||
return "default"
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewChallenge create a new Challenge
|
|
||||||
func NewChallenge() *Challenge {
|
|
||||||
return &Challenge{
|
|
||||||
Model: cool.NewModel(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// init 创建表
|
|
||||||
func init() {
|
|
||||||
cool.CreateTable(&Challenge{})
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ const TableNamePlayerInfo = "player_info"
|
|||||||
type PlayerInfo struct {
|
type PlayerInfo struct {
|
||||||
*cool.Model
|
*cool.Model
|
||||||
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
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"`
|
Data string `gorm:"type:text;not null;comment:'全部数据'" json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName PlayerInfo's table name
|
// TableName PlayerInfo's table name
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"blazing/cool"
|
|
||||||
)
|
|
||||||
|
|
||||||
const TableNamePlayerBattery = "player_battery"
|
|
||||||
|
|
||||||
// PlayerBattery mapped from table <player_battery>
|
|
||||||
type PlayerBattery struct {
|
|
||||||
*cool.Model
|
|
||||||
PlayerID uint64 `gorm:"not null;uniqueIndex:idx_player_battery_unique_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
|
||||||
RemainingTime int64 `gorm:"not null;default:0;comment:'剩余电池时间单位秒(uint32)'" json:"remaining_time"`
|
|
||||||
LastResetTime string `gorm:"comment:'上一次重置时间'" json:"last_reset_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TableName PlayerBattery's table name
|
|
||||||
func (*PlayerBattery) TableName() string {
|
|
||||||
return TableNamePlayerBattery
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupName PlayerBattery's table group
|
|
||||||
func (*PlayerBattery) GroupName() string {
|
|
||||||
return "default"
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPlayerBattery create a new PlayerBattery
|
|
||||||
func NewPlayerBattery() *PlayerBattery {
|
|
||||||
return &PlayerBattery{
|
|
||||||
Model: cool.NewModel(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// init 创建表
|
|
||||||
func init() {
|
|
||||||
cool.CreateTable(&PlayerBattery{})
|
|
||||||
}
|
|
||||||
142
modules/blazing/model/playerinfo.go
Normal file
142
modules/blazing/model/playerinfo.go
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/creasty/defaults"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Pos struct {
|
||||||
|
X uint32 `struc:"uint32" default:"0"`
|
||||||
|
Y uint32 `struc:"uint32" default:"0"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PeopleItemInfo 穿戴装备信息结构(对应Java的PeopleItemInfo)
|
||||||
|
type PeopleItemInfo struct {
|
||||||
|
ID uint32 `struc:"uint32"` // 装备id(对应Java的@UInt long)
|
||||||
|
Level uint32 `struc:"uint32" default:"1"` // 未知字段(默认值1,对应Java的@Builder.Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitDefaults 初始化默认值(确保默认值正确赋值)
|
||||||
|
func (p *PeopleItemInfo) InitDefaults() {
|
||||||
|
p.Level = 1 // 未知字段默认值1,与Java的@Builder.Default保持一致
|
||||||
|
}
|
||||||
|
|
||||||
|
type PlayerLoginInfo struct {
|
||||||
|
GoldBean int32 `struc:"skip" json:"nieo_gold_bean"` // 金豆(特殊货币)
|
||||||
|
// EquipmentHead int32 `struc:"skip" json:"equipment_head"` // 头部穿戴装备ID(0=未穿戴)
|
||||||
|
// EquipmentFace int32 `struc:"skip" json:"equipment_face"` // 脸部穿戴装备ID
|
||||||
|
// EquipmentHand int32 `struc:"skip" json:"equipment_hand"` // 手部穿戴装备ID
|
||||||
|
// EquipmentWaist int32 `struc:"skip" json:"equipment_waist"` // 腰部穿戴装备ID
|
||||||
|
// EquipmentLeg int32 `struc:"skip" json:"equipment_leg"` // 腿部穿戴装备ID
|
||||||
|
// EquipmentBackground int32 `struc:"skip" json:"equipment_background"` // 背景穿戴装备ID
|
||||||
|
// RobotColor int64 `struc:"skip" json:"robot_color"` // RGB颜色值(uint32,实际为3个uint8)
|
||||||
|
|
||||||
|
ExpPool int64 `struc:"skip" json:"exp_pool"` // 累计经验池
|
||||||
|
|
||||||
|
// OutInfo 字段
|
||||||
|
UserID uint32 `struc:"uint32" json:"user_id"` // 米米号 通过sid拿到
|
||||||
|
RegisterTime uint32 `struc:"uint32" json:"register_time"` // 注册时间(秒时间戳)
|
||||||
|
Nick string `struc:"[16]byte" default:"seer" json:"nick"` // 16字节昵称
|
||||||
|
Vip uint16 `struc:"uint16" json:"vip"` // 固定0
|
||||||
|
Viped uint16 `struc:"uint16" default:"15" json:"viped"` // 固定15
|
||||||
|
DSFlag uint32 `struc:"uint32" json:"ds_flag"` // 固定0
|
||||||
|
Color uint32 `struc:"uint32" json:"color"` // 机器人颜色RGB颜色值(uint32,实际为3个uint8)
|
||||||
|
Texture uint32 `struc:"uint32" json:"texture"` // 固定0
|
||||||
|
Energy uint32 `struc:"uint32" default:"3000" json:"energy"` // 固定3000
|
||||||
|
Coins uint32 `struc:"uint32" json:"coins"` // 赛尔豆
|
||||||
|
FightBadge uint32 `struc:"uint32" json:"fight_badge"` // 固定0
|
||||||
|
MapID uint32 `struc:"uint32" default:"1" json:"map_id"` // 上线地图ID
|
||||||
|
Pos Pos `json:"pos"` // 坐标
|
||||||
|
TimeToday uint32 `struc:"uint32" json:"time_today"` // 已消耗时间(秒)
|
||||||
|
TimeLimit uint32 `struc:"uint32" json:"time_limit"` // 总电池限制(秒)
|
||||||
|
IsClothHalfDay byte `struc:"byte" json:"is_cloth_half_day"` // 活动标志0/1
|
||||||
|
IsRoomHalfDay byte `struc:"byte" json:"is_room_half_day"` // 活动标志0/1
|
||||||
|
IFortressHalfDay byte `struc:"byte" json:"i_fortress_half_day"` // 活动标志0/1
|
||||||
|
IsHQHalfDay byte `struc:"byte" json:"is_hq_half_day"` // 活动标志0/1
|
||||||
|
LoginCount uint32 `struc:"uint32" json:"login_count"` // 固定0
|
||||||
|
Inviter uint32 `struc:"uint32" json:"inviter"` // 固定0
|
||||||
|
NewInviteeCount uint32 `struc:"uint32" json:"new_invitee_count"` // 固定0
|
||||||
|
VipLevel uint32 `struc:"uint32" default:"8" json:"vip_level"` // 固定8
|
||||||
|
VipValue uint32 `struc:"uint32" default:"80000" json:"vip_value"` // 固定80000
|
||||||
|
VipStage uint32 `struc:"uint32" default:"1" json:"vip_stage"` // 固定1
|
||||||
|
AutoCharge uint32 `struc:"uint32" default:"1" json:"auto_charge"` // 固定1
|
||||||
|
VipEndTime uint32 `struc:"uint32" default:"4294967295" json:"vip_end_time"` // 尽可能大值
|
||||||
|
FreshManBonus uint32 `struc:"uint32" json:"fresh_man_bonus"` // 固定0
|
||||||
|
NonoChipList [80]byte `struc:"[80]byte" json:"nono_chip_list"` // 超no芯片列表
|
||||||
|
DailyResArr [50]byte `struc:"[50]byte" default:"3" json:"daily_res_arr"` // 任务状态数组默认3
|
||||||
|
TeacherID uint32 `struc:"uint32" json:"teacher_id"` // 教官id
|
||||||
|
StudentID uint32 `struc:"uint32" json:"student_id"` // 学员id
|
||||||
|
GraduationCount uint32 `struc:"uint32" default:"0" json:"graduation_count"` // 毕业人数
|
||||||
|
MaxPuniLv uint32 `struc:"uint32" default:"0" json:"max_puni_lv"` // 默认0
|
||||||
|
PetMaxLevel uint32 `struc:"uint32" json:"pet_max_level"` // 精灵最高等级
|
||||||
|
AllPetNumber uint32 `struc:"uint32" json:"all_pet_number"` // 精灵数量
|
||||||
|
MonKingWin uint32 `struc:"uint32" json:"mon_king_win"` // 精灵王胜场
|
||||||
|
CurrentStage uint32 `struc:"uint32" json:"current_stage"` // 勇者之塔层数
|
||||||
|
MaxStage uint32 `struc:"uint32" json:"max_stage"` // 试炼之塔最高层
|
||||||
|
CurrentFreshStage uint32 `struc:"uint32" json:"current_fresh_stage"` // 当前试炼层数
|
||||||
|
MaxFreshStage uint32 `struc:"uint32" json:"max_fresh_stage"` // 最高试炼层
|
||||||
|
MaxArenaWins uint32 `struc:"uint32" json:"max_arena_wins"` // 星际擂台连胜
|
||||||
|
TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 默认0
|
||||||
|
ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 默认0
|
||||||
|
AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 默认0
|
||||||
|
AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 默认0
|
||||||
|
EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 默认0
|
||||||
|
LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 默认0
|
||||||
|
MonBattleMedal uint32 `struc:"uint32" default:"0" json:"mon_battle_medal"` // 默认0
|
||||||
|
RecordCount uint32 `struc:"uint32" default:"0" json:"record_count"` // 默认0
|
||||||
|
ObtainTm uint32 `struc:"uint32" default:"0" json:"obtain_tm"` // 默认0
|
||||||
|
SoulBeadItemID uint32 `struc:"uint32" json:"soul_bead_item_id"` // 当前元神珠id
|
||||||
|
ExpireTm uint32 `struc:"uint32" default:"0" json:"expire_tm"` // 默认0
|
||||||
|
FuseTimes uint32 `struc:"uint32" default:"0" json:"fuse_times"` // 默认0
|
||||||
|
HasNono uint32 `struc:"uint32" default:"1" json:"has_nono"` // 玩家是否有nono
|
||||||
|
SuperNono uint32 `struc:"uint32" default:"1" json:"super_nono"` // 玩家是否有超能nono
|
||||||
|
NonoState uint32 `struc:"uint32" default:"4294967295" json:"nono_state"` // 默认-1
|
||||||
|
NonoColor uint32 `struc:"uint32" json:"nono_color"` // nono颜色
|
||||||
|
NonoNick string `struc:"[16]byte" default:"nono" json:"nono_nick"` // nono名字(16字节)
|
||||||
|
TeamInfo TeamInfo `struc:"struct" json:"team_info"` // 战队信息24字节
|
||||||
|
TeamPkInfo TeamPKInfo `struc:"struct" json:"team_pk_info"` // 8字节
|
||||||
|
Reserved byte `struc:"byte" json:"reserved"` // 1字节无内容
|
||||||
|
Badge uint32 `struc:"uint32" default:"0" json:"badge"` // 默认0
|
||||||
|
Reserved1 [27]byte `struc:"[27]byte" default:"3" json:"reserved1"` // 27字节默认3
|
||||||
|
TaskList [500]byte `struc:"[500]byte" default:"3" json:"task_list"` // 任务状态数组500字节,默认3
|
||||||
|
PetListCount uint32 `struc:"sizeof=PetList" json:"pet_list_count"` // 精灵列表长度
|
||||||
|
PetList []PetInfo ` json:"pet_list"` // 精灵背包内信息
|
||||||
|
ClothesCount uint32 `struc:"sizeof=Clothes" json:"clothes_count"` // 穿戴装备数量
|
||||||
|
Clothes []PeopleItemInfo ` json:"clothes"` // 穿戴装备
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPlayerLoginInfo() *PlayerLoginInfo {
|
||||||
|
l := &PlayerLoginInfo{
|
||||||
|
Clothes: make([]PeopleItemInfo, 0),
|
||||||
|
PetList: make([]PetInfo, 0),
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自动填充 struct tag 里的 default 值
|
||||||
|
if err := defaults.Set(l); err != nil {
|
||||||
|
panic(err) // 方便发现 default 设置错误
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充需要重复值的数组
|
||||||
|
fillBytes(&l.DailyResArr, 3)
|
||||||
|
fillBytes(&l.Reserved1, 3)
|
||||||
|
fillBytes(&l.TaskList, 3)
|
||||||
|
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
// 工具函数:给数组/切片批量赋同一个 byte 值
|
||||||
|
func fillBytes(arr any, val byte) {
|
||||||
|
switch a := arr.(type) {
|
||||||
|
case *[50]byte:
|
||||||
|
for i := range a {
|
||||||
|
a[i] = val
|
||||||
|
}
|
||||||
|
case *[27]byte:
|
||||||
|
for i := range a {
|
||||||
|
a[i] = val
|
||||||
|
}
|
||||||
|
case *[500]byte:
|
||||||
|
for i := range a {
|
||||||
|
a[i] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user