Add an inhouse hero, Hall of Fame, rankings, and event-specific schedules. Carry the event type through the API and admin tools, and improve results and player history displays.
1014 lines
31 KiB
TypeScript
1014 lines
31 KiB
TypeScript
import { useState, type ReactNode } from "react";
|
|
import type { ApiInternalMatchDetailResponse, DdragonManifest, TeamSide } from "../api/types";
|
|
import {
|
|
championDisplayName,
|
|
championIconUrl,
|
|
} from "../lib/ddragon";
|
|
import { teamIndexLabel } from "../lib/league";
|
|
import { LANE_LABELS } from "../lib/riot-history";
|
|
import {
|
|
DEFAULT_LANE_CHECKPOINT,
|
|
pairLaneParticipants,
|
|
resolveCheckpointComparison,
|
|
type LaneCheckpointKey,
|
|
type LaneParticipantLike,
|
|
type NormalizedLanePosition,
|
|
} from "../lib/internal-game-matchups";
|
|
import { ItemIcon, RuneIcon, RuneStyleIcon } from "./ItemTooltip";
|
|
|
|
import { Tab, TabList } from "@astryxdesign/core/TabList";
|
|
export type InternalGameDetailTab = "scoreboard" | "matchup" | "build";
|
|
|
|
type InternalGameDetail = ApiInternalMatchDetailResponse["games"][number];
|
|
type InternalGameTeam = InternalGameDetail["teams"][number];
|
|
type InternalGameParticipant = InternalGameTeam["participants"][number];
|
|
type CheckpointParticipant = InternalGameParticipant & LaneParticipantLike;
|
|
type DdragonManifestData = DdragonManifest | null | undefined;
|
|
type RuneStyleEntry = DdragonManifest["runesReforged"][number];
|
|
|
|
const DETAIL_TABS: Array<{ id: InternalGameDetailTab; label: string }> = [
|
|
{ id: "scoreboard", label: "스코어보드" },
|
|
{ id: "matchup", label: "라인전" },
|
|
{ id: "build", label: "룬 / 빌드" },
|
|
];
|
|
|
|
const SKILL_ROWS: Array<{
|
|
slot: 1 | 2 | 3 | 4;
|
|
label: string;
|
|
className: string;
|
|
}> = [
|
|
{ slot: 1, label: "Q", className: "bg-win text-white" },
|
|
{ slot: 2, label: "W", className: "bg-cyan-500 text-white" },
|
|
{ slot: 3, label: "E", className: "bg-amber-500 text-black" },
|
|
{ slot: 4, label: "R", className: "bg-loss text-white" },
|
|
];
|
|
|
|
const STAT_PERK_LABELS: Record<number, string> = {
|
|
5001: "체력",
|
|
5002: "방어",
|
|
5003: "마저",
|
|
5005: "공속",
|
|
5007: "가속",
|
|
5008: "적응",
|
|
5010: "이속",
|
|
5011: "체력",
|
|
};
|
|
|
|
function formatDuration(seconds: number) {
|
|
const minutes = Math.floor(seconds / 60);
|
|
const rest = seconds % 60;
|
|
return `${minutes}:${String(rest).padStart(2, "0")}`;
|
|
}
|
|
|
|
function formatNumber(value: number) {
|
|
return new Intl.NumberFormat("ko-KR").format(value);
|
|
}
|
|
|
|
function formatSignedNumber(value: number) {
|
|
if (value === 0) return "0";
|
|
return `${value > 0 ? "+" : "-"}${formatNumber(Math.abs(value))}`;
|
|
}
|
|
|
|
function sideTone(side: TeamSide) {
|
|
return side === "blue"
|
|
? {
|
|
border: "border-win-line",
|
|
bg: "bg-win-tint",
|
|
text: "text-win",
|
|
bar: "bg-win",
|
|
}
|
|
: {
|
|
border: "border-loss-line",
|
|
bg: "bg-loss-tint",
|
|
text: "text-loss",
|
|
bar: "bg-loss",
|
|
};
|
|
}
|
|
|
|
function getTeamName(
|
|
detail: ApiInternalMatchDetailResponse,
|
|
teamIndex: number,
|
|
) {
|
|
return teamIndexLabel(
|
|
teamIndex,
|
|
detail.match.teams.find((team) => team.teamIndex === teamIndex)?.name,
|
|
);
|
|
}
|
|
|
|
function participantBuildKey(participant: InternalGameParticipant) {
|
|
return `${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`;
|
|
}
|
|
|
|
function findRuneStyle(
|
|
manifest: DdragonManifestData,
|
|
styleId: number | undefined,
|
|
) {
|
|
return manifest?.runesReforged.find((style) => style.id === styleId) ?? null;
|
|
}
|
|
|
|
function selectedRuneIds(participant: InternalGameParticipant) {
|
|
const explicit = participant.perks.selectedPerkIds ?? [];
|
|
const fromStyles =
|
|
participant.perks.styles?.flatMap((style) => style.perkIds) ?? [];
|
|
return new Set([
|
|
...explicit,
|
|
...fromStyles,
|
|
...(participant.perks.keystone ? [participant.perks.keystone] : []),
|
|
]);
|
|
}
|
|
|
|
function runeStyleSelection(
|
|
participant: InternalGameParticipant,
|
|
styleId: number | undefined,
|
|
) {
|
|
return participant.perks.styles?.find((style) => style.styleId === styleId);
|
|
}
|
|
|
|
function ChampionCell({
|
|
participant,
|
|
manifest,
|
|
}: {
|
|
participant: InternalGameParticipant;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
const icon = championIconUrl(manifest, participant.championId);
|
|
const name =
|
|
championDisplayName(manifest, participant.championId) ??
|
|
String(participant.championId);
|
|
|
|
return (
|
|
<div className="flex min-w-0 items-center gap-2">
|
|
<span className="relative h-10 w-10 shrink-0 overflow-hidden bg-base-content/10">
|
|
{icon ? (
|
|
<img src={icon} alt={name} className="h-full w-full object-cover scale-[1.18]" />
|
|
) : null}
|
|
{participant.championLevel > 0 && (
|
|
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-bold leading-4 text-base-content">
|
|
{participant.championLevel}
|
|
</span>
|
|
)}
|
|
</span>
|
|
<div className="min-w-0">
|
|
<span className="block truncate text-sm font-bold text-base-content">
|
|
{name}
|
|
</span>
|
|
<span className="text-xs text-base-content/35">
|
|
{LANE_LABELS[participant.teamPosition] ??
|
|
participant.teamPosition ??
|
|
"-"}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ChampionAvatar({
|
|
participant,
|
|
manifest,
|
|
size = "h-9 w-9",
|
|
}: {
|
|
participant: InternalGameParticipant;
|
|
manifest: DdragonManifestData;
|
|
size?: string;
|
|
}) {
|
|
const icon = championIconUrl(manifest, participant.championId);
|
|
const name =
|
|
championDisplayName(manifest, participant.championId) ??
|
|
String(participant.championId);
|
|
return (
|
|
<span
|
|
className={`relative ${size} shrink-0 overflow-hidden bg-base-content/10`}
|
|
title={name}
|
|
>
|
|
{icon ? (
|
|
<img src={icon} alt={name} className="h-full w-full object-cover scale-[1.18]" />
|
|
) : null}
|
|
{participant.championLevel > 0 ? (
|
|
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-bold leading-4 text-base-content">
|
|
{participant.championLevel}
|
|
</span>
|
|
) : null}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
function RuneBuildPanel({
|
|
selectedGame,
|
|
detail,
|
|
manifest,
|
|
}: {
|
|
selectedGame: InternalGameDetail;
|
|
detail: ApiInternalMatchDetailResponse;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
const orderedTeams = [...selectedGame.teams].sort((left, right) =>
|
|
left.side === right.side ? 0 : left.side === "blue" ? -1 : 1,
|
|
);
|
|
const participants = orderedTeams.flatMap((team) => team.participants);
|
|
const defaultKey = participants[0]
|
|
? participantBuildKey(participants[0])
|
|
: "";
|
|
const [selectedKey, setSelectedKey] = useState(defaultKey);
|
|
const effectiveSelectedKey = participants.some(
|
|
(participant) => participantBuildKey(participant) === selectedKey,
|
|
)
|
|
? selectedKey
|
|
: defaultKey;
|
|
const selectedParticipant =
|
|
participants.find(
|
|
(participant) =>
|
|
participantBuildKey(participant) === effectiveSelectedKey,
|
|
) ?? participants[0];
|
|
|
|
if (!selectedParticipant) {
|
|
return (
|
|
<section className="border border-base-content/10 bg-base-100 px-4 py-12 text-center text-sm font-bold text-base-content/35">
|
|
빌드 데이터가 없습니다
|
|
</section>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<section className="overflow-hidden border border-base-content/10 bg-base-100">
|
|
<BuildChampionSelector
|
|
selectedGame={selectedGame}
|
|
detail={detail}
|
|
manifest={manifest}
|
|
selectedKey={participantBuildKey(selectedParticipant)}
|
|
onSelect={setSelectedKey}
|
|
/>
|
|
<div className="grid border-t border-base-content/8 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)]">
|
|
<RunesPanel participant={selectedParticipant} manifest={manifest} />
|
|
<div className="border-t border-base-content/8 lg:border-l lg:border-t-0">
|
|
<ItemBuildPanel
|
|
participant={selectedParticipant}
|
|
manifest={manifest}
|
|
/>
|
|
<SkillBuildPanel participant={selectedParticipant} />
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
function BuildChampionSelector({
|
|
selectedGame,
|
|
detail,
|
|
manifest,
|
|
selectedKey,
|
|
onSelect,
|
|
}: {
|
|
selectedGame: InternalGameDetail;
|
|
detail: ApiInternalMatchDetailResponse;
|
|
manifest: DdragonManifestData;
|
|
selectedKey: string;
|
|
onSelect: (key: string) => void;
|
|
}) {
|
|
const orderedTeams = [...selectedGame.teams].sort((left, right) =>
|
|
left.side === right.side ? 0 : left.side === "blue" ? -1 : 1,
|
|
);
|
|
|
|
return (
|
|
<div className="grid gap-4 bg-base-content/[0.015] p-3 lg:grid-cols-2">
|
|
{orderedTeams.map((team) => {
|
|
const tone = sideTone(team.side);
|
|
return (
|
|
<div key={`build-selector-${team.side}`} className="min-w-0">
|
|
<div className="flex items-center justify-between gap-3">
|
|
<div className={`text-sm font-bold ${tone.text}`}>
|
|
{team.side === "blue" ? "블루" : "레드"}
|
|
</div>
|
|
<div className="truncate text-xs font-bold text-base-content/40">
|
|
{getTeamName(detail, team.teamIndex)}
|
|
</div>
|
|
</div>
|
|
<div className="mt-2 flex flex-wrap gap-1.5">
|
|
{team.participants.map((participant) => (
|
|
<BuildChampionButton
|
|
key={`build-select-${participantBuildKey(participant)}`}
|
|
participant={participant}
|
|
manifest={manifest}
|
|
selected={participantBuildKey(participant) === selectedKey}
|
|
onClick={() => onSelect(participantBuildKey(participant))}
|
|
/>
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function BuildChampionButton({
|
|
participant,
|
|
manifest,
|
|
selected,
|
|
onClick,
|
|
}: {
|
|
participant: InternalGameParticipant;
|
|
manifest: DdragonManifestData;
|
|
selected: boolean;
|
|
onClick: () => void;
|
|
}) {
|
|
const icon = championIconUrl(manifest, participant.championId);
|
|
const championName =
|
|
championDisplayName(manifest, participant.championId) ??
|
|
String(participant.championId);
|
|
const tone = sideTone(participant.side);
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={onClick}
|
|
title={`${participant.summonerName} · ${championName}`}
|
|
className={`relative h-11 w-11 overflow-hidden border bg-base-content/10 transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
|
selected
|
|
? `border-transparent opacity-100 ring-1 ring-current ${tone.text}`
|
|
: "border-base-content/5 opacity-35 hover:opacity-75"
|
|
}`}
|
|
>
|
|
{icon ? (
|
|
<img src={icon} alt="" className="h-full w-full object-cover scale-[1.18]" />
|
|
) : null}
|
|
{participant.championLevel > 0 ? (
|
|
<span className="absolute bottom-0 right-0 min-w-4 bg-base-300 px-1 text-center text-[10px] font-bold leading-4 text-base-content">
|
|
{participant.championLevel}
|
|
</span>
|
|
) : null}
|
|
</button>
|
|
);
|
|
}
|
|
|
|
function RunesPanel({
|
|
participant,
|
|
manifest,
|
|
}: {
|
|
participant: InternalGameParticipant;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
const selectedIds = selectedRuneIds(participant);
|
|
const primaryStyleId =
|
|
participant.perks.primaryStyle ?? participant.perks.styles?.[0]?.styleId;
|
|
const subStyleId =
|
|
participant.perks.subStyle ?? participant.perks.styles?.[1]?.styleId;
|
|
const primaryStyle = findRuneStyle(manifest, primaryStyleId);
|
|
const subStyle = findRuneStyle(manifest, subStyleId);
|
|
|
|
return (
|
|
<div className="p-3">
|
|
<div className="mb-3 flex min-w-0 items-center justify-between gap-3">
|
|
<div>
|
|
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
|
룬
|
|
</div>
|
|
<div className="mt-0.5 truncate text-xs text-base-content/40">
|
|
{participant.summonerName}
|
|
</div>
|
|
</div>
|
|
<ChampionCell participant={participant} manifest={manifest} />
|
|
</div>
|
|
<div className="grid gap-x-6 gap-y-4 md:grid-cols-2">
|
|
<RuneTreeColumn
|
|
label="주 룬"
|
|
isPrimary
|
|
runeStyle={primaryStyle}
|
|
selection={runeStyleSelection(participant, primaryStyleId)}
|
|
selectedIds={selectedIds}
|
|
manifest={manifest}
|
|
/>
|
|
<RuneTreeColumn
|
|
label="보조 룬"
|
|
isPrimary={false}
|
|
runeStyle={subStyle}
|
|
selection={runeStyleSelection(participant, subStyleId)}
|
|
selectedIds={selectedIds}
|
|
manifest={manifest}
|
|
/>
|
|
</div>
|
|
<RuneShardRows participant={participant} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function RuneTreeColumn({
|
|
label,
|
|
isPrimary,
|
|
runeStyle,
|
|
selection,
|
|
selectedIds,
|
|
manifest,
|
|
}: {
|
|
label: string;
|
|
isPrimary: boolean;
|
|
runeStyle: RuneStyleEntry | null;
|
|
selection: ReturnType<typeof runeStyleSelection>;
|
|
selectedIds: Set<number>;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
if (!runeStyle) {
|
|
return (
|
|
<div>
|
|
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
|
{label}
|
|
</div>
|
|
<div className="mt-8 text-center text-xs font-bold text-base-content/35">
|
|
룬 데이터 없음
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const selectionIds = new Set(selection?.perkIds ?? []);
|
|
|
|
return (
|
|
<div>
|
|
<div className="flex items-center gap-2">
|
|
<RuneStyleIcon
|
|
styleId={runeStyle.id}
|
|
manifest={manifest}
|
|
className="h-6 w-6"
|
|
slotClassName="bg-base-content/10"
|
|
/>
|
|
<div className="min-w-0">
|
|
<div className="text-[10px] font-bold uppercase tracking-wider text-base-content/35">
|
|
{label}
|
|
</div>
|
|
<div className="truncate text-xs font-bold text-base-content">
|
|
{runeStyle.name}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="mt-3 space-y-2.5">
|
|
{runeStyle.slots.map((slot, slotIndex) => {
|
|
// 보조 룬 트리는 핵심 룬(0번 행)을 선택하지 않으므로 숨긴다.
|
|
if (!isPrimary && slotIndex === 0) return null;
|
|
const isKeystoneRow = isPrimary && slotIndex === 0;
|
|
const cell = isKeystoneRow ? "2.5rem" : "2.25rem";
|
|
const iconSize = isKeystoneRow ? "h-10 w-10" : "h-9 w-9";
|
|
return (
|
|
<div
|
|
key={`${runeStyle.id}-${slotIndex}`}
|
|
className="grid justify-start gap-2 border-b border-base-content/8 pb-3 last:border-b-0 last:pb-0"
|
|
style={{
|
|
gridTemplateColumns: `repeat(${slot.runes.length}, minmax(0, ${cell}))`,
|
|
}}
|
|
>
|
|
{slot.runes.map((rune) => {
|
|
const selected =
|
|
selectedIds.has(rune.id) || selectionIds.has(rune.id);
|
|
return (
|
|
<RuneIcon
|
|
key={rune.id}
|
|
runeId={rune.id}
|
|
manifest={manifest}
|
|
className={iconSize}
|
|
slotClassName={`border bg-base-content/10 transition ${
|
|
selected
|
|
? "border-transparent opacity-100 ring-1 ring-primary/60"
|
|
: "border-transparent opacity-20 grayscale"
|
|
}`}
|
|
/>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function RuneShardRows({ participant }: { participant: InternalGameParticipant }) {
|
|
const statPerks = participant.perks.statPerks;
|
|
const shards = [
|
|
{ label: "공격", value: statPerks?.offense },
|
|
{ label: "보조", value: statPerks?.flex },
|
|
{ label: "방어", value: statPerks?.defense },
|
|
].filter((shard) => typeof shard.value === "number" && shard.value > 0);
|
|
|
|
if (shards.length === 0) return null;
|
|
|
|
return (
|
|
<div className="mt-4 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-base-content/8 pt-3 text-xs">
|
|
<span className="font-bold uppercase tracking-wider text-base-content/35">
|
|
스탯 파편
|
|
</span>
|
|
{shards.map((shard) => (
|
|
<span key={`${shard.label}-${shard.value}`} className="text-base-content/60">
|
|
<span className="text-base-content/35">{shard.label} </span>
|
|
<span className="font-bold">
|
|
{STAT_PERK_LABELS[shard.value ?? 0] ?? shard.value}
|
|
</span>
|
|
</span>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ItemBuildPanel({
|
|
participant,
|
|
manifest,
|
|
}: {
|
|
participant: InternalGameParticipant;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
const buildEvents = (participant.itemBuild ?? []).filter(
|
|
(event) => event.itemId > 0 && event.type === "purchased",
|
|
);
|
|
const fallbackItems = [
|
|
...participant.items
|
|
.filter((itemId) => itemId > 0)
|
|
.map((itemId) => ({ itemId, trinket: false })),
|
|
...(participant.trinket > 0
|
|
? [{ itemId: participant.trinket, trinket: true }]
|
|
: []),
|
|
];
|
|
|
|
return (
|
|
<div className="p-3">
|
|
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
|
아이템 빌드
|
|
</div>
|
|
{buildEvents.length > 0 ? (
|
|
<div className="mt-3 flex flex-wrap items-start gap-x-2 gap-y-4">
|
|
{buildEvents.map((event, index) => (
|
|
<div
|
|
key={`${event.timestamp}-${event.itemId}-${event.type}-${index}`}
|
|
className="flex items-start gap-2"
|
|
>
|
|
<ItemBuildNode
|
|
itemId={event.itemId}
|
|
timestamp={event.timestamp}
|
|
manifest={manifest}
|
|
/>
|
|
{index < buildEvents.length - 1 ? (
|
|
<span className="pt-2 text-xs font-bold text-base-content/25">
|
|
>
|
|
</span>
|
|
) : null}
|
|
</div>
|
|
))}
|
|
</div>
|
|
) : fallbackItems.length > 0 ? (
|
|
<div className="mt-3 flex flex-wrap gap-1.5">
|
|
{fallbackItems.map((item, index) => (
|
|
<ItemIcon
|
|
key={`fallback-item-${item.itemId}-${index}`}
|
|
itemId={item.itemId}
|
|
manifest={manifest}
|
|
trinket={item.trinket}
|
|
className="h-9 w-9"
|
|
/>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<div className="mt-6 text-center text-xs font-bold text-base-content/35">
|
|
아이템 빌드 데이터 없음
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ItemBuildNode({
|
|
itemId,
|
|
timestamp,
|
|
manifest,
|
|
}: {
|
|
itemId: number;
|
|
timestamp: number;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
return (
|
|
<div className="w-11 text-center">
|
|
<ItemIcon itemId={itemId} manifest={manifest} className="h-9 w-9" />
|
|
<span className="mt-1 block text-[11px] font-bold tabular-nums text-base-content/35">
|
|
{formatDuration(timestamp)}
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function SkillBuildPanel({
|
|
participant,
|
|
}: {
|
|
participant: InternalGameParticipant;
|
|
}) {
|
|
const skillEvents = participant.skillBuild ?? [];
|
|
const skillByLevel = new Map(
|
|
skillEvents.map((event) => [event.level, event]),
|
|
);
|
|
|
|
return (
|
|
<div className="border-t border-base-content/8 p-3">
|
|
<div className="flex items-center justify-between gap-3">
|
|
<div className="text-xs font-bold uppercase tracking-wider text-base-content/35">
|
|
스킬 빌드
|
|
</div>
|
|
<div className="text-xs font-bold text-base-content/35">
|
|
Lv. {skillEvents.length || participant.championLevel || "-"}
|
|
</div>
|
|
</div>
|
|
{skillEvents.length > 0 ? (
|
|
<div className="mt-3 overflow-x-auto">
|
|
<div className="min-w-[400px] space-y-1">
|
|
{SKILL_ROWS.map((row) => (
|
|
<div
|
|
key={`skill-row-${row.slot}`}
|
|
className="grid grid-cols-[2rem_repeat(18,minmax(1.1rem,1fr))] gap-0.5"
|
|
>
|
|
<div
|
|
className={`flex h-7 items-center justify-center text-xs font-bold ${row.className}`}
|
|
>
|
|
{row.label}
|
|
</div>
|
|
{Array.from({ length: 18 }, (_, index) => index + 1).map(
|
|
(level) => {
|
|
const event = skillByLevel.get(level);
|
|
const active = event?.skillSlot === row.slot;
|
|
return (
|
|
<div
|
|
key={`${row.slot}-${level}`}
|
|
className={`flex h-7 items-center justify-center text-[11px] font-bold tabular-nums ${
|
|
active
|
|
? row.className
|
|
: "bg-base-content/[0.045] text-transparent"
|
|
}`}
|
|
>
|
|
{active ? level : ""}
|
|
</div>
|
|
);
|
|
},
|
|
)}
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<div className="mt-6 text-center text-xs font-bold text-base-content/35">
|
|
스킬 빌드 데이터 없음
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function MatchupMetricRow({
|
|
label,
|
|
difference,
|
|
blueLead,
|
|
redLead,
|
|
blueText,
|
|
redText,
|
|
}: {
|
|
label: string;
|
|
difference?: string;
|
|
blueLead: boolean;
|
|
redLead: boolean;
|
|
blueText: string;
|
|
redText: string;
|
|
}) {
|
|
return (
|
|
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2 px-3 py-1.5 text-xs">
|
|
<span
|
|
className={`text-right tabular-nums ${
|
|
blueLead ? "font-bold text-win" : "text-base-content/55"
|
|
}`}
|
|
>
|
|
{blueText}
|
|
</span>
|
|
<span className="min-w-16 text-center text-[10px] font-bold uppercase tracking-wider text-base-content/30">
|
|
<span className="block">{label}</span>
|
|
{difference ? (
|
|
<span className="mt-0.5 block normal-case text-base-content/50">
|
|
{difference}
|
|
</span>
|
|
) : null}
|
|
</span>
|
|
<span
|
|
className={`tabular-nums ${
|
|
redLead ? "font-bold text-loss" : "text-base-content/55"
|
|
}`}
|
|
>
|
|
{redText}
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function checkpointKda(kills: number, deaths: number, assists: number) {
|
|
return deaths === 0 ? kills + assists : (kills + assists) / deaths;
|
|
}
|
|
|
|
function LaneParticipantIdentity({
|
|
participant,
|
|
manifest,
|
|
align,
|
|
ambiguous,
|
|
}: {
|
|
participant: CheckpointParticipant | null;
|
|
manifest: DdragonManifestData;
|
|
align: "left" | "right";
|
|
ambiguous: boolean;
|
|
}) {
|
|
if (!participant) {
|
|
return (
|
|
<div
|
|
className={`min-w-0 text-[11px] font-bold text-base-content/30 ${
|
|
align === "right" ? "text-right" : "text-left"
|
|
}`}
|
|
>
|
|
{ambiguous ? "포지션 중복" : "선수 없음"}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const championName =
|
|
championDisplayName(manifest, participant.championId) ??
|
|
String(participant.championId);
|
|
const details = (
|
|
<div className={`min-w-0 ${align === "right" ? "text-right" : ""}`}>
|
|
<div className="truncate text-xs font-bold text-base-content">
|
|
{participant.summonerName}
|
|
</div>
|
|
<div className="truncate text-[11px] text-base-content/40">
|
|
{championName}
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
return (
|
|
<div
|
|
className={`flex min-w-0 items-center gap-2 ${
|
|
align === "right" ? "justify-end" : ""
|
|
}`}
|
|
>
|
|
{align === "right" ? details : null}
|
|
<ChampionAvatar participant={participant} manifest={manifest} />
|
|
{align === "left" ? details : null}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function LaneMatchupCard({
|
|
position,
|
|
blue,
|
|
red,
|
|
ambiguousBlue,
|
|
ambiguousRed,
|
|
checkpointKey,
|
|
manifest,
|
|
}: {
|
|
position: NormalizedLanePosition;
|
|
blue: CheckpointParticipant | null;
|
|
red: CheckpointParticipant | null;
|
|
ambiguousBlue: boolean;
|
|
ambiguousRed: boolean;
|
|
checkpointKey: LaneCheckpointKey;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
const laneLabel = LANE_LABELS[position] ?? position;
|
|
const comparison = resolveCheckpointComparison(blue, red, checkpointKey);
|
|
const metrics = comparison
|
|
? [
|
|
{
|
|
key: "gold",
|
|
label: "골드",
|
|
difference: `GD ${formatSignedNumber(comparison.goldDiff)}`,
|
|
blueValue: comparison.blue.gold,
|
|
redValue: comparison.red.gold,
|
|
blueText: formatNumber(comparison.blue.gold),
|
|
redText: formatNumber(comparison.red.gold),
|
|
},
|
|
{
|
|
key: "cs",
|
|
label: "CS",
|
|
difference: `CSD ${formatSignedNumber(comparison.csDiff)}`,
|
|
blueValue: comparison.blue.cs,
|
|
redValue: comparison.red.cs,
|
|
blueText: formatNumber(comparison.blue.cs),
|
|
redText: formatNumber(comparison.red.cs),
|
|
},
|
|
{
|
|
key: "xp",
|
|
label: "경험치",
|
|
difference: `XPD ${formatSignedNumber(comparison.xpDiff)}`,
|
|
blueValue: comparison.blue.xp,
|
|
redValue: comparison.red.xp,
|
|
blueText: formatNumber(comparison.blue.xp),
|
|
redText: formatNumber(comparison.red.xp),
|
|
},
|
|
{
|
|
key: "kda",
|
|
label: "K / D / A",
|
|
blueValue: checkpointKda(
|
|
comparison.blue.kills,
|
|
comparison.blue.deaths,
|
|
comparison.blue.assists,
|
|
),
|
|
redValue: checkpointKda(
|
|
comparison.red.kills,
|
|
comparison.red.deaths,
|
|
comparison.red.assists,
|
|
),
|
|
blueText: `${comparison.blue.kills}/${comparison.blue.deaths}/${comparison.blue.assists}`,
|
|
redText: `${comparison.red.kills}/${comparison.red.deaths}/${comparison.red.assists}`,
|
|
},
|
|
]
|
|
: [];
|
|
|
|
return (
|
|
<div className="overflow-hidden border border-base-content/10 bg-base-100">
|
|
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2 border-b border-base-content/8 bg-base-content/[0.015] px-3 py-2">
|
|
<LaneParticipantIdentity
|
|
participant={blue}
|
|
manifest={manifest}
|
|
align="right"
|
|
ambiguous={ambiguousBlue}
|
|
/>
|
|
<span className="border border-base-content/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider text-base-content/45">
|
|
{laneLabel}
|
|
</span>
|
|
<LaneParticipantIdentity
|
|
participant={red}
|
|
manifest={manifest}
|
|
align="left"
|
|
ambiguous={ambiguousRed}
|
|
/>
|
|
</div>
|
|
{comparison ? (
|
|
<>
|
|
<div className="divide-y divide-base-content/5">
|
|
{metrics.map((metric) => (
|
|
<MatchupMetricRow
|
|
key={`${position}-${checkpointKey}-${metric.key}`}
|
|
label={metric.label}
|
|
difference={metric.difference}
|
|
blueLead={metric.blueValue > metric.redValue}
|
|
redLead={metric.redValue > metric.blueValue}
|
|
blueText={metric.blueText}
|
|
redText={metric.redText}
|
|
/>
|
|
))}
|
|
</div>
|
|
<div className="border-t border-base-content/5 px-3 py-1.5 text-center text-[10px] font-bold text-base-content/30">
|
|
실제 기준 {formatDuration(comparison.blue.timestamp)} · {formatDuration(comparison.red.timestamp)}
|
|
</div>
|
|
</>
|
|
) : (
|
|
<div className="px-3 py-7 text-center text-xs font-bold text-base-content/35">
|
|
{ambiguousBlue || ambiguousRed
|
|
? "포지션이 중복되어 상대를 확정할 수 없습니다"
|
|
: "선택한 시점의 라인전 데이터가 없습니다"}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function LaneMatchupPanel({
|
|
selectedGame,
|
|
detail,
|
|
manifest,
|
|
}: {
|
|
selectedGame: InternalGameDetail;
|
|
detail: ApiInternalMatchDetailResponse;
|
|
manifest: DdragonManifestData;
|
|
}) {
|
|
const [checkpointKey, setCheckpointKey] =
|
|
useState<LaneCheckpointKey>(DEFAULT_LANE_CHECKPOINT);
|
|
const blueTeam = selectedGame.teams.find((team) => team.side === "blue");
|
|
const redTeam = selectedGame.teams.find((team) => team.side === "red");
|
|
|
|
if (!blueTeam || !redTeam) {
|
|
return (
|
|
<section className="border border-base-content/10 bg-base-100 px-4 py-12 text-center text-sm font-bold text-base-content/35">
|
|
라인전 비교 데이터가 없습니다
|
|
</section>
|
|
);
|
|
}
|
|
|
|
const matchups = pairLaneParticipants(
|
|
blueTeam.participants as CheckpointParticipant[],
|
|
redTeam.participants as CheckpointParticipant[],
|
|
);
|
|
const blueTeamName = getTeamName(detail, blueTeam.teamIndex);
|
|
const redTeamName = getTeamName(detail, redTeam.teamIndex);
|
|
|
|
return (
|
|
<section className="overflow-hidden border border-base-content/10 bg-base-100">
|
|
<div className="border-b border-base-content/8 px-4 py-3">
|
|
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-3 text-xs font-bold">
|
|
<span className="truncate text-right text-win">
|
|
{blueTeamName}
|
|
</span>
|
|
<span className="text-base-content/20">VS</span>
|
|
<span className="truncate text-loss">{redTeamName}</span>
|
|
</div>
|
|
<div
|
|
className="mx-auto mt-3 flex w-fit border border-base-content/10"
|
|
role="group"
|
|
aria-label="라인전 비교 시점"
|
|
>
|
|
{(["at10", "at15"] as const).map((key) => (
|
|
<button
|
|
key={key}
|
|
type="button"
|
|
aria-pressed={checkpointKey === key}
|
|
onClick={() => setCheckpointKey(key)}
|
|
className={`border-r border-base-content/8 px-4 py-1.5 text-xs font-black transition-colors last:border-r-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
|
checkpointKey === key
|
|
? "bg-primary text-primary-content"
|
|
: "text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
|
}`}
|
|
>
|
|
{key === "at10" ? "10분" : "15분"}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
<div className="grid gap-3 p-4 lg:grid-cols-2">
|
|
{matchups.length > 0 ? (
|
|
matchups.map((matchup) => (
|
|
<LaneMatchupCard
|
|
key={`matchup-${matchup.position}`}
|
|
position={matchup.position}
|
|
blue={matchup.blue}
|
|
red={matchup.red}
|
|
ambiguousBlue={matchup.ambiguousBlue}
|
|
ambiguousRed={matchup.ambiguousRed}
|
|
checkpointKey={checkpointKey}
|
|
manifest={manifest}
|
|
/>
|
|
))
|
|
) : (
|
|
<div className="py-10 text-center text-sm font-bold text-base-content/35 lg:col-span-2">
|
|
비교 가능한 포지션 정보가 없습니다
|
|
</div>
|
|
)}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
export function InternalGameDetailTabBar({
|
|
activeTab,
|
|
onChange,
|
|
}: {
|
|
activeTab: InternalGameDetailTab;
|
|
onChange: (tab: InternalGameDetailTab) => void;
|
|
}) {
|
|
return (
|
|
<TabList
|
|
aria-label="상세 분석"
|
|
value={activeTab}
|
|
hasDivider
|
|
onChange={(next) => {
|
|
const tab = DETAIL_TABS.find((candidate) => candidate.id === next);
|
|
if (tab) onChange(tab.id);
|
|
}}
|
|
>
|
|
{DETAIL_TABS.map((tab) => (
|
|
<Tab key={tab.id} value={tab.id} label={tab.label} />
|
|
))}
|
|
</TabList>
|
|
);
|
|
}
|
|
|
|
export function InternalGameAnalysisPanel({
|
|
activeTab,
|
|
selectedGame,
|
|
detail,
|
|
manifest,
|
|
scoreboard,
|
|
}: {
|
|
activeTab: InternalGameDetailTab;
|
|
selectedGame: InternalGameDetail;
|
|
detail: ApiInternalMatchDetailResponse;
|
|
manifest: DdragonManifestData;
|
|
scoreboard: ReactNode;
|
|
}) {
|
|
if (activeTab === "scoreboard") {
|
|
return <>{scoreboard}</>;
|
|
}
|
|
|
|
if (activeTab === "build") {
|
|
return (
|
|
<RuneBuildPanel
|
|
selectedGame={selectedGame}
|
|
detail={detail}
|
|
manifest={manifest}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<LaneMatchupPanel
|
|
selectedGame={selectedGame}
|
|
detail={detail}
|
|
manifest={manifest}
|
|
/>
|
|
);
|
|
}
|