- 修改了 Login 方法的返回类型,使用新的 PlayerLoginInfo 结构体 - 新增 NewPlayerLoginInfo 函数用于创建并初始化 PlayerLoginInfo 对象 - 重构了 LoginSidInfo 和 LoginUserInfo 文件中的结构体 - 优化了数据初始化和默认值设置的方式
118 lines
4.5 KiB
Go
118 lines
4.5 KiB
Go
package model
|
|
|
|
import (
|
|
"blazing/cool"
|
|
)
|
|
|
|
const TableNamePet = "pet"
|
|
|
|
// Pet mapped from table <pet>
|
|
type Pet struct {
|
|
*cool.Model
|
|
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"`
|
|
}
|
|
|
|
// PetInfo 精灵信息结构(合并后的优化版本)
|
|
type PetInfo struct {
|
|
// 第一个版本字段
|
|
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 精灵技能信息结构
|
|
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 精灵特性信息结构
|
|
type PetEffectInfo struct {
|
|
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
|
|
func (*Pet) TableName() string {
|
|
return TableNamePet
|
|
}
|
|
|
|
// GroupName Pet's table group
|
|
func (*Pet) GroupName() string {
|
|
return "default"
|
|
}
|
|
|
|
// NewPet create a new Pet
|
|
func NewPet() *Pet {
|
|
return &Pet{
|
|
Model: cool.NewModel(),
|
|
}
|
|
}
|
|
|
|
// init 创建表
|
|
func init() {
|
|
_ = cool.CreateTable(&Pet{})
|
|
// fmt.Println(err)
|
|
}
|