2025-12-13 22:51:39 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 基地房型表名
|
2026-01-19 18:51:56 +08:00
|
|
|
|
const TableNameBaseHouse = "player_room_house"
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
|
|
|
|
|
// NewBaseHouse 构造函数:创建基地房型实例
|
|
|
|
|
|
func NewBaseHouse() *BaseHouse {
|
|
|
|
|
|
return &BaseHouse{
|
2026-01-08 03:30:18 +08:00
|
|
|
|
Base: *NewBase(),
|
2025-12-13 22:51:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// BaseHouse 基地房型核心结构体
|
|
|
|
|
|
// 包含:基地展示精灵、基地拥有物品、基地摆放物品三大核心字段
|
|
|
|
|
|
type BaseHouse struct {
|
2026-01-08 03:30:18 +08:00
|
|
|
|
Base
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
|
|
|
|
|
// 基础关联字段
|
|
|
|
|
|
PlayerID uint64 `gorm:"not null;index:idx_player_house;comment:'所属玩家ID'" json:"player_id"`
|
|
|
|
|
|
|
|
|
|
|
|
// 核心业务字段
|
|
|
|
|
|
// ShowPokemon 基地展示精灵ID列表(支持展示多个精灵)
|
2026-01-19 18:51:56 +08:00
|
|
|
|
ShowPokemon []uint32 `gorm:"type:jsonb;default:'[]';comment:'基地展示精灵ID列表'" json:"show_pokemon"`
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
2026-01-19 18:51:56 +08:00
|
|
|
|
UsedItems string `gorm:"type:jsonb;default:'{}';comment:'用户物品列表(物品ID:数量)'" json:"used_items"`
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
|
|
|
|
|
// PlacedItems 基地摆放物品(包含物品ID、摆放坐标、朝向等信息)
|
2026-01-19 18:51:56 +08:00
|
|
|
|
PlacedItems string `gorm:"type:jsonb;default:'[]';comment:'基地摆放物品列表(含位置/朝向)'" json:"placed_items"`
|
2025-12-13 22:51:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (*BaseHouse) TableName() string {
|
|
|
|
|
|
return TableNameBaseHouse
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type BaseHouseEx struct {
|
|
|
|
|
|
BaseHouse
|
|
|
|
|
|
PlacedItems []FitmentShowInfo `json:"placed_items"`
|
2026-01-19 18:51:56 +08:00
|
|
|
|
//OwnedItems map[uint32]uint32 `json:"owned_items"`
|
|
|
|
|
|
UsedItems map[uint32]uint32 `json:"used_items"`
|
2025-12-13 22:51:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FitmentShowInfo 表示家具展示信息
|
|
|
|
|
|
type FitmentShowInfo struct {
|
|
|
|
|
|
// 家具id 或 默认房型id: 500001
|
|
|
|
|
|
Id uint32 `json:"id"`
|
|
|
|
|
|
// x坐标
|
|
|
|
|
|
X uint32 `json:"x"`
|
|
|
|
|
|
// y坐标
|
|
|
|
|
|
Y uint32 `json:"y"`
|
|
|
|
|
|
// 默认0
|
|
|
|
|
|
Dir uint32 `json:"dir"`
|
|
|
|
|
|
// 默认0
|
|
|
|
|
|
Status uint32 `json:"status"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateShowPokemon 更新基地展示精灵列表
|
|
|
|
|
|
func (bh *BaseHouse) UpdateShowPokemon(pokemonIDs []uint32) {
|
|
|
|
|
|
bh.ShowPokemon = pokemonIDs
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------- 初始化创建表 ---------------
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
// 初始化时创建基地房型表(与现有Talk表初始化逻辑一致)
|
|
|
|
|
|
cool.CreateTable(&BaseHouse{})
|
|
|
|
|
|
}
|