feat: add double elimination match mode

This commit is contained in:
dahyeon committed 2026-06-26 05:00:08 -07:00
1 parent b9aaf55193
commit e12f182e7f
19 files changed
+3415 -58

No files matched your search

+58 -3
View File
@@ -24,6 +24,7 @@ const DEFAULT_FORM: MatchMutationRequest = {
maxParticipants: 10,
gameCount: 3,
gameMode: 'pair',
doubleEliminationResetFinalEnabled: true,
prizes: [],
notices: [],
schedule: [],
@@ -33,6 +34,7 @@ const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
pair: '페어',
bracket: '브래킷',
'round-robin': '라운드 로빈',
'double-elimination': '더블 엘리미네이션',
};
function resolveRoundRobinFullRoundCount(maxParticipants?: number) {
@@ -122,6 +124,8 @@ function makeForm(match?: ApiMatch): MatchMutationRequest & {
gameCount: match.gameCount,
gameMode: match.gameMode ?? 'pair',
roundRobinMaxRounds: match.roundRobinMaxRounds,
doubleEliminationResetFinalEnabled:
match.doubleElimination?.resetFinalEnabled ?? true,
prizes: match.prizes,
notices: match.notices,
schedule: match.schedule,
@@ -188,6 +192,10 @@ export default function MatchAdminPage() {
maxParticipants: Number(form.maxParticipants ?? 10),
gameCount: Number(form.gameCount ?? 3),
gameMode: form.gameMode,
doubleEliminationResetFinalEnabled:
form.gameMode === 'double-elimination'
? Boolean(form.doubleEliminationResetFinalEnabled)
: undefined,
roundRobinMaxRounds:
form.gameMode === 'round-robin'
? normalizeRoundRobinMaxRounds(
@@ -329,7 +337,10 @@ export default function MatchAdminPage() {
}}
className="mt-1 w-full border border-base-content/10 bg-transparent px-3 py-2 text-sm"
>
{[10, 20, 30, 40, 50, 60].map((value) => (
{(form.gameMode === 'double-elimination'
? [20, 40]
: [10, 20, 30, 40, 50, 60]
).map((value) => (
<option key={value} value={value}>{value}명</option>
))}
</select>
@@ -339,16 +350,36 @@ export default function MatchAdminPage() {
<input
type="number"
min={1}
value={form.gameCount}
disabled={form.gameMode === 'double-elimination'}
value={form.gameMode === 'double-elimination' ? 1 : form.gameCount}
onChange={(event) => setForm((current) => ({ ...current, gameCount: Number(event.target.value) }))}
className="mt-1 w-full border border-base-content/10 bg-transparent px-3 py-2 text-sm"
/>
{form.gameMode === 'double-elimination' && (
<span className="mt-1 block text-xs text-base-content/30">
더블 엘리미네이션은 단판으로 진행됩니다.
</span>
)}
</label>
<label className="text-xs text-base-content/45">
게임 모드
<select
value={form.gameMode}
onChange={(event) => setForm((current) => ({ ...current, gameMode: event.target.value as MatchGameMode }))}
onChange={(event) => {
const gameMode = event.target.value as MatchGameMode;
setForm((current) => ({
...current,
gameMode,
maxParticipants:
gameMode === 'double-elimination' &&
current.maxParticipants !== 20 &&
current.maxParticipants !== 40
? 20
: current.maxParticipants,
gameCount:
gameMode === 'double-elimination' ? 1 : current.gameCount,
}));
}}
className="mt-1 w-full border border-base-content/10 bg-transparent px-3 py-2 text-sm"
>
{Object.entries(GAME_MODE_LABEL).map(([value, label]) => (
@@ -385,6 +416,22 @@ export default function MatchAdminPage() {
</span>
</label>
)}
{form.gameMode === 'double-elimination' && (
<label className="flex items-center gap-2 border border-base-content/10 px-3 py-2 text-xs text-base-content/55">
<input
type="checkbox"
checked={Boolean(form.doubleEliminationResetFinalEnabled)}
onChange={(event) =>
setForm((current) => ({
...current,
doubleEliminationResetFinalEnabled:
event.target.checked,
}))
}
/>
그랜드 파이널 리셋 허용
</label>
)}
<label className="text-xs text-base-content/45">
상품 (줄바꿈 구분)
<textarea
@@ -474,6 +521,14 @@ export default function MatchAdminPage() {
최대 {match.roundRobinMaxRounds}R
</span>
)}
{match.gameMode === 'double-elimination' && (
<span className="block text-xs text-base-content/30">
GF 리셋{' '}
{match.doubleElimination?.resetFinalEnabled
? '허용'
: '없음'}
</span>
)}
</td>
<td className="px-3 py-2 text-right">
<div className="inline-flex gap-2">