Fix prepared maps round robin crash Closes #1919

This commit is contained in:
Kalle 2024-10-10 17:40:34 +03:00
parent 0932e8a5b5
commit 7cff3d290e
3 changed files with 10 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import {
useTournament,
useTournamentPreparedMaps,
} from "~/features/tournament/routes/to.$id";
import { TOURNAMENT } from "~/features/tournament/tournament-constants";
import type { TournamentManagerDataSet } from "~/modules/brackets-manager/types";
import type { ModeShort, StageId } from "~/modules/in-game-lists";
import { nullFilledArray } from "~/utils/arrays";
@ -576,9 +577,11 @@ function teamCountAdjustedBracketData({
// always has the same amount of rounds even if 0 participants
return bracket.data;
case "round_robin":
// 10 to ensure a full bracket gets generated even if registration is underway
// ensure a full bracket (no bye round) gets generated even if registration is underway
return tournament.generateMatchesData(
nullFilledArray(10).map((_, i) => i + 1),
nullFilledArray(TOURNAMENT.DEFAULT_TEAM_COUNT_PER_RR_GROUP).map(
(_, i) => i + 1,
),
bracket.type,
);
case "single_elimination":

View File

@ -447,7 +447,9 @@ export class Tournament {
case "round_robin":
return {
groupCount: Math.ceil(
participantsCount / (this.ctx.settings.teamsPerGroup ?? 4),
participantsCount /
(this.ctx.settings.teamsPerGroup ??
TOURNAMENT.DEFAULT_TEAM_COUNT_PER_RR_GROUP),
),
seedOrdering: ["groups.seed_optimized"],
};

View File

@ -7,6 +7,8 @@ export const TOURNAMENT = {
ENOUGH_TEAMS_TO_START: 2,
MIN_GROUP_SIZE: 3,
MAX_GROUP_SIZE: 6,
// just a fallback, normally this should be set by user explicitly
DEFAULT_TEAM_COUNT_PER_RR_GROUP: 4,
} as const;
export const BRACKET_NAMES = {