fix stuff headmanager

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

@ -2119,7 +2119,18 @@ defer {
} }
} }
} }
public func removeRound(_ round: Round) async {
await MainActor.run {
let teams = round.seeds()
teams.forEach { team in
team.resetBracketPosition()
}
tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams)
tournamentStore?.rounds.delete(instance: round)
}
}
public func addNewRound(_ roundIndex: Int) async { public func addNewRound(_ roundIndex: Int) async {
await MainActor.run { await MainActor.run {
let round = Round(tournament: id, index: roundIndex, format: matchFormat) let round = Round(tournament: id, index: roundIndex, format: matchFormat)

@ -1852,6 +1852,16 @@ public enum RoundRule {
} }
} }
public static func cumulatedNumberOfMatches(forTeams teams: Int) -> Int {
var i = teams / 2
if teams / 2 > 1 {
i += Self.cumulatedNumberOfMatches(forTeams: teams / 2)
i += Self.cumulatedNumberOfMatches(forTeams: teams / 4)
}
return i
}
public static func teamsInFirstRound(forTeams teams: Int) -> Int { public static func teamsInFirstRound(forTeams teams: Int) -> Int {
Int(pow(2.0, ceil(log2(Double(teams))))) Int(pow(2.0, ceil(log2(Double(teams)))))
} }

Loading…
Cancel
Save