From fbd730eae69f5c4da129d7bf9b5d96763f36d9e0 Mon Sep 17 00:00:00 2001 From: Raz Date: Wed, 26 Mar 2025 06:21:28 +0100 Subject: [PATCH] fix issue with ts setup --- PadelClub/Data/Tournament.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 + } + } } } }