sendou.ink/app/modules/map-list-generator/modes.ts
2022-10-09 00:58:19 +03:00

16 lines
399 B
TypeScript

import shuffle from "just-shuffle";
import type { ModeShort } from "../in-game-lists";
export function modesOrder(
type: "EQUAL" | "SZ_EVERY_OTHER",
modes: ModeShort[]
): ModeShort[] {
if (type === "EQUAL") {
return shuffle(modes);
}
const withoutSZ = shuffle(modes.filter((mode) => mode !== "SZ"));
return withoutSZ.flatMap((mode, i) => (i % 2 === 0 ? ["SZ", mode] : [mode]));
}