|
|
|
|
@ -11,36 +11,6 @@ import PadelClubData |
|
|
|
|
import LeStorage |
|
|
|
|
|
|
|
|
|
extension Tournament { |
|
|
|
|
|
|
|
|
|
func setupFederalSettings() { |
|
|
|
|
teamSorting = tournamentLevel.defaultTeamSortingType |
|
|
|
|
groupStageMatchFormat = groupStageSmartMatchFormat() |
|
|
|
|
loserBracketMatchFormat = loserBracketSmartMatchFormat(5) |
|
|
|
|
matchFormat = roundSmartMatchFormat(5) |
|
|
|
|
entryFee = tournamentLevel.entryFee |
|
|
|
|
registrationDateLimit = deadline(for: .inscription) |
|
|
|
|
if enableOnlineRegistration, isAnimation() == false { |
|
|
|
|
accountIsRequired = true |
|
|
|
|
licenseIsRequired = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func customizeUsingPreferences() { |
|
|
|
|
guard let lastTournamentWithSameBuild = DataStore.shared.tournaments.filter({ tournament in |
|
|
|
|
tournament.tournamentLevel == self.tournamentLevel |
|
|
|
|
&& tournament.tournamentCategory == self.tournamentCategory |
|
|
|
|
&& tournament.federalTournamentAge == self.federalTournamentAge |
|
|
|
|
&& tournament.hasEnded() == true |
|
|
|
|
&& tournament.isCanceled == false |
|
|
|
|
&& tournament.isDeleted == false |
|
|
|
|
}).sorted(by: \.endDate!, order: .descending).first else { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self.dayDuration = lastTournamentWithSameBuild.dayDuration |
|
|
|
|
self.teamCount = (lastTournamentWithSameBuild.teamCount / 2) * 2 |
|
|
|
|
self.enableOnlineRegistration = lastTournamentWithSameBuild.enableOnlineRegistration |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func addTeam(_ players: Set<PlayerRegistration>, registrationDate: Date? = nil, name: String? = nil) -> TeamRegistration { |
|
|
|
|
let team = TeamRegistration(tournament: id, registrationDate: registrationDate ?? Date(), name: name) |
|
|
|
|
|