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 let tournamentStore else { return }
let roundCount = RoundRule.numberOfRounds(forTeams: currentRoundMatchCount)
let loserBracketMatchFormat = tournamentObject()?.loserBracketMatchFormat
// if let parentRound {
// loserBracketMatchFormat = tournamentObject()?.loserBracketSmartMatchFormat(parentRound.index)
// }
let loserBracketMatchFormat = tournamentObject()?.loserBracketSmartMatchFormat()
var titles = [String: String]()

@ -1485,7 +1485,7 @@ defer {
let matchCount = RoundRule.numberOfMatches(forTeams: minimalBracketTeamCount ?? bracketTeamCount())
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 {
@ -1684,9 +1684,9 @@ defer {
set {
federalLevelCategory = newValue
teamSorting = newValue.defaultTeamSortingType
groupStageMatchFormat = groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(1)
matchFormat = roundSmartMatchFormat(5)
groupStageMatchFormat = DataStore.shared.user.groupStageMatchFormatPreference ?? groupStageSmartMatchFormat()
loserBracketMatchFormat = DataStore.shared.user.loserBracketMatchFormatPreference ?? loserBracketSmartMatchFormat()
matchFormat = DataStore.shared.user.bracketMatchFormatPreference ?? roundSmartMatchFormat(5)
}
}
@ -1699,8 +1699,8 @@ defer {
}
}
public func loserBracketSmartMatchFormat(_ roundIndex: Int) -> MatchFormat {
let format = tournamentLevel.federalFormatForLoserBracketRound(roundIndex)
public func loserBracketSmartMatchFormat() -> MatchFormat {
let format = tournamentLevel.federalFormatForLoserBracketRound()
if tournamentLevel == .p25 { return .superTie }
if format.rank < loserBracketMatchFormat.rank {
return format
@ -1732,9 +1732,9 @@ defer {
public func setupFederalSettings() {
teamSorting = tournamentLevel.defaultTeamSortingType
groupStageMatchFormat = groupStageSmartMatchFormat()
loserBracketMatchFormat = loserBracketSmartMatchFormat(5)
matchFormat = roundSmartMatchFormat(5)
groupStageMatchFormat = DataStore.shared.user.groupStageMatchFormatPreference ?? groupStageSmartMatchFormat()
loserBracketMatchFormat = DataStore.shared.user.loserBracketMatchFormatPreference ?? loserBracketSmartMatchFormat()
matchFormat = DataStore.shared.user.bracketMatchFormatPreference ?? roundSmartMatchFormat(5)
entryFee = tournamentLevel.entryFee
registrationDateLimit = deadline(for: .inscription)
if enableOnlineRegistration, isAnimation() == false {

@ -550,7 +550,7 @@ public enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable
}
case .p1500, .p2000:
if roundIndex <= 3 { //demi / finale / quart / 8eme
return .twoSetsDecisivePoint
return .twoSets
} else {
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 {
case .p25:
return .superTie

Loading…
Cancel
Save