diff --git a/PadelClubData/Data/Match.swift b/PadelClubData/Data/Match.swift index 60aa3eb..51c8e4c 100644 --- a/PadelClubData/Data/Match.swift +++ b/PadelClubData/Data/Match.swift @@ -478,7 +478,15 @@ defer { return (groupStageObject.index + 1) * 100 + groupStageObject.indexOf(index) } guard let roundObject else { return index } - return (300 - (roundObject.theoryCumulativeMatchCount * 10 + roundObject.index * 22)) * 10 + RoundRule.matchIndexWithinRound(fromMatchIndex: index) + + // primary: theoryCumulativeMatchCount (final = 1, semis = 3, quarters = 7, ...) + // multiply by a factor big enough to separate match indexes + let primary = roundObject.theoryCumulativeMatchCount * 1_000 + + // tie-breaker: match position inside the round (0..N-1) + let secondary = RoundRule.matchIndexWithinRound(fromMatchIndex: index) + + return primary + secondary } public func previousMatches() -> [Match] { diff --git a/PadelClubData/Data/MatchScheduler.swift b/PadelClubData/Data/MatchScheduler.swift index 637d21f..0421a4a 100644 --- a/PadelClubData/Data/MatchScheduler.swift +++ b/PadelClubData/Data/MatchScheduler.swift @@ -420,7 +420,7 @@ final public class MatchScheduler: BaseMatchScheduler, SideStorable { rotationIndex += 1 } - let timeMatch = TimeMatch(matchID: match.id, rotationIndex: rotationIndex, courtIndex: match.courtIndex ?? 0, startDate: match.startDate!, durationLeft: match.matchFormat.getEstimatedDuration(additionalEstimationDuration), minimumBreakTime: match.matchFormat.breakTime.breakTime) + let timeMatch = TimeMatch(matchID: match.id, rotationIndex: rotationIndex, matchRank: match.computedOrder, courtIndex: match.courtIndex ?? 0, startDate: match.startDate!, durationLeft: match.matchFormat.getEstimatedDuration(additionalEstimationDuration), minimumBreakTime: match.matchFormat.breakTime.breakTime) slots.append(timeMatch) } @@ -534,7 +534,7 @@ final public class MatchScheduler: BaseMatchScheduler, SideStorable { for i in 0..