```
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
This commit is contained in:
@@ -4,8 +4,11 @@ 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"
|
||||
)
|
||||
|
||||
// 获取基地物品
|
||||
@@ -24,14 +27,16 @@ func (h Controller) OnFitmentUsering(data *room.FitmentUseringInboundInfo, c *pl
|
||||
// 获取基地展示精灵
|
||||
func (h Controller) OnGetRoomPetShowInfo(data *room.PetRoomListInboundInfo, c *player.Player) (result *room.PetRoomListOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &room.PetRoomListOutboundInfo{}
|
||||
result.Pets = make([]room.PetShowInfo, 0)
|
||||
result.Pets = make([]pet.PetShortInfo, 0)
|
||||
r := c.Service.Room.Get(data.TargetUserID)
|
||||
for _, v := range r.ShowPokemon {
|
||||
pet := c.Service.Pet.PetInfo_One_ohter(data.TargetUserID, v)
|
||||
if pet.Data.ID == 0 {
|
||||
pet12 := c.Service.Pet.PetInfo_One_ohter(data.TargetUserID, v)
|
||||
if pet12.Data.ID == 0 {
|
||||
continue
|
||||
}
|
||||
result.Pets = append(result.Pets, room.PetShowInfo{CatchTime: v, TypeId: pet.Data.ID})
|
||||
var pet1 pet.PetShortInfo
|
||||
copier.Copy(&pet1, &pet12.Data)
|
||||
result.Pets = append(result.Pets, pet1)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,18 +17,25 @@ func (h Controller) SET_FITMENT(data *room.SET_FITMENT, c *player.Player) (resul
|
||||
return
|
||||
}
|
||||
|
||||
func (h Controller) SET_Pet(data *room.C2S_PetShowList, c *player.Player) (result *room.S2C_PET_ROOM_SHOW, err errorcode.ErrorCode) {
|
||||
func (h Controller) SET_Pet(data *room.C2S_PET_ROOM_SHOW, c *player.Player) (result *room.S2C_PET_ROOM_SHOW, err errorcode.ErrorCode) {
|
||||
var showpet []uint32
|
||||
for _, v := range data.PetShowList {
|
||||
showpet = append(showpet, v.CatchTime)
|
||||
|
||||
c.Service.Room.Show(data.CatchTime)
|
||||
}
|
||||
c.Service.Room.Show(showpet)
|
||||
result = &room.S2C_PET_ROOM_SHOW{}
|
||||
r := c.Service.Room.Get(c.Info.UserID)
|
||||
result.PetShowList = make([]pet.PetShortInfo, len(r.ShowPokemon))
|
||||
for _, v := range r.ShowPokemon {
|
||||
|
||||
result.PetShowList = make([]pet.PetShortInfo, len(showpet))
|
||||
for _, v := range showpet {
|
||||
r1 := c.Service.Pet.PetInfo_One(v)
|
||||
if r1.Data.ID == 0 {
|
||||
continue
|
||||
|
||||
}
|
||||
var r12 pet.PetShortInfo
|
||||
copier.Copy(&r12, &r1)
|
||||
copier.Copy(&r12, &r1.Data)
|
||||
result.PetShowList = append(result.PetShowList, r12)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package room
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
@@ -12,6 +13,7 @@ type FitmentUseringInboundInfo struct {
|
||||
TargetUserID uint32 `json:"targetUserId"`
|
||||
}
|
||||
type SET_FITMENT struct {
|
||||
Head common.TomeeHeader `cmd:"10008" struc:"skip"` //玩家登录
|
||||
// RoomID 房间ID
|
||||
// 特殊规则:怀旧服官服固定为1,新服与用户ID(userid)相同
|
||||
RoomID uint32 `json:"roomID"`
|
||||
@@ -34,13 +36,10 @@ type FitmentUseringOutboundInfo struct {
|
||||
}
|
||||
|
||||
// PetShowInfo 宠物展示信息
|
||||
type PetShowInfo struct {
|
||||
TypeId uint32 // 精灵类型ID
|
||||
CatchTime uint32 // 精灵生成时间
|
||||
}
|
||||
|
||||
type PetRoomListOutboundInfo struct {
|
||||
PetsLen uint32 `json:"petsLen" struc:"sizeof=Pets"`
|
||||
Pets []PetShowInfo `json:"pets"`
|
||||
PetsLen uint32 `json:"petsLen" struc:"sizeof=Pets"`
|
||||
Pets []pet.PetShortInfo `json:"pets"`
|
||||
}
|
||||
|
||||
type PetRoomListInboundInfo struct {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// 基地房型表名
|
||||
const TableNameBaseHouse = "base_house"
|
||||
const TableNameBaseHouse = "room_house"
|
||||
|
||||
// NewBaseHouse 构造函数:创建基地房型实例
|
||||
func NewBaseHouse() *BaseHouse {
|
||||
|
||||
@@ -46,12 +46,13 @@ func (s *RoomService) Set(id []model.FitmentShowInfo) {
|
||||
m.Save(ttt)
|
||||
|
||||
}
|
||||
func (s *RoomService) Show(cactime uint32) {
|
||||
func (s *RoomService) Show(cactime []uint32) {
|
||||
|
||||
//todo待测试
|
||||
var ttt model.BaseHouseEx
|
||||
m := s.GModel(s.Model)
|
||||
m.Scan(&ttt)
|
||||
ttt.ShowPokemon = append(ttt.ShowPokemon, cactime)
|
||||
ttt.ShowPokemon = cactime
|
||||
|
||||
ttt.PlayerID = uint64(s.userid)
|
||||
m.Save(ttt)
|
||||
|
||||
Reference in New Issue
Block a user