From 79a3b25eeec5d1f5e870f96b893c57cc8eaaedb9 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Fri, 24 May 2024 21:20:49 +0300 Subject: [PATCH] Fix 1 swiss group with 7 teams excluding one team --- app/features/tournament-bracket/core/Swiss.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/features/tournament-bracket/core/Swiss.ts b/app/features/tournament-bracket/core/Swiss.ts index 6790c55f0..c8aea74c9 100644 --- a/app/features/tournament-bracket/core/Swiss.ts +++ b/app/features/tournament-bracket/core/Swiss.ts @@ -7,8 +7,10 @@ import { nullFilledArray } from "~/utils/arrays"; import type { Bracket, Standing } from "./Bracket"; import type { TournamentRepositoryInsertableMatch } from "~/features/tournament/TournamentRepository.server"; +type SwissSeeding = { id: number; name: string }; + interface CreateArgs extends Omit { - seeding: Array<{ id: number; name: string }>; + seeding: readonly SwissSeeding[]; } export function create(args: CreateArgs): ValueToArray { @@ -133,11 +135,9 @@ function firstRoundMatches({ function splitToGroups() { if (!seeding) return []; - if (groupCount === 1) return [seeding]; + if (groupCount === 1) return [[...seeding]]; - const groups: CreateArgs["seeding"][] = nullFilledArray(groupCount).map( - () => [], - ); + const groups: SwissSeeding[][] = nullFilledArray(groupCount).map(() => []); for (let i = 0; i < seeding.length; i++) { const groupIndex = i % groupCount;