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

+95
View File
@@ -310,6 +310,101 @@ export function useUpdateMatch(communityId = DEFAULT_COMMUNITY_ID) {
});
}
export function useReshuffleDoubleEliminationSeeds(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (matchId: string) =>
apiFetch<ApiMatch>(
`/communities/${communityId}/matches/${matchId}/double-elimination/seeds/reshuffle`,
{ method: 'POST' },
),
});
}
export function useSwapDoubleEliminationSeeds(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (params: {
matchId: string;
leftSeedNumber: number;
rightSeedNumber: number;
}) =>
apiFetch<ApiMatch>(
`/communities/${communityId}/matches/${params.matchId}/double-elimination/seeds/swap`,
{
method: 'POST',
body: JSON.stringify({
leftSeedNumber: params.leftSeedNumber,
rightSeedNumber: params.rightSeedNumber,
}),
},
),
});
}
export function useApplyDoubleEliminationWalkover(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (params: {
matchId: string;
bracketMatchId: string;
winnerTeamIndex: number;
reason?: string;
}) =>
apiFetch<ApiMatch>(
`/communities/${communityId}/matches/${params.matchId}/double-elimination/bracket-matches/${params.bracketMatchId}/walkover`,
{
method: 'POST',
body: JSON.stringify({
winnerTeamIndex: params.winnerTeamIndex,
reason: params.reason,
}),
},
),
});
}
export function useCancelDoubleEliminationWalkover(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (params: {
matchId: string;
bracketMatchId: string;
reason?: string;
}) =>
apiFetch<ApiMatch>(
`/communities/${communityId}/matches/${params.matchId}/double-elimination/bracket-matches/${params.bracketMatchId}/walkover/cancel`,
{
method: 'POST',
body: JSON.stringify({ reason: params.reason }),
},
),
});
}
export function useCancelDoubleEliminationRiotResult(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (params: {
matchId: string;
bracketMatchId: string;
reason?: string;
}) =>
apiFetch<ApiMatch>(
`/communities/${communityId}/matches/${params.matchId}/double-elimination/bracket-matches/${params.bracketMatchId}/result/cancel`,
{
method: 'POST',
body: JSON.stringify({ reason: params.reason }),
},
),
});
}
function createUserHistoryPath(
communityId: string,
userId: string,
+4
View File
@@ -9,6 +9,7 @@ import type {
ApiRiotRecentStatsSummary,
ApiTierHistoryEntry,
ApiTierInfo,
ApiDoubleEliminationBracket,
MatchStatus,
Position,
RiotLane,
@@ -53,6 +54,7 @@ export interface MatchDetailView {
maxParticipants: number;
gameCount: number;
gameMode: ApiMatch["gameMode"];
doubleElimination?: ApiDoubleEliminationBracket;
tournamentCodes: TournamentCodeSlotView[];
joined: boolean;
participants: ParticipantView[];
@@ -63,6 +65,7 @@ export interface MatchDetailView {
riotMatchIds: string[];
games: Array<{
gameNumber: number;
bracketMatchId?: string;
riotMatchId: string;
blueTeamIndex: number;
redTeamIndex: number;
@@ -462,6 +465,7 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
maxParticipants: match.maxParticipants,
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
doubleElimination: match.doubleElimination,
tournamentCodes: match.tournamentCodes ?? [],
joined: Boolean(match.joined),
participants,
+66 -4
View File
@@ -1,7 +1,11 @@
export type Position = 'TOP' | 'JGL' | 'MID' | 'ADC' | 'SUP';
export type RiotLane = 'TOP' | 'JUNGLE' | 'MIDDLE' | 'BOTTOM' | 'UTILITY';
export type TeamSide = 'blue' | 'red';
export type MatchGameMode = 'pair' | 'bracket' | 'round-robin';
export type MatchGameMode =
| 'pair'
| 'bracket'
| 'round-robin'
| 'double-elimination';
export type MatchStatus =
| 'recruiting'
| 'team-built'
@@ -136,15 +140,19 @@ export type TournamentCodeState =
| 'reserved'
| 'used'
| 'expired'
| 'released';
| 'released'
| 'voided';
export type TournamentCodeSlotState = TournamentCodeState | 'pending';
export interface TournamentCodeSlotView {
gameNumber: number;
bracketMatchId?: string;
bracketSide?: string;
roundNumber?: number;
teamAIndex: number;
teamBIndex: number;
matchNumber?: number;
teamAIndex?: number;
teamBIndex?: number;
code: string | null;
expiresAt: string | null;
state: TournamentCodeSlotState;
@@ -189,6 +197,7 @@ export interface ApiMatchGameResultParticipant {
export interface ApiMatchGameResult {
gameNumber: number;
bracketMatchId?: string;
riotMatchId: string;
blueTeamIndex: number;
redTeamIndex: number;
@@ -205,6 +214,7 @@ export interface ApiMatchResult {
riotMatchIds: string[];
games: ApiMatchGameResult[];
seriesResults?: Array<{
bracketMatchId?: string;
teamAIndex: number;
teamBIndex: number;
teamAWins: number;
@@ -225,6 +235,56 @@ export interface ApiMatchGameAssignment {
teamBIndex: number;
}
export interface ApiDoubleEliminationSeed {
seedNumber: number;
teamIndex: number;
}
export interface ApiDoubleEliminationBracketDestination {
bracketMatchId: string;
position: 'A' | 'B';
}
export interface ApiDoubleEliminationWalkover {
winnerTeamIndex: number;
reason?: string;
awardedAt: string;
cancelledAt?: string;
cancelReason?: string;
active: boolean;
}
export interface ApiDoubleEliminationBracketMatch {
bracketMatchId: string;
gameNumber: number;
bracketSide: 'winner' | 'loser' | 'grand-final' | 'reset-final';
roundNumber: number;
matchNumber: number;
state: 'pending' | 'ready' | 'completed';
teamAIndex?: number;
teamBIndex?: number;
winnerAdvancesTo?: ApiDoubleEliminationBracketDestination;
loserAdvancesTo?: ApiDoubleEliminationBracketDestination;
winnerTeamIndex?: number;
loserTeamIndex?: number;
completedBy?: 'riot-result' | 'walkover';
completedAt?: string;
walkover?: ApiDoubleEliminationWalkover;
}
export interface ApiDoubleEliminationBracket {
teamCount: 4 | 8;
resetFinalEnabled: boolean;
resetFinalCreated: boolean;
seeds: ApiDoubleEliminationSeed[];
bracketMatches: ApiDoubleEliminationBracketMatch[];
placements: {
firstTeamIndex?: number;
secondTeamIndex?: number;
thirdTeamIndex?: number;
};
}
export interface ManualTournamentResultCollectResponse {
scanned: number;
matched: number;
@@ -247,6 +307,7 @@ export interface ApiMatch {
gameMode: MatchGameMode;
roundRobinMaxRounds?: number;
gameSchedule?: ApiMatchGameAssignment[];
doubleElimination?: ApiDoubleEliminationBracket;
tournamentCodes?: TournamentCodeSlotView[];
hostUserId?: string;
participants: ApiMatchParticipant[];
@@ -407,6 +468,7 @@ export interface MatchMutationRequest {
gameCount?: number;
gameMode?: MatchGameMode;
roundRobinMaxRounds?: number;
doubleEliminationResetFinalEnabled?: boolean;
prizes?: string[];
notices?: string[];
schedule?: ApiMatchScheduleItem[];