.
This commit is contained in:
1 parent
6d62de4ec4
commit
285f72b3ee
16 files changed
+2095
-136
No files matched your search
+69
-32
@@ -5,9 +5,12 @@ import type {
|
||||
ApiMatch,
|
||||
ApiMatchParticipant,
|
||||
ApiPositionPreference,
|
||||
ApiRiotLaneStats,
|
||||
ApiRiotRecentStatsSummary,
|
||||
ApiTierInfo,
|
||||
MatchStatus,
|
||||
Position,
|
||||
RiotLane,
|
||||
TeamSide,
|
||||
} from './types';
|
||||
import { POSITION_ORDER, sideLabel } from '../lib/league';
|
||||
@@ -63,15 +66,10 @@ export interface AuctionPlayerView extends ParticipantView {
|
||||
points: number;
|
||||
}[];
|
||||
recentStats: {
|
||||
games: number;
|
||||
wins: number;
|
||||
losses: number;
|
||||
kda: {
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
};
|
||||
avgCs: number;
|
||||
overall: ApiRiotLaneStats;
|
||||
byLane: Partial<Record<RiotLane, ApiRiotLaneStats>>;
|
||||
primary: ApiRiotLaneStats | null;
|
||||
primarySource: 'lane' | 'overall' | 'none';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -126,6 +124,37 @@ const TIER_NAMES: Record<string, string> = {
|
||||
CHALLENGER: '챌린저',
|
||||
};
|
||||
|
||||
const POSITION_TO_RIOT_LANE: Record<Position, RiotLane> = {
|
||||
TOP: 'TOP',
|
||||
JGL: 'JUNGLE',
|
||||
MID: 'MIDDLE',
|
||||
ADC: 'BOTTOM',
|
||||
SUP: 'UTILITY',
|
||||
};
|
||||
|
||||
function createEmptyLaneStats(): ApiRiotLaneStats {
|
||||
return {
|
||||
games: 0,
|
||||
wins: 0,
|
||||
losses: 0,
|
||||
avgKills: 0,
|
||||
avgDeaths: 0,
|
||||
avgAssists: 0,
|
||||
avgCs: 0,
|
||||
avgCsPerMin: 0,
|
||||
mostPlayedChampionIds: [],
|
||||
};
|
||||
}
|
||||
|
||||
function createEmptyRecentStatsView(): AuctionPlayerView['recentStats'] {
|
||||
return {
|
||||
overall: createEmptyLaneStats(),
|
||||
byLane: {},
|
||||
primary: null,
|
||||
primarySource: 'none',
|
||||
};
|
||||
}
|
||||
|
||||
function sortPreferredPositions(preferredPositions: ApiPositionPreference[]) {
|
||||
return [...preferredPositions].sort((left, right) => left.priority - right.priority);
|
||||
}
|
||||
@@ -163,6 +192,8 @@ function mapAuctionPlayerToView(
|
||||
const { mainPosition, subPosition } = resolveMainAndSubPosition(
|
||||
player.preferredPositions,
|
||||
);
|
||||
const summary = player.recentStatsSummary;
|
||||
const primary = pickPrimary(summary, mainPosition);
|
||||
|
||||
return {
|
||||
id: player.userId,
|
||||
@@ -179,15 +210,10 @@ function mapAuctionPlayerToView(
|
||||
points: mastery.championPoints,
|
||||
})),
|
||||
recentStats: {
|
||||
games: player.recentStatsSummary?.games ?? 0,
|
||||
wins: player.recentStatsSummary?.wins ?? 0,
|
||||
losses: player.recentStatsSummary?.losses ?? 0,
|
||||
kda: {
|
||||
kills: player.recentStatsSummary?.avgKills ?? 0,
|
||||
deaths: player.recentStatsSummary?.avgDeaths ?? 0,
|
||||
assists: player.recentStatsSummary?.avgAssists ?? 0,
|
||||
},
|
||||
avgCs: Math.round(player.recentStatsSummary?.avgCs ?? 0),
|
||||
overall: summary?.overall ?? createEmptyLaneStats(),
|
||||
byLane: summary?.byLane ?? {},
|
||||
primary: primary.stats,
|
||||
primarySource: primary.source,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -224,24 +250,12 @@ function mapAuctionTeamToView(
|
||||
? {
|
||||
...participant,
|
||||
masteries: [],
|
||||
recentStats: {
|
||||
games: 0,
|
||||
wins: 0,
|
||||
losses: 0,
|
||||
kda: { kills: 0, deaths: 0, assists: 0 },
|
||||
avgCs: 0,
|
||||
},
|
||||
recentStats: createEmptyRecentStatsView(),
|
||||
}
|
||||
: {
|
||||
...createFallbackParticipant(member.userId),
|
||||
masteries: [],
|
||||
recentStats: {
|
||||
games: 0,
|
||||
wins: 0,
|
||||
losses: 0,
|
||||
kda: { kills: 0, deaths: 0, assists: 0 },
|
||||
avgCs: 0,
|
||||
},
|
||||
recentStats: createEmptyRecentStatsView(),
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -274,6 +288,29 @@ export function formatKoreanDate(dateLike: string | Date) {
|
||||
};
|
||||
}
|
||||
|
||||
function pickPrimary(
|
||||
summary: ApiRiotRecentStatsSummary | undefined,
|
||||
mainPosition: Position,
|
||||
): {
|
||||
stats: ApiRiotLaneStats | null;
|
||||
source: 'lane' | 'overall' | 'none';
|
||||
} {
|
||||
if (!summary) {
|
||||
return { stats: null, source: 'none' };
|
||||
}
|
||||
|
||||
const laneStats = summary.byLane[POSITION_TO_RIOT_LANE[mainPosition]];
|
||||
if (laneStats && laneStats.games > 0) {
|
||||
return { stats: laneStats, source: 'lane' };
|
||||
}
|
||||
|
||||
if (summary.overall.games > 0) {
|
||||
return { stats: summary.overall, source: 'overall' };
|
||||
}
|
||||
|
||||
return { stats: null, source: 'none' };
|
||||
}
|
||||
|
||||
export function selectPrimaryTier(tiers: ApiTierInfo[]) {
|
||||
return tiers.find((tier) => tier.queueType === 'RANKED_SOLO_5x5') ?? tiers[0];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export type Position = 'TOP' | 'JGL' | 'MID' | 'ADC' | 'SUP';
|
||||
export type RiotLane = 'TOP' | 'JUNGLE' | 'MIDDLE' | 'BOTTOM' | 'UTILITY';
|
||||
export type TeamSide = 'blue' | 'red';
|
||||
export type MatchStatus =
|
||||
| 'recruiting'
|
||||
@@ -43,7 +44,7 @@ export interface ApiChampionMasteryEntry {
|
||||
nextSeasonMilestone?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface ApiRiotRecentStatsSummary {
|
||||
export interface ApiRiotLaneStats {
|
||||
games: number;
|
||||
wins: number;
|
||||
losses: number;
|
||||
@@ -51,8 +52,13 @@ export interface ApiRiotRecentStatsSummary {
|
||||
avgDeaths: number;
|
||||
avgAssists: number;
|
||||
avgCs: number;
|
||||
mostPlayedChampionIds: string[];
|
||||
extras?: Record<string, unknown>;
|
||||
avgCsPerMin: number;
|
||||
mostPlayedChampionIds: number[];
|
||||
}
|
||||
|
||||
export interface ApiRiotRecentStatsSummary {
|
||||
overall: ApiRiotLaneStats;
|
||||
byLane: Partial<Record<RiotLane, ApiRiotLaneStats>>;
|
||||
}
|
||||
|
||||
export interface ApiRiotAccount {
|
||||
|
||||
@@ -20,12 +20,21 @@ import {
|
||||
profileIconUrl,
|
||||
} from '../lib/ddragon';
|
||||
import { positionIcon, positionLabel } from '../lib/league';
|
||||
import type { Position } from '../api/types';
|
||||
import type { ApiRiotLaneStats, Position } from '../api/types';
|
||||
|
||||
function formatPoints(value: number) {
|
||||
return value.toLocaleString();
|
||||
}
|
||||
|
||||
const LANE_ROWS: Position[] = ['TOP', 'JGL', 'MID', 'ADC', 'SUP'];
|
||||
const POSITION_TO_RIOT_LANE = {
|
||||
TOP: 'TOP',
|
||||
JGL: 'JUNGLE',
|
||||
MID: 'MIDDLE',
|
||||
ADC: 'BOTTOM',
|
||||
SUP: 'UTILITY',
|
||||
} as const;
|
||||
|
||||
function PosBadge({ pos }: { pos: Position }) {
|
||||
return (
|
||||
<span className="inline-flex items-center gap-1.5 text-[11px] font-medium px-1.5 py-0.5 border border-primary/20 text-primary bg-primary/5">
|
||||
@@ -49,6 +58,127 @@ function TimerBar({ timer, maxTimer }: { timer: number; maxTimer: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
function getWinRate(stats: ApiRiotLaneStats) {
|
||||
return stats.games > 0 ? Math.round((stats.wins / stats.games) * 100) : 0;
|
||||
}
|
||||
|
||||
function getWinRateClass(winRate: number) {
|
||||
if (winRate >= 55) return 'text-blue-400';
|
||||
if (winRate >= 50) return 'text-base-content';
|
||||
return 'text-red-400';
|
||||
}
|
||||
|
||||
function formatKdaRatio(stats: ApiRiotLaneStats) {
|
||||
if (stats.avgDeaths === 0) return 'Perfect';
|
||||
return ((stats.avgKills + stats.avgAssists) / stats.avgDeaths).toFixed(2);
|
||||
}
|
||||
|
||||
function RecentSoloStats({
|
||||
player,
|
||||
}: {
|
||||
player: NonNullable<AuctionStateView['currentPlayer']>;
|
||||
}) {
|
||||
const primaryStats = player.recentStats.primary;
|
||||
|
||||
if (!primaryStats) {
|
||||
return (
|
||||
<div className="p-4">
|
||||
<h4 className="text-[10px] font-bold uppercase tracking-wider text-base-content/30 mb-2.5">
|
||||
최근 솔로랭크
|
||||
</h4>
|
||||
<div className="rounded border border-dashed border-base-content/10 px-3 py-6 text-center text-[11px] text-base-content/25">
|
||||
최근 솔로랭크 기록이 없습니다
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const primaryWinRate = getWinRate(primaryStats);
|
||||
const primaryKdaRatio = formatKdaRatio(primaryStats);
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<div className="flex items-start justify-between gap-3 mb-3">
|
||||
<div>
|
||||
<h4 className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
|
||||
최근 솔로랭크
|
||||
</h4>
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
<span className="text-[12px] font-semibold text-base-content">
|
||||
{positionLabel[player.mainPosition]}
|
||||
</span>
|
||||
{player.recentStats.primarySource === 'overall' ? (
|
||||
<span className="text-[10px] text-base-content/35">
|
||||
전체 기준
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className={`text-sm font-bold tabular-nums ${getWinRateClass(primaryWinRate)}`}
|
||||
>
|
||||
{primaryWinRate}%
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">전적</span>
|
||||
<span className="text-[12px] text-base-content/60 tabular-nums">
|
||||
<span className="text-blue-400">{primaryStats.wins}W</span>{' '}
|
||||
<span className="text-red-400">{primaryStats.losses}L</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">KDA</span>
|
||||
<span className="text-[12px] text-base-content/60 tabular-nums">
|
||||
{primaryStats.avgKills}/{primaryStats.avgDeaths}/{primaryStats.avgAssists}
|
||||
<span
|
||||
className={`ml-1 font-bold ${Number(primaryKdaRatio) >= 3 ? 'text-emerald-400' : 'text-base-content/50'}`}
|
||||
>
|
||||
({primaryKdaRatio})
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">분당 CS</span>
|
||||
<span className="text-[12px] text-base-content/60 tabular-nums">
|
||||
{primaryStats.avgCsPerMin}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 border-t border-base-content/8 pt-3 space-y-1.5">
|
||||
{LANE_ROWS.map((position) => {
|
||||
const laneStats =
|
||||
player.recentStats.byLane[POSITION_TO_RIOT_LANE[position]];
|
||||
const isMainLane = position === player.mainPosition;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={position}
|
||||
className={`flex items-center justify-between gap-3 text-[11px] ${isMainLane ? 'font-semibold text-base-content' : 'text-base-content/65'}`}
|
||||
>
|
||||
<span className={isMainLane ? 'text-base-content' : 'text-base-content/35'}>
|
||||
{positionLabel[position]}
|
||||
</span>
|
||||
{laneStats && laneStats.games > 0 ? (
|
||||
<span className="tabular-nums text-right">
|
||||
{laneStats.wins}W {laneStats.losses}L · {laneStats.avgKills}/
|
||||
{laneStats.avgDeaths}/{laneStats.avgAssists} ·{' '}
|
||||
{laneStats.avgCsPerMin} CS/min
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-base-content/20">—</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamPanel({
|
||||
team,
|
||||
isActive,
|
||||
@@ -140,18 +270,6 @@ function PlayerSpotlight({
|
||||
const player = state.currentPlayer;
|
||||
if (!player) return null;
|
||||
|
||||
const winRate =
|
||||
player.recentStats.games > 0
|
||||
? Math.round((player.recentStats.wins / player.recentStats.games) * 100)
|
||||
: 0;
|
||||
const kdaRatio =
|
||||
player.recentStats.kda.deaths > 0
|
||||
? (
|
||||
(player.recentStats.kda.kills + player.recentStats.kda.assists) /
|
||||
player.recentStats.kda.deaths
|
||||
).toFixed(2)
|
||||
: 'Perfect';
|
||||
|
||||
return (
|
||||
<div className="border border-base-content/10 bg-base-100">
|
||||
<div className="p-5 border-b border-base-content/8">
|
||||
@@ -233,46 +351,7 @@ function PlayerSpotlight({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
<h4 className="text-[10px] font-bold uppercase tracking-wider text-base-content/30 mb-2.5">
|
||||
최근 솔로랭크
|
||||
</h4>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">승률</span>
|
||||
<span
|
||||
className={`text-sm font-bold tabular-nums ${winRate >= 55 ? 'text-blue-400' : winRate >= 50 ? 'text-base-content' : 'text-red-400'}`}
|
||||
>
|
||||
{winRate}%
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">전적</span>
|
||||
<span className="text-[12px] text-base-content/60 tabular-nums">
|
||||
<span className="text-blue-400">{player.recentStats.wins}W</span>{' '}
|
||||
<span className="text-red-400">{player.recentStats.losses}L</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">KDA</span>
|
||||
<span className="text-[12px] text-base-content/60 tabular-nums">
|
||||
{player.recentStats.kda.kills}/{player.recentStats.kda.deaths}/
|
||||
{player.recentStats.kda.assists}
|
||||
<span
|
||||
className={`ml-1 font-bold ${Number(kdaRatio) >= 3 ? 'text-emerald-400' : 'text-base-content/50'}`}
|
||||
>
|
||||
({kdaRatio})
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-[11px] text-base-content/40">평균 CS</span>
|
||||
<span className="text-[12px] text-base-content/60 tabular-nums">
|
||||
{player.recentStats.avgCs}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<RecentSoloStats player={player} />
|
||||
</div>
|
||||
|
||||
{(state.phase === 'bidding' || state.phase === 'sold') && (
|
||||
|
||||
Reference in new issue
Block a user