|
|
|
|
@ -156,6 +156,7 @@ enum TournamentDifficulty { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
case unlisted = 0 |
|
|
|
|
case a11_12 = 120 |
|
|
|
|
case a13_14 = 140 |
|
|
|
|
case a15_16 = 160 |
|
|
|
|
@ -187,6 +188,8 @@ enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
var order: Int { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return 7 |
|
|
|
|
case .a11_12: |
|
|
|
|
return 6 |
|
|
|
|
case .a13_14: |
|
|
|
|
@ -206,6 +209,8 @@ enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return displayStyle == .wide ? "Aucune" : "" |
|
|
|
|
case .a11_12: |
|
|
|
|
return "11/12 ans" |
|
|
|
|
case .a13_14: |
|
|
|
|
@ -236,6 +241,7 @@ enum FederalTournamentAge: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
case unlisted = 0 |
|
|
|
|
case p25 = 25 |
|
|
|
|
case p100 = 100 |
|
|
|
|
case p250 = 250 |
|
|
|
|
@ -249,6 +255,15 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
self.init(rawValue: value) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func hideWeight() -> Bool { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return true |
|
|
|
|
default: |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static func mostRecent(inTournaments tournaments: [Tournament]) -> Self { |
|
|
|
|
return tournaments.first?.tournamentLevel ?? .p100 |
|
|
|
|
} |
|
|
|
|
@ -265,15 +280,6 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
var id: Int { self.rawValue } |
|
|
|
|
|
|
|
|
|
func maximumDuration() -> Double { |
|
|
|
|
switch self { |
|
|
|
|
case .p25: |
|
|
|
|
return 0.5 |
|
|
|
|
default: |
|
|
|
|
return 3 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func minimumPlayerRank(category: TournamentCategory, ageCategory: FederalTournamentAge) -> Int { |
|
|
|
|
switch self { |
|
|
|
|
case .p25: |
|
|
|
|
@ -376,6 +382,8 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
var order: Int { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return 7 |
|
|
|
|
case .p25: |
|
|
|
|
return 6 |
|
|
|
|
case .p100: |
|
|
|
|
@ -394,6 +402,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { |
|
|
|
|
if self == .unlisted { return displayStyle == .wide ? "Animation" : "" } |
|
|
|
|
return String(describing: self).capitalized |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -407,6 +416,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func points(for rank: Int, count: Int) -> Int { |
|
|
|
|
if self == .unlisted { return 0 } |
|
|
|
|
let points = points(for: count) |
|
|
|
|
if rank >= points.count { |
|
|
|
|
return points.last! |
|
|
|
|
@ -423,6 +433,8 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
func points(for count: Int) -> [Int] { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return [] |
|
|
|
|
case .p25: |
|
|
|
|
switch count { |
|
|
|
|
case 9...12: |
|
|
|
|
@ -559,7 +571,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
// |
|
|
|
|
func minimumFormatFinalTableAndQualifier(roundIndex: Int) -> MatchFormat? { |
|
|
|
|
switch self { |
|
|
|
|
case .p25: |
|
|
|
|
case .p25, .unlisted: |
|
|
|
|
return nil |
|
|
|
|
case .p100: |
|
|
|
|
return .nineGamesDecisivePoint |
|
|
|
|
@ -588,7 +600,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
func minimumFormatLoserBracket(roundIndex: Int) -> MatchFormat? { |
|
|
|
|
switch self { |
|
|
|
|
case .p25: |
|
|
|
|
case .p25, .unlisted: |
|
|
|
|
return nil |
|
|
|
|
case .p100, .p250, .p500: |
|
|
|
|
return .nineGamesDecisivePoint |
|
|
|
|
@ -632,6 +644,7 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
case men |
|
|
|
|
case women |
|
|
|
|
case mix |
|
|
|
|
case unlisted |
|
|
|
|
|
|
|
|
|
init?(rawValue: Int?) { |
|
|
|
|
guard let value = rawValue else { return nil } |
|
|
|
|
@ -640,6 +653,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
func mandatoryPlayerType() -> [Int] { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return [] |
|
|
|
|
case .mix: |
|
|
|
|
return [0, 1] |
|
|
|
|
case .women: |
|
|
|
|
@ -694,43 +709,25 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var next: TournamentCategory { |
|
|
|
|
switch self { |
|
|
|
|
case .men: |
|
|
|
|
return .women |
|
|
|
|
case .women: |
|
|
|
|
return .mix |
|
|
|
|
case .mix: |
|
|
|
|
return .men |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var id: Int { self.rawValue } |
|
|
|
|
|
|
|
|
|
var sexValue: Int { |
|
|
|
|
switch self { |
|
|
|
|
case .men: |
|
|
|
|
return 1 |
|
|
|
|
case .women: |
|
|
|
|
return 0 |
|
|
|
|
case .mix: |
|
|
|
|
return -1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var order: Int { |
|
|
|
|
switch self { |
|
|
|
|
case .men: |
|
|
|
|
case .unlisted: |
|
|
|
|
return 0 |
|
|
|
|
case .women: |
|
|
|
|
case .men: |
|
|
|
|
return 1 |
|
|
|
|
case .mix: |
|
|
|
|
case .women: |
|
|
|
|
return 2 |
|
|
|
|
case .mix: |
|
|
|
|
return 3 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var buildLabel: String { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return "-" |
|
|
|
|
case .men: |
|
|
|
|
return "H" |
|
|
|
|
case .women: |
|
|
|
|
@ -742,6 +739,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
var requestLabel: String { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return "-" |
|
|
|
|
case .men: |
|
|
|
|
return "DM" |
|
|
|
|
case .women: |
|
|
|
|
@ -753,6 +752,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
var importingRawValue: String { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return "-" |
|
|
|
|
case .men: |
|
|
|
|
return "messieurs" |
|
|
|
|
case .women: |
|
|
|
|
@ -764,6 +765,8 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
|
|
|
|
|
func localizedLabel(_ displayStyle: DisplayStyle = .wide) -> String { |
|
|
|
|
switch self { |
|
|
|
|
case .unlisted: |
|
|
|
|
return displayStyle == .wide ? "Aucune" : "" |
|
|
|
|
case .men: |
|
|
|
|
return displayStyle == .wide ? "Hommes" : "H" |
|
|
|
|
case .women: |
|
|
|
|
@ -773,20 +776,9 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var rankingDataSourceMale: Bool { |
|
|
|
|
switch self { |
|
|
|
|
case .men: |
|
|
|
|
return true |
|
|
|
|
case .women: |
|
|
|
|
return false |
|
|
|
|
case .mix: |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var playerFilterOption: PlayerFilterOption { |
|
|
|
|
switch self { |
|
|
|
|
case .men: |
|
|
|
|
case .men, .unlisted: |
|
|
|
|
return .all |
|
|
|
|
case .women: |
|
|
|
|
return .female |
|
|
|
|
|