.
This commit is contained in:
1 parent
4bad21c2d8
commit
8369fbead7
4 files changed
+108
-104
No files matched your search
+92
-83
@@ -12,8 +12,8 @@ import type {
|
||||
Position,
|
||||
RiotLane,
|
||||
TeamSide,
|
||||
} from './types';
|
||||
import { POSITION_ORDER, sideLabel } from '../lib/league';
|
||||
} from "./types";
|
||||
import { POSITION_ORDER, sideLabel } from "../lib/league";
|
||||
|
||||
export interface ParticipantView {
|
||||
id: string;
|
||||
@@ -69,7 +69,7 @@ export interface AuctionPlayerView extends ParticipantView {
|
||||
overall: ApiRiotLaneStats;
|
||||
byLane: Partial<Record<RiotLane, ApiRiotLaneStats>>;
|
||||
primary: ApiRiotLaneStats | null;
|
||||
primarySource: 'lane' | 'overall' | 'none';
|
||||
primarySource: "lane" | "overall" | "none";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export interface AuctionTeamView {
|
||||
|
||||
export interface AuctionStateView {
|
||||
matchId: string;
|
||||
phase: ApiAuction['phase'];
|
||||
phase: ApiAuction["phase"];
|
||||
teams: [AuctionTeamView, AuctionTeamView];
|
||||
currentPlayer: AuctionPlayerView | null;
|
||||
currentPlayerIndex: number;
|
||||
@@ -105,31 +105,31 @@ export interface AuctionStateView {
|
||||
}
|
||||
|
||||
const MAP_LABELS: Record<number, string> = {
|
||||
11: '소환사의 협곡',
|
||||
12: '칼바람 나락',
|
||||
21: '소환사의 협곡',
|
||||
22: '전략적 팀 전투',
|
||||
11: "소환사의 협곡",
|
||||
12: "칼바람 나락",
|
||||
21: "소환사의 협곡",
|
||||
22: "전략적 팀 전투",
|
||||
};
|
||||
|
||||
const TIER_NAMES: Record<string, string> = {
|
||||
IRON: '아이언',
|
||||
BRONZE: '브론즈',
|
||||
SILVER: '실버',
|
||||
GOLD: '골드',
|
||||
PLATINUM: '플래티넘',
|
||||
EMERALD: '에메랄드',
|
||||
DIAMOND: '다이아',
|
||||
MASTER: '마스터',
|
||||
GRANDMASTER: '그랜드마스터',
|
||||
CHALLENGER: '챌린저',
|
||||
IRON: "아이언",
|
||||
BRONZE: "브론즈",
|
||||
SILVER: "실버",
|
||||
GOLD: "골드",
|
||||
PLATINUM: "플래티넘",
|
||||
EMERALD: "에메랄드",
|
||||
DIAMOND: "다이아",
|
||||
MASTER: "마스터",
|
||||
GRANDMASTER: "그랜드마스터",
|
||||
CHALLENGER: "챌린저",
|
||||
};
|
||||
|
||||
const POSITION_TO_RIOT_LANE: Record<Position, RiotLane> = {
|
||||
TOP: 'TOP',
|
||||
JGL: 'JUNGLE',
|
||||
MID: 'MIDDLE',
|
||||
ADC: 'BOTTOM',
|
||||
SUP: 'UTILITY',
|
||||
TOP: "TOP",
|
||||
JGL: "JUNGLE",
|
||||
MID: "MIDDLE",
|
||||
ADC: "BOTTOM",
|
||||
SUP: "UTILITY",
|
||||
};
|
||||
|
||||
function createEmptyLaneStats(): ApiRiotLaneStats {
|
||||
@@ -146,24 +146,28 @@ function createEmptyLaneStats(): ApiRiotLaneStats {
|
||||
};
|
||||
}
|
||||
|
||||
function createEmptyRecentStatsView(): AuctionPlayerView['recentStats'] {
|
||||
function createEmptyRecentStatsView(): AuctionPlayerView["recentStats"] {
|
||||
return {
|
||||
overall: createEmptyLaneStats(),
|
||||
byLane: {},
|
||||
primary: null,
|
||||
primarySource: 'none',
|
||||
primarySource: "none",
|
||||
};
|
||||
}
|
||||
|
||||
function sortPreferredPositions(preferredPositions: ApiPositionPreference[]) {
|
||||
return [...preferredPositions].sort((left, right) => left.priority - right.priority);
|
||||
return [...preferredPositions].sort(
|
||||
(left, right) => left.priority - right.priority,
|
||||
);
|
||||
}
|
||||
|
||||
function resolveMainAndSubPosition(preferredPositions: ApiPositionPreference[]) {
|
||||
function resolveMainAndSubPosition(
|
||||
preferredPositions: ApiPositionPreference[],
|
||||
) {
|
||||
const sorted = sortPreferredPositions(preferredPositions);
|
||||
return {
|
||||
mainPosition: sorted[0]?.position ?? 'MID',
|
||||
subPosition: sorted[1]?.position ?? sorted[0]?.position ?? 'MID',
|
||||
mainPosition: sorted[0]?.position ?? "MID",
|
||||
subPosition: sorted[1]?.position ?? sorted[0]?.position ?? "MID",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -177,8 +181,8 @@ function mapMatchParticipantToView(
|
||||
return {
|
||||
id: participant.userId,
|
||||
userId: participant.userId,
|
||||
summonerName: participant.gameName ?? '알 수 없음',
|
||||
tag: participant.tagLine ?? '----',
|
||||
summonerName: participant.gameName ?? "알 수 없음",
|
||||
tag: participant.tagLine ?? "----",
|
||||
tier: participant.tier,
|
||||
mainPosition,
|
||||
subPosition,
|
||||
@@ -204,7 +208,7 @@ function mapAuctionPlayerToView(
|
||||
mainPosition,
|
||||
subPosition,
|
||||
profileIconId: player.profileIconId,
|
||||
masteries: player.masteries.slice(0, 3).map((mastery) => ({
|
||||
masteries: player.masteries.slice(0, 5).map((mastery) => ({
|
||||
championId: mastery.championId,
|
||||
level: mastery.championLevel,
|
||||
points: mastery.championPoints,
|
||||
@@ -223,9 +227,9 @@ function createFallbackParticipant(userId: string): ParticipantView {
|
||||
id: userId,
|
||||
userId,
|
||||
summonerName: `User ${userId.slice(-4)}`,
|
||||
tag: '----',
|
||||
mainPosition: 'MID',
|
||||
subPosition: 'MID',
|
||||
tag: "----",
|
||||
mainPosition: "MID",
|
||||
subPosition: "MID",
|
||||
profileIconId: 0,
|
||||
};
|
||||
}
|
||||
@@ -275,15 +279,15 @@ export function formatKoreanDate(dateLike: string | Date) {
|
||||
const date = new Date(dateLike);
|
||||
|
||||
return {
|
||||
date: new Intl.DateTimeFormat('ko-KR', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
weekday: 'short',
|
||||
date: new Intl.DateTimeFormat("ko-KR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
weekday: "short",
|
||||
}).format(date),
|
||||
time: new Intl.DateTimeFormat('ko-KR', {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
time: new Intl.DateTimeFormat("ko-KR", {
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
}).format(date),
|
||||
};
|
||||
}
|
||||
@@ -293,33 +297,33 @@ function pickPrimary(
|
||||
mainPosition: Position,
|
||||
): {
|
||||
stats: ApiRiotLaneStats | null;
|
||||
source: 'lane' | 'overall' | 'none';
|
||||
source: "lane" | "overall" | "none";
|
||||
} {
|
||||
if (!summary) {
|
||||
return { stats: null, source: 'none' };
|
||||
return { stats: null, source: "none" };
|
||||
}
|
||||
|
||||
const laneStats = summary.byLane[POSITION_TO_RIOT_LANE[mainPosition]];
|
||||
if (laneStats && laneStats.games > 0) {
|
||||
return { stats: laneStats, source: 'lane' };
|
||||
return { stats: laneStats, source: "lane" };
|
||||
}
|
||||
|
||||
if (summary.overall.games > 0) {
|
||||
return { stats: summary.overall, source: 'overall' };
|
||||
return { stats: summary.overall, source: "overall" };
|
||||
}
|
||||
|
||||
return { stats: null, source: 'none' };
|
||||
return { stats: null, source: "none" };
|
||||
}
|
||||
|
||||
export function selectPrimaryTier(tiers: ApiTierInfo[]) {
|
||||
return tiers.find((tier) => tier.queueType === 'RANKED_SOLO_5x5') ?? tiers[0];
|
||||
return tiers.find((tier) => tier.queueType === "RANKED_SOLO_5x5") ?? tiers[0];
|
||||
}
|
||||
|
||||
export function formatTierLabel(tier?: ApiTierInfo) {
|
||||
if (!tier) return '미등록';
|
||||
if (!tier) return "미등록";
|
||||
|
||||
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
|
||||
const highTier = ['MASTER', 'GRANDMASTER', 'CHALLENGER'].includes(tier.tier);
|
||||
const highTier = ["MASTER", "GRANDMASTER", "CHALLENGER"].includes(tier.tier);
|
||||
|
||||
if (highTier && tier.leaguePoints > 0) {
|
||||
return `${tierName} ${tier.leaguePoints}LP`;
|
||||
@@ -330,28 +334,28 @@ export function formatTierLabel(tier?: ApiTierInfo) {
|
||||
|
||||
export function getTierColorToken(tier?: ApiTierInfo) {
|
||||
switch (tier?.tier) {
|
||||
case 'CHALLENGER':
|
||||
return 'text-amber-400';
|
||||
case 'GRANDMASTER':
|
||||
return 'text-red-400';
|
||||
case 'MASTER':
|
||||
return 'text-fuchsia-400';
|
||||
case 'DIAMOND':
|
||||
return 'text-cyan-400';
|
||||
case 'EMERALD':
|
||||
return 'text-emerald-400';
|
||||
case 'PLATINUM':
|
||||
return 'text-teal-300';
|
||||
case 'GOLD':
|
||||
return 'text-yellow-400';
|
||||
case 'SILVER':
|
||||
return 'text-gray-300';
|
||||
case 'BRONZE':
|
||||
return 'text-amber-700';
|
||||
case 'IRON':
|
||||
return 'text-stone-400';
|
||||
case "CHALLENGER":
|
||||
return "text-amber-400";
|
||||
case "GRANDMASTER":
|
||||
return "text-red-400";
|
||||
case "MASTER":
|
||||
return "text-fuchsia-400";
|
||||
case "DIAMOND":
|
||||
return "text-cyan-400";
|
||||
case "EMERALD":
|
||||
return "text-emerald-400";
|
||||
case "PLATINUM":
|
||||
return "text-teal-300";
|
||||
case "GOLD":
|
||||
return "text-yellow-400";
|
||||
case "SILVER":
|
||||
return "text-gray-300";
|
||||
case "BRONZE":
|
||||
return "text-amber-700";
|
||||
case "IRON":
|
||||
return "text-stone-400";
|
||||
default:
|
||||
return 'text-base-content/50';
|
||||
return "text-base-content/50";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +378,8 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
|
||||
name: team.name || sideLabel(team.side),
|
||||
participants: team.members.map((member) => {
|
||||
const participant =
|
||||
participantLookup.get(member.userId) ?? createFallbackParticipant(member.userId);
|
||||
participantLookup.get(member.userId) ??
|
||||
createFallbackParticipant(member.userId);
|
||||
|
||||
return {
|
||||
...participant,
|
||||
@@ -428,33 +433,37 @@ export function mapApiAuctionToAuctionState(
|
||||
auctionOrder.map((player) => [player.userId, player]),
|
||||
);
|
||||
const blueTeam =
|
||||
auction.teams.find((team) => team.side === 'blue') ??
|
||||
auction.teams.find((team) => team.side === "blue") ??
|
||||
({
|
||||
side: 'blue',
|
||||
captainUserId: '',
|
||||
side: "blue",
|
||||
captainUserId: "",
|
||||
points: 0,
|
||||
members: [],
|
||||
} satisfies ApiAuctionTeam);
|
||||
const redTeam =
|
||||
auction.teams.find((team) => team.side === 'red') ??
|
||||
auction.teams.find((team) => team.side === "red") ??
|
||||
({
|
||||
side: 'red',
|
||||
captainUserId: '',
|
||||
side: "red",
|
||||
captainUserId: "",
|
||||
points: 0,
|
||||
members: [],
|
||||
} satisfies ApiAuctionTeam);
|
||||
|
||||
const totalPlayers = auctionOrder.length;
|
||||
const currentPlayer =
|
||||
auction.phase === 'complete'
|
||||
auction.phase === "complete"
|
||||
? null
|
||||
: auctionPlayerLookup.get(auction.order[auction.currentIndex]?.userId ?? '') ?? null;
|
||||
: (auctionPlayerLookup.get(
|
||||
auction.order[auction.currentIndex]?.userId ?? "",
|
||||
) ?? null);
|
||||
const currentPlayerIndex =
|
||||
auction.phase === 'complete' ? totalPlayers : auction.currentIndex;
|
||||
auction.phase === "complete" ? totalPlayers : auction.currentIndex;
|
||||
const timer = auction.currentDeadline
|
||||
? Math.max(
|
||||
0,
|
||||
Math.ceil((new Date(auction.currentDeadline).getTime() - now.getTime()) / 1000),
|
||||
Math.ceil(
|
||||
(new Date(auction.currentDeadline).getTime() - now.getTime()) / 1000,
|
||||
),
|
||||
)
|
||||
: 0;
|
||||
|
||||
|
||||
@@ -637,19 +637,18 @@ export default function AuctionPage() {
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-xs text-base-content/40">
|
||||
<span>소켓: {socket.connectionStatus}</span>
|
||||
{import.meta.env.DEV && (
|
||||
<select
|
||||
value={captainSide}
|
||||
onChange={(event) =>
|
||||
setDevCaptainSide(event.target.value as 'spectator' | 'blue' | 'red')
|
||||
}
|
||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||
>
|
||||
<option value="spectator">관전자</option>
|
||||
<option value="blue">블루팀장</option>
|
||||
<option value="red">레드팀장</option>
|
||||
</select>
|
||||
)}
|
||||
{/* 임시 운영용: 로그인/권한 확인 없이 조작자 역할을 선택할 수 있게 열어둔다. */}
|
||||
<select
|
||||
value={captainSide}
|
||||
onChange={(event) =>
|
||||
setDevCaptainSide(event.target.value as 'spectator' | 'blue' | 'red')
|
||||
}
|
||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||
>
|
||||
<option value="spectator">관전자</option>
|
||||
<option value="blue">블루팀장</option>
|
||||
<option value="red">레드팀장</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user