85 lines
2.9 KiB
Go
85 lines
2.9 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/modules/player/model"
|
|
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
"blazing/logic/service/room"
|
|
|
|
"github.com/jinzhu/copier"
|
|
)
|
|
|
|
// GetFitmentUsing 获取基地展示的家具物品
|
|
// data: 包含目标用户ID的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 基地家具信息和错误码
|
|
func (h Controller) GetFitmentUsing(data *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})
|
|
|
|
roomInfo := c.Service.Room.Get(data.TargetUserID)
|
|
result.Fitments = append(result.Fitments, roomInfo.PlacedItems...)
|
|
return
|
|
}
|
|
|
|
// GetRoomPetShowInfo 获取基地展示的精灵列表
|
|
// data: 包含目标用户ID的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 精灵展示列表和错误码
|
|
func (h Controller) GetRoomPetShowInfo(data *PetRoomListInboundInfo, c *player.Player) (result *room.PetRoomListOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.PetRoomListOutboundInfo{}
|
|
result.Pets = make([]pet.PetShortInfo, 0)
|
|
roomInfo := c.Service.Room.Get(data.TargetUserID)
|
|
for _, catchTime := range roomInfo.ShowPokemon {
|
|
petInfo := c.Service.Pet.PetInfoOneOther(data.TargetUserID, catchTime)
|
|
if petInfo.Data.ID == 0 {
|
|
continue
|
|
}
|
|
var petShortInfo pet.PetShortInfo
|
|
copier.Copy(&petShortInfo, &petInfo.Data)
|
|
if petInfo.ID != 0 {
|
|
result.Pets = append(result.Pets, petShortInfo)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// GetAllFurniture 获取玩家的所有家具
|
|
// data: 空输入结构
|
|
// c: 当前玩家对象
|
|
// 返回: 玩家所有家具列表和错误码
|
|
func (h Controller) GetAllFurniture(data *FitmentAllInboundEmpty, c *player.Player) (result *room.FitmentAllOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.FitmentAllOutboundInfo{}
|
|
result.Fitments = make([]room.FitmentItemInfo, 0)
|
|
|
|
items := c.Service.Item.Get(500000, 600000)
|
|
roomData := c.Service.Room.Get(c.Info.UserID)
|
|
for _, item := range items {
|
|
var itemInfo room.FitmentItemInfo
|
|
itemInfo.Id = item.ItemId
|
|
itemInfo.AllCount = uint32(item.ItemCnt)
|
|
i, ok := roomData.UsedItems[item.ItemId]
|
|
if ok {
|
|
itemInfo.UsedCount = i
|
|
}
|
|
result.Fitments = append(result.Fitments, itemInfo)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetRoomPetInfo 获取玩家跟随精灵的信息
|
|
// data: 包含用户ID和精灵捕获时间的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 精灵详细信息和错误码
|
|
func (h Controller) GetRoomPetInfo(data *C2S_RoomPetInfo, c *player.Player) (result *pet.RoomPetInfo, err errorcode.ErrorCode) {
|
|
petInfo := c.Service.Pet.PetInfoOneOther(data.UserID, data.CatchTime)
|
|
result = &pet.RoomPetInfo{}
|
|
copier.CopyWithOption(result, &petInfo.Data, copier.Option{DeepCopy: true})
|
|
result.OwnerId = data.UserID
|
|
return
|
|
}
|