|
|
|
|
@ -22,49 +22,6 @@ struct RoundSettingsView: View { |
|
|
|
|
List { |
|
|
|
|
Toggle("Éditer les têtes de série", isOn: $isEditingTournamentSeed) |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Effacer classement", role: .destructive) { |
|
|
|
|
tournament.rounds().forEach { round in |
|
|
|
|
try? dataStore.rounds.delete(contentOfs: round.loserRounds()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Match de classement") { |
|
|
|
|
tournament.rounds().forEach { round in |
|
|
|
|
round.buildLoserBracket() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Retirer toutes les têtes de séries", role: .destructive) { |
|
|
|
|
tournament.unsortedTeams().forEach({ $0.bracketPosition = nil }) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
if let lastRound = tournament.rounds().first { // first is final, last round |
|
|
|
|
RowButtonView("Supprimer " + lastRound.roundTitle(), role: .destructive) { |
|
|
|
|
try? dataStore.rounds.delete(instance: lastRound) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
let roundIndex = tournament.rounds().count |
|
|
|
|
RowButtonView("Ajouter " + RoundRule.roundName(fromRoundIndex: roundIndex)) { |
|
|
|
|
let round = Round(tournament: tournament.id, index: roundIndex, matchFormat: tournament.matchFormat) |
|
|
|
|
let matchCount = RoundRule.numberOfMatches(forRoundIndex: roundIndex) |
|
|
|
|
let matchStartIndex = RoundRule.matchIndex(fromRoundIndex: roundIndex) |
|
|
|
|
let matches = (0..<matchCount).map { //0 is final match |
|
|
|
|
return Match(round: round.id, index: $0 + matchStartIndex, matchFormat: round.matchFormat) |
|
|
|
|
} |
|
|
|
|
try? dataStore.rounds.addOrUpdate(instance: round) |
|
|
|
|
try? dataStore.matches.addOrUpdate(contentOfs: matches) |
|
|
|
|
round.buildLoserBracket() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if let availableSeedGroup = tournament.availableSeedGroup() { |
|
|
|
|
Section { |
|
|
|
|
|
|
|
|
|
@ -108,6 +65,55 @@ struct RoundSettingsView: View { |
|
|
|
|
Text("Placement des têtes de série") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Effacer classement", role: .destructive) { |
|
|
|
|
tournament.rounds().forEach { round in |
|
|
|
|
try? dataStore.rounds.delete(contentOfs: round.loserRounds()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Match de classement") { |
|
|
|
|
tournament.rounds().forEach { round in |
|
|
|
|
round.buildLoserBracket() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Retirer toutes les têtes de séries", role: .destructive) { |
|
|
|
|
tournament.unsortedTeams().forEach({ $0.bracketPosition = nil }) |
|
|
|
|
try? dataStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams()) |
|
|
|
|
tournament.allRounds().forEach({ round in |
|
|
|
|
round.enableRound() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
if let lastRound = tournament.rounds().first { // first is final, last round |
|
|
|
|
RowButtonView("Supprimer " + lastRound.roundTitle(), role: .destructive) { |
|
|
|
|
try? dataStore.rounds.delete(instance: lastRound) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
let roundIndex = tournament.rounds().count |
|
|
|
|
RowButtonView("Ajouter " + RoundRule.roundName(fromRoundIndex: roundIndex)) { |
|
|
|
|
let round = Round(tournament: tournament.id, index: roundIndex, matchFormat: tournament.matchFormat) |
|
|
|
|
let matchCount = RoundRule.numberOfMatches(forRoundIndex: roundIndex) |
|
|
|
|
let matchStartIndex = RoundRule.matchIndex(fromRoundIndex: roundIndex) |
|
|
|
|
let matches = (0..<matchCount).map { //0 is final match |
|
|
|
|
return Match(round: round.id, index: $0 + matchStartIndex, matchFormat: round.matchFormat) |
|
|
|
|
} |
|
|
|
|
try? dataStore.rounds.addOrUpdate(instance: round) |
|
|
|
|
try? dataStore.matches.addOrUpdate(contentOfs: matches) |
|
|
|
|
round.buildLoserBracket() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|