This commit is contained in:
@@ -87,6 +87,14 @@ type C2S_RoomPetInfo struct {
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
}
|
||||
|
||||
// C2S_RoomPetShowToggle 基地展示精灵添加/移除请求
|
||||
type C2S_RoomPetShowToggle struct {
|
||||
Head common.TomeeHeader `cmd:"2326" struc:"skip"`
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
PetID uint32 `json:"petID"`
|
||||
Flag uint32 `json:"flag"` // 1=添加展示, 0=移除展示
|
||||
}
|
||||
|
||||
// C2S_BUY_FITMENT 定义请求或响应数据结构。
|
||||
type C2S_BUY_FITMENT struct {
|
||||
Head common.TomeeHeader `cmd:"10004" struc:"skip"`
|
||||
|
||||
@@ -85,18 +85,17 @@ func (h Controller) PlayerShowPet(
|
||||
return
|
||||
}
|
||||
|
||||
// 仅允许仓库精灵展示:背包中的精灵直接拒绝
|
||||
if _, ok := player.FindPetBagSlot(data.CatchTime); ok {
|
||||
// 仅允许背包精灵跟随:仓库中的精灵不允许跟随
|
||||
slot, found := player.FindPetBagSlot(data.CatchTime)
|
||||
if !found {
|
||||
return nil, errorcode.ErrorCodes.ErrCannotShowBagPokemon
|
||||
}
|
||||
|
||||
ret := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
||||
if ret == nil {
|
||||
currentPet := slot.PetInfoPtr()
|
||||
if currentPet == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
currentPet := &ret.Data
|
||||
|
||||
player.SetPetDisplay(data.Flag, currentPet)
|
||||
player.GetSpace().RefreshUserInfo(player)
|
||||
result = buildPetShowOutboundInfo(data.Head.UserID, data.Flag, currentPet)
|
||||
|
||||
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/player/model"
|
||||
"blazing/modules/player/service"
|
||||
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
@@ -32,17 +33,11 @@ func (h Controller) GetFitmentUsing(data *FitmentUseringInboundInfo, c *player.P
|
||||
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
|
||||
}
|
||||
showPets := service.NewPetService(data.TargetUserID).GetShowPets()
|
||||
for i := range showPets {
|
||||
var petShortInfo pet.PetShortInfo
|
||||
copier.Copy(&petShortInfo, &petInfo.Data)
|
||||
if petInfo.ID != 0 {
|
||||
result.Pets = append(result.Pets, petShortInfo)
|
||||
}
|
||||
copier.Copy(&petShortInfo, &showPets[i].Data)
|
||||
result.Pets = append(result.Pets, petShortInfo)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/room"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
// SetFitment 设置基地家具摆放
|
||||
@@ -18,29 +15,3 @@ func (h Controller) SetFitment(data *SET_FITMENT, c *player.Player) (result *roo
|
||||
c.Service.Room.Set(data.Fitments)
|
||||
return
|
||||
}
|
||||
|
||||
// SetPet 设置基地展示的精灵
|
||||
// data: 包含精灵展示列表的输入信息
|
||||
// c: 当前玩家对象
|
||||
// 返回: 精灵展示列表和错误码
|
||||
func (h Controller) SetPet(data *C2S_PET_ROOM_SHOW, c *player.Player) (result *room.S2C_PET_ROOM_SHOW, err errorcode.ErrorCode) {
|
||||
var showPetCatchTimes []uint32
|
||||
for _, petShowInfo := range data.PetShowList {
|
||||
if petShowInfo.CatchTime != 0 {
|
||||
showPetCatchTimes = append(showPetCatchTimes, petShowInfo.CatchTime)
|
||||
}
|
||||
}
|
||||
c.Service.Room.Show(showPetCatchTimes)
|
||||
result = &room.S2C_PET_ROOM_SHOW{}
|
||||
result.PetShowList = make([]pet.PetShortInfo, 0, len(showPetCatchTimes))
|
||||
for _, catchTime := range showPetCatchTimes {
|
||||
petInfo := c.Service.Pet.PetInfoOneByCatchTime(catchTime)
|
||||
if petInfo == nil {
|
||||
continue
|
||||
}
|
||||
var petShortInfo pet.PetShortInfo
|
||||
copier.Copy(&petShortInfo, &petInfo.Data)
|
||||
result.PetShowList = append(result.PetShowList, petShortInfo)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user