Fix "losses against" tiebreaker calculation with dropped teams Closes #1989
Some checks are pending
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run

This commit is contained in:
Kalle
2024-12-20 16:15:48 +02:00
parent 938a4f45f3
commit 00035cbc82
3 changed files with 15113 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
import { describe, expect, it } from "vitest";
import { Tournament } from "./Tournament";
import { LOW_INK_DECEMBER_2024 } from "./tests/mocks-li";
import invariant from "../../../utils/invariant";
const TEAM_ERROR_404_ID = 17354;
const TEAM_THIS_IS_FINE_ID = 17513;
describe("swiss standings", () => {
it("should calculate losses against tied", () => {
const tournament = new Tournament({
...LOW_INK_DECEMBER_2024(),
simulateBrackets: false,
});
const standing = tournament
.bracketByIdx(0)
?.currentStandings(false)
.find((standing) => standing.team.id === TEAM_THIS_IS_FINE_ID);
invariant(standing, "Standing not found");
expect(standing.stats?.lossesAgainstTied).toBe(1);
});
it("should ignore early dropped out teams for standings (losses against tied)", () => {
const tournament = new Tournament({
...LOW_INK_DECEMBER_2024(),
simulateBrackets: false,
});
const standing = tournament
.bracketByIdx(0)
?.currentStandings(false)
.find((standing) => standing.team.id === TEAM_ERROR_404_ID);
invariant(standing, "Standing not found");
expect(standing.stats?.lossesAgainstTied).toBe(0); // they lost against "Tidy Tidings" but that team dropped out before final round
});
});

View File

@@ -1388,7 +1388,13 @@ class SwissBracket extends Bracket {
for (const team of teams) {
for (const team2 of teams) {
if (team.id === team2.id) continue;
if (team.setWins !== team2.setWins) continue;
if (
team.setWins !== team2.setWins ||
// check also set losses to account for dropped teams
team.setLosses !== team2.setLosses
) {
continue;
}
// they are different teams and are tied, let's check who won

File diff suppressed because it is too large Load Diff