.
This commit is contained in:
1 parent
86d6767eba
commit
09286e7711
7 files changed
+639
-56
No files matched your search
@@ -883,10 +883,24 @@ export class CommunityStatsService {
|
|||||||
gameName: participant.summonerName,
|
gameName: participant.summonerName,
|
||||||
tagLine: '',
|
tagLine: '',
|
||||||
championId: participant.championId,
|
championId: participant.championId,
|
||||||
|
championLevel: participant.championLevel,
|
||||||
teamPosition: participant.teamPosition,
|
teamPosition: participant.teamPosition,
|
||||||
kills: participant.kills,
|
kills: participant.kills,
|
||||||
deaths: participant.deaths,
|
deaths: participant.deaths,
|
||||||
assists: participant.assists,
|
assists: participant.assists,
|
||||||
|
items: participant.items,
|
||||||
|
trinket: participant.trinket,
|
||||||
|
summonerSpells: participant.summonerSpells,
|
||||||
|
perks: participant.perks,
|
||||||
|
totalCs: participant.cs,
|
||||||
|
csPerMin: participant.csPerMin,
|
||||||
|
goldEarned: participant.gold,
|
||||||
|
damageDealtToChampions: participant.damageDealtToChampions,
|
||||||
|
damageTaken: participant.damageTaken,
|
||||||
|
visionScore: participant.visionScore,
|
||||||
|
wardsPlaced: participant.wardsPlaced,
|
||||||
|
wardsKilled: participant.wardsKilled,
|
||||||
|
controlWardsBought: participant.controlWardsBought,
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -579,16 +579,45 @@ export class MatchHistoryService {
|
|||||||
},
|
},
|
||||||
participants: match.info.participants
|
participants: match.info.participants
|
||||||
.filter((participant) => participant.teamId === team.teamId)
|
.filter((participant) => participant.teamId === team.teamId)
|
||||||
.map((participant) => ({
|
.map((participant) => {
|
||||||
puuid: participant.puuid,
|
const totalCs = this.resolveTotalCs(participant);
|
||||||
gameName: participant.riotIdGameName || participant.summonerName || 'Unknown',
|
const minutes = this.resolveGameMinutes(match, participant);
|
||||||
tagLine: participant.riotIdTagLine || '',
|
|
||||||
championId: participant.championId,
|
return {
|
||||||
teamPosition: participant.teamPosition || participant.individualPosition,
|
puuid: participant.puuid,
|
||||||
kills: participant.kills,
|
gameName: participant.riotIdGameName || participant.summonerName || 'Unknown',
|
||||||
deaths: participant.deaths,
|
tagLine: participant.riotIdTagLine || '',
|
||||||
assists: participant.assists,
|
championId: participant.championId,
|
||||||
})),
|
championLevel: participant.champLevel,
|
||||||
|
teamPosition: participant.teamPosition || participant.individualPosition,
|
||||||
|
kills: participant.kills,
|
||||||
|
deaths: participant.deaths,
|
||||||
|
assists: participant.assists,
|
||||||
|
items: [
|
||||||
|
participant.item0,
|
||||||
|
participant.item1,
|
||||||
|
participant.item2,
|
||||||
|
participant.item3,
|
||||||
|
participant.item4,
|
||||||
|
participant.item5,
|
||||||
|
],
|
||||||
|
trinket: participant.item6,
|
||||||
|
summonerSpells: [participant.summoner1Id, participant.summoner2Id],
|
||||||
|
perks: this.resolvePerks(participant),
|
||||||
|
totalCs,
|
||||||
|
csPerMin: this.average(totalCs, minutes),
|
||||||
|
goldEarned: participant.goldEarned,
|
||||||
|
damageDealtToChampions: participant.totalDamageDealtToChampions,
|
||||||
|
damageTaken: participant.totalDamageTaken,
|
||||||
|
visionScore: participant.visionScore,
|
||||||
|
wardsPlaced: participant.wardsPlaced,
|
||||||
|
wardsKilled: participant.wardsKilled,
|
||||||
|
controlWardsBought: this.numberField(
|
||||||
|
participant,
|
||||||
|
'visionWardsBoughtInGame',
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,31 @@ export interface RecentMatchesResponse {
|
|||||||
season: HistorySeasonDto;
|
season: HistorySeasonDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RecentMatchTeamParticipantView {
|
||||||
|
puuid: string;
|
||||||
|
gameName: string;
|
||||||
|
tagLine: string;
|
||||||
|
championId: number;
|
||||||
|
championLevel: number;
|
||||||
|
teamPosition: string;
|
||||||
|
kills: number;
|
||||||
|
deaths: number;
|
||||||
|
assists: number;
|
||||||
|
items: number[];
|
||||||
|
trinket: number;
|
||||||
|
summonerSpells: [number, number];
|
||||||
|
perks: { primaryStyle?: number; subStyle?: number; keystone?: number };
|
||||||
|
totalCs: number;
|
||||||
|
csPerMin: number;
|
||||||
|
goldEarned: number;
|
||||||
|
damageDealtToChampions: number;
|
||||||
|
damageTaken: number;
|
||||||
|
visionScore: number;
|
||||||
|
wardsPlaced: number;
|
||||||
|
wardsKilled: number;
|
||||||
|
controlWardsBought: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface RecentMatchView {
|
export interface RecentMatchView {
|
||||||
matchId: string;
|
matchId: string;
|
||||||
queueId: number;
|
queueId: number;
|
||||||
@@ -132,15 +157,6 @@ export interface RecentMatchView {
|
|||||||
side: 100 | 200;
|
side: 100 | 200;
|
||||||
win: boolean;
|
win: boolean;
|
||||||
objectives?: { baron?: number; dragon?: number; tower?: number };
|
objectives?: { baron?: number; dragon?: number; tower?: number };
|
||||||
participants: Array<{
|
participants: RecentMatchTeamParticipantView[];
|
||||||
puuid: string;
|
|
||||||
gameName: string;
|
|
||||||
tagLine: string;
|
|
||||||
championId: number;
|
|
||||||
teamPosition: string;
|
|
||||||
kills: number;
|
|
||||||
deaths: number;
|
|
||||||
assists: number;
|
|
||||||
}>;
|
|
||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ const DDRAGON_BASE = 'https://ddragon.leagueoflegends.com';
|
|||||||
const DDRAGON_CDN = `${DDRAGON_BASE}/cdn`;
|
const DDRAGON_CDN = `${DDRAGON_BASE}/cdn`;
|
||||||
const DEFAULT_LOCALE = 'ko_KR';
|
const DEFAULT_LOCALE = 'ko_KR';
|
||||||
const CACHE_TTL_SECONDS = 24 * 60 * 60;
|
const CACHE_TTL_SECONDS = 24 * 60 * 60;
|
||||||
const CACHE_VERSION = 'v2';
|
const CACHE_VERSION = 'v3';
|
||||||
const FETCH_TIMEOUT_MS = 10_000;
|
const FETCH_TIMEOUT_MS = 10_000;
|
||||||
|
|
||||||
export interface DdragonChampionEntry {
|
export interface DdragonChampionEntry {
|
||||||
@@ -13,11 +13,29 @@ export interface DdragonChampionEntry {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DdragonSummonerSpellEntry {
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DdragonRuneEntry {
|
||||||
|
id: number;
|
||||||
|
key: string;
|
||||||
|
icon: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DdragonRuneStyleEntry extends DdragonRuneEntry {
|
||||||
|
slots: Array<{ runes: DdragonRuneEntry[] }>;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DdragonManifest {
|
export interface DdragonManifest {
|
||||||
version: string;
|
version: string;
|
||||||
cdn: string;
|
cdn: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
champions: Record<string, DdragonChampionEntry>;
|
champions: Record<string, DdragonChampionEntry>;
|
||||||
|
summonerSpells: Record<string, DdragonSummonerSpellEntry>;
|
||||||
|
runesReforged: DdragonRuneStyleEntry[];
|
||||||
fetchedAt: string;
|
fetchedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +49,27 @@ interface ChampionDataResponse {
|
|||||||
data: Record<string, ChampionDataEntry>;
|
data: Record<string, ChampionDataEntry>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SummonerSpellDataEntry {
|
||||||
|
key: string;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SummonerSpellDataResponse {
|
||||||
|
data: Record<string, SummonerSpellDataEntry>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RuneDataEntry {
|
||||||
|
id: number;
|
||||||
|
key: string;
|
||||||
|
icon: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RuneStyleDataEntry extends RuneDataEntry {
|
||||||
|
slots?: Array<{ runes?: RuneDataEntry[] }>;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RiotDdragonService {
|
export class RiotDdragonService {
|
||||||
private readonly logger = new Logger(RiotDdragonService.name);
|
private readonly logger = new Logger(RiotDdragonService.name);
|
||||||
@@ -63,12 +102,18 @@ export class RiotDdragonService {
|
|||||||
|
|
||||||
private async buildManifest(locale: string): Promise<DdragonManifest> {
|
private async buildManifest(locale: string): Promise<DdragonManifest> {
|
||||||
const version = await this.fetchLatestVersion();
|
const version = await this.fetchLatestVersion();
|
||||||
const champions = await this.fetchChampionMap(version, locale);
|
const [champions, summonerSpells, runesReforged] = await Promise.all([
|
||||||
|
this.fetchChampionMap(version, locale),
|
||||||
|
this.fetchSummonerSpellMap(version, locale),
|
||||||
|
this.fetchRuneStyles(version, locale),
|
||||||
|
]);
|
||||||
return {
|
return {
|
||||||
version,
|
version,
|
||||||
cdn: DDRAGON_CDN,
|
cdn: DDRAGON_CDN,
|
||||||
locale,
|
locale,
|
||||||
champions,
|
champions,
|
||||||
|
summonerSpells,
|
||||||
|
runesReforged,
|
||||||
fetchedAt: new Date().toISOString(),
|
fetchedAt: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -103,6 +148,58 @@ export class RiotDdragonService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async fetchSummonerSpellMap(
|
||||||
|
version: string,
|
||||||
|
locale: string,
|
||||||
|
): Promise<Record<string, DdragonSummonerSpellEntry>> {
|
||||||
|
const url = `${DDRAGON_CDN}/${version}/data/${locale}/summoner.json`;
|
||||||
|
const payload = await this.fetchJson<SummonerSpellDataResponse>(url);
|
||||||
|
if (!payload || typeof payload !== 'object' || !payload.data) {
|
||||||
|
throw new Error(`ddragon summoner.json response is malformed (${url}).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const map: Record<string, DdragonSummonerSpellEntry> = {};
|
||||||
|
for (const entry of Object.values(payload.data)) {
|
||||||
|
if (entry?.key && entry.id) {
|
||||||
|
map[entry.key] = {
|
||||||
|
key: entry.id,
|
||||||
|
name: typeof entry.name === 'string' ? entry.name : entry.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchRuneStyles(
|
||||||
|
version: string,
|
||||||
|
locale: string,
|
||||||
|
): Promise<DdragonRuneStyleEntry[]> {
|
||||||
|
const url = `${DDRAGON_CDN}/${version}/data/${locale}/runesReforged.json`;
|
||||||
|
const payload = await this.fetchJson<unknown>(url);
|
||||||
|
if (!Array.isArray(payload)) {
|
||||||
|
throw new Error(`ddragon runesReforged.json response is malformed (${url}).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload
|
||||||
|
.filter((style): style is RuneStyleDataEntry => isRuneEntry(style))
|
||||||
|
.map((style) => ({
|
||||||
|
id: style.id,
|
||||||
|
key: style.key,
|
||||||
|
icon: style.icon,
|
||||||
|
name: style.name,
|
||||||
|
slots: (style.slots ?? []).map((slot) => ({
|
||||||
|
runes: (slot.runes ?? [])
|
||||||
|
.filter((rune): rune is RuneDataEntry => isRuneEntry(rune))
|
||||||
|
.map((rune) => ({
|
||||||
|
id: rune.id,
|
||||||
|
key: rune.key,
|
||||||
|
icon: rune.icon,
|
||||||
|
name: rune.name,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
private async fetchJson<T>(url: string): Promise<T> {
|
private async fetchJson<T>(url: string): Promise<T> {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
||||||
@@ -137,6 +234,17 @@ function normalizeLocale(locale: string): string {
|
|||||||
return `${trimmed.slice(0, 2).toLowerCase()}_${trimmed.slice(3).toUpperCase()}`;
|
return `${trimmed.slice(0, 2).toLowerCase()}_${trimmed.slice(3).toUpperCase()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isRuneEntry(value: unknown): value is RuneDataEntry {
|
||||||
|
if (!value || typeof value !== 'object') return false;
|
||||||
|
const entry = value as Partial<RuneDataEntry>;
|
||||||
|
return (
|
||||||
|
typeof entry.id === 'number' &&
|
||||||
|
typeof entry.key === 'string' &&
|
||||||
|
typeof entry.icon === 'string' &&
|
||||||
|
typeof entry.name === 'string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function manifestCacheKey(locale: string): string {
|
function manifestCacheKey(locale: string): string {
|
||||||
return `ddragon:manifest:${CACHE_VERSION}:${locale}`;
|
return `ddragon:manifest:${CACHE_VERSION}:${locale}`;
|
||||||
}
|
}
|
||||||
+44
-10
@@ -333,11 +333,29 @@ export interface DdragonChampionEntry {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DdragonSummonerSpellEntry {
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DdragonRuneEntry {
|
||||||
|
id: number;
|
||||||
|
key: string;
|
||||||
|
icon: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DdragonRuneStyleEntry extends DdragonRuneEntry {
|
||||||
|
slots: Array<{ runes: DdragonRuneEntry[] }>;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DdragonManifest {
|
export interface DdragonManifest {
|
||||||
version: string;
|
version: string;
|
||||||
cdn: string;
|
cdn: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
champions: Record<string, DdragonChampionEntry>;
|
champions: Record<string, DdragonChampionEntry>;
|
||||||
|
summonerSpells: Record<string, DdragonSummonerSpellEntry>;
|
||||||
|
runesReforged: DdragonRuneStyleEntry[];
|
||||||
fetchedAt: string;
|
fetchedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,20 +498,36 @@ export interface ApiRecentSummaryResponse {
|
|||||||
lastFetchedAt: string | null;
|
lastFetchedAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApiRecentMatchTeamParticipant {
|
||||||
|
puuid: string;
|
||||||
|
gameName: string;
|
||||||
|
tagLine: string;
|
||||||
|
championId: number;
|
||||||
|
championLevel: number;
|
||||||
|
teamPosition: string;
|
||||||
|
kills: number;
|
||||||
|
deaths: number;
|
||||||
|
assists: number;
|
||||||
|
items: number[];
|
||||||
|
trinket: number;
|
||||||
|
summonerSpells: [number, number];
|
||||||
|
perks: { primaryStyle?: number; subStyle?: number; keystone?: number };
|
||||||
|
totalCs: number;
|
||||||
|
csPerMin: number;
|
||||||
|
goldEarned: number;
|
||||||
|
damageDealtToChampions: number;
|
||||||
|
damageTaken: number;
|
||||||
|
visionScore: number;
|
||||||
|
wardsPlaced: number;
|
||||||
|
wardsKilled: number;
|
||||||
|
controlWardsBought: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApiRecentMatchTeam {
|
export interface ApiRecentMatchTeam {
|
||||||
side: 100 | 200;
|
side: 100 | 200;
|
||||||
win: boolean;
|
win: boolean;
|
||||||
objectives?: { baron?: number; dragon?: number; tower?: number };
|
objectives?: { baron?: number; dragon?: number; tower?: number };
|
||||||
participants: Array<{
|
participants: ApiRecentMatchTeamParticipant[];
|
||||||
puuid: string;
|
|
||||||
gameName: string;
|
|
||||||
tagLine: string;
|
|
||||||
championId: number;
|
|
||||||
teamPosition: string;
|
|
||||||
kills: number;
|
|
||||||
deaths: number;
|
|
||||||
assists: number;
|
|
||||||
}>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiRecentMatchView {
|
export interface ApiRecentMatchView {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useState } from "react";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { ChevronDown, ChevronUp } from "lucide-react";
|
||||||
import { Link, useLocation, useParams, useSearchParams } from "react-router";
|
import { Link, useLocation, useParams, useSearchParams } from "react-router";
|
||||||
import {
|
import {
|
||||||
useChampionStats,
|
useChampionStats,
|
||||||
@@ -17,6 +18,8 @@ import type {
|
|||||||
ApiEnqueueRefreshResult,
|
ApiEnqueueRefreshResult,
|
||||||
ApiTierInfo,
|
ApiTierInfo,
|
||||||
ApiRiotRefreshEvent,
|
ApiRiotRefreshEvent,
|
||||||
|
ApiRecentMatchTeam,
|
||||||
|
ApiRecentMatchTeamParticipant,
|
||||||
ApiRecentMatchView,
|
ApiRecentMatchView,
|
||||||
DdragonManifest,
|
DdragonManifest,
|
||||||
RiotQueueGroup,
|
RiotQueueGroup,
|
||||||
@@ -29,6 +32,9 @@ import {
|
|||||||
championIconUrl,
|
championIconUrl,
|
||||||
itemIconUrl,
|
itemIconUrl,
|
||||||
profileIconUrl,
|
profileIconUrl,
|
||||||
|
runeKeystoneIconUrl,
|
||||||
|
runeStyleIconUrl,
|
||||||
|
summonerSpellIconUrl,
|
||||||
} from "../lib/ddragon";
|
} from "../lib/ddragon";
|
||||||
import {
|
import {
|
||||||
isRiotQueueGroup,
|
isRiotQueueGroup,
|
||||||
@@ -415,20 +421,29 @@ function ChampionStatsTable({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ItemGrid({
|
function ItemGrid({
|
||||||
match,
|
items,
|
||||||
|
trinket,
|
||||||
manifest,
|
manifest,
|
||||||
|
itemKey,
|
||||||
|
variant = "card",
|
||||||
}: {
|
}: {
|
||||||
match: ApiRecentMatchView;
|
items: number[];
|
||||||
|
trinket: number;
|
||||||
manifest: DdragonManifest | null | undefined;
|
manifest: DdragonManifest | null | undefined;
|
||||||
|
itemKey: string;
|
||||||
|
variant?: "card" | "detail";
|
||||||
}) {
|
}) {
|
||||||
const slots = [...match.items, match.trinket];
|
const slots = [...items.slice(0, 6), trinket];
|
||||||
|
const layoutClass =
|
||||||
|
variant === "detail" ? "grid-cols-7 w-[164px]" : "grid-cols-4 w-[92px]";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-4 gap-1 w-[92px]">
|
<div className={`grid gap-1 ${layoutClass}`}>
|
||||||
{slots.map((itemId, index) => {
|
{slots.map((itemId, index) => {
|
||||||
const url = itemIconUrl(manifest, itemId);
|
const url = itemIconUrl(manifest, itemId);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={`${match.matchId}-item-${index}`}
|
key={`${itemKey}-item-${index}`}
|
||||||
className="w-5 h-5 bg-base-content/8 overflow-hidden border border-base-content/5"
|
className="w-5 h-5 bg-base-content/8 overflow-hidden border border-base-content/5"
|
||||||
>
|
>
|
||||||
{url ? (
|
{url ? (
|
||||||
@@ -486,13 +501,355 @@ function TeamMini({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function RecentMatchCard({
|
type MatchDetailScales = {
|
||||||
|
maxGold: number;
|
||||||
|
maxDamage: number;
|
||||||
|
maxTaken: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatCompactNumber(value: number) {
|
||||||
|
const safeValue = Number.isFinite(value) ? value : 0;
|
||||||
|
const abs = Math.abs(safeValue);
|
||||||
|
if (abs >= 1000) {
|
||||||
|
return `${(safeValue / 1000).toFixed(1).replace(/\.0$/, "")}k`;
|
||||||
|
}
|
||||||
|
return safeValue.toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveParticipantKda(participant: ApiRecentMatchTeamParticipant) {
|
||||||
|
const score = participant.kills + participant.assists;
|
||||||
|
return participant.deaths === 0
|
||||||
|
? score
|
||||||
|
: Math.round((score / participant.deaths) * 10) / 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
function barPercent(value: number, max: number) {
|
||||||
|
if (!Number.isFinite(value) || !Number.isFinite(max) || max <= 0) return 0;
|
||||||
|
return Math.max(0, Math.min(100, Math.round((value / max) * 100)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function AssetIcon({
|
||||||
|
url,
|
||||||
|
label,
|
||||||
|
className = "w-4 h-4",
|
||||||
|
}: {
|
||||||
|
url: string | null;
|
||||||
|
label: string;
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`${className} bg-base-content/8 overflow-hidden border border-base-content/5`}
|
||||||
|
title={label}
|
||||||
|
aria-label={label}
|
||||||
|
>
|
||||||
|
{url ? (
|
||||||
|
<img src={url} alt="" className="w-full h-full object-cover" loading="lazy" />
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LoadoutIcons({
|
||||||
|
summonerSpells,
|
||||||
|
perks,
|
||||||
|
manifest,
|
||||||
|
}: {
|
||||||
|
summonerSpells: [number, number];
|
||||||
|
perks: ApiRecentMatchTeamParticipant["perks"];
|
||||||
|
manifest: DdragonManifest | null | undefined;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<AssetIcon
|
||||||
|
url={summonerSpellIconUrl(manifest, summonerSpells[0])}
|
||||||
|
label="스펠 1"
|
||||||
|
/>
|
||||||
|
<AssetIcon
|
||||||
|
url={summonerSpellIconUrl(manifest, summonerSpells[1])}
|
||||||
|
label="스펠 2"
|
||||||
|
/>
|
||||||
|
<AssetIcon
|
||||||
|
url={runeKeystoneIconUrl(manifest, perks.keystone)}
|
||||||
|
label="핵심 룬"
|
||||||
|
/>
|
||||||
|
<AssetIcon
|
||||||
|
url={runeStyleIconUrl(manifest, perks.subStyle ?? perks.primaryStyle)}
|
||||||
|
label="보조 룬"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailStatBar({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
max,
|
||||||
|
fillClass,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
max: number;
|
||||||
|
fillClass: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="flex items-center justify-between gap-2 text-[10px] text-base-content/45">
|
||||||
|
<span>{label}</span>
|
||||||
|
<span className="font-bold text-base-content/70 tabular-nums">
|
||||||
|
{formatCompactNumber(value)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 h-1.5 overflow-hidden bg-base-content/8">
|
||||||
|
<div
|
||||||
|
className={`h-full ${fillClass}`}
|
||||||
|
style={{ width: `${barPercent(value, max)}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function TeamHeader({ team }: { team: ApiRecentMatchTeam }) {
|
||||||
|
const sideLabel = team.side === 100 ? "블루팀" : "레드팀";
|
||||||
|
const sideClass = team.side === 100 ? "text-sky-400" : "text-rose-400";
|
||||||
|
const resultClass = team.win ? "text-blue-400" : "text-red-400";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="px-3 py-2 flex flex-wrap items-center justify-between gap-2 border-b border-base-content/10">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span
|
||||||
|
className={`text-[11px] font-black uppercase tracking-wider ${sideClass}`}
|
||||||
|
>
|
||||||
|
{sideLabel}
|
||||||
|
</span>
|
||||||
|
<span className={`text-[11px] font-black ${resultClass}`}>
|
||||||
|
{team.win ? "승리" : "패배"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-3 text-[11px] text-base-content/45">
|
||||||
|
<span>드래곤 {team.objectives?.dragon ?? 0}</span>
|
||||||
|
<span>바론 {team.objectives?.baron ?? 0}</span>
|
||||||
|
<span>타워 {team.objectives?.tower ?? 0}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ParticipantRow({
|
||||||
|
participant,
|
||||||
|
manifest,
|
||||||
|
ownerParticipantId,
|
||||||
|
scales,
|
||||||
|
teamSide,
|
||||||
|
}: {
|
||||||
|
participant: ApiRecentMatchTeamParticipant;
|
||||||
|
manifest: DdragonManifest | null | undefined;
|
||||||
|
ownerParticipantId: string;
|
||||||
|
scales: MatchDetailScales;
|
||||||
|
teamSide: 100 | 200;
|
||||||
|
}) {
|
||||||
|
const championName =
|
||||||
|
championDisplayName(manifest, participant.championId) ??
|
||||||
|
String(participant.championId);
|
||||||
|
const championUrl = championIconUrl(manifest, participant.championId);
|
||||||
|
const participantName = participant.gameName || championName;
|
||||||
|
const isOwner = participant.puuid === ownerParticipantId;
|
||||||
|
const kda = resolveParticipantKda(participant);
|
||||||
|
const fillClass = teamSide === 100 ? "bg-sky-400/70" : "bg-rose-400/70";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`grid min-w-[920px] grid-cols-[260px_86px_132px_220px_164px] gap-3 items-center border-b border-base-content/5 border-l-2 px-3 py-2 text-[11px] last:border-b-0 ${
|
||||||
|
isOwner
|
||||||
|
? "border-l-primary bg-primary/[0.05]"
|
||||||
|
: "border-l-transparent hover:bg-base-content/[0.02]"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
|
<div className="relative w-10 h-10 shrink-0 overflow-hidden bg-base-content/10">
|
||||||
|
{championUrl ? (
|
||||||
|
<img
|
||||||
|
src={championUrl}
|
||||||
|
alt={championName}
|
||||||
|
className="w-full h-full object-cover"
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
{participant.championLevel > 0 && (
|
||||||
|
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[9px] font-black leading-4 text-base-content">
|
||||||
|
{participant.championLevel}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-0.5 shrink-0">
|
||||||
|
<AssetIcon
|
||||||
|
url={summonerSpellIconUrl(manifest, participant.summonerSpells[0])}
|
||||||
|
label="스펠 1"
|
||||||
|
/>
|
||||||
|
<AssetIcon
|
||||||
|
url={runeKeystoneIconUrl(manifest, participant.perks.keystone)}
|
||||||
|
label="핵심 룬"
|
||||||
|
/>
|
||||||
|
<AssetIcon
|
||||||
|
url={summonerSpellIconUrl(manifest, participant.summonerSpells[1])}
|
||||||
|
label="스펠 2"
|
||||||
|
/>
|
||||||
|
<AssetIcon
|
||||||
|
url={runeStyleIconUrl(
|
||||||
|
manifest,
|
||||||
|
participant.perks.subStyle ?? participant.perks.primaryStyle,
|
||||||
|
)}
|
||||||
|
label="보조 룬"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div
|
||||||
|
className={`truncate font-bold ${
|
||||||
|
isOwner ? "text-primary" : "text-base-content/80"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{participantName}
|
||||||
|
</div>
|
||||||
|
<div className="truncate text-[10px] text-base-content/35">
|
||||||
|
{participant.tagLine ? `#${participant.tagLine} · ` : ""}
|
||||||
|
{(LANE_LABELS[participant.teamPosition] ?? participant.teamPosition) ||
|
||||||
|
"포지션 없음"}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-center tabular-nums">
|
||||||
|
<div className="font-black text-base-content">
|
||||||
|
{participant.kills}
|
||||||
|
<span className="text-base-content/25"> / </span>
|
||||||
|
<span className="text-red-400">{participant.deaths}</span>
|
||||||
|
<span className="text-base-content/25"> / </span>
|
||||||
|
{participant.assists}
|
||||||
|
</div>
|
||||||
|
<div className={`mt-0.5 text-[10px] font-bold ${kdaClass(kda)}`}>
|
||||||
|
{participant.deaths === 0 ? "Perfect" : `${kda} KDA`}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2 tabular-nums">
|
||||||
|
<div className="flex items-center justify-between gap-2 text-[10px] text-base-content/45">
|
||||||
|
<span>CS</span>
|
||||||
|
<span className="font-bold text-base-content/70">
|
||||||
|
{participant.totalCs} ({participant.csPerMin}/m)
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<DetailStatBar
|
||||||
|
label="골드"
|
||||||
|
value={participant.goldEarned}
|
||||||
|
max={scales.maxGold}
|
||||||
|
fillClass="bg-amber-400/70"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2 tabular-nums">
|
||||||
|
<div className="grid grid-cols-2 gap-3">
|
||||||
|
<DetailStatBar
|
||||||
|
label="가한 피해"
|
||||||
|
value={participant.damageDealtToChampions}
|
||||||
|
max={scales.maxDamage}
|
||||||
|
fillClass={fillClass}
|
||||||
|
/>
|
||||||
|
<DetailStatBar
|
||||||
|
label="받은 피해"
|
||||||
|
value={participant.damageTaken}
|
||||||
|
max={scales.maxTaken}
|
||||||
|
fillClass="bg-base-content/35"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="text-[10px] text-base-content/40">
|
||||||
|
시야 {participant.visionScore} · 와드 {participant.wardsPlaced}/
|
||||||
|
{participant.wardsKilled} · 제어 {participant.controlWardsBought}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ItemGrid
|
||||||
|
items={participant.items}
|
||||||
|
trinket={participant.trinket}
|
||||||
|
manifest={manifest}
|
||||||
|
itemKey={`${participant.puuid}-${participant.championId}`}
|
||||||
|
variant="detail"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MatchDetailPanel({
|
||||||
match,
|
match,
|
||||||
manifest,
|
manifest,
|
||||||
|
ownerParticipantId,
|
||||||
}: {
|
}: {
|
||||||
match: ApiRecentMatchView;
|
match: ApiRecentMatchView;
|
||||||
manifest: DdragonManifest | null | undefined;
|
manifest: DdragonManifest | null | undefined;
|
||||||
|
ownerParticipantId: string;
|
||||||
}) {
|
}) {
|
||||||
|
const teams = [...match.teams].sort((left, right) => left.side - right.side);
|
||||||
|
const participants = teams.flatMap((team) => team.participants);
|
||||||
|
const scales: MatchDetailScales = {
|
||||||
|
maxGold: Math.max(1, ...participants.map((participant) => participant.goldEarned)),
|
||||||
|
maxDamage: Math.max(
|
||||||
|
1,
|
||||||
|
...participants.map((participant) => participant.damageDealtToChampions),
|
||||||
|
),
|
||||||
|
maxTaken: Math.max(1, ...participants.map((participant) => participant.damageTaken)),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (participants.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="p-4 text-center text-[12px] text-base-content/35">
|
||||||
|
이 경기의 상세 팀 데이터가 아직 없습니다.
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-3 sm:p-4 space-y-4">
|
||||||
|
{teams.map((team) => (
|
||||||
|
<section
|
||||||
|
key={`${match.matchId}-detail-${team.side}`}
|
||||||
|
className="overflow-hidden border border-base-content/10 bg-base-100"
|
||||||
|
>
|
||||||
|
<TeamHeader team={team} />
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<div className="grid min-w-[920px] grid-cols-[260px_86px_132px_220px_164px] gap-3 border-b border-base-content/10 bg-base-200/40 px-3 py-2 text-[10px] font-black uppercase tracking-wider text-base-content/35">
|
||||||
|
<div>소환사</div>
|
||||||
|
<div className="text-center">KDA</div>
|
||||||
|
<div>CS · 골드</div>
|
||||||
|
<div>피해량 · 와드</div>
|
||||||
|
<div>아이템</div>
|
||||||
|
</div>
|
||||||
|
{team.participants.map((participant) => (
|
||||||
|
<ParticipantRow
|
||||||
|
key={`${participant.puuid}-${participant.championId}`}
|
||||||
|
participant={participant}
|
||||||
|
manifest={manifest}
|
||||||
|
ownerParticipantId={ownerParticipantId}
|
||||||
|
scales={scales}
|
||||||
|
teamSide={team.side}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RecentMatchCard({
|
||||||
|
match,
|
||||||
|
manifest,
|
||||||
|
ownerParticipantId,
|
||||||
|
}: {
|
||||||
|
match: ApiRecentMatchView;
|
||||||
|
manifest: DdragonManifest | null | undefined;
|
||||||
|
ownerParticipantId: string;
|
||||||
|
}) {
|
||||||
|
const [expanded, setExpanded] = useState(false);
|
||||||
const championName =
|
const championName =
|
||||||
championDisplayName(manifest, match.championId) ?? String(match.championId);
|
championDisplayName(manifest, match.championId) ?? String(match.championId);
|
||||||
const accent = match.win ? "border-l-blue-500" : "border-l-red-500";
|
const accent = match.win ? "border-l-blue-500" : "border-l-red-500";
|
||||||
@@ -502,7 +859,7 @@ function RecentMatchCard({
|
|||||||
<article
|
<article
|
||||||
className={`border border-l-4 ${accent} border-base-content/10 bg-base-100`}
|
className={`border border-l-4 ${accent} border-base-content/10 bg-base-100`}
|
||||||
>
|
>
|
||||||
<div className="p-4 grid lg:grid-cols-[120px_1fr_120px_1.5fr_32px] gap-4 items-center">
|
<div className="p-4 grid lg:grid-cols-[120px_1fr_120px_1.5fr_40px] gap-4 items-center">
|
||||||
<div className="text-center lg:text-left">
|
<div className="text-center lg:text-left">
|
||||||
<div className={`text-[12px] font-black ${resultClass}`}>
|
<div className={`text-[12px] font-black ${resultClass}`}>
|
||||||
{match.remake ? "다시하기" : match.win ? "승리" : "패배"}
|
{match.remake ? "다시하기" : match.win ? "승리" : "패배"}
|
||||||
@@ -533,8 +890,12 @@ function RecentMatchCard({
|
|||||||
{(LANE_LABELS[match.teamPosition] ?? match.teamPosition) ||
|
{(LANE_LABELS[match.teamPosition] ?? match.teamPosition) ||
|
||||||
"포지션 없음"}
|
"포지션 없음"}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 text-[10px] text-base-content/30">
|
<div className="mt-1">
|
||||||
스펠 {match.summonerSpells.join(" / ")}
|
<LoadoutIcons
|
||||||
|
summonerSpells={match.summonerSpells}
|
||||||
|
perks={match.perks}
|
||||||
|
manifest={manifest}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -581,17 +942,44 @@ function RecentMatchCard({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<ItemGrid match={match} manifest={manifest} />
|
<ItemGrid
|
||||||
|
items={match.items}
|
||||||
|
trinket={match.trinket}
|
||||||
|
manifest={manifest}
|
||||||
|
itemKey={match.matchId}
|
||||||
|
/>
|
||||||
<TeamMini match={match} manifest={manifest} />
|
<TeamMini match={match} manifest={manifest} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="hidden lg:flex justify-end">
|
<div className="flex justify-end">
|
||||||
<div
|
<button
|
||||||
className={`w-2 h-14 ${match.win ? "bg-blue-500/70" : "bg-red-500/70"}`}
|
type="button"
|
||||||
/>
|
onClick={() => setExpanded((current) => !current)}
|
||||||
|
className="flex h-10 w-full items-center justify-center gap-1 border border-base-content/10 text-base-content/35 transition-colors hover:text-base-content/70 sm:w-auto sm:px-3 lg:h-14 lg:w-8 lg:border-0 lg:px-0"
|
||||||
|
aria-expanded={expanded}
|
||||||
|
aria-label={expanded ? "상세 전적 접기" : "상세 전적 펼치기"}
|
||||||
|
>
|
||||||
|
<span className="text-[11px] font-bold lg:hidden">
|
||||||
|
{expanded ? "상세 접기" : "상세 보기"}
|
||||||
|
</span>
|
||||||
|
{expanded ? (
|
||||||
|
<ChevronUp className="h-4 w-4" aria-hidden="true" />
|
||||||
|
) : (
|
||||||
|
<ChevronDown className="h-4 w-4" aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{expanded && (
|
||||||
|
<div className="border-t border-base-content/10 bg-base-200/30">
|
||||||
|
<MatchDetailPanel
|
||||||
|
match={match}
|
||||||
|
manifest={manifest}
|
||||||
|
ownerParticipantId={ownerParticipantId}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -688,7 +1076,7 @@ export default function UserHistoryPage() {
|
|||||||
? (championDisplayName(ddragon, championId) ?? String(championId))
|
? (championDisplayName(ddragon, championId) ?? String(championId))
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const visibleChampionRows = useMemo(() => {
|
const visibleChampionRows = (() => {
|
||||||
const rows = isInternalQueue
|
const rows = isInternalQueue
|
||||||
? (internalFirstPage?.championStats.champions ?? [])
|
? (internalFirstPage?.championStats.champions ?? [])
|
||||||
: (championStatsQuery.data?.champions ?? []);
|
: (championStatsQuery.data?.champions ?? []);
|
||||||
@@ -702,14 +1090,7 @@ export default function UserHistoryPage() {
|
|||||||
return displayName.toLowerCase().includes(keyword);
|
return displayName.toLowerCase().includes(keyword);
|
||||||
})
|
})
|
||||||
.sort((left, right) => right[sortKey] - left[sortKey]);
|
.sort((left, right) => right[sortKey] - left[sortKey]);
|
||||||
}, [
|
})();
|
||||||
championSearch,
|
|
||||||
championStatsQuery.data?.champions,
|
|
||||||
ddragon,
|
|
||||||
internalFirstPage?.championStats.champions,
|
|
||||||
isInternalQueue,
|
|
||||||
sortKey,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const refreshSocket = useRiotRefreshSocket({
|
const refreshSocket = useRiotRefreshSocket({
|
||||||
puuid: isInternalQueue ? undefined : profile?.puuid,
|
puuid: isInternalQueue ? undefined : profile?.puuid,
|
||||||
@@ -1104,6 +1485,7 @@ export default function UserHistoryPage() {
|
|||||||
key={match.matchId}
|
key={match.matchId}
|
||||||
match={match}
|
match={match}
|
||||||
manifest={ddragon}
|
manifest={ddragon}
|
||||||
|
ownerParticipantId={isInternalQueue ? profile.userId : profile.puuid}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user