|
|
|
@ -1660,31 +1660,32 @@ defer { |
|
|
|
if groupStageCount != numberOfBracketsAsInt { |
|
|
|
if groupStageCount != numberOfBracketsAsInt { |
|
|
|
deleteGroupStages() |
|
|
|
deleteGroupStages() |
|
|
|
buildGroupStages() |
|
|
|
buildGroupStages() |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
let max = groupStages.map { $0.size }.reduce(0,+) |
|
|
|
let max = groupStages.map { $0.size }.reduce(0,+) |
|
|
|
var chunks = selectedSortedTeams().suffix(max).chunked(into: groupStageCount) |
|
|
|
var chunks = selectedSortedTeams().suffix(max).chunked(into: groupStageCount) |
|
|
|
for (index, _) in chunks.enumerated() { |
|
|
|
for (index, _) in chunks.enumerated() { |
|
|
|
if randomize { |
|
|
|
if randomize { |
|
|
|
chunks[index].shuffle() |
|
|
|
chunks[index].shuffle() |
|
|
|
} else if index % 2 != 0 { |
|
|
|
} else if index % 2 != 0 { |
|
|
|
chunks[index].reverse() |
|
|
|
chunks[index].reverse() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
print("Equipes \(chunks[index].map { $0.weight })") |
|
|
|
print("Equipes \(chunks[index].map { $0.weight })") |
|
|
|
for (jIndex, _) in chunks[index].enumerated() { |
|
|
|
for (jIndex, _) in chunks[index].enumerated() { |
|
|
|
print("Position \(index + 1) Poule \(groupStages[jIndex].index)") |
|
|
|
print("Position \(index + 1) Poule \(groupStages[jIndex].index)") |
|
|
|
chunks[index][jIndex].groupStage = groupStages[jIndex].id |
|
|
|
chunks[index][jIndex].groupStage = groupStages[jIndex].id |
|
|
|
chunks[index][jIndex].groupStagePosition = index |
|
|
|
chunks[index][jIndex].groupStagePosition = index |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
do { |
|
|
|
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams()) |
|
|
|
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams()) |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
groupStages.forEach { $0.buildMatches() } |
|
|
|
} |
|
|
|
} |
|
|
|
groupStages.forEach { $0.buildMatches() } |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|