mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
Fix TOO_MANY_PLACEMENTS check when using different teams per group for different round robins
This commit is contained in:
parent
52d41cfcc1
commit
42fbf60a3e
|
|
@ -407,6 +407,26 @@ describe("validatedSources - other rules", () => {
|
|||
expect((error as any).bracketIdx).toEqual(1);
|
||||
});
|
||||
|
||||
it("does not flag TOO_MANY_PLACEMENTS when larger round robin has valid high placements", () => {
|
||||
const result = getValidatedBrackets([
|
||||
{
|
||||
settings: { teamsPerGroup: 6 },
|
||||
type: "round_robin",
|
||||
},
|
||||
{
|
||||
settings: {},
|
||||
type: "single_elimination",
|
||||
sources: [{ bracketId: "0", placements: "1,2,3,4,5,6" }],
|
||||
},
|
||||
{
|
||||
settings: { teamsPerGroup: 4 },
|
||||
type: "round_robin",
|
||||
},
|
||||
]);
|
||||
|
||||
expect(Array.isArray(result)).toBe(true);
|
||||
});
|
||||
|
||||
it("handles DUPLICATE_BRACKET_NAME", () => {
|
||||
const error = getValidatedBrackets([
|
||||
{
|
||||
|
|
|
|||
|
|
@ -469,20 +469,16 @@ function tooManyPlacements(brackets: ParsedBracket[]) {
|
|||
const roundRobins = brackets.flatMap((bracket, bracketIdx) =>
|
||||
bracket.type === "round_robin" ? [bracketIdx] : [],
|
||||
);
|
||||
// technically not correct but i guess not too common to have different round robins in the same bracket
|
||||
const size = Math.min(
|
||||
...roundRobins.map(
|
||||
(bracketIdx) =>
|
||||
brackets[bracketIdx].settings.teamsPerGroup ?? Number.POSITIVE_INFINITY,
|
||||
),
|
||||
);
|
||||
|
||||
for (const [bracketIdx, bracket] of brackets.entries()) {
|
||||
for (const source of bracket.sources ?? []) {
|
||||
if (
|
||||
roundRobins.includes(source.bracketIdx) &&
|
||||
source.placements.some((placement) => placement > size)
|
||||
) {
|
||||
if (!roundRobins.includes(source.bracketIdx)) continue;
|
||||
|
||||
const size =
|
||||
brackets[source.bracketIdx].settings.teamsPerGroup ??
|
||||
TOURNAMENT.RR_DEFAULT_TEAM_COUNT_PER_GROUP;
|
||||
|
||||
if (source.placements.some((placement) => placement > size)) {
|
||||
return bracketIdx;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user