|
|
|
|
@ -807,6 +807,12 @@ defer { |
|
|
|
|
return teams + waitingListTeams(in: teams) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func waitingListSortedTeams() -> [TeamRegistration] { |
|
|
|
|
let teams = selectedSortedTeams() |
|
|
|
|
return waitingListTeams(in: teams) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func selectedSortedTeams() -> [TeamRegistration] { |
|
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
|
let start = Date() |
|
|
|
|
@ -875,7 +881,7 @@ defer { |
|
|
|
|
return waitingList.filter { $0.walkOut == false }.sorted(using: _defaultSorting(), order: .ascending) + waitingList.filter { $0.walkOut == true }.sorted(using: _defaultSorting(), order: .ascending) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func bracketCut() -> Int { |
|
|
|
|
func bracketCut(teamCount: Int) -> Int { |
|
|
|
|
return max(0, teamCount - groupStageCut()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -883,10 +889,12 @@ defer { |
|
|
|
|
return groupStageSpots() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cutLabel(index: Int) -> String { |
|
|
|
|
if index < bracketCut() { |
|
|
|
|
func cutLabel(index: Int, teamCount: Int?) -> String { |
|
|
|
|
let _teamCount = teamCount ?? selectedSortedTeams().count |
|
|
|
|
let bracketCut = bracketCut(teamCount: _teamCount) |
|
|
|
|
if index < bracketCut { |
|
|
|
|
return "Tableau" |
|
|
|
|
} else if index - bracketCut() < groupStageCut() { |
|
|
|
|
} else if index - bracketCut < groupStageCut() && _teamCount > 0 { |
|
|
|
|
return "Poule" |
|
|
|
|
} else { |
|
|
|
|
return "Attente" |
|
|
|
|
@ -1543,7 +1551,7 @@ defer { |
|
|
|
|
|
|
|
|
|
var _groupStages = [GroupStage]() |
|
|
|
|
for index in 0..<groupStageCount { |
|
|
|
|
let groupStage = GroupStage(tournament: id, index: index, size: teamsPerGroupStage, matchFormat: groupStageMatchFormat) |
|
|
|
|
let groupStage = GroupStage(tournament: id, index: index, size: teamsPerGroupStage, matchFormat: groupStageSmartMatchFormat()) |
|
|
|
|
_groupStages.append(groupStage) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1566,7 +1574,7 @@ defer { |
|
|
|
|
let roundCount = RoundRule.numberOfRounds(forTeams: bracketTeamCount()) |
|
|
|
|
|
|
|
|
|
let rounds = (0..<roundCount).map { //index 0 is the final |
|
|
|
|
Round(tournament: id, index: $0) |
|
|
|
|
return Round(tournament: id, index: $0, matchFormat: roundSmartMatchFormat($0)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
@ -1579,7 +1587,7 @@ defer { |
|
|
|
|
let matches = (0..<matchCount).map { //0 is final match |
|
|
|
|
let roundIndex = RoundRule.roundIndex(fromMatchIndex: $0) |
|
|
|
|
let round = rounds[roundIndex] |
|
|
|
|
return Match(round: round.id, index: $0, matchFormat: matchFormat, name: Match.setServerTitle(upperRound: round, matchIndex: RoundRule.matchIndexWithinRound(fromMatchIndex: $0))) |
|
|
|
|
return Match(round: round.id, index: $0, matchFormat: round.matchFormat, name: Match.setServerTitle(upperRound: round, matchIndex: RoundRule.matchIndexWithinRound(fromMatchIndex: $0))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
print(matches.map { |
|
|
|
|
@ -1783,7 +1791,7 @@ defer { |
|
|
|
|
teamSorting = newValue.defaultTeamSortingType |
|
|
|
|
groupStageMatchFormat = groupStageSmartMatchFormat() |
|
|
|
|
loserBracketMatchFormat = loserBracketSmartMatchFormat(1) |
|
|
|
|
matchFormat = roundSmartMatchFormat(1) |
|
|
|
|
matchFormat = roundSmartMatchFormat(5) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|