This commit is contained in:
dahyeon committed 2026-05-02 04:05:35 -07:00
1 parent 4baea89f89
commit fd386ed202
32 files changed
+1128 -601

No files matched your search

+28 -40
View File
@@ -11,10 +11,9 @@ import type {
MatchStatus,
Position,
RiotLane,
TeamSide,
TournamentCodeSlotView,
} from "./types";
import { POSITION_ORDER, sideLabel } from "../lib/league";
import { POSITION_ORDER, teamIndexLabel } from "../lib/league";
export interface ParticipantView {
id: string;
@@ -34,8 +33,7 @@ export interface TeamParticipantView extends ParticipantView {
}
export interface TeamView {
side: TeamSide;
groupIndex: number;
teamIndex: number;
name: string;
participants: TeamParticipantView[];
}
@@ -57,21 +55,21 @@ export interface MatchDetailView {
teams: TeamView[];
result?: {
winner?: string;
winnerSide?: TeamSide;
blueScore: number;
redScore: number;
winnerTeamIndex?: number;
riotMatchIds: string[];
games: Array<{
gameNumber: number;
riotMatchId: string;
winnerSide: TeamSide;
blueGroupIndex: number;
redGroupIndex: number;
blueTeamIndex: number;
redTeamIndex: number;
winnerTeamIndex: number;
winnerSide: "blue" | "red";
gameCreation: number;
gameDuration: number;
participants: Array<{
userId: string;
side: TeamSide;
teamIndex: number;
side: "blue" | "red";
championId: number;
kills: number;
deaths: number;
@@ -101,8 +99,8 @@ export interface AuctionPlayerView extends ParticipantView {
}
export interface AuctionTeamView {
side: TeamSide;
groupIndex: number;
teamIndex: number;
name: string;
captainUserId: string;
captainName: string;
points: number;
@@ -121,13 +119,12 @@ export interface AuctionStateView {
totalPlayers: number;
auctionOrder: AuctionPlayerView[];
bids: {
side: TeamSide;
groupIndex: number;
teamIndex: number;
amount: number;
timestamp: string;
}[];
currentBid: number;
currentBidder: { side: TeamSide; groupIndex: number } | null;
currentBidder: { teamIndex: number } | null;
timer: number;
maxTimer: number;
deadline?: string;
@@ -270,8 +267,8 @@ function mapAuctionTeamToView(
participantLookup: Map<string, ParticipantView>,
): AuctionTeamView {
return {
side: team.side,
groupIndex: team.groupIndex ?? 1,
teamIndex: team.teamIndex,
name: teamIndexLabel(team.teamIndex),
captainUserId: team.captainUserId,
captainName:
participantLookup.get(team.captainUserId)?.summonerName ??
@@ -405,9 +402,8 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
);
const teams = match.teams.map((team) => ({
side: team.side,
groupIndex: team.groupIndex ?? 1,
name: team.name || sideLabel(team.side),
teamIndex: team.teamIndex,
name: teamIndexLabel(team.teamIndex, team.name),
participants: team.members.map((member) => {
const participant =
participantLookup.get(member.userId) ??
@@ -421,8 +417,8 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
}),
}));
const winnerTeam = match.result?.winnerSide
? teams.find((team) => team.side === match.result?.winnerSide)
const winnerTeam = match.result?.winnerTeamIndex
? teams.find((team) => team.teamIndex === match.result?.winnerTeamIndex)
: undefined;
return {
@@ -434,20 +430,16 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
description: match.description,
map: mapIdToLabel(match.mapId),
maxParticipants: match.maxParticipants,
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
gameCount: match.gameCount ?? 3,
gameMode: match.gameMode ?? "pair",
tournamentCodes: match.tournamentCodes ?? [],
joined: Boolean(match.joined),
participants,
teams,
result: match.result
? {
winner: match.result.winnerSide
? winnerTeam?.name ?? sideLabel(match.result.winnerSide)
: undefined,
winnerSide: match.result.winnerSide,
blueScore: match.result.blueScore,
redScore: match.result.redScore,
? {
winner: match.result.winnerTeamIndex ? winnerTeam?.name : undefined,
winnerTeamIndex: match.result.winnerTeamIndex,
riotMatchIds: match.result.riotMatchIds,
games: [...(match.result.games ?? [])].sort(
(left, right) => left.gameNumber - right.gameNumber,
@@ -476,9 +468,7 @@ export function mapApiAuctionToAuctionState(
auctionOrder.map((player) => [player.userId, player]),
);
const teams = [...auction.teams].sort(
(left, right) =>
(left.groupIndex ?? 1) - (right.groupIndex ?? 1) ||
(left.side === "blue" ? -1 : 1),
(left, right) => left.teamIndex - right.teamIndex,
);
const totalPlayers = auctionOrder.length;
@@ -510,16 +500,14 @@ export function mapApiAuctionToAuctionState(
totalPlayers,
auctionOrder,
bids: auction.bids.map((bid) => ({
side: bid.side,
groupIndex: bid.groupIndex ?? 1,
teamIndex: bid.teamIndex,
amount: bid.amount,
timestamp: bid.timestamp,
})),
currentBid: auction.currentBid,
currentBidder: auction.currentBidder
currentBidder: auction.currentBidderTeamIndex
? {
side: auction.currentBidder,
groupIndex: auction.currentBidderGroupIndex ?? 1,
teamIndex: auction.currentBidderTeamIndex,
}
: null,
timer,