feat(room): 增加房间宠物信息获取逻辑并优化展示条件

新增 Controller.RoomPetInfo 方法用于获取指定用户的房间宠物详细信息,
同时修复了宠物展示时可能因空数据导致的问题。在设置房间宠物展示和
处理房间装饰时增加对 CatchTime 和 ID
This commit is contained in:
2025-12-13 23:52:16 +08:00
parent 648e963562
commit 6368e2f2e9
4 changed files with 48 additions and 3 deletions

View File

@@ -36,7 +36,9 @@ func (h Controller) OnGetRoomPetShowInfo(data *room.PetRoomListInboundInfo, c *p
}
var pet1 pet.PetShortInfo
copier.Copy(&pet1, &pet12.Data)
result.Pets = append(result.Pets, pet1)
if pet12.ID != 0 {
result.Pets = append(result.Pets, pet1)
}
}
@@ -57,3 +59,12 @@ func (h Controller) OnGetFitmentAll(data *room.FitmentAllInboundEmpty, c *player
return
}
func (h Controller) RoomPetInfo(data *room.C2S_RoomPetInfo, c *player.Player) (result *pet.RoomPetInfo, err errorcode.ErrorCode) {
r := c.Service.Pet.PetInfo_One_ohter(data.UserID, data.CatchTime)
result = &pet.RoomPetInfo{}
copier.CopyWithOption(result, &r.Data, copier.Option{DeepCopy: true})
result.OwnerId = data.UserID
return
}

View File

@@ -20,7 +20,9 @@ func (h Controller) SET_FITMENT(data *room.SET_FITMENT, c *player.Player) (resul
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)
if v.CatchTime != 0 {
showpet = append(showpet, v.CatchTime)
}
}
c.Service.Room.Show(showpet)