|
|
|
|
@ -51,7 +51,8 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
var shouldVerifyGroupStage: Bool = false |
|
|
|
|
var shouldVerifyBracket: Bool = false |
|
|
|
|
var hideTeamsWeight: Bool = false |
|
|
|
|
|
|
|
|
|
var publishTournament: Bool = false |
|
|
|
|
|
|
|
|
|
@ObservationIgnored |
|
|
|
|
var navigationPath: [Screen] = [] |
|
|
|
|
|
|
|
|
|
@ -96,9 +97,10 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
case _shouldVerifyGroupStage = "shouldVerifyGroupStage" |
|
|
|
|
case _shouldVerifyBracket = "shouldVerifyBracket" |
|
|
|
|
case _hideTeamsWeight = "hideTeamsWeight" |
|
|
|
|
case _publishTournament = "publishTournament" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal init(event: String? = nil, name: String? = nil, startDate: Date = Date(), endDate: Date? = nil, creationDate: Date = Date(), isPrivate: Bool = false, groupStageFormat: MatchFormat? = nil, roundFormat: MatchFormat? = nil, loserRoundFormat: MatchFormat? = nil, groupStageSortMode: GroupStageOrderingMode, groupStageCount: Int = 4, rankSourceDate: Date? = nil, dayDuration: Int = 1, teamCount: Int = 24, teamSorting: TeamSortingType? = nil, federalCategory: TournamentCategory, federalLevelCategory: TournamentLevel, federalAgeCategory: FederalTournamentAge, closedRegistrationDate: Date? = nil, groupStageAdditionalQualified: Int = 0, courtCount: Int = 2, prioritizeClubMembers: Bool = false, qualifiedPerGroupStage: Int = 1, teamsPerGroupStage: Int = 4, entryFee: Double? = nil, additionalEstimationDuration: Int = 0, isDeleted: Bool = false, publishTeams: Bool = false, publishSummons: Bool = false, publishGroupStages: Bool = false, publishBrackets: Bool = false, shouldVerifyBracket: Bool = false, shouldVerifyGroupStage: Bool = false, hideTeamsWeight: Bool = false) { |
|
|
|
|
internal init(event: String? = nil, name: String? = nil, startDate: Date = Date(), endDate: Date? = nil, creationDate: Date = Date(), isPrivate: Bool = false, groupStageFormat: MatchFormat? = nil, roundFormat: MatchFormat? = nil, loserRoundFormat: MatchFormat? = nil, groupStageSortMode: GroupStageOrderingMode, groupStageCount: Int = 4, rankSourceDate: Date? = nil, dayDuration: Int = 1, teamCount: Int = 24, teamSorting: TeamSortingType? = nil, federalCategory: TournamentCategory, federalLevelCategory: TournamentLevel, federalAgeCategory: FederalTournamentAge, closedRegistrationDate: Date? = nil, groupStageAdditionalQualified: Int = 0, courtCount: Int = 2, prioritizeClubMembers: Bool = false, qualifiedPerGroupStage: Int = 1, teamsPerGroupStage: Int = 4, entryFee: Double? = nil, additionalEstimationDuration: Int = 0, isDeleted: Bool = false, publishTeams: Bool = false, publishSummons: Bool = false, publishGroupStages: Bool = false, publishBrackets: Bool = false, shouldVerifyBracket: Bool = false, shouldVerifyGroupStage: Bool = false, hideTeamsWeight: Bool = false, publishTournament: Bool = false) { |
|
|
|
|
self.event = event |
|
|
|
|
self.name = name |
|
|
|
|
self.startDate = startDate |
|
|
|
|
@ -133,6 +135,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
self.shouldVerifyBracket = shouldVerifyBracket |
|
|
|
|
self.shouldVerifyGroupStage = shouldVerifyGroupStage |
|
|
|
|
self.hideTeamsWeight = hideTeamsWeight |
|
|
|
|
self.publishTournament = publishTournament |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
required init(from decoder: Decoder) throws { |
|
|
|
|
@ -174,6 +177,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
shouldVerifyBracket = try container.decodeIfPresent(Bool.self, forKey: ._shouldVerifyBracket) ?? false |
|
|
|
|
shouldVerifyGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._shouldVerifyGroupStage) ?? false |
|
|
|
|
hideTeamsWeight = try container.decodeIfPresent(Bool.self, forKey: ._hideTeamsWeight) ?? false |
|
|
|
|
publishTournament = try container.decodeIfPresent(Bool.self, forKey: ._publishTournament) ?? false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate static let _numberFormatter: NumberFormatter = NumberFormatter() |
|
|
|
|
@ -286,6 +290,7 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
try container.encode(shouldVerifyBracket, forKey: ._shouldVerifyBracket) |
|
|
|
|
try container.encode(shouldVerifyGroupStage, forKey: ._shouldVerifyGroupStage) |
|
|
|
|
try container.encode(hideTeamsWeight, forKey: ._hideTeamsWeight) |
|
|
|
|
try container.encode(publishTournament, forKey: ._publishTournament) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _encodePayment(container: inout KeyedEncodingContainer<CodingKeys>) throws { |
|
|
|
|
@ -378,10 +383,19 @@ class Tournament : ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func publishedTournamentDate() -> Date { |
|
|
|
|
let publishedTournamentDate = Calendar.current.date(byAdding: .day, value: 1, to: creationDate)! |
|
|
|
|
return publishedTournamentDate |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func publishedTeamsDate() -> Date { |
|
|
|
|
startDate |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func isTournamentPublished() -> Bool { |
|
|
|
|
Date() >= publishedTournamentDate() || publishTournament |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func areTeamsPublished() -> Bool { |
|
|
|
|
Date() >= startDate || publishTeams |
|
|
|
|
} |
|
|
|
|
|