This commit is contained in:
dahyeon committed 2026-04-26 04:18:05 -07:00
1 parent 4bad21c2d8
commit 8369fbead7
4 files changed
+108 -104

No files matched your search

@@ -232,7 +232,8 @@ export class AuctionGateway
const token = this.readHandshakeToken(socket); const token = this.readHandshakeToken(socket);
if (!token) { if (!token) {
throw new Error('Missing auction socket token.'); // 임시 운영용: 경매 진행 중에는 로그인 없이도 관전/팀장 모드 선택/입찰을 허용한다.
return;
} }
const { payload } = await this.jwtService.verify( const { payload } = await this.jwtService.verify(
@@ -203,12 +203,7 @@ export class AuctionService {
if (params.amount > team.points) { if (params.amount > team.points) {
throw new BadRequestException('Bid exceeds team points.'); throw new BadRequestException('Bid exceeds team points.');
} }
if ( // 임시 운영용: 클라이언트에서 선택한 팀장 모드를 신뢰하고 실제 로그인 사용자 검증은 건너뛴다.
params.bidderUserId &&
!team.captainUserId.equals(params.bidderUserId)
) {
throw new BadRequestException('Bidder is not the captain of this team.');
}
auction.currentBid = params.amount; auction.currentBid = params.amount;
auction.currentBidder = params.side; auction.currentBidder = params.side;
@@ -218,7 +213,7 @@ export class AuctionService {
auction.bids.push({ auction.bids.push({
side: params.side, side: params.side,
amount: params.amount, amount: params.amount,
bidderUserId: params.bidderUserId ?? team.captainUserId, bidderUserId: team.captainUserId,
timestamp: new Date(), timestamp: new Date(),
}); });
await auction.save(); await auction.save();
+92 -83
View File
@@ -12,8 +12,8 @@ import type {
Position, Position,
RiotLane, RiotLane,
TeamSide, TeamSide,
} from './types'; } from "./types";
import { POSITION_ORDER, sideLabel } from '../lib/league'; import { POSITION_ORDER, sideLabel } from "../lib/league";
export interface ParticipantView { export interface ParticipantView {
id: string; id: string;
@@ -69,7 +69,7 @@ export interface AuctionPlayerView extends ParticipantView {
overall: ApiRiotLaneStats; overall: ApiRiotLaneStats;
byLane: Partial<Record<RiotLane, ApiRiotLaneStats>>; byLane: Partial<Record<RiotLane, ApiRiotLaneStats>>;
primary: ApiRiotLaneStats | null; primary: ApiRiotLaneStats | null;
primarySource: 'lane' | 'overall' | 'none'; primarySource: "lane" | "overall" | "none";
}; };
} }
@@ -86,7 +86,7 @@ export interface AuctionTeamView {
export interface AuctionStateView { export interface AuctionStateView {
matchId: string; matchId: string;
phase: ApiAuction['phase']; phase: ApiAuction["phase"];
teams: [AuctionTeamView, AuctionTeamView]; teams: [AuctionTeamView, AuctionTeamView];
currentPlayer: AuctionPlayerView | null; currentPlayer: AuctionPlayerView | null;
currentPlayerIndex: number; currentPlayerIndex: number;
@@ -105,31 +105,31 @@ export interface AuctionStateView {
} }
const MAP_LABELS: Record<number, string> = { const MAP_LABELS: Record<number, string> = {
11: '소환사의 협곡', 11: "소환사의 협곡",
12: '칼바람 나락', 12: "칼바람 나락",
21: '소환사의 협곡', 21: "소환사의 협곡",
22: '전략적 팀 전투', 22: "전략적 팀 전투",
}; };
const TIER_NAMES: Record<string, string> = { const TIER_NAMES: Record<string, string> = {
IRON: '아이언', IRON: "아이언",
BRONZE: '브론즈', BRONZE: "브론즈",
SILVER: '실버', SILVER: "실버",
GOLD: '골드', GOLD: "골드",
PLATINUM: '플래티넘', PLATINUM: "플래티넘",
EMERALD: '에메랄드', EMERALD: "에메랄드",
DIAMOND: '다이아', DIAMOND: "다이아",
MASTER: '마스터', MASTER: "마스터",
GRANDMASTER: '그랜드마스터', GRANDMASTER: "그랜드마스터",
CHALLENGER: '챌린저', CHALLENGER: "챌린저",
}; };
const POSITION_TO_RIOT_LANE: Record<Position, RiotLane> = { const POSITION_TO_RIOT_LANE: Record<Position, RiotLane> = {
TOP: 'TOP', TOP: "TOP",
JGL: 'JUNGLE', JGL: "JUNGLE",
MID: 'MIDDLE', MID: "MIDDLE",
ADC: 'BOTTOM', ADC: "BOTTOM",
SUP: 'UTILITY', SUP: "UTILITY",
}; };
function createEmptyLaneStats(): ApiRiotLaneStats { function createEmptyLaneStats(): ApiRiotLaneStats {
@@ -146,24 +146,28 @@ function createEmptyLaneStats(): ApiRiotLaneStats {
}; };
} }
function createEmptyRecentStatsView(): AuctionPlayerView['recentStats'] { function createEmptyRecentStatsView(): AuctionPlayerView["recentStats"] {
return { return {
overall: createEmptyLaneStats(), overall: createEmptyLaneStats(),
byLane: {}, byLane: {},
primary: null, primary: null,
primarySource: 'none', primarySource: "none",
}; };
} }
function sortPreferredPositions(preferredPositions: ApiPositionPreference[]) { 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); const sorted = sortPreferredPositions(preferredPositions);
return { return {
mainPosition: sorted[0]?.position ?? 'MID', mainPosition: sorted[0]?.position ?? "MID",
subPosition: sorted[1]?.position ?? sorted[0]?.position ?? 'MID', subPosition: sorted[1]?.position ?? sorted[0]?.position ?? "MID",
}; };
} }
@@ -177,8 +181,8 @@ function mapMatchParticipantToView(
return { return {
id: participant.userId, id: participant.userId,
userId: participant.userId, userId: participant.userId,
summonerName: participant.gameName ?? '알 수 없음', summonerName: participant.gameName ?? "알 수 없음",
tag: participant.tagLine ?? '----', tag: participant.tagLine ?? "----",
tier: participant.tier, tier: participant.tier,
mainPosition, mainPosition,
subPosition, subPosition,
@@ -204,7 +208,7 @@ function mapAuctionPlayerToView(
mainPosition, mainPosition,
subPosition, subPosition,
profileIconId: player.profileIconId, profileIconId: player.profileIconId,
masteries: player.masteries.slice(0, 3).map((mastery) => ({ masteries: player.masteries.slice(0, 5).map((mastery) => ({
championId: mastery.championId, championId: mastery.championId,
level: mastery.championLevel, level: mastery.championLevel,
points: mastery.championPoints, points: mastery.championPoints,
@@ -223,9 +227,9 @@ function createFallbackParticipant(userId: string): ParticipantView {
id: userId, id: userId,
userId, userId,
summonerName: `User ${userId.slice(-4)}`, summonerName: `User ${userId.slice(-4)}`,
tag: '----', tag: "----",
mainPosition: 'MID', mainPosition: "MID",
subPosition: 'MID', subPosition: "MID",
profileIconId: 0, profileIconId: 0,
}; };
} }
@@ -275,15 +279,15 @@ export function formatKoreanDate(dateLike: string | Date) {
const date = new Date(dateLike); const date = new Date(dateLike);
return { return {
date: new Intl.DateTimeFormat('ko-KR', { date: new Intl.DateTimeFormat("ko-KR", {
year: 'numeric', year: "numeric",
month: 'long', month: "long",
day: 'numeric', day: "numeric",
weekday: 'short', weekday: "short",
}).format(date), }).format(date),
time: new Intl.DateTimeFormat('ko-KR', { time: new Intl.DateTimeFormat("ko-KR", {
hour: 'numeric', hour: "numeric",
minute: '2-digit', minute: "2-digit",
}).format(date), }).format(date),
}; };
} }
@@ -293,33 +297,33 @@ function pickPrimary(
mainPosition: Position, mainPosition: Position,
): { ): {
stats: ApiRiotLaneStats | null; stats: ApiRiotLaneStats | null;
source: 'lane' | 'overall' | 'none'; source: "lane" | "overall" | "none";
} { } {
if (!summary) { if (!summary) {
return { stats: null, source: 'none' }; return { stats: null, source: "none" };
} }
const laneStats = summary.byLane[POSITION_TO_RIOT_LANE[mainPosition]]; const laneStats = summary.byLane[POSITION_TO_RIOT_LANE[mainPosition]];
if (laneStats && laneStats.games > 0) { if (laneStats && laneStats.games > 0) {
return { stats: laneStats, source: 'lane' }; return { stats: laneStats, source: "lane" };
} }
if (summary.overall.games > 0) { 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[]) { 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) { export function formatTierLabel(tier?: ApiTierInfo) {
if (!tier) return '미등록'; if (!tier) return "미등록";
const tierName = TIER_NAMES[tier.tier] ?? tier.tier; 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) { if (highTier && tier.leaguePoints > 0) {
return `${tierName} ${tier.leaguePoints}LP`; return `${tierName} ${tier.leaguePoints}LP`;
@@ -330,28 +334,28 @@ export function formatTierLabel(tier?: ApiTierInfo) {
export function getTierColorToken(tier?: ApiTierInfo) { export function getTierColorToken(tier?: ApiTierInfo) {
switch (tier?.tier) { switch (tier?.tier) {
case 'CHALLENGER': case "CHALLENGER":
return 'text-amber-400'; return "text-amber-400";
case 'GRANDMASTER': case "GRANDMASTER":
return 'text-red-400'; return "text-red-400";
case 'MASTER': case "MASTER":
return 'text-fuchsia-400'; return "text-fuchsia-400";
case 'DIAMOND': case "DIAMOND":
return 'text-cyan-400'; return "text-cyan-400";
case 'EMERALD': case "EMERALD":
return 'text-emerald-400'; return "text-emerald-400";
case 'PLATINUM': case "PLATINUM":
return 'text-teal-300'; return "text-teal-300";
case 'GOLD': case "GOLD":
return 'text-yellow-400'; return "text-yellow-400";
case 'SILVER': case "SILVER":
return 'text-gray-300'; return "text-gray-300";
case 'BRONZE': case "BRONZE":
return 'text-amber-700'; return "text-amber-700";
case 'IRON': case "IRON":
return 'text-stone-400'; return "text-stone-400";
default: 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), name: team.name || sideLabel(team.side),
participants: team.members.map((member) => { participants: team.members.map((member) => {
const participant = const participant =
participantLookup.get(member.userId) ?? createFallbackParticipant(member.userId); participantLookup.get(member.userId) ??
createFallbackParticipant(member.userId);
return { return {
...participant, ...participant,
@@ -428,33 +433,37 @@ export function mapApiAuctionToAuctionState(
auctionOrder.map((player) => [player.userId, player]), auctionOrder.map((player) => [player.userId, player]),
); );
const blueTeam = const blueTeam =
auction.teams.find((team) => team.side === 'blue') ?? auction.teams.find((team) => team.side === "blue") ??
({ ({
side: 'blue', side: "blue",
captainUserId: '', captainUserId: "",
points: 0, points: 0,
members: [], members: [],
} satisfies ApiAuctionTeam); } satisfies ApiAuctionTeam);
const redTeam = const redTeam =
auction.teams.find((team) => team.side === 'red') ?? auction.teams.find((team) => team.side === "red") ??
({ ({
side: 'red', side: "red",
captainUserId: '', captainUserId: "",
points: 0, points: 0,
members: [], members: [],
} satisfies ApiAuctionTeam); } satisfies ApiAuctionTeam);
const totalPlayers = auctionOrder.length; const totalPlayers = auctionOrder.length;
const currentPlayer = const currentPlayer =
auction.phase === 'complete' auction.phase === "complete"
? null ? null
: auctionPlayerLookup.get(auction.order[auction.currentIndex]?.userId ?? '') ?? null; : (auctionPlayerLookup.get(
auction.order[auction.currentIndex]?.userId ?? "",
) ?? null);
const currentPlayerIndex = const currentPlayerIndex =
auction.phase === 'complete' ? totalPlayers : auction.currentIndex; auction.phase === "complete" ? totalPlayers : auction.currentIndex;
const timer = auction.currentDeadline const timer = auction.currentDeadline
? Math.max( ? Math.max(
0, 0,
Math.ceil((new Date(auction.currentDeadline).getTime() - now.getTime()) / 1000), Math.ceil(
(new Date(auction.currentDeadline).getTime() - now.getTime()) / 1000,
),
) )
: 0; : 0;
+12 -13
View File
@@ -637,19 +637,18 @@ export default function AuctionPage() {
</div> </div>
<div className="flex items-center gap-2 text-xs text-base-content/40"> <div className="flex items-center gap-2 text-xs text-base-content/40">
<span>소켓: {socket.connectionStatus}</span> <span>소켓: {socket.connectionStatus}</span>
{import.meta.env.DEV && ( {/* 임시 운영용: 로그인/권한 확인 없이 조작자 역할을 선택할 수 있게 열어둔다. */}
<select <select
value={captainSide} value={captainSide}
onChange={(event) => onChange={(event) =>
setDevCaptainSide(event.target.value as 'spectator' | 'blue' | 'red') setDevCaptainSide(event.target.value as 'spectator' | 'blue' | 'red')
} }
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs" className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
> >
<option value="spectator">관전자</option> <option value="spectator">관전자</option>
<option value="blue">블루팀장</option> <option value="blue">블루팀장</option>
<option value="red">레드팀장</option> <option value="red">레드팀장</option>
</select> </select>
)}
</div> </div>
</div> </div>
</div> </div>