From 9c8f88ed45ce0296d268cfe11648e05acef39d64 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Mon, 25 Aug 2025 10:13:21 +0200 Subject: [PATCH 1/3] fix issue with groupstage possible crash when calculating score add the ability to always create a final table structure --- PadelClubData/Data/Match.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PadelClubData/Data/Match.swift b/PadelClubData/Data/Match.swift index 8deb733..60aa3eb 100644 --- a/PadelClubData/Data/Match.swift +++ b/PadelClubData/Data/Match.swift @@ -875,7 +875,7 @@ defer { let endedSetsTwo = teamScoreOtherTeam.score?.components(separatedBy: ",").compactMap({ $0.components(separatedBy: "-").first }).compactMap({ Int($0) }) ?? matchFormat.defaultWalkOutScore(teamScoreOtherTeam.isWalkOut()) var setDifference : Int = 0 let zip = zip(endedSetsOne, endedSetsTwo) - if matchFormat.setsToWin == 1 { + if matchFormat.setsToWin == 1, endedSetsOne.count > 0, endedSetsTwo.count > 0 { setDifference = endedSetsOne[0] - endedSetsTwo[0] } else { setDifference = zip.filter { $0 > $1 }.count - zip.filter { $1 > $0 }.count From 28973c4bcfb30fc8ae5ce5de1468d99e0cae9c86 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 2 Sep 2025 17:24:00 +0200 Subject: [PATCH 2/3] v1.2.48 fix p1000 dates --- PadelClubData/Data/Tournament.swift | 10 ++++++---- PadelClubData/ViewModel/PadelRule.swift | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index d50bb0f..0fab86a 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -1662,11 +1662,11 @@ defer { } } - public func initSettings(templateTournament: Tournament?) { + public func initSettings(templateTournament: Tournament?, overrideTeamCount: Bool = true) { setupDefaultPrivateSettings(templateTournament: templateTournament) setupUmpireSettings(defaultTournament: nil) //default is not template, default is for event sharing settings if let templateTournament { - setupRegistrationSettings(templateTournament: templateTournament) + setupRegistrationSettings(templateTournament: templateTournament, overrideTeamCount: overrideTeamCount) } setupFederalSettings() } @@ -1739,7 +1739,7 @@ defer { } } - public func setupRegistrationSettings(templateTournament: Tournament) { + public func setupRegistrationSettings(templateTournament: Tournament, overrideTeamCount: Bool = true) { self.enableOnlineRegistration = templateTournament.enableOnlineRegistration self.unregisterDeltaInHours = templateTournament.unregisterDeltaInHours self.accountIsRequired = templateTournament.accountIsRequired @@ -1748,7 +1748,9 @@ defer { self.maximumPlayerPerTeam = templateTournament.maximumPlayerPerTeam self.waitingListLimit = templateTournament.waitingListLimit self.teamCountLimit = templateTournament.teamCountLimit - self.teamCount = templateTournament.teamCount + if overrideTeamCount { + self.teamCount = templateTournament.teamCount + } self.enableOnlinePayment = templateTournament.enableOnlinePayment self.onlinePaymentIsMandatory = templateTournament.onlinePaymentIsMandatory self.enableOnlinePaymentRefund = templateTournament.enableOnlinePaymentRefund diff --git a/PadelClubData/ViewModel/PadelRule.swift b/PadelClubData/ViewModel/PadelRule.swift index 2c8a0cb..2c954c8 100644 --- a/PadelClubData/ViewModel/PadelRule.swift +++ b/PadelClubData/ViewModel/PadelRule.swift @@ -2178,7 +2178,7 @@ public enum TournamentDeadlineType: String, CaseIterable { case definitiveBroadcastList = "Publication définitive" public func daysOffset(level: TournamentLevel) -> Int { - if level == .p500 { + if level == .p500 || level == .p1000 { switch self { case .inscription: return -6 From f67f283b5eaf66c4ac3ebb54b1bb17172c54df2d Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Fri, 5 Sep 2025 14:05:40 +0200 Subject: [PATCH 3/3] fix editscoreview yes add menu to change name --- PadelClubData/Data/TeamRegistration.swift | 2 +- PadelClubData/Data/Tournament.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/PadelClubData/Data/TeamRegistration.swift b/PadelClubData/Data/TeamRegistration.swift index 865dfaf..cb3ef5c 100644 --- a/PadelClubData/Data/TeamRegistration.swift +++ b/PadelClubData/Data/TeamRegistration.swift @@ -256,7 +256,7 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable { public func teamLabel( _ displayStyle: DisplayStyle = .wide, twoLines: Bool = false, separator: String = "&" ) -> String { - if let name { return name } + if let name, name.isEmpty == false { return name } return players().map { $0.playerLabel(displayStyle) }.joined( separator: twoLines ? "\n" : " \(separator) ") } diff --git a/PadelClubData/Data/Tournament.swift b/PadelClubData/Data/Tournament.swift index 0fab86a..4d328c2 100644 --- a/PadelClubData/Data/Tournament.swift +++ b/PadelClubData/Data/Tournament.swift @@ -345,6 +345,7 @@ defer { public func availableSeedOpponentSpot(inRoundIndex roundIndex: Int) -> [Match] { return getRound(atRoundIndex: roundIndex)?.playedMatches().filter { $0.hasSpaceLeft() } ?? [] } + public func availableSeedGroups(includeAll: Bool = false) -> [SeedInterval] { let seeds = seeds() var availableSeedGroup = Set() @@ -362,6 +363,24 @@ defer { return availableSeedGroup.sorted(by: <) } + public func generateSeedGroups(base: Int, teamCount: Int) -> [SeedInterval] { + let start = base + 1 + let root = SeedInterval(first: start, last: start + teamCount - 1) + var groups: [SeedInterval] = [] + + func split(interval: SeedInterval) { + groups.append(interval) + if let chunks = interval.chunks() { + for chunk in chunks { + split(interval: chunk) + } + } + } + + split(interval: root) + return groups.sorted(by: <) + } + public func chunksBy(in chunks: [SeedInterval], availableSeedGroup: inout Set) { chunks.forEach { chunk in availableSeedGroup.insert(chunk)