Merge branch 'main'

sync3
Razmig Sarkissian 2 months ago
commit 6ab981f334
  1. 2
      PadelClubData/Data/Match.swift
  2. 2
      PadelClubData/Data/TeamRegistration.swift
  3. 29
      PadelClubData/Data/Tournament.swift
  4. 2
      PadelClubData/ViewModel/PadelRule.swift

@ -891,7 +891,7 @@ defer {
let endedSetsTwo = teamScoreOtherTeam.score?.components(separatedBy: ",").compactMap({ $0.components(separatedBy: "-").first }).compactMap({ Int($0) }) ?? matchFormat.defaultWalkOutScore(teamScoreOtherTeam.isWalkOut())
var setDifference : Int = 0
let zip = zip(endedSetsOne, endedSetsTwo)
if matchFormat.setsToWin == 1 {
if matchFormat.setsToWin == 1, endedSetsOne.count > 0, endedSetsTwo.count > 0 {
setDifference = endedSetsOne[0] - endedSetsTwo[0]
} else {
setDifference = zip.filter { $0 > $1 }.count - zip.filter { $1 > $0 }.count

@ -250,7 +250,7 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable {
public func teamLabel(
_ displayStyle: DisplayStyle = .wide, twoLines: Bool = false, separator: String = "&"
) -> String {
if let name { return name }
if let name, name.isEmpty == false { return name }
return players().map { $0.playerLabel(displayStyle) }.joined(
separator: twoLines ? "\n" : " \(separator) ")
}

@ -361,6 +361,7 @@ defer {
public func availableSeedOpponentSpot(inRoundIndex roundIndex: Int) -> [Match] {
return getRound(atRoundIndex: roundIndex)?.playedMatches().filter { $0.hasSpaceLeft() } ?? []
}
public func availableSeedGroups(includeAll: Bool = false) -> [SeedInterval] {
let seeds = seeds()
var availableSeedGroup = Set<SeedInterval>()
@ -378,6 +379,24 @@ defer {
return availableSeedGroup.sorted(by: <)
}
public func generateSeedGroups(base: Int, teamCount: Int) -> [SeedInterval] {
let start = base + 1
let root = SeedInterval(first: start, last: start + teamCount - 1)
var groups: [SeedInterval] = []
func split(interval: SeedInterval) {
groups.append(interval)
if let chunks = interval.chunks() {
for chunk in chunks {
split(interval: chunk)
}
}
}
split(interval: root)
return groups.sorted(by: <)
}
public func chunksBy(in chunks: [SeedInterval], availableSeedGroup: inout Set<SeedInterval>) {
chunks.forEach { chunk in
availableSeedGroup.insert(chunk)
@ -1678,11 +1697,11 @@ defer {
}
}
public func initSettings(templateTournament: Tournament?) {
public func initSettings(templateTournament: Tournament?, overrideTeamCount: Bool = true) {
setupDefaultPrivateSettings(templateTournament: templateTournament)
setupUmpireSettings(defaultTournament: nil) //default is not template, default is for event sharing settings
if let templateTournament {
setupRegistrationSettings(templateTournament: templateTournament)
setupRegistrationSettings(templateTournament: templateTournament, overrideTeamCount: overrideTeamCount)
}
setupFederalSettings()
}
@ -1755,7 +1774,7 @@ defer {
}
}
public func setupRegistrationSettings(templateTournament: Tournament) {
public func setupRegistrationSettings(templateTournament: Tournament, overrideTeamCount: Bool = true) {
self.enableOnlineRegistration = templateTournament.enableOnlineRegistration
self.unregisterDeltaInHours = templateTournament.unregisterDeltaInHours
self.accountIsRequired = templateTournament.accountIsRequired
@ -1764,7 +1783,9 @@ defer {
self.maximumPlayerPerTeam = templateTournament.maximumPlayerPerTeam
self.waitingListLimit = templateTournament.waitingListLimit
self.teamCountLimit = templateTournament.teamCountLimit
self.teamCount = templateTournament.teamCount
if overrideTeamCount {
self.teamCount = templateTournament.teamCount
}
self.enableOnlinePayment = templateTournament.enableOnlinePayment
self.onlinePaymentIsMandatory = templateTournament.onlinePaymentIsMandatory
self.enableOnlinePaymentRefund = templateTournament.enableOnlinePaymentRefund

@ -2178,7 +2178,7 @@ public enum TournamentDeadlineType: String, CaseIterable {
case definitiveBroadcastList = "Publication définitive"
public func daysOffset(level: TournamentLevel) -> Int {
if level == .p500 {
if level == .p500 || level == .p1000 {
switch self {
case .inscription:
return -6

Loading…
Cancel
Save