add heads config system

main
Razmig Sarkissian 4 weeks ago
parent ecf14eaa32
commit 54a35571b1
  1. 3
      PadelClubData/Data/Tournament.swift
  2. 10
      PadelClubData/ViewModel/PadelRule.swift

@ -1547,6 +1547,9 @@ defer {
public func deleteGroupStages() { public func deleteGroupStages() {
self.tournamentStore?.groupStages.delete(contentOfs: allGroupStages()) self.tournamentStore?.groupStages.delete(contentOfs: allGroupStages())
if let gs = self.groupStageLoserBracket() {
self.tournamentStore?.rounds.delete(instance: gs)
}
} }
public func refreshGroupStages(keepExistingMatches: Bool = false) { public func refreshGroupStages(keepExistingMatches: Bool = false) {

@ -1882,12 +1882,16 @@ public enum RoundRule {
} }
public static func numberOfMatches(forRoundIndex roundIndex: Int) -> Int { public static func numberOfMatches(forRoundIndex roundIndex: Int) -> Int {
Int(pow(2.0, Double(roundIndex))) (1 << roundIndex)
}
public static func baseIndex(forRoundIndex roundIndex: Int) -> Int {
numberOfMatches(forRoundIndex: roundIndex) - 1
} }
static func matchIndexWithinRound(fromMatchIndex matchIndex: Int) -> Int { static func matchIndexWithinRound(fromMatchIndex matchIndex: Int) -> Int {
let roundIndex = roundIndex(fromMatchIndex: matchIndex) let roundIndex = roundIndex(fromMatchIndex: matchIndex)
let matchIndexWithinRound = matchIndex - (Int(pow(2.0, Double(roundIndex))) - 1) let matchIndexWithinRound = matchIndex - baseIndex(forRoundIndex: roundIndex)
return matchIndexWithinRound return matchIndexWithinRound
} }
@ -1911,7 +1915,7 @@ public enum RoundRule {
} }
return "Quart de finale" return "Quart de finale"
default: default:
return "\(Int(pow(2.0, Double(roundIndex))))ème" return "\((1 << roundIndex))ème"
} }
} }
} }

Loading…
Cancel
Save