|
|
|
|
@ -39,22 +39,15 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
var finalRanking: Int? |
|
|
|
|
var pointsEarned: Int? |
|
|
|
|
|
|
|
|
|
var unregistered: Bool = false |
|
|
|
|
var unregistrationDate: Date? = nil |
|
|
|
|
|
|
|
|
|
func hasUnregistered() -> Bool { |
|
|
|
|
unregistered |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func hasRegisteredOnline() -> Bool { |
|
|
|
|
players().anySatisfy({ $0.source == .onlineRegistration }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func isOutOfTournament() -> Bool { |
|
|
|
|
walkOut || unregistered |
|
|
|
|
walkOut |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init(tournament: String, groupStage: String? = nil, registrationDate: Date? = nil, callDate: Date? = nil, bracketPosition: Int? = nil, groupStagePosition: Int? = nil, comment: String? = nil, source: String? = nil, sourceValue: String? = nil, logo: String? = nil, name: String? = nil, walkOut: Bool = false, wildCardBracket: Bool = false, wildCardGroupStage: Bool = false, weight: Int = 0, lockedWeight: Int? = nil, confirmationDate: Date? = nil, qualified: Bool = false, finalRanking: Int? = nil, pointsEarned: Int? = nil, unregistered: Bool = false, unregistrationDate: Date? = nil) { |
|
|
|
|
init(tournament: String, groupStage: String? = nil, registrationDate: Date? = nil, callDate: Date? = nil, bracketPosition: Int? = nil, groupStagePosition: Int? = nil, comment: String? = nil, source: String? = nil, sourceValue: String? = nil, logo: String? = nil, name: String? = nil, walkOut: Bool = false, wildCardBracket: Bool = false, wildCardGroupStage: Bool = false, weight: Int = 0, lockedWeight: Int? = nil, confirmationDate: Date? = nil, qualified: Bool = false, finalRanking: Int? = nil, pointsEarned: Int? = nil) { |
|
|
|
|
self.tournament = tournament |
|
|
|
|
self.groupStage = groupStage |
|
|
|
|
self.registrationDate = registrationDate ?? Date() |
|
|
|
|
@ -75,8 +68,6 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
self.qualified = qualified |
|
|
|
|
self.finalRanking = finalRanking |
|
|
|
|
self.pointsEarned = pointsEarned |
|
|
|
|
self.unregistered = unregistered |
|
|
|
|
self.unregistrationDate = unregistrationDate |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
|
@ -333,7 +324,6 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func initialRoundColor() -> Color? { |
|
|
|
|
if unregistered { return Color.black } |
|
|
|
|
if walkOut { return Color.logoRed } |
|
|
|
|
if groupStagePosition != nil { return Color.blue } |
|
|
|
|
if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] { |
|
|
|
|
@ -640,8 +630,6 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
case _qualified = "qualified" |
|
|
|
|
case _finalRanking = "finalRanking" |
|
|
|
|
case _pointsEarned = "pointsEarned" |
|
|
|
|
case _unregistered = "unregistered" |
|
|
|
|
case _unregistrationDate = "unregistrationDate" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init(from decoder: Decoder) throws { |
|
|
|
|
@ -654,7 +642,6 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
wildCardGroupStage = try container.decodeIfPresent(Bool.self, forKey: ._wildCardGroupStage) ?? false |
|
|
|
|
weight = try container.decodeIfPresent(Int.self, forKey: ._weight) ?? 0 |
|
|
|
|
qualified = try container.decodeIfPresent(Bool.self, forKey: ._qualified) ?? false |
|
|
|
|
unregistered = try container.decodeIfPresent(Bool.self, forKey: ._unregistered) ?? false |
|
|
|
|
|
|
|
|
|
// Optional properties |
|
|
|
|
groupStage = try container.decodeIfPresent(String.self, forKey: ._groupStage) |
|
|
|
|
@ -671,7 +658,6 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
confirmationDate = try container.decodeIfPresent(Date.self, forKey: ._confirmationDate) |
|
|
|
|
finalRanking = try container.decodeIfPresent(Int.self, forKey: ._finalRanking) |
|
|
|
|
pointsEarned = try container.decodeIfPresent(Int.self, forKey: ._pointsEarned) |
|
|
|
|
unregistrationDate = try container.decodeIfPresent(Date.self, forKey: ._unregistrationDate) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func encode(to encoder: Encoder) throws { |
|
|
|
|
@ -698,8 +684,6 @@ final class TeamRegistration: ModelObject, Storable { |
|
|
|
|
try container.encode(qualified, forKey: ._qualified) |
|
|
|
|
try container.encode(finalRanking, forKey: ._finalRanking) |
|
|
|
|
try container.encode(pointsEarned, forKey: ._pointsEarned) |
|
|
|
|
try container.encode(unregistered, forKey: ._unregistered) |
|
|
|
|
try container.encode(unregistrationDate, forKey: ._unregistrationDate) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func insertOnServer() { |
|
|
|
|
|