|
|
|
|
@ -102,6 +102,7 @@ struct MatchSetupView: View { |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if let tournament = match.currentTournament() { |
|
|
|
|
let availableQualifiedTeams = tournament.availableQualifiedTeams() |
|
|
|
|
let availableSeedGroups = tournament.availableSeedGroups() |
|
|
|
|
Text("ou") |
|
|
|
|
Menu { |
|
|
|
|
@ -119,6 +120,27 @@ struct MatchSetupView: View { |
|
|
|
|
Label("Repêchage", systemImage: "dice") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if availableQualifiedTeams.isEmpty == false { |
|
|
|
|
Button { |
|
|
|
|
if let randomTeam = availableQualifiedTeams.randomElement() { |
|
|
|
|
randomTeam.setSeedPosition(inSpot: match, slot: teamPosition, opposingSeeding: false) |
|
|
|
|
do { |
|
|
|
|
try tournamentStore.matches.addOrUpdate(instance: match) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
do { |
|
|
|
|
try tournamentStore.teamRegistrations.addOrUpdate(instance: randomTeam) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Label("Qualifié sortant", systemImage: "dice") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ForEach(availableSeedGroups, id: \.self) { seedGroup in |
|
|
|
|
Button { |
|
|
|
|
if let randomTeam = tournament.randomSeed(fromSeedGroup: seedGroup) { |
|
|
|
|
@ -142,7 +164,7 @@ struct MatchSetupView: View { |
|
|
|
|
Text("Tirer au sort").tag(nil as SeedInterval?) |
|
|
|
|
.underline() |
|
|
|
|
} |
|
|
|
|
.disabled(availableSeedGroups.isEmpty && walkOutSpot == false) |
|
|
|
|
.disabled(availableSeedGroups.isEmpty && walkOutSpot == false && availableQualifiedTeams.isEmpty) |
|
|
|
|
Spacer() |
|
|
|
|
if match.isSeedLocked(atTeamPosition: teamPosition) { |
|
|
|
|
Button { |
|
|
|
|
|