From b3e9c80990ae46e1c88bd3ca3b6c0e145eb9645e Mon Sep 17 00:00:00 2001 From: Raz Date: Thu, 20 Feb 2025 15:57:48 +0100 Subject: [PATCH] fix cut display stuff --- PadelClub/Data/TeamRegistration.swift | 4 +++- PadelClub/Data/Tournament.swift | 20 ++++++++++++-------- PadelClub/InscriptionLegendView.swift | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index e9337af..6744812 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -338,9 +338,11 @@ final class TeamRegistration: ModelObject, Storable { func initialRoundColor() -> Color? { if walkOut { return Color.logoRed } - if groupStagePosition != nil { return Color.blue } + if groupStagePosition != nil || wildCardGroupStage { return Color.blue } if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] { return Color(uiColor: .init(fromHex: colorHex)) + } else if wildCardBracket { + return Color.mint } else { return nil } diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 4470155..2521583 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -925,7 +925,7 @@ defer { let wcBracket = _teams.filter { $0.wildCardBracket }.sorted(using: _currentSelectionSorting, order: .ascending) let groupStageSpots: Int = self.groupStageSpots() - var bracketSeeds: Int = min(teamCount, _teams.count) - groupStageSpots - wcBracket.count + var bracketSeeds: Int = teamCount - groupStageSpots - wcBracket.count var groupStageTeamCount: Int = groupStageSpots - wcGroupStage.count if groupStageTeamCount < 0 { groupStageTeamCount = 0 } if bracketSeeds < 0 { bracketSeeds = 0 } @@ -969,8 +969,8 @@ defer { } } - func bracketCut(teamCount: Int) -> Int { - return max(0, teamCount - groupStageCut()) + func bracketCut(teamCount: Int, groupStageCut: Int) -> Int { + return self.teamCount - groupStageCut } func groupStageCut() -> Int { @@ -979,10 +979,12 @@ defer { func cutLabel(index: Int, teamCount: Int?) -> String { let _teamCount = teamCount ?? selectedSortedTeams().count - let bracketCut = bracketCut(teamCount: _teamCount) + let groupStageCut = groupStageCut() + let bracketCut = bracketCut(teamCount: _teamCount, groupStageCut: groupStageCut) + if index < bracketCut { return "Tableau" - } else if index - bracketCut < groupStageCut() && _teamCount > 0 { + } else if index - bracketCut < groupStageCut && _teamCount > 0 { return "Poule" } else { return "Attente" @@ -992,11 +994,12 @@ defer { func cutLabelColor(index: Int?, teamCount: Int?) -> Color { guard let index else { return Color.gray } let _teamCount = teamCount ?? selectedSortedTeams().count - let bracketCut = bracketCut(teamCount: _teamCount) + let groupStageCut = groupStageCut() + let bracketCut = bracketCut(teamCount: _teamCount, groupStageCut: groupStageCut) if index < bracketCut { return Color.mint - } else if index - bracketCut < groupStageCut() && _teamCount > 0 { - return Color.cyan + } else if index - bracketCut < groupStageCut && _teamCount > 0 { + return Color.indigo } else { return Color.gray } @@ -1858,6 +1861,7 @@ defer { } team.setWeight(from: [], inTournamentCategory: self.tournamentCategory) + team.weight += 200_000 return team } diff --git a/PadelClub/InscriptionLegendView.swift b/PadelClub/InscriptionLegendView.swift index 031e206..9589fc6 100644 --- a/PadelClub/InscriptionLegendView.swift +++ b/PadelClub/InscriptionLegendView.swift @@ -36,7 +36,7 @@ struct InscriptionLegendView: View { Text("Équipe estimée en tableau") .listRowView(isActive: true, color: .mint, hideColorVariation: true, alignment: .leading) Text("Équipe estimée en poule") - .listRowView(isActive: true, color: .cyan, hideColorVariation: true, alignment: .leading) + .listRowView(isActive: true, color: .indigo, hideColorVariation: true, alignment: .leading) }