|
|
|
|
@ -361,6 +361,7 @@ defer { |
|
|
|
|
public func availableSeedOpponentSpot(inRoundIndex roundIndex: Int) -> [Match] { |
|
|
|
|
return getRound(atRoundIndex: roundIndex)?.playedMatches().filter { $0.hasSpaceLeft() } ?? [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func availableSeedGroups(includeAll: Bool = false) -> [SeedInterval] { |
|
|
|
|
let seeds = seeds() |
|
|
|
|
var availableSeedGroup = Set<SeedInterval>() |
|
|
|
|
@ -378,6 +379,24 @@ defer { |
|
|
|
|
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>) { |
|
|
|
|
chunks.forEach { chunk in |
|
|
|
|
availableSeedGroup.insert(chunk) |
|
|
|
|
@ -1678,11 +1697,11 @@ defer { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func initSettings(templateTournament: Tournament?) { |
|
|
|
|
public func initSettings(templateTournament: Tournament?, overrideTeamCount: Bool = true) { |
|
|
|
|
setupDefaultPrivateSettings(templateTournament: templateTournament) |
|
|
|
|
setupUmpireSettings(defaultTournament: nil) //default is not template, default is for event sharing settings |
|
|
|
|
if let templateTournament { |
|
|
|
|
setupRegistrationSettings(templateTournament: templateTournament) |
|
|
|
|
setupRegistrationSettings(templateTournament: templateTournament, overrideTeamCount: overrideTeamCount) |
|
|
|
|
} |
|
|
|
|
setupFederalSettings() |
|
|
|
|
} |
|
|
|
|
@ -1755,7 +1774,7 @@ defer { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func setupRegistrationSettings(templateTournament: Tournament) { |
|
|
|
|
public func setupRegistrationSettings(templateTournament: Tournament, overrideTeamCount: Bool = true) { |
|
|
|
|
self.enableOnlineRegistration = templateTournament.enableOnlineRegistration |
|
|
|
|
self.unregisterDeltaInHours = templateTournament.unregisterDeltaInHours |
|
|
|
|
self.accountIsRequired = templateTournament.accountIsRequired |
|
|
|
|
@ -1764,7 +1783,9 @@ defer { |
|
|
|
|
self.maximumPlayerPerTeam = templateTournament.maximumPlayerPerTeam |
|
|
|
|
self.waitingListLimit = templateTournament.waitingListLimit |
|
|
|
|
self.teamCountLimit = templateTournament.teamCountLimit |
|
|
|
|
self.teamCount = templateTournament.teamCount |
|
|
|
|
if overrideTeamCount { |
|
|
|
|
self.teamCount = templateTournament.teamCount |
|
|
|
|
} |
|
|
|
|
self.enableOnlinePayment = templateTournament.enableOnlinePayment |
|
|
|
|
self.onlinePaymentIsMandatory = templateTournament.onlinePaymentIsMandatory |
|
|
|
|
self.enableOnlinePaymentRefund = templateTournament.enableOnlinePaymentRefund |
|
|
|
|
|