Fix swiss round advancing missing teams

This commit is contained in:
Kalle 2024-05-04 11:11:05 +03:00
parent 209f3e8dc3
commit a96af50cdb
2 changed files with 10 additions and 21 deletions

View File

@ -1256,8 +1256,8 @@ class SwissBracket extends Bracket {
round?.maps?.type === "PLAY_ALL"
? round?.maps?.count
: Math.ceil((round?.maps?.count ?? 0) / 2);
// preview
if (!mapWins) {
logger.warn("SwissBracket.currentStandings: mapWins not found");
continue;
}

View File

@ -545,27 +545,16 @@ function matchesByNotPlayedBefore(
return null;
}
// https://stackoverflow.com/a/75330248
// https://stackoverflow.com/a/75330079
function makeRounds(n: number) {
const sets: Record<number, number>[] = [];
const rounds: [number, number][][] = [];
for (let r = 0; r < n - 1; r++) {
sets.push({});
rounds.push([]);
}
for (let i = 0; i < n - 1; i++) {
for (let j = i + 1; j < n; j++) {
for (let r = 0; r < n - 1; r++) {
if (!sets[r][i] && !sets[r][j]) {
sets[r][i] = sets[r][j] = 1;
rounds[r].push([i, j]);
break;
}
}
const pairings = [];
const max = n - 1;
for (let i = 0; i < max; i++) {
const pairing = [[max, i]];
for (let k = 1; k < n / 2; k++) {
pairing.push([(i + k) % max, (max + i - k) % max]);
}
pairings.push(pairing);
}
return rounds;
return pairings;
}