Fix loser source matches logic + add tests

This commit is contained in:
Kalle (Sendou)
2022-01-11 08:38:45 +02:00
parent 2db01de454
commit af49b5be39
3 changed files with 40 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@@ -108,7 +108,7 @@ function modifyRounds(
});
}
function addLoserTeamSourceInfo({
export function addLoserTeamSourceInfo({
winners,
losers,
}: {
@@ -129,13 +129,7 @@ function addLoserTeamSourceInfo({
.flatMap((round) => round.matches)
.reduce((acc: Map<string, number[]>, match) => {
if (!match.loserDestinationMatchId) return acc;
acc.set(
match.loserDestinationMatchId,
(acc.get(match.loserDestinationMatchId) ?? [])
.concat(match.number)
.sort((a, b) => a - b)
);
if (match.number === 0) return acc;
const nextMatchAfterByeId = nextMatchAfterBye(
match.loserDestinationMatchId
@@ -147,6 +141,13 @@ function addLoserTeamSourceInfo({
.concat(match.number)
.sort((a, b) => a - b)
);
} else {
acc.set(
match.loserDestinationMatchId,
(acc.get(match.loserDestinationMatchId) ?? [])
.concat(match.number)
.sort((a, b) => a - b)
);
}
return acc;

View File

@@ -79,7 +79,7 @@
"uvu": "^0.5.3"
},
"engines": {
"node": "16.3.1",
"node": ">=16",
"npm": ">=8"
},
"sideEffects": false,