|
|
|
|
@ -49,6 +49,10 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
var publishGroupStages: Bool = false |
|
|
|
|
var publishBrackets: Bool = false |
|
|
|
|
|
|
|
|
|
//local |
|
|
|
|
var shouldVerifyGroupStage: Bool = false |
|
|
|
|
var shouldVerifyBracket: Bool = false |
|
|
|
|
|
|
|
|
|
@ObservationIgnored |
|
|
|
|
var navigationPath: [Screen] = [] |
|
|
|
|
|
|
|
|
|
@ -460,7 +464,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func groupStageTeams() -> [TeamRegistration] { |
|
|
|
|
selectedSortedTeams().filter({ $0.bracketPosition == nil && $0.groupStagePosition != nil }) |
|
|
|
|
selectedSortedTeams().filter({ $0.groupStagePosition != nil }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func seeds() -> [TeamRegistration] { |
|
|
|
|
@ -939,7 +943,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
let groupStageTeams = groupStage.teams(true) |
|
|
|
|
for (index, team) in groupStageTeams.enumerated() { |
|
|
|
|
if team.qualified == false { |
|
|
|
|
let groupStageWidth = max(((index == qualifiedPerGroupStage) ? teamsPerGroupStage - groupStageAdditionalQualified : teamsPerGroupStage) * (index - qualifiedPerGroupStage), 0) |
|
|
|
|
let groupStageWidth = max(((index == qualifiedPerGroupStage) ? groupStageCount - groupStageAdditionalQualified : groupStageCount) * (index - qualifiedPerGroupStage), 0) |
|
|
|
|
|
|
|
|
|
let _index = baseRank + groupStageWidth + 1 |
|
|
|
|
if let existingTeams = teams[_index] { |
|
|
|
|
@ -1125,6 +1129,14 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func bracketStatus() -> String { |
|
|
|
|
let availableSeeds = availableSeeds() |
|
|
|
|
if availableSeeds.isEmpty == false { |
|
|
|
|
return "placer \(availableSeeds.count) tête\(availableSeeds.count.pluralSuffix) de série" |
|
|
|
|
} |
|
|
|
|
let availableQualifiedTeams = availableQualifiedTeams() |
|
|
|
|
if availableQualifiedTeams.isEmpty == false { |
|
|
|
|
return "placer \(availableQualifiedTeams.count) qualifié" + availableQualifiedTeams.count.pluralSuffix |
|
|
|
|
} |
|
|
|
|
if let round = getActiveRound() { |
|
|
|
|
return [round.roundTitle(), round.roundStatus()].joined(separator: " ") |
|
|
|
|
} else { |
|
|
|
|
@ -1133,6 +1145,10 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func groupStageStatus() -> String { |
|
|
|
|
let groupStageTeamsCount = groupStageTeams().count |
|
|
|
|
if groupStageTeamsCount == 0 || groupStageTeamsCount != teamsPerGroupStage * groupStageCount { |
|
|
|
|
return "à faire" |
|
|
|
|
} |
|
|
|
|
let runningGroupStages = groupStages().filter({ $0.isRunning() }) |
|
|
|
|
if groupStagesAreOver() { return "terminées" } |
|
|
|
|
if runningGroupStages.isEmpty { |
|
|
|
|
@ -1152,8 +1168,12 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func structureDescriptionLocalizedLabel() -> String { |
|
|
|
|
let groupStageLabel: String? = groupStageCount > 0 ? groupStageCount.formatted() + " poule\(groupStageCount.pluralSuffix)" : nil |
|
|
|
|
return [teamCount.formatted() + " équipes", groupStageLabel].compactMap({ $0 }).joined(separator: ", ") |
|
|
|
|
if state() == .initial { |
|
|
|
|
return "à valider" |
|
|
|
|
} else { |
|
|
|
|
let groupStageLabel: String? = groupStageCount > 0 ? groupStageCount.formatted() + " poule\(groupStageCount.pluralSuffix)" : nil |
|
|
|
|
return [teamCount.formatted() + " équipes", groupStageLabel].compactMap({ $0 }).joined(separator: ", ") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func deleteAndBuildEverything() { |
|
|
|
|
|