Merge branch 'main'

sync3
Razmig Sarkissian 1 month ago
commit 2433dbb003
  1. 5
      PadelClubData/Data/Round.swift
  2. 18
      PadelClubData/Data/Tournament.swift
  3. 4
      PadelClubData/ViewModel/PadelRule.swift

@ -761,10 +761,7 @@ defer {
guard currentRoundMatchCount > 1 else { return } guard currentRoundMatchCount > 1 else { return }
guard let tournamentStore else { return } guard let tournamentStore else { return }
let roundCount = RoundRule.numberOfRounds(forTeams: currentRoundMatchCount) let roundCount = RoundRule.numberOfRounds(forTeams: currentRoundMatchCount)
let loserBracketMatchFormat = tournamentObject()?.loserBracketMatchFormat let loserBracketMatchFormat = tournamentObject()?.loserBracketSmartMatchFormat()
// if let parentRound {
// loserBracketMatchFormat = tournamentObject()?.loserBracketSmartMatchFormat(parentRound.index)
// }
var titles = [String: String]() var titles = [String: String]()

@ -1485,7 +1485,7 @@ defer {
let matchCount = RoundRule.numberOfMatches(forTeams: minimalBracketTeamCount ?? bracketTeamCount()) let matchCount = RoundRule.numberOfMatches(forTeams: minimalBracketTeamCount ?? bracketTeamCount())
let rounds = (0..<roundCount).map { //index 0 is the final let rounds = (0..<roundCount).map { //index 0 is the final
return Round(tournament: id, index: $0, format: matchFormat, loserBracketMode: loserBracketMode) return Round(tournament: id, index: $0, format: roundSmartMatchFormat($0), loserBracketMode: loserBracketMode)
} }
if rounds.isEmpty { if rounds.isEmpty {
@ -1684,9 +1684,9 @@ defer {
set { set {
federalLevelCategory = newValue federalLevelCategory = newValue
teamSorting = newValue.defaultTeamSortingType teamSorting = newValue.defaultTeamSortingType
groupStageMatchFormat = groupStageSmartMatchFormat() groupStageMatchFormat = DataStore.shared.user.groupStageMatchFormatPreference ?? groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(1) loserBracketMatchFormat = DataStore.shared.user.loserBracketMatchFormatPreference ?? loserBracketSmartMatchFormat()
matchFormat = roundSmartMatchFormat(5) matchFormat = DataStore.shared.user.bracketMatchFormatPreference ?? roundSmartMatchFormat(5)
} }
} }
@ -1699,8 +1699,8 @@ defer {
} }
} }
public func loserBracketSmartMatchFormat(_ roundIndex: Int) -> MatchFormat { public func loserBracketSmartMatchFormat() -> MatchFormat {
let format = tournamentLevel.federalFormatForLoserBracketRound(roundIndex) let format = tournamentLevel.federalFormatForLoserBracketRound()
if tournamentLevel == .p25 { return .superTie } if tournamentLevel == .p25 { return .superTie }
if format.rank < loserBracketMatchFormat.rank { if format.rank < loserBracketMatchFormat.rank {
return format return format
@ -1732,9 +1732,9 @@ defer {
public func setupFederalSettings() { public func setupFederalSettings() {
teamSorting = tournamentLevel.defaultTeamSortingType teamSorting = tournamentLevel.defaultTeamSortingType
groupStageMatchFormat = groupStageSmartMatchFormat() groupStageMatchFormat = DataStore.shared.user.groupStageMatchFormatPreference ?? groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(5) loserBracketMatchFormat = DataStore.shared.user.loserBracketMatchFormatPreference ?? loserBracketSmartMatchFormat()
matchFormat = roundSmartMatchFormat(5) matchFormat = DataStore.shared.user.bracketMatchFormatPreference ?? roundSmartMatchFormat(5)
entryFee = tournamentLevel.entryFee entryFee = tournamentLevel.entryFee
registrationDateLimit = deadline(for: .inscription) registrationDateLimit = deadline(for: .inscription)
if enableOnlineRegistration, isAnimation() == false { if enableOnlineRegistration, isAnimation() == false {

@ -550,7 +550,7 @@ public enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable
} }
case .p1500, .p2000: case .p1500, .p2000:
if roundIndex <= 3 { //demi / finale / quart / 8eme if roundIndex <= 3 { //demi / finale / quart / 8eme
return .twoSetsDecisivePoint return .twoSets
} else { } else {
return .twoSetsSuperTie return .twoSetsSuperTie
} }
@ -568,7 +568,7 @@ public enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable
} }
} }
public func federalFormatForLoserBracketRound(_ roundIndex: Int) -> MatchFormat { public func federalFormatForLoserBracketRound() -> MatchFormat {
switch self { switch self {
case .p25: case .p25:
return .superTie return .superTie

Loading…
Cancel
Save