diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 48092f9..fe0ef7b 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1439,7 +1439,17 @@ defer { } let groupStages = groupStages() - let baseRank = teamCount - groupStageSpots() + qualifiedPerGroupStage * groupStageCount + groupStageAdditionalQualified + var baseRank = teamCount - groupStageSpots() + qualifiedPerGroupStage * groupStageCount + groupStageAdditionalQualified + + //TODO: RAZ ajouté une option pour choisir entre la règle officiel et la règle 'maison' + /* + Request by Philippe Morin 24/03/2025 + */ + let defaultOption = false + + if defaultOption { + baseRank += qualifiedPerGroupStage * groupStageCount + groupStageAdditionalQualified - 1 + } let alreadyPlaceTeams = Array(teams.values.flatMap({ $0 })) groupStages.forEach { groupStage in let groupStageTeams = groupStage.teams(true) @@ -1449,6 +1459,7 @@ defer { let groupStageWidth = max(((index == qualifiedPerGroupStage) ? groupStageCount - groupStageAdditionalQualified : groupStageCount) * (index - qualifiedPerGroupStage), 0) let _index = baseRank + groupStageWidth + 1 - (index > qualifiedPerGroupStage ? groupStageAdditionalQualified : 0) + print("finalRanking", team.teamLabel() , _index, baseRank, groupStageWidth) if let existingTeams = teams[_index] { teams[_index] = existingTeams + [team.id] } else { @@ -2951,7 +2962,7 @@ extension Tournament { func deadline(for type: TournamentDeadlineType) -> Date? { guard [.p500, .p1000, .p1500, .p2000].contains(tournamentLevel) else { return nil } - var daysOffset = type.daysOffset(level: tournamentLevel) + let daysOffset = type.daysOffset(level: tournamentLevel) if let date = Calendar.current.date(byAdding: .day, value: daysOffset, to: startDate) { let startOfDay = Calendar.current.startOfDay(for: date) return Calendar.current.date(byAdding: type.timeOffset, to: startOfDay) diff --git a/PadelClub/Views/Navigation/Agenda/EventListView.swift b/PadelClub/Views/Navigation/Agenda/EventListView.swift index dc869dc..adc4c01 100644 --- a/PadelClub/Views/Navigation/Agenda/EventListView.swift +++ b/PadelClub/Views/Navigation/Agenda/EventListView.swift @@ -312,8 +312,10 @@ struct EventListView: View { TournamentCellView(tournament: tournament) .onReceive(NotificationCenter.default.publisher(for: NSNotification.Name.CollectionDidLoad), perform: { notification in - if let store = notification.object as? StoredCollection, store.id == tournament.id { - tournament.lastTeamRefresh = Date() + if let store = notification.object as? StoredCollection { + if store.storeId == tournament.id { + tournament.lastTeamRefresh = Date() + } } }) diff --git a/PadelClub/Views/Tournament/Screen/TournamentRankView.swift b/PadelClub/Views/Tournament/Screen/TournamentRankView.swift index b3214ca..17c0061 100644 --- a/PadelClub/Views/Tournament/Screen/TournamentRankView.swift +++ b/PadelClub/Views/Tournament/Screen/TournamentRankView.swift @@ -175,7 +175,7 @@ struct TournamentRankView: View { @State var key: Int var body: some View { - VStack(spacing: 0) { + VStack { if editMode?.wrappedValue.isEditing == true { if key > 1 { FooterButtonView("monter") {