feat: add limited round-robin scheduling
This commit is contained in:
1 parent
24983aeb09
commit
658592973e
15 files changed
+403
-63
No files matched your search
@@ -19,9 +19,8 @@ import type { RiotJobPriority } from '../riot-job-queue/riot-job-queue.types';
|
||||
import { RiotMatchService } from '../riot/riot-match.service';
|
||||
import type { RiotMatchDto, RiotRegionalRoute } from '../riot/riot.types';
|
||||
import {
|
||||
roundRobinGameSchedule,
|
||||
resolveRoundRobinTeamCount,
|
||||
roundRobinPairCount,
|
||||
roundRobinPairs,
|
||||
} from '../tournament-code/round-robin.util';
|
||||
import {
|
||||
collectCaptainUserIds,
|
||||
@@ -785,14 +784,18 @@ export class TournamentResultService {
|
||||
};
|
||||
}
|
||||
|
||||
const perSeries = match.gameCount || 1;
|
||||
const pairIndex = Math.max(0, Math.ceil(gameNumber / perSeries) - 1);
|
||||
return (
|
||||
roundRobinPairs(resolveRoundRobinTeamCount(match))[pairIndex] ?? {
|
||||
teamAIndex: 1,
|
||||
teamBIndex: 2,
|
||||
}
|
||||
const fallback = this.buildRoundRobinGameSchedule(match).find(
|
||||
(entry) => entry.gameNumber === gameNumber,
|
||||
);
|
||||
return fallback
|
||||
? {
|
||||
teamAIndex: fallback.teamAIndex,
|
||||
teamBIndex: fallback.teamBIndex,
|
||||
}
|
||||
: {
|
||||
teamAIndex: 1,
|
||||
teamBIndex: 2,
|
||||
};
|
||||
}
|
||||
|
||||
const perSeries = match.gameCount || 1;
|
||||
@@ -806,8 +809,10 @@ export class TournamentResultService {
|
||||
private resolveRequiredGameSlots(match: MatchDocument): number {
|
||||
const gameMode = match.gameMode ?? 'pair';
|
||||
if (gameMode === 'round-robin') {
|
||||
const teamCount = resolveRoundRobinTeamCount(match);
|
||||
return roundRobinPairCount(teamCount) * (match.gameCount || 1);
|
||||
if ((match.gameSchedule?.length ?? 0) > 0) {
|
||||
return match.gameSchedule.length;
|
||||
}
|
||||
return this.buildRoundRobinGameSchedule(match).length;
|
||||
}
|
||||
|
||||
const activeParticipantCount = match.participants.filter(
|
||||
@@ -819,6 +824,13 @@ export class TournamentResultService {
|
||||
return seriesCount * (match.gameCount || 1);
|
||||
}
|
||||
|
||||
private buildRoundRobinGameSchedule(match: MatchDocument) {
|
||||
return roundRobinGameSchedule(resolveRoundRobinTeamCount(match), {
|
||||
gamesPerPair: match.gameCount || 1,
|
||||
maxRounds: match.roundRobinMaxRounds,
|
||||
});
|
||||
}
|
||||
|
||||
private resolveMatchWinnerTeamIndex(
|
||||
seriesResults: NonNullable<MatchDocument['result']>['seriesResults'],
|
||||
): number | undefined {
|
||||
|
||||
Reference in new issue
Block a user