This commit is contained in:
@@ -42,6 +42,40 @@ func (h Controller) GetRoomPetShowInfo(data *PetRoomListInboundInfo, c *player.P
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRoomPetShowInfo 设置基地展示精灵并返回最新展示列表(cmd:2323)
|
||||||
|
func (h Controller) SetRoomPetShowInfo(data *C2S_PET_ROOM_SHOW, c *player.Player) (result *room.S2C_PET_ROOM_SHOW, err errorcode.ErrorCode) {
|
||||||
|
result = &room.S2C_PET_ROOM_SHOW{}
|
||||||
|
result.PetShowList = make([]pet.PetShortInfo, 0)
|
||||||
|
|
||||||
|
catchTimes := make([]uint32, 0, len(data.PetShowList))
|
||||||
|
seen := make(map[uint32]struct{}, len(data.PetShowList))
|
||||||
|
for _, item := range data.PetShowList {
|
||||||
|
ct := uint32(item.CatchTime)
|
||||||
|
if ct == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := seen[ct]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seen[ct] = struct{}{}
|
||||||
|
catchTimes = append(catchTimes, ct)
|
||||||
|
}
|
||||||
|
|
||||||
|
petSvc := service.NewPetService(c.Info.UserID)
|
||||||
|
if !petSvc.SetShowCatchTimes(catchTimes) {
|
||||||
|
err = errorcode.ErrorCodes.ErrSystemError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
showPets := petSvc.GetShowPets()
|
||||||
|
for i := range showPets {
|
||||||
|
var petShortInfo pet.PetShortInfo
|
||||||
|
copier.Copy(&petShortInfo, &showPets[i].Data)
|
||||||
|
result.PetShowList = append(result.PetShowList, petShortInfo)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// GetAllFurniture 获取玩家的所有家具
|
// GetAllFurniture 获取玩家的所有家具
|
||||||
// data: 空输入结构
|
// data: 空输入结构
|
||||||
// c: 当前玩家对象
|
// c: 当前玩家对象
|
||||||
|
|||||||
@@ -101,6 +101,27 @@ func (s *PetService) UpdateIsShow(catchTime uint32, isShow int) bool {
|
|||||||
return r > 0
|
return r > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetShowCatchTimes 批量设置基地展示精灵:
|
||||||
|
// 先清空当前玩家的展示状态,再将传入 catchTime 列表置为展示。
|
||||||
|
func (s *PetService) SetShowCatchTimes(catchTimes []uint32) bool {
|
||||||
|
if _, err := s.dbm(s.Model).
|
||||||
|
Where("is_show", 1).
|
||||||
|
Data("is_show", 0).
|
||||||
|
Update(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(catchTimes) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if _, err := s.dbm(s.Model).
|
||||||
|
WhereIn("catch_time", catchTimes).
|
||||||
|
Data("is_show", 1).
|
||||||
|
Update(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (s *PetService) UpdateFree(catchTime, fromFree, toFree uint32) bool {
|
func (s *PetService) UpdateFree(catchTime, fromFree, toFree uint32) bool {
|
||||||
res, err := s.dbm(s.Model).
|
res, err := s.dbm(s.Model).
|
||||||
Where("catch_time", catchTime).
|
Where("catch_time", catchTime).
|
||||||
|
|||||||
Reference in New Issue
Block a user