|
|
|
|
@ -551,7 +551,7 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func unrankValue(for malePlayer: Bool) -> Int { |
|
|
|
|
return tournamentObject()?.unrankValue(for: malePlayer) ?? 90_415 |
|
|
|
|
return tournamentObject()?.unrankValue(for: malePlayer) ?? 92_327 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func groupStageObject() -> GroupStage? { |
|
|
|
|
@ -697,6 +697,27 @@ final public class TeamRegistration: BaseTeamRegistration, SideStorable { |
|
|
|
|
}) |
|
|
|
|
return matches.sorted(by: \.computedStartDateForSorting) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func nextMatch(in followingMatches: [Match]) -> Match? { |
|
|
|
|
return followingMatches.filter({ $0.hasEnded() == false }).first |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func lastMatchPlayed(in followingMatches: [Match]) -> Match? { |
|
|
|
|
return followingMatches.first(where: { $0.hasEnded() }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func numberOfRotation(in followingMatches: [Match]) -> (Int, Int)? { |
|
|
|
|
if let nextMatch = nextMatch(in: followingMatches), let nextMatchPlannedStartDate = nextMatch.plannedStartDate, let lastMatchPlayed = lastMatchPlayed(in: followingMatches), let lastMatchPlayedPlannedStartDate = lastMatchPlayed.plannedStartDate { |
|
|
|
|
|
|
|
|
|
let courtCount = self.tournamentStore?.matches.filter({ $0.plannedStartDate == nextMatchPlannedStartDate && $0.disabled == false && $0.hasEnded() == false && $0.confirmed == true && $0.id != nextMatch.id && $0.hasStarted() == false }).count ?? 0 |
|
|
|
|
let interval = nextMatchPlannedStartDate.timeIntervalSince(lastMatchPlayedPlannedStartDate) |
|
|
|
|
let matchDuration = lastMatchPlayed.matchFormat.defaultEstimatedDuration * 60 |
|
|
|
|
let rotation = Int(interval) / matchDuration |
|
|
|
|
print("numberOfRotation", interval, matchDuration, courtCount, rotation) |
|
|
|
|
return (rotation, (rotation - 1) * lastMatchPlayed.courtCount() + courtCount + 1) |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func insertOnServer() { |
|
|
|
|
self.tournamentStore?.teamRegistrations.writeChangeAndInsertOnServer(instance: self) |
|
|
|
|
|