fix live scoring

fix p1500 points repartition
fix planning view stuff
newoffer2025
Raz 6 months ago
parent 7f0a532126
commit be1a8e1687
  1. 12
      PadelClubData/Data/Tournament.swift
  2. 4
      PadelClubData/ViewModel/MatchDescriptor.swift
  3. 46
      PadelClubData/ViewModel/PadelRule.swift

@ -1039,20 +1039,12 @@ defer {
}
if rankings.isEmpty == false {
let teams = unsortedTeams()
Task {
await MainActor.run {
self.tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams)
}
}
self.tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams)
if self.publishRankings == false {
self.publishRankings = true
}
Task {
await MainActor.run {
DataStore.shared.tournaments.addOrUpdate(instance: self)
}
}
DataStore.shared.tournaments.addOrUpdate(instance: self)
}
return rankings

@ -102,8 +102,8 @@ public class MatchDescriptor: ObservableObject {
setDescriptors.compactMap { $0.getValue(teamPosition: .two) }
}
public var scoreTeamOne: Int { setDescriptors.compactMap { $0.winner }.filter { $0 == .one }.count }
public var scoreTeamTwo: Int { setDescriptors.compactMap { $0.winner }.filter { $0 == .two }.count }
public var scoreTeamOne: Int { setDescriptors.filter({ $0.hasEnded }).compactMap { $0.winner }.filter { $0 == .one }.count }
public var scoreTeamTwo: Int { setDescriptors.filter({ $0.hasEnded }).compactMap { $0.winner }.filter { $0 == .two }.count }
public var hasEnded: Bool {
return matchFormat.hasEnded(scoreTeamOne: scoreTeamOne, scoreTeamTwo: scoreTeamTwo)

@ -647,7 +647,7 @@ public enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable
case _ where count > 28:
return [80,75,72,70,65,63,60,58,55,53,50,48,45,43,40,38,35,33,30,28,25,23,20,18,15,12,10,8,5,3, 1]
default:
return [60,50,40,25,10,5]
return [60,50,40,25,10,5, 1]
}
case .p250:
switch count {
@ -698,33 +698,47 @@ public enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable
case _ where count > 28:
return [800,750,720,700,650,630,600,580,550,530,500,480,450,430,400,380,350,330,300,280,250,230,200,180,150,120,100,80,50,30, 10]
default:
return [600,500,400,250,100,50]
return [600,500,400,250,100,50, 10]
}
case .p1500:
switch count {
case 9...12:
return [975, 825, 750, 525, 375, 300, 225, 150, 75, 45, 15]
case 13...16:
return [1050, 900, 825, 675, 600, 525, 450, 375, 315, 270, 225, 150, 75, 45, 15]
case 17...20:
return [1125, 975, 900, 825, 750, 675, 600, 525, 450, 375, 345, 300, 270, 225, 180, 150, 75, 45, 15]
case 21...24:
return [1125,1050,975,900,825,750,705,645,600,555,495,450,420,375,345,300,270,225,180,150,75,45,15]
return [1125, 1050, 975, 900, 825, 750, 705, 645, 600, 555, 495, 450, 420, 375, 345, 300, 270, 225, 180, 150, 75, 45, 15]
case 25...28:
return [1200,1125,1050,975,900,825,795,750,720,675,645,600,570,525,495,450,420,375,345,300,270,225,180,150,75,45,15]
return [1200, 1125, 1050, 975, 900, 825, 795, 750, 720, 675, 645, 600, 570, 525, 495, 450, 420, 375, 345, 300, 270, 225, 180, 150, 75, 45, 15]
case _ where count > 28:
return [1200,1125,1080,1050,975,945,900,870,825,795,750,720,675,645,600,570,525,495,450,420,375,345,300,270,225,180,150,120,75,45,15]
return [1200, 1125, 1080, 1050, 975, 945, 900, 870, 825, 795, 750, 720, 675, 645, 600, 570, 525, 495, 450, 420, 375, 345, 300, 270, 225, 180, 150, 120, 75, 45, 15]
default:
return [1125,975,900,825,750,675,600,525,450,375,345,300,270,225,180,150,75,45,15]
}
return [900, 750, 600, 375, 150, 75, 15]
}
case .p2000:
return [1600,1440,1300,1180,1120,1060,1000,880,840,800,760,720,680,640,600,540,520,500,480,460,440,420,400,260,200,40]
switch count {
case 9...12:
return [1300, 1100, 1000, 700, 500, 400, 300, 200, 100, 60, 20]
case 13...16:
return [1400, 1200, 1100, 900, 800, 700, 600, 500, 420, 360, 300, 200, 100, 60, 20]
case 17...20:
return [1500, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 460, 400, 360, 300, 240, 200, 100, 60, 20]
case 21...24:
return [1600, 1400, 1300, 1200, 1100, 1000, 940, 860, 800, 740, 660, 600, 560, 500, 460, 400, 360, 300, 240, 200, 100, 60, 20]
case 25...28:
return [1600, 1500, 1440, 1400, 1300, 1200, 1160, 1100, 1060, 1000, 960, 900, 860, 800, 760, 700, 660, 600, 560, 500, 460, 400, 360, 300, 240, 200, 60]
case _ where count > 28:
return [1600, 1500, 1440, 1400, 1300, 1260, 1200, 1160, 1100, 1060, 1000, 960, 900, 860, 800, 760, 700, 660, 600, 560, 500, 460, 400, 360, 300, 240, 200, 160, 100, 60, 20]
default:
return [1200, 1000, 800, 500, 200, 100, 20]
}
}
}
public var ranges: [PlayersCountRange] {
switch self {
case .p1500:
return [.N16, .N24, .N28, .N32]
case .p2000:
return [.N32]
default:
return PlayersCountRange.allCases
}
return PlayersCountRange.allCases
}
// enum NewBallSystem {

Loading…
Cancel
Save