diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index cd458bf..63c88ed 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -489,9 +489,20 @@ defer { }) { return seedGroupAvailable(atRoundIndex: roundIndex, availableSeedGroup: chunk) } else if fullLeftSeeds.count > 1, targetSpots > 1, fullLeftSeeds.count >= targetSpots { - let seeds = seeds() - if let firstIndex = seeds.firstIndex(where: { $0.isSeedable() }) { - return seedGroupAvailable(atRoundIndex: roundIndex, availableSeedGroup: SeedInterval(first: firstIndex + 1, last: firstIndex + targetSpots)) + let currentSeeds = seeds() + if let firstIndex = currentSeeds.firstIndex(where: { $0.isSeedable() }) { + + if firstIndex < seededTeamsCount { + return nil + } else { + let sg = SeedInterval(first: seededTeamsCount + 1, last: seededTeamsCount + targetSpots) + let futureAvailableSeeds = self.seeds(inSeedGroup: sg) + if futureAvailableSeeds.count >= targetSpots { + return seedGroupAvailable(atRoundIndex: roundIndex, availableSeedGroup: sg) + } else { + return nil + } + } } } }