feat(room): 更新房间宠物展示逻辑并优化数据结构 - 修改 `OnGetRoomPetShowInfo` 方法,使用 `pet.PetShortInfo` 替代原有的 `room.PetShowInfo` 结构体 - 引入 `github.com/jinzhu/copier` 实现结构体字段自动复制 - 调整 `SET_Pet` 接口实现逻辑以支持批量设置展示中的宠物 - 更新 `PetRoomListOutboundInfo` 中 Pets 字段类型为 `[]pet.PetShortInfo` - 将 `RoomService.Show` 方法参数由单个 uint32 改为切片 []uint32 以支持多宠物展示 - 修改数据库表名常量 `TableNameBaseHouse` 从 "base_house" 更名为 "room_house
60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/modules/blazing/model"
|
|
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
"blazing/logic/service/room"
|
|
|
|
"github.com/jinzhu/copier"
|
|
)
|
|
|
|
// 获取基地物品
|
|
func (h Controller) OnFitmentUsering(data *room.FitmentUseringInboundInfo, c *player.Player) (result *room.FitmentUseringOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
result = &room.FitmentUseringOutboundInfo{UserId: c.Info.UserID, RoomId: data.TargetUserID}
|
|
result.Fitments = make([]model.FitmentShowInfo, 0)
|
|
result.Fitments = append(result.Fitments, model.FitmentShowInfo{Id: 500001, Status: 1, X: 1, Y: 1, Dir: 1})
|
|
|
|
r := c.Service.Room.Get(data.TargetUserID)
|
|
result.Fitments = append(result.Fitments, r.PlacedItems...)
|
|
|
|
return
|
|
}
|
|
|
|
// 获取基地展示精灵
|
|
func (h Controller) OnGetRoomPetShowInfo(data *room.PetRoomListInboundInfo, c *player.Player) (result *room.PetRoomListOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.PetRoomListOutboundInfo{}
|
|
result.Pets = make([]pet.PetShortInfo, 0)
|
|
r := c.Service.Room.Get(data.TargetUserID)
|
|
for _, v := range r.ShowPokemon {
|
|
pet12 := c.Service.Pet.PetInfo_One_ohter(data.TargetUserID, v)
|
|
if pet12.Data.ID == 0 {
|
|
continue
|
|
}
|
|
var pet1 pet.PetShortInfo
|
|
copier.Copy(&pet1, &pet12.Data)
|
|
result.Pets = append(result.Pets, pet1)
|
|
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// 获取自己房间的家具
|
|
func (h Controller) OnGetFitmentAll(data *room.FitmentAllInboundEmpty, c *player.Player) (result *room.FitmentAllOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.FitmentAllOutboundInfo{}
|
|
result.Fitments = make([]room.FitmentItemInfo, 0)
|
|
|
|
r := c.Service.Room.Get(c.Info.UserID)
|
|
|
|
for k, v := range r.OwnedItems {
|
|
|
|
result.Fitments = append(result.Fitments, room.FitmentItemInfo{Id: k, AllCount: v, UsedCount: r.UserItems[k]})
|
|
}
|
|
|
|
return
|
|
}
|