diff --git a/PadelClub/Utils/PadelRule.swift b/PadelClub/Utils/PadelRule.swift index 81bb541..e69e5ee 100644 --- a/PadelClub/Utils/PadelRule.swift +++ b/PadelClub/Utils/PadelRule.swift @@ -1152,6 +1152,9 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { case twoSetsOfSuperTie case singleSet case singleSetDecisivePoint + case singleSetOfFourGames + case singleSetOfFourGamesDecisivePoint + init?(rawValue: Int?) { guard let value = rawValue else { return nil } @@ -1180,6 +1183,8 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return 6 case .singleSet, .singleSetDecisivePoint: return 7 + case .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: + return 8 } } @@ -1209,6 +1214,8 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return 6 case .singleSet, .singleSetDecisivePoint: return 7 + case .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: + return 8 } } @@ -1224,7 +1231,7 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { } static var allCases: [MatchFormat] { - [.twoSets, .twoSetsDecisivePoint, .twoSetsSuperTie, .twoSetsDecisivePointSuperTie, .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, .nineGames, .nineGamesDecisivePoint, .superTie, .megaTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint] + [.twoSets, .twoSetsDecisivePoint, .twoSetsSuperTie, .twoSetsDecisivePointSuperTie, .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, .nineGames, .nineGamesDecisivePoint, .superTie, .megaTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint, .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint] } func winner(scoreTeamOne: Int, scoreTeamTwo: Int) -> TeamPosition { @@ -1237,7 +1244,7 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { var canSuperTie: Bool { switch self { - case .twoSetsSuperTie, .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, .twoSetsDecisivePointSuperTie: + case .twoSetsSuperTie, .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, .twoSetsDecisivePointSuperTie, .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: return true default: return false @@ -1259,8 +1266,10 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { func formattedEstimatedBreakDuration() -> String { var label = Duration.seconds(breakTime.breakTime * 60).formatted(.units(allowed: [.minutes])) if breakTime.matchCount > 1 { - label += " après \(breakTime.matchCount) match" + label += " de pause après \(breakTime.matchCount) match" label += breakTime.matchCount.pluralSuffix + } else { + label += " de pause" } return label } @@ -1293,6 +1302,10 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return 30 case .singleSetDecisivePoint: return 25 + case .singleSetOfFourGames: + return 15 + case .singleSetOfFourGamesDecisivePoint: + return 10 } } @@ -1311,10 +1324,8 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return (30, 1) case .superTie: return (15, 3) - case .megaTie: + default: return (5, 1) - case .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint: - return (10, 1) } } @@ -1326,16 +1337,16 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return matchCount < 6 ? 3 : 0 case .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, .nineGames, .nineGamesDecisivePoint: return matchCount < 7 ? 6 : 2 - case .superTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint: - return 7 - case .megaTie: + case .superTie: return 7 + default: + return 10 } } var hasDecisivePoint: Bool { switch self { - case .nineGamesDecisivePoint, .twoSetsDecisivePoint, .twoSetsOfFourGamesDecisivePoint, .twoSetsDecisivePointSuperTie, .singleSetDecisivePoint: + case .nineGamesDecisivePoint, .twoSetsDecisivePoint, .twoSetsOfFourGamesDecisivePoint, .twoSetsDecisivePointSuperTie, .singleSetDecisivePoint, .singleSetOfFourGamesDecisivePoint: return true default: return false @@ -1377,7 +1388,7 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { var isFederal: Bool { switch self { - case .megaTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint: + case .megaTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint, .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: return false default: return true @@ -1415,6 +1426,10 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return "C2" case .nineGamesDecisivePoint: return "D2" + case .singleSetOfFourGames: + return "I1" + case .singleSetOfFourGamesDecisivePoint: + return "I2" } } @@ -1436,6 +1451,8 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { return "supertie de 10 points" case .megaTie: return "supertie de 15 points" + case .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: + return "1 set de 4 jeux, tiebreak à 4/4" } } @@ -1455,7 +1472,7 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { switch self { case .twoSets, .twoSetsSuperTie, .twoSetsOfFourGames, .twoSetsDecisivePoint, .twoSetsOfFourGamesDecisivePoint, .twoSetsDecisivePointSuperTie, .twoSetsOfSuperTie: return 2 - case .nineGames, .nineGamesDecisivePoint, .superTie, .megaTie, .singleSet, .singleSetDecisivePoint: + case .nineGames, .nineGamesDecisivePoint, .superTie, .megaTie, .singleSet, .singleSetDecisivePoint, .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: return 1 } } @@ -1464,7 +1481,7 @@ enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable { switch self { case .twoSets, .twoSetsSuperTie, .twoSetsDecisivePoint, .twoSetsDecisivePointSuperTie, .singleSet, .singleSetDecisivePoint: return .six - case .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint: + case .twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: return .four case .nineGames, .nineGamesDecisivePoint: return .nine diff --git a/PadelClub/Views/Shared/MatchFormatRowView.swift b/PadelClub/Views/Shared/MatchFormatRowView.swift index c03a13b..b253e63 100644 --- a/PadelClub/Views/Shared/MatchFormatRowView.swift +++ b/PadelClub/Views/Shared/MatchFormatRowView.swift @@ -37,7 +37,7 @@ struct MatchFormatRowView: View { if hideExplanation == false { Text(matchFormat.longLabel) - Text(matchFormat.formattedEstimatedBreakDuration() + " de pause").font(.footnote) + Text(matchFormat.formattedEstimatedBreakDuration()).font(.footnote) if matchFormat.isFederal == false { Text("Non officiel").foregroundStyle(.logoRed).font(.footnote) }