112 lines
4.3 KiB
Go
112 lines
4.3 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 []SkillInfo `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"`
|
||
}
|
||
|
||
// 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"`
|
||
}
|
||
|
||
// 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
|
||
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)
|
||
}
|