Skip to content

Commit

Permalink
Fix Swiss losses against tied calculation while bracket in progress C…
Browse files Browse the repository at this point in the history
…loses #2040
  • Loading branch information
Sendouc committed Jan 19, 2025
1 parent 84d936e commit 81b4ae5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/features/tournament-bracket/core/Bracket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 81b4ae5

Please sign in to comment.