|
|
|
@ -531,9 +531,18 @@ class Tournament : ModelObject, Storable { |
|
|
|
selectedSortedTeams().filter({ $0.groupStagePosition != nil }) |
|
|
|
selectedSortedTeams().filter({ $0.groupStagePosition != nil }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func groupStageSpots() -> Int { |
|
|
|
|
|
|
|
let _groupStagesCount = groupStages().count |
|
|
|
|
|
|
|
if groupStageCount != _groupStagesCount { |
|
|
|
|
|
|
|
return groupStageCount * teamsPerGroupStage |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return groupStages().map { $0.size }.reduce(0,+) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func seeds() -> [TeamRegistration] { |
|
|
|
func seeds() -> [TeamRegistration] { |
|
|
|
let selectedSortedTeams = selectedSortedTeams() |
|
|
|
let selectedSortedTeams = selectedSortedTeams() |
|
|
|
let seeds = max(selectedSortedTeams.count - groupStageCount * teamsPerGroupStage, 0) |
|
|
|
let seeds = max(selectedSortedTeams.count - groupStageSpots() , 0) |
|
|
|
return Array(selectedSortedTeams.prefix(seeds)) |
|
|
|
return Array(selectedSortedTeams.prefix(seeds)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -761,8 +770,9 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
|
|
let wcBracket = _teams.filter { $0.wildCardBracket }.sorted(using: _currentSelectionSorting, order: .ascending) |
|
|
|
let wcBracket = _teams.filter { $0.wildCardBracket }.sorted(using: _currentSelectionSorting, order: .ascending) |
|
|
|
|
|
|
|
|
|
|
|
var bracketSeeds = min(teamCount, _completeTeams.count) - groupStageCount * teamsPerGroupStage - wcBracket.count |
|
|
|
let groupStageSpots = groupStageSpots() |
|
|
|
var groupStageTeamCount = groupStageCount * teamsPerGroupStage - wcGroupStage.count |
|
|
|
var bracketSeeds = min(teamCount, _completeTeams.count) - groupStageSpots - wcBracket.count |
|
|
|
|
|
|
|
var groupStageTeamCount = groupStageSpots - wcGroupStage.count |
|
|
|
if groupStageTeamCount < 0 { groupStageTeamCount = 0 } |
|
|
|
if groupStageTeamCount < 0 { groupStageTeamCount = 0 } |
|
|
|
if bracketSeeds < 0 { bracketSeeds = 0 } |
|
|
|
if bracketSeeds < 0 { bracketSeeds = 0 } |
|
|
|
|
|
|
|
|
|
|
|
@ -792,7 +802,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func groupStageCut() -> Int { |
|
|
|
func groupStageCut() -> Int { |
|
|
|
groupStageCount * teamsPerGroupStage |
|
|
|
groupStageSpots() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func cutLabel(index: Int) -> String { |
|
|
|
func cutLabel(index: Int) -> String { |
|
|
|
@ -1299,7 +1309,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
|
|
|
|
|
|
|
func groupStageStatus() async -> String { |
|
|
|
func groupStageStatus() async -> String { |
|
|
|
let groupStageTeamsCount = groupStageTeams().count |
|
|
|
let groupStageTeamsCount = groupStageTeams().count |
|
|
|
if groupStageTeamsCount == 0 || groupStageTeamsCount != teamsPerGroupStage * groupStageCount { |
|
|
|
if groupStageTeamsCount == 0 || groupStageTeamsCount != groupStageSpots() { |
|
|
|
return "à faire" |
|
|
|
return "à faire" |
|
|
|
} |
|
|
|
} |
|
|
|
let runningGroupStages = groupStages().filter({ $0.isRunning() }) |
|
|
|
let runningGroupStages = groupStages().filter({ $0.isRunning() }) |
|
|
|
|