Throw an error in map list generation if duplicate maps

This commit is contained in:
Kalle 2023-08-26 13:19:18 +03:00
parent 7d08d184ca
commit 768fc62b2c
2 changed files with 38 additions and 0 deletions

View File

@ -763,5 +763,32 @@ TournamentMapListGeneratorOneMode(
}
);
TournamentMapListGeneratorOneMode(
"Throws if duplicate maps in the pool",
() => {
assert.throws(
() =>
generateMaps({
teams: [
{
id: 1,
maps: new MapPool([
{ mode: "SZ", stageId: 1 },
{ mode: "SZ", stageId: 1 },
]),
},
{
id: 2,
maps: new MapPool([]),
},
],
modesIncluded: ["SZ"],
}),
(err: Error) => err.message.includes("Duplicate map"),
"Expected error to be thrown about duplicate maps"
);
}
);
TournamentMapListGenerator.run();
TournamentMapListGeneratorOneMode.run();

View File

@ -163,6 +163,17 @@ export function createTournamentMapList(
),
"Maps submitted for modes not included in the tournament"
);
for (const team of input.teams) {
const stringified = team.maps.stageModePairs.map(
(p) => `${p.stageId}-${p.mode}`
);
const unique = new Set(stringified);
invariant(
unique.size === stringified.length,
`Duplicate maps in map pool (team ${team.id})`
);
}
}
function utilizeOtherStageIdsWhenNoTiebreaker() {