refactor: 重构宠物仓库列表获取逻辑
This commit is contained in:
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/player/model"
|
||||
@@ -43,13 +44,17 @@ func (h Controller) GetPetList(
|
||||
return buildPetListOutboundInfo(player.Info.PetList), 0
|
||||
}
|
||||
|
||||
type GetPetListFreeInboundEmpty struct {
|
||||
Head common.TomeeHeader `cmd:"2320" struc:"skip"`
|
||||
}
|
||||
|
||||
// GetPetReleaseList 获取仓库可放生列表
|
||||
func (h Controller) GetPetReleaseList(
|
||||
data *pet.GetPetListFreeInboundEmpty,
|
||||
data *GetPetListFreeInboundEmpty,
|
||||
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
||||
err errorcode.ErrorCode) {
|
||||
|
||||
return buildPetListOutboundInfo(buildWarehousePetList(player)), 0
|
||||
return buildPetListOutboundInfo(player.WarehousePetList()), 0
|
||||
}
|
||||
|
||||
// PlayerShowPet 精灵展示
|
||||
|
||||
@@ -88,23 +88,7 @@ func buildPetInfoMap(petLists ...[]model.PetInfo) map[uint32]model.PetInfo {
|
||||
return petMap
|
||||
}
|
||||
|
||||
func buildWarehousePetList(player *player.Player) []model.PetInfo {
|
||||
allPets := player.Service.Pet.PetInfo(0)
|
||||
if len(allPets) == 0 {
|
||||
return make([]model.PetInfo, 0)
|
||||
}
|
||||
|
||||
usedCatchTimes := buildCatchTimeSet(player.Info.PetList, player.Info.BackupPetList)
|
||||
result := make([]model.PetInfo, 0, len(allPets))
|
||||
for i := range allPets {
|
||||
catchTime := allPets[i].Data.CatchTime
|
||||
if _, exists := usedCatchTimes[catchTime]; exists {
|
||||
continue
|
||||
}
|
||||
result = append(result, allPets[i].Data)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func findBackupPet(player *player.Player, catchTime uint32) (int, *model.PetInfo, bool) {
|
||||
for i := range player.Info.BackupPetList {
|
||||
|
||||
Reference in New Issue
Block a user