2025-08-20 22:50:55 +08:00
|
|
|
package controller
|
2025-08-24 17:33:19 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2026-04-05 05:32:39 +08:00
|
|
|
"blazing/logic/service/common"
|
2025-08-24 17:33:19 +08:00
|
|
|
"blazing/logic/service/pet"
|
2026-04-15 00:07:36 +08:00
|
|
|
playersvc "blazing/logic/service/player"
|
2026-03-31 09:19:36 +08:00
|
|
|
"blazing/modules/player/model"
|
2025-08-24 17:33:19 +08:00
|
|
|
)
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
// GetPetInfo 获取精灵信息
|
|
|
|
|
func (h Controller) GetPetInfo(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *GetPetInfoInboundInfo,
|
2026-04-15 00:07:36 +08:00
|
|
|
player *playersvc.Player) (result *model.PetInfo,
|
2025-12-24 19:03:11 +08:00
|
|
|
err errorcode.ErrorCode) {
|
2026-04-15 00:07:36 +08:00
|
|
|
levelLimit := player.CurrentMapPetLevelLimit()
|
2026-04-14 00:43:32 +08:00
|
|
|
if slot, found := player.FindPetBagSlot(data.CatchTime); found {
|
|
|
|
|
if petInfo := slot.PetInfoPtr(); petInfo != nil {
|
2026-04-15 00:07:36 +08:00
|
|
|
petCopy := playersvc.ApplyPetLevelLimit(*petInfo, levelLimit)
|
|
|
|
|
result = &petCopy
|
2026-04-14 00:43:32 +08:00
|
|
|
return result, 0
|
|
|
|
|
}
|
2025-09-11 02:44:21 +08:00
|
|
|
}
|
2026-04-03 00:02:34 +08:00
|
|
|
|
2026-03-26 04:51:36 +08:00
|
|
|
ret := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
2026-01-20 16:01:15 +00:00
|
|
|
if ret == nil {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
2026-04-03 00:02:34 +08:00
|
|
|
|
2026-04-15 00:07:36 +08:00
|
|
|
petData := ret.Data
|
|
|
|
|
petData = playersvc.ApplyPetLevelLimit(petData, levelLimit)
|
|
|
|
|
result = &petData
|
2025-09-11 02:44:21 +08:00
|
|
|
return result, 0
|
2025-08-30 21:59:52 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-02 02:33:05 +08:00
|
|
|
// GetUserBagPetInfo 获取主背包和并列备用精灵列表
|
|
|
|
|
func (h Controller) GetUserBagPetInfo(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *GetUserBagPetInfoInboundEmpty,
|
2026-04-15 00:07:36 +08:00
|
|
|
player *playersvc.Player) (result *pet.GetUserBagPetInfoOutboundInfo,
|
2026-04-02 02:33:05 +08:00
|
|
|
err errorcode.ErrorCode) {
|
2026-04-15 00:07:36 +08:00
|
|
|
return player.GetUserBagPetInfo(player.CurrentMapPetLevelLimit()), 0
|
2026-04-05 05:47:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 23:13:06 +08:00
|
|
|
// GetPetListInboundEmpty 定义请求或响应数据结构。
|
2026-04-05 05:47:25 +08:00
|
|
|
type GetPetListInboundEmpty struct {
|
|
|
|
|
Head common.TomeeHeader `cmd:"2303" struc:"skip"`
|
2026-04-02 02:33:05 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-03 00:02:34 +08:00
|
|
|
// GetPetList 获取当前主背包列表
|
2025-12-24 19:03:11 +08:00
|
|
|
func (h Controller) GetPetList(
|
2026-04-05 05:47:25 +08:00
|
|
|
data *GetPetListInboundEmpty,
|
2026-04-15 00:07:36 +08:00
|
|
|
player *playersvc.Player) (result *pet.GetPetListOutboundInfo,
|
2025-12-24 19:03:11 +08:00
|
|
|
err errorcode.ErrorCode) {
|
2026-04-02 02:33:05 +08:00
|
|
|
return buildPetListOutboundInfo(player.Info.PetList), 0
|
2025-09-01 01:03:46 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 23:13:06 +08:00
|
|
|
// GetPetListFreeInboundEmpty 定义请求或响应数据结构。
|
2026-04-05 05:32:39 +08:00
|
|
|
type GetPetListFreeInboundEmpty struct {
|
|
|
|
|
Head common.TomeeHeader `cmd:"2320" struc:"skip"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 00:02:34 +08:00
|
|
|
// GetPetReleaseList 获取仓库可放生列表
|
2025-12-24 19:03:11 +08:00
|
|
|
func (h Controller) GetPetReleaseList(
|
2026-04-05 05:32:39 +08:00
|
|
|
data *GetPetListFreeInboundEmpty,
|
2026-04-15 00:07:36 +08:00
|
|
|
player *playersvc.Player) (result *pet.GetPetListOutboundInfo,
|
2025-12-24 19:03:11 +08:00
|
|
|
err errorcode.ErrorCode) {
|
2026-04-05 05:24:55 +08:00
|
|
|
|
2026-04-05 05:32:39 +08:00
|
|
|
return buildPetListOutboundInfo(player.WarehousePetList()), 0
|
2025-11-24 11:56:20 +08:00
|
|
|
}
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
// PlayerShowPet 精灵展示
|
|
|
|
|
func (h Controller) PlayerShowPet(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *PetShowInboundInfo,
|
2026-04-15 00:07:36 +08:00
|
|
|
player *playersvc.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) {
|
2026-04-01 02:48:09 +08:00
|
|
|
result = &pet.PetShowOutboundInfo{
|
|
|
|
|
UserID: data.Head.UserID,
|
|
|
|
|
CatchTime: data.CatchTime,
|
|
|
|
|
Flag: data.Flag,
|
|
|
|
|
}
|
2025-09-11 01:07:00 +08:00
|
|
|
|
2026-04-01 02:48:09 +08:00
|
|
|
if data.Flag == 0 {
|
|
|
|
|
player.SetPetDisplay(0, nil)
|
|
|
|
|
player.GetSpace().RefreshUserInfo(player)
|
2025-12-25 12:21:15 +08:00
|
|
|
defer player.GetSpace().Broadcast(player, data.Head.CMD, result)
|
2026-04-01 02:48:09 +08:00
|
|
|
return
|
2025-09-11 01:07:00 +08:00
|
|
|
}
|
2026-04-01 02:48:09 +08:00
|
|
|
|
2026-04-14 00:43:32 +08:00
|
|
|
slot, ok := player.FindPetBagSlot(data.CatchTime)
|
2026-04-01 02:48:09 +08:00
|
|
|
if !ok {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-14 00:43:32 +08:00
|
|
|
currentPet := slot.PetInfoPtr()
|
|
|
|
|
if currentPet == nil {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 02:48:09 +08:00
|
|
|
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)
|
2025-11-18 20:52:04 +00:00
|
|
|
return
|
2025-09-26 13:33:55 +08:00
|
|
|
}
|