update 2026 rules

newoffer2025
Razmig Sarkissian 3 months ago
parent 74907497ba
commit 47e15706b9
  1. 16
      PadelClubData/Data/PlayerRegistration.swift
  2. 4
      PadelClubData/Data/TeamRegistration.swift
  3. 19
      PadelClubData/Data/Tournament.swift
  4. 8
      PadelClubData/Extensions/Date+Extensions.swift
  5. 37
      PadelClubData/ViewModel/PadelRule.swift

@ -119,7 +119,9 @@ final public class PlayerRegistration: BasePlayerRegistration, SideStorable {
public func playerLabel(_ displayStyle: DisplayStyle = .wide) -> String { public func playerLabel(_ displayStyle: DisplayStyle = .wide) -> String {
switch displayStyle { switch displayStyle {
case .wide, .title: case .title:
return firstName.trimmed.capitalized + " " + lastName.trimmed.capitalized
case .wide:
return lastName.trimmed.capitalized + " " + firstName.trimmed.capitalized return lastName.trimmed.capitalized + " " + firstName.trimmed.capitalized
case .short: case .short:
let names = lastName.components(separatedBy: .whitespaces) let names = lastName.components(separatedBy: .whitespaces)
@ -170,7 +172,7 @@ final public class PlayerRegistration: BasePlayerRegistration, SideStorable {
let currentRank = rank ?? maleUnranked let currentRank = rank ?? maleUnranked
switch tournament.tournamentCategory { switch tournament.tournamentCategory {
case .men: case .men:
let addon = PlayerRegistration.addon(for: currentRank, manMax: maleUnranked, womanMax: femaleUnranked) let addon = tournament.addon(for: currentRank, manMax: maleUnranked, womanMax: femaleUnranked)
computedRank = isMalePlayer() ? currentRank : currentRank + addon computedRank = isMalePlayer() ? currentRank : currentRank + addon
default: default:
computedRank = currentRank computedRank = currentRank
@ -279,16 +281,6 @@ final public class PlayerRegistration: BasePlayerRegistration, SideStorable {
} }
} }
public static func addon(for playerRank: Int, manMax: Int, womanMax: Int) -> Int {
switch playerRank {
case 0: return 0
case womanMax: return manMax - womanMax
case manMax: return 0
default:
return TournamentCategory.femaleInMaleAssimilationAddition(playerRank)
}
}
func insertOnServer() { func insertOnServer() {
self.tournamentStore?.playerRegistrations.writeChangeAndInsertOnServer(instance: self) self.tournamentStore?.playerRegistrations.writeChangeAndInsertOnServer(instance: self)
} }

@ -261,10 +261,10 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable {
separator: twoLines ? "\n" : " \(separator) ") separator: twoLines ? "\n" : " \(separator) ")
} }
public func teamLabelRanked(displayRank: Bool, displayTeamName: Bool) -> String { public func teamLabelRanked(displayStyle: DisplayStyle = .wide, displayRank: Bool, displayTeamName: Bool) -> String {
[ [
displayTeamName ? name : nil, displayRank ? seedIndex() : nil, displayTeamName ? name : nil, displayRank ? seedIndex() : nil,
displayTeamName ? (name == nil ? teamLabel() : name) : teamLabel(), displayTeamName ? (name == nil ? teamLabel(displayStyle) : name) : teamLabel(displayStyle),
].compactMap({ $0 }).joined(separator: " ") ].compactMap({ $0 }).joined(separator: " ")
} }

@ -2363,6 +2363,25 @@ defer {
} }
} }
public func addon(for playerRank: Int, manMax: Int, womanMax: Int) -> Int {
switch playerRank {
case 0: return 0
case womanMax: return manMax - womanMax
case manMax: return 0
default:
return TournamentCategory.femaleInMaleAssimilationAddition(playerRank, seasonYear: self.startDate.seasonYear())
}
}
public func coachingIsAuthorized() -> Bool {
switch startDate.seasonYear() {
case 2026:
return true
default:
return tournamentLevel.coachingIsAuthorized
}
}
// MARK: - // MARK: -
func insertOnServer() throws { func insertOnServer() throws {

@ -37,6 +37,14 @@ public enum TimeOfDay {
public extension Date { public extension Date {
func seasonYear() -> Int {
if self.monthInt >= 9 {
return self.yearInt + 1
}
return self.yearInt
}
func withoutSeconds() -> Date { func withoutSeconds() -> Date {
let calendar = Calendar.current let calendar = Calendar.current
return calendar.date(bySettingHour: calendar.component(.hour, from: self), return calendar.date(bySettingHour: calendar.component(.hour, from: self),

@ -876,7 +876,10 @@ public enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiab
} }
} }
public static func femaleInMaleAssimilationAddition(_ rank: Int) -> Int { public static func femaleInMaleAssimilationAddition(_ rank: Int, seasonYear: Int?) -> Int {
switch seasonYear {
case .some(let year):
if year < 2026 {
switch rank { switch rank {
case 1...10: return 400 case 1...10: return 400
case 11...30: return 1000 case 11...30: return 1000
@ -891,6 +894,26 @@ public enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiab
return 50000 return 50000
} }
} }
case .none:
break
}
switch rank {
case 1...10: return 400
case 11...30: return 1000
case 31...60: return 2000
case 61...100: return 3500
case 101...200: return 10000
case 201...500: return 15000
case 501...1000: return 25000
case 1001...2000: return 35000
case 2001...3000: return 45000
case 3001...5000: return 55000
case 5001...10000: return 70000
default:
return 90000
}
}
public static func mostRecent(inTournaments tournaments: [Tournament]) -> Self { public static func mostRecent(inTournaments tournaments: [Tournament]) -> Self {
return tournaments.first?.tournamentCategory ?? .men return tournaments.first?.tournamentCategory ?? .men
@ -1499,7 +1522,7 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
public var isFederal: Bool { public var isFederal: Bool {
switch self { switch self {
case .megaTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint, .singleSetOfFourGames, .singleSetOfFourGamesDecisivePoint: case .megaTie, .twoSetsOfSuperTie, .singleSet, .singleSetDecisivePoint, .singleSetOfFourGamesDecisivePoint:
return false return false
default: default:
return true return true
@ -1525,11 +1548,11 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
case .twoSetsOfSuperTie: case .twoSetsOfSuperTie:
return "G" return "G"
case .megaTie: case .megaTie:
return "F" return "H"
case .singleSet: case .singleSet:
return "H1" return "I1"
case .singleSetDecisivePoint: case .singleSetDecisivePoint:
return "H2" return "I2"
case .twoSetsDecisivePoint: case .twoSetsDecisivePoint:
return "A2" return "A2"
case .twoSetsDecisivePointSuperTie: case .twoSetsDecisivePointSuperTie:
@ -1539,9 +1562,9 @@ public enum MatchFormat: Int, Hashable, Codable, CaseIterable, Identifiable {
case .nineGamesDecisivePoint: case .nineGamesDecisivePoint:
return "D2" return "D2"
case .singleSetOfFourGames: case .singleSetOfFourGames:
return "I1" return "F1"
case .singleSetOfFourGamesDecisivePoint: case .singleSetOfFourGamesDecisivePoint:
return "I2" return "F2"
} }
} }

Loading…
Cancel
Save