94 lines
2.6 KiB
Go
94 lines
2.6 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/common"
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
"blazing/modules/player/model"
|
|
)
|
|
|
|
// GetPetInfo 获取精灵信息
|
|
func (h Controller) GetPetInfo(
|
|
data *GetPetInfoInboundInfo,
|
|
player *player.Player) (result *model.PetInfo,
|
|
err errorcode.ErrorCode) {
|
|
_, petInfo, found := player.FindPet(data.CatchTime)
|
|
if found {
|
|
result = petInfo
|
|
return result, 0
|
|
}
|
|
|
|
ret := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
|
if ret == nil {
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
}
|
|
|
|
result = &ret.Data
|
|
return result, 0
|
|
}
|
|
|
|
// GetUserBagPetInfo 获取主背包和并列备用精灵列表
|
|
func (h Controller) GetUserBagPetInfo(
|
|
data *GetUserBagPetInfoInboundEmpty,
|
|
player *player.Player) (result *pet.GetUserBagPetInfoOutboundInfo,
|
|
err errorcode.ErrorCode) {
|
|
return player.GetUserBagPetInfo(), 0
|
|
}
|
|
|
|
// GetPetListInboundEmpty 定义请求或响应数据结构。
|
|
type GetPetListInboundEmpty struct {
|
|
Head common.TomeeHeader `cmd:"2303" struc:"skip"`
|
|
}
|
|
|
|
// GetPetList 获取当前主背包列表
|
|
func (h Controller) GetPetList(
|
|
data *GetPetListInboundEmpty,
|
|
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
|
err errorcode.ErrorCode) {
|
|
return buildPetListOutboundInfo(player.Info.PetList), 0
|
|
}
|
|
|
|
// GetPetListFreeInboundEmpty 定义请求或响应数据结构。
|
|
type GetPetListFreeInboundEmpty struct {
|
|
Head common.TomeeHeader `cmd:"2320" struc:"skip"`
|
|
}
|
|
|
|
// GetPetReleaseList 获取仓库可放生列表
|
|
func (h Controller) GetPetReleaseList(
|
|
data *GetPetListFreeInboundEmpty,
|
|
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
|
err errorcode.ErrorCode) {
|
|
|
|
return buildPetListOutboundInfo(player.WarehousePetList()), 0
|
|
}
|
|
|
|
// PlayerShowPet 精灵展示
|
|
func (h Controller) PlayerShowPet(
|
|
data *PetShowInboundInfo,
|
|
player *player.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &pet.PetShowOutboundInfo{
|
|
UserID: data.Head.UserID,
|
|
CatchTime: data.CatchTime,
|
|
Flag: data.Flag,
|
|
}
|
|
|
|
_, currentPet, ok := player.FindPet(data.CatchTime)
|
|
if data.Flag == 0 {
|
|
player.SetPetDisplay(0, nil)
|
|
player.GetSpace().RefreshUserInfo(player)
|
|
defer player.GetSpace().Broadcast(player, data.Head.CMD, result)
|
|
return
|
|
}
|
|
|
|
if !ok {
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
}
|
|
|
|
player.SetPetDisplay(data.Flag, currentPet)
|
|
player.GetSpace().RefreshUserInfo(player)
|
|
result = buildPetShowOutboundInfo(data.Head.UserID, data.Flag, currentPet)
|
|
defer player.GetSpace().Broadcast(player, data.Head.CMD, result)
|
|
return
|
|
}
|