From 8eb852f84083f1007af6bd471cf12018907feb64 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:04:54 +0300 Subject: [PATCH] Add "Start with SZ" toggleable option on the Preparing Maps page Closes #1887 --- .../components/BracketMapListDialog.tsx | 44 ++++++++++++++++ .../tournament-bracket/core/toMapList.ts | 50 ++++++++++++++----- 2 files changed, 81 insertions(+), 13 deletions(-) diff --git a/app/features/tournament-bracket/components/BracketMapListDialog.tsx b/app/features/tournament-bracket/components/BracketMapListDialog.tsx index 93af5c5b1..0478d3119 100644 --- a/app/features/tournament-bracket/components/BracketMapListDialog.tsx +++ b/app/features/tournament-bracket/components/BracketMapListDialog.tsx @@ -65,6 +65,7 @@ export function BracketMapListDialog({ }) : untrimmedPreparedMaps; + const [szFirst, setSzFirst] = React.useState(false); const [eliminationTeamCount, setEliminationTeamCount] = React.useState(() => { if (preparedMaps?.eliminationTeamCount) { return preparedMaps.eliminationTeamCount; @@ -91,6 +92,8 @@ export function BracketMapListDialog({ preparedMaps?.maps[0].type ?? "BEST_OF", ); + const flavor = szFirst ? "SZ_FIRST" : null; + const [maps, setMaps] = React.useState(() => { if (preparedMaps) { return new Map(preparedMaps.maps.map((map) => [map.roundId, map])); @@ -103,6 +106,7 @@ export function BracketMapListDialog({ rounds, type: bracket.type, pickBanStyle: null, + flavor, }); }); const [pickBanStyle, setPickBanStyle] = React.useState( @@ -271,6 +275,7 @@ export function BracketMapListDialog({ type: bracket.type, roundsWithPickBan: newRoundsWithPickBan, pickBanStyle, + flavor, }), ); }} @@ -297,6 +302,7 @@ export function BracketMapListDialog({ type: bracket.type, roundsWithPickBan, pickBanStyle, + flavor, }), ); setEliminationTeamCount(newCount); @@ -319,6 +325,7 @@ export function BracketMapListDialog({ type: bracket.type, roundsWithPickBan, pickBanStyle, + flavor, }); setMaps(newMaps); }} @@ -330,6 +337,25 @@ export function BracketMapListDialog({ onSetCountType={setCountType} /> ) : null} + {tournament.ctx.mapPickingStyle === "TO" ? ( + { + setSzFirst(newSzFirst); + setMaps( + generateTournamentRoundMaplist({ + mapCounts, + pool: tournament.ctx.toSetMapPool, + rounds, + type: bracket.type, + roundsWithPickBan, + pickBanStyle, + flavor: newSzFirst ? "SZ_FIRST" : null, + }), + ); + }} + /> + ) : null} {tournament.ctx.toSetMapPool.length > 0 ? (