|
|
|
@ -105,6 +105,80 @@ struct GroupStagesView: View { |
|
|
|
allDestinations.append(contentsOf: groupStageDestinations) |
|
|
|
allDestinations.append(contentsOf: groupStageDestinations) |
|
|
|
return allDestinations |
|
|
|
return allDestinations |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func sortedTeams(missingQualifiedFromGroupStages: [TeamRegistration]) -> [GroupStage.TeamGroupStageScore] { |
|
|
|
|
|
|
|
let sortedTeams = missingQualifiedFromGroupStages.compactMap({ team in |
|
|
|
|
|
|
|
team.groupStageObject()?.computedScore(forTeam: team) |
|
|
|
|
|
|
|
}).sorted { (lhs, rhs) in |
|
|
|
|
|
|
|
let predicates: [GroupStage.TeamScoreAreInIncreasingOrder] = [ |
|
|
|
|
|
|
|
{ $0.wins < $1.wins }, |
|
|
|
|
|
|
|
{ $0.setDifference < $1.setDifference }, |
|
|
|
|
|
|
|
{ $0.gameDifference < $1.gameDifference}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for predicate in predicates { |
|
|
|
|
|
|
|
if !predicate(lhs, rhs) && !predicate(rhs, lhs) { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return predicate(lhs, rhs) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return sortedTeams |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _sortedAdditionnalTeams(missingQualifiedFromGroupStages: [TeamRegistration]) -> some View { |
|
|
|
|
|
|
|
Section { |
|
|
|
|
|
|
|
let teamGroupStageScores = self.sortedTeams(missingQualifiedFromGroupStages: missingQualifiedFromGroupStages).reversed() |
|
|
|
|
|
|
|
ForEach(teamGroupStageScores, id: \.team.id) { teamGroupStageScore in |
|
|
|
|
|
|
|
let team = teamGroupStageScore.team |
|
|
|
|
|
|
|
let groupStage = team.groupStageObject()! |
|
|
|
|
|
|
|
let groupStagePosition = team.groupStagePosition! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NavigationLink { |
|
|
|
|
|
|
|
GroupStageTeamView(groupStage: groupStage, team: team) |
|
|
|
|
|
|
|
.environment(self.tournament) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
HStack { |
|
|
|
|
|
|
|
VStack(alignment: .leading) { |
|
|
|
|
|
|
|
if let teamName = team.name, teamName.isEmpty == false { |
|
|
|
|
|
|
|
Text(teamName).foregroundStyle(.secondary).font(.footnote) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ForEach(team.players()) { player in |
|
|
|
|
|
|
|
Text(player.playerLabel()).lineLimit(1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Spacer() |
|
|
|
|
|
|
|
if let score = groupStage.scoreLabel(forGroupStagePosition: groupStagePosition, score: teamGroupStageScore) { |
|
|
|
|
|
|
|
VStack(alignment: .trailing) { |
|
|
|
|
|
|
|
HStack(spacing: 0.0) { |
|
|
|
|
|
|
|
Text(score.wins) |
|
|
|
|
|
|
|
Text("/") |
|
|
|
|
|
|
|
Text(score.losses) |
|
|
|
|
|
|
|
}.font(.headline).monospacedDigit() |
|
|
|
|
|
|
|
if let setsDifference = score.setsDifference { |
|
|
|
|
|
|
|
HStack(spacing: 4.0) { |
|
|
|
|
|
|
|
Text(setsDifference) |
|
|
|
|
|
|
|
}.font(.footnote) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if let gamesDifference = score.gamesDifference { |
|
|
|
|
|
|
|
HStack(spacing: 4.0) { |
|
|
|
|
|
|
|
Text(gamesDifference) |
|
|
|
|
|
|
|
}.font(.footnote) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} header: { |
|
|
|
|
|
|
|
let name = "\((tournament.qualifiedPerGroupStage + 1).ordinalFormatted())" |
|
|
|
|
|
|
|
Text("Meilleurs \(name) de poule") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
VStack(spacing: 0) { |
|
|
|
VStack(spacing: 0) { |
|
|
|
@ -116,9 +190,8 @@ struct GroupStagesView: View { |
|
|
|
List { |
|
|
|
List { |
|
|
|
if tournament.groupStageAdditionalQualified > 0 { |
|
|
|
if tournament.groupStageAdditionalQualified > 0 { |
|
|
|
let missingQualifiedFromGroupStages = tournament.missingQualifiedFromGroupStages() |
|
|
|
let missingQualifiedFromGroupStages = tournament.missingQualifiedFromGroupStages() |
|
|
|
|
|
|
|
let name = "\((tournament.qualifiedPerGroupStage + 1).ordinalFormatted())" |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
let name = "\((tournament.qualifiedPerGroupStage + 1).ordinalFormatted())" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NavigationLink { |
|
|
|
NavigationLink { |
|
|
|
SpinDrawView(drawees: ["Qualification d'un \(name) de poule"], segments: missingQualifiedFromGroupStages) { results in |
|
|
|
SpinDrawView(drawees: ["Qualification d'un \(name) de poule"], segments: missingQualifiedFromGroupStages) { results in |
|
|
|
results.forEach { drawResult in |
|
|
|
results.forEach { drawResult in |
|
|
|
@ -134,6 +207,8 @@ struct GroupStagesView: View { |
|
|
|
Text("Qualifier un \(name) de poule par tirage au sort") |
|
|
|
Text("Qualifier un \(name) de poule par tirage au sort") |
|
|
|
} |
|
|
|
} |
|
|
|
.disabled(tournament.moreQualifiedToDraw() == 0 || missingQualifiedFromGroupStages.isEmpty) |
|
|
|
.disabled(tournament.moreQualifiedToDraw() == 0 || missingQualifiedFromGroupStages.isEmpty) |
|
|
|
|
|
|
|
} header: { |
|
|
|
|
|
|
|
Text("Tirage au sort d'un \(name) de poule") |
|
|
|
} footer: { |
|
|
|
} footer: { |
|
|
|
if tournament.moreQualifiedToDraw() == 0 { |
|
|
|
if tournament.moreQualifiedToDraw() == 0 { |
|
|
|
Text("Aucune équipe supplémentaire à qualifier. Vous pouvez en rajouter en modifier le paramètre dans structure.") |
|
|
|
Text("Aucune équipe supplémentaire à qualifier. Vous pouvez en rajouter en modifier le paramètre dans structure.") |
|
|
|
@ -141,6 +216,8 @@ struct GroupStagesView: View { |
|
|
|
Text("Aucune équipe supplémentaire à tirer au sort. Attendez la fin des poules.") |
|
|
|
Text("Aucune équipe supplémentaire à tirer au sort. Attendez la fin des poules.") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_sortedAdditionnalTeams(missingQualifiedFromGroupStages: missingQualifiedFromGroupStages) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let runningMatches = Tournament.runningMatches(allMatches) |
|
|
|
let runningMatches = Tournament.runningMatches(allMatches) |
|
|
|
|