fix cut display stuff

sync2
Raz 9 months ago
parent 0afde57d8c
commit b3e9c80990
  1. 4
      PadelClub/Data/TeamRegistration.swift
  2. 20
      PadelClub/Data/Tournament.swift
  3. 2
      PadelClub/InscriptionLegendView.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
}

@ -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
}

@ -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)
}

Loading…
Cancel
Save