From 81b4ae5680ae50356d0b63accb59c490019cc897 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:48:59 +0200 Subject: [PATCH] Fix Swiss losses against tied calculation while bracket in progress Closes #2040 --- app/features/tournament-bracket/core/Bracket.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/features/tournament-bracket/core/Bracket.ts b/app/features/tournament-bracket/core/Bracket.ts index 57feefcb50..627ced2e64 100644 --- a/app/features/tournament-bracket/core/Bracket.ts +++ b/app/features/tournament-bracket/core/Bracket.ts @@ -1419,15 +1419,19 @@ class SwissBracket extends Bracket { // they are different teams and are tied, let's check who won - const finishedMatchBetweenTeams = matches.find( - (match) => + const finishedMatchBetweenTeams = matches.find((match) => { + const isBetweenTeams = (match.opponent1?.id === team.id && match.opponent2?.id === team2.id) || (match.opponent1?.id === team2.id && - match.opponent2?.id === team.id && - (match.opponent1?.result === "win" || - match.opponent2?.result === "win")), - ); + match.opponent2?.id === team.id); + + const isFinished = + match.opponent1?.result === "win" || + match.opponent2?.result === "win"; + + return isBetweenTeams && isFinished; + }); // they did not play each other if (!finishedMatchBetweenTeams) continue;