|
|
|
@ -345,6 +345,7 @@ defer { |
|
|
|
public func availableSeedOpponentSpot(inRoundIndex roundIndex: Int) -> [Match] { |
|
|
|
public func availableSeedOpponentSpot(inRoundIndex roundIndex: Int) -> [Match] { |
|
|
|
return getRound(atRoundIndex: roundIndex)?.playedMatches().filter { $0.hasSpaceLeft() } ?? [] |
|
|
|
return getRound(atRoundIndex: roundIndex)?.playedMatches().filter { $0.hasSpaceLeft() } ?? [] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public func availableSeedGroups(includeAll: Bool = false) -> [SeedInterval] { |
|
|
|
public func availableSeedGroups(includeAll: Bool = false) -> [SeedInterval] { |
|
|
|
let seeds = seeds() |
|
|
|
let seeds = seeds() |
|
|
|
var availableSeedGroup = Set<SeedInterval>() |
|
|
|
var availableSeedGroup = Set<SeedInterval>() |
|
|
|
@ -362,6 +363,24 @@ defer { |
|
|
|
return availableSeedGroup.sorted(by: <) |
|
|
|
return availableSeedGroup.sorted(by: <) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public func generateSeedGroups(base: Int, teamCount: Int) -> [SeedInterval] { |
|
|
|
|
|
|
|
let start = base + 1 |
|
|
|
|
|
|
|
let root = SeedInterval(first: start, last: start + teamCount - 1) |
|
|
|
|
|
|
|
var groups: [SeedInterval] = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func split(interval: SeedInterval) { |
|
|
|
|
|
|
|
groups.append(interval) |
|
|
|
|
|
|
|
if let chunks = interval.chunks() { |
|
|
|
|
|
|
|
for chunk in chunks { |
|
|
|
|
|
|
|
split(interval: chunk) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
split(interval: root) |
|
|
|
|
|
|
|
return groups.sorted(by: <) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public func chunksBy(in chunks: [SeedInterval], availableSeedGroup: inout Set<SeedInterval>) { |
|
|
|
public func chunksBy(in chunks: [SeedInterval], availableSeedGroup: inout Set<SeedInterval>) { |
|
|
|
chunks.forEach { chunk in |
|
|
|
chunks.forEach { chunk in |
|
|
|
availableSeedGroup.insert(chunk) |
|
|
|
availableSeedGroup.insert(chunk) |
|
|
|
|