feat: enrich internal match game analysis
This commit is contained in:
1 parent
9f698a8fec
commit
aa675199af
22 files changed
+3123
-241
No files matched your search
@@ -701,6 +701,24 @@ export interface ApiInternalMatchDetailResponse {
|
||||
type: 'dragon' | 'elderDragon' | 'baron' | 'riftHerald' | 'voidGrub';
|
||||
monsterSubType?: string;
|
||||
}>;
|
||||
timelineEvents?: Array<{
|
||||
timestamp: number;
|
||||
side?: TeamSide;
|
||||
type:
|
||||
| 'dragon'
|
||||
| 'elderDragon'
|
||||
| 'baron'
|
||||
| 'riftHerald'
|
||||
| 'voidGrub'
|
||||
| 'championKill'
|
||||
| 'tower'
|
||||
| 'inhibitor';
|
||||
monsterSubType?: string;
|
||||
killerParticipantId?: number;
|
||||
victimParticipantId?: number;
|
||||
assistingParticipantIds?: number[];
|
||||
towerType?: string;
|
||||
}>;
|
||||
teams: Array<{
|
||||
teamIndex: number;
|
||||
side: TeamSide;
|
||||
@@ -716,6 +734,27 @@ export interface ApiInternalMatchDetailResponse {
|
||||
};
|
||||
bans: Array<{ championId: number; pickTurn: number }>;
|
||||
participants: Array<{
|
||||
participantId?: number;
|
||||
checkpoints?: {
|
||||
at10?: {
|
||||
timestamp: number;
|
||||
gold: number;
|
||||
cs: number;
|
||||
xp: number;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
};
|
||||
at15?: {
|
||||
timestamp: number;
|
||||
gold: number;
|
||||
cs: number;
|
||||
xp: number;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
};
|
||||
};
|
||||
userId: string | null;
|
||||
summonerName: string;
|
||||
tagLine: string;
|
||||
|
||||
@@ -6,6 +6,14 @@ import {
|
||||
} 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";
|
||||
|
||||
export type InternalGameDetailTab = "scoreboard" | "matchup" | "build";
|
||||
@@ -13,6 +21,7 @@ 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];
|
||||
|
||||
@@ -44,8 +53,6 @@ const STAT_PERK_LABELS: Record<number, string> = {
|
||||
5011: "체력",
|
||||
};
|
||||
|
||||
const LANE_SORT_ORDER = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"];
|
||||
|
||||
function formatDuration(seconds: number) {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const rest = seconds % 60;
|
||||
@@ -56,6 +63,11 @@ 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"
|
||||
? {
|
||||
@@ -111,11 +123,6 @@ function runeStyleSelection(
|
||||
return participant.perks.styles?.find((style) => style.styleId === styleId);
|
||||
}
|
||||
|
||||
function laneSortValue(position: string) {
|
||||
const index = LANE_SORT_ORDER.indexOf(position);
|
||||
return index === -1 ? 99 : index;
|
||||
}
|
||||
|
||||
function ChampionCell({
|
||||
participant,
|
||||
manifest,
|
||||
@@ -648,12 +655,14 @@ function SkillBuildPanel({
|
||||
|
||||
function MatchupMetricRow({
|
||||
label,
|
||||
difference,
|
||||
blueLead,
|
||||
redLead,
|
||||
blueText,
|
||||
redText,
|
||||
}: {
|
||||
label: string;
|
||||
difference?: string;
|
||||
blueLead: boolean;
|
||||
redLead: boolean;
|
||||
blueText: string;
|
||||
@@ -668,8 +677,13 @@ function MatchupMetricRow({
|
||||
>
|
||||
{blueText}
|
||||
</span>
|
||||
<span className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
|
||||
{label}
|
||||
<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 ${
|
||||
@@ -682,101 +696,172 @@ function MatchupMetricRow({
|
||||
);
|
||||
}
|
||||
|
||||
function LaneMatchupCard({
|
||||
blue,
|
||||
red,
|
||||
detail,
|
||||
function checkpointKda(kills: number, deaths: number, assists: number) {
|
||||
return deaths === 0 ? kills + assists : (kills + assists) / deaths;
|
||||
}
|
||||
|
||||
function LaneParticipantIdentity({
|
||||
participant,
|
||||
manifest,
|
||||
align,
|
||||
ambiguous,
|
||||
}: {
|
||||
blue: InternalGameParticipant;
|
||||
red: InternalGameParticipant;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
participant: CheckpointParticipant | null;
|
||||
manifest: DdragonManifestData;
|
||||
align: "left" | "right";
|
||||
ambiguous: boolean;
|
||||
}) {
|
||||
const laneLabel =
|
||||
LANE_LABELS[blue.teamPosition] ??
|
||||
LANE_LABELS[red.teamPosition] ??
|
||||
blue.teamPosition ??
|
||||
"-";
|
||||
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 metrics = [
|
||||
{
|
||||
key: "kda",
|
||||
label: "KDA",
|
||||
blueValue:
|
||||
blue.deaths === 0
|
||||
? blue.kills + blue.assists
|
||||
: (blue.kills + blue.assists) / blue.deaths,
|
||||
redValue:
|
||||
red.deaths === 0
|
||||
? red.kills + red.assists
|
||||
: (red.kills + red.assists) / red.deaths,
|
||||
blueText: `${blue.kills}/${blue.deaths}/${blue.assists}`,
|
||||
redText: `${red.kills}/${red.deaths}/${red.assists}`,
|
||||
},
|
||||
{
|
||||
key: "gold",
|
||||
label: "골드",
|
||||
blueValue: blue.gold,
|
||||
redValue: red.gold,
|
||||
blueText: formatNumber(blue.gold),
|
||||
redText: formatNumber(red.gold),
|
||||
},
|
||||
{
|
||||
key: "cs",
|
||||
label: "CS",
|
||||
blueValue: blue.cs,
|
||||
redValue: red.cs,
|
||||
blueText: `${blue.cs} (${blue.csPerMin}/m)`,
|
||||
redText: `${red.cs} (${red.csPerMin}/m)`,
|
||||
},
|
||||
];
|
||||
|
||||
const championName = (participant: InternalGameParticipant) =>
|
||||
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">
|
||||
<div className="flex min-w-0 items-center justify-end gap-2">
|
||||
<div className="min-w-0 text-right">
|
||||
<div className="truncate text-xs font-bold text-base-content">
|
||||
{blue.summonerName}
|
||||
</div>
|
||||
<div className="truncate text-[11px] text-base-content/40">
|
||||
{championName(blue)}
|
||||
</div>
|
||||
</div>
|
||||
<ChampionAvatar participant={blue} manifest={manifest} />
|
||||
</div>
|
||||
<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>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<ChampionAvatar participant={red} manifest={manifest} />
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-xs font-bold text-base-content">
|
||||
{red.summonerName}
|
||||
</div>
|
||||
<div className="truncate text-[11px] text-base-content/40">
|
||||
{championName(red)}
|
||||
</div>
|
||||
<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>
|
||||
<div className="divide-y divide-base-content/5">
|
||||
{metrics.map((metric) => (
|
||||
<MatchupMetricRow
|
||||
key={`${detail.match.matchId}-${blue.teamPosition}-${metric.key}`}
|
||||
label={metric.label}
|
||||
blueLead={metric.blueValue > metric.redValue}
|
||||
redLead={metric.redValue > metric.blueValue}
|
||||
blueText={metric.blueText}
|
||||
redText={metric.redText}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -790,6 +875,8 @@ function LaneMatchupPanel({
|
||||
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");
|
||||
|
||||
@@ -801,40 +888,64 @@ function LaneMatchupPanel({
|
||||
);
|
||||
}
|
||||
|
||||
const blueSorted = [...blueTeam.participants].sort(
|
||||
(left, right) =>
|
||||
laneSortValue(left.teamPosition) - laneSortValue(right.teamPosition),
|
||||
);
|
||||
const redSorted = [...redTeam.participants].sort(
|
||||
(left, right) =>
|
||||
laneSortValue(left.teamPosition) - laneSortValue(right.teamPosition),
|
||||
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="grid grid-cols-[1fr_auto_1fr] items-center gap-3 border-b border-base-content/8 px-4 py-3 text-xs font-bold">
|
||||
<span className="truncate text-right text-blue-400">
|
||||
{blueTeamName}
|
||||
</span>
|
||||
<span className="text-base-content/20">VS</span>
|
||||
<span className="truncate text-red-400">{redTeamName}</span>
|
||||
<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-blue-400">
|
||||
{blueTeamName}
|
||||
</span>
|
||||
<span className="text-base-content/20">VS</span>
|
||||
<span className="truncate text-red-400">{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">
|
||||
{blueSorted.map((blue, index) => {
|
||||
const red = redSorted[index];
|
||||
if (!red) return null;
|
||||
return (
|
||||
{matchups.length > 0 ? (
|
||||
matchups.map((matchup) => (
|
||||
<LaneMatchupCard
|
||||
key={`matchup-${blue.teamPosition}-${blue.summonerName}`}
|
||||
blue={blue}
|
||||
red={red}
|
||||
detail={detail}
|
||||
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>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
export type LaneCheckpointKey = "at10" | "at15";
|
||||
|
||||
export const DEFAULT_LANE_CHECKPOINT: LaneCheckpointKey = "at15";
|
||||
|
||||
export type NormalizedLanePosition =
|
||||
| "TOP"
|
||||
| "JUNGLE"
|
||||
| "MIDDLE"
|
||||
| "BOTTOM"
|
||||
| "UTILITY";
|
||||
|
||||
export interface LaneCheckpoint {
|
||||
timestamp: number;
|
||||
gold: number;
|
||||
cs: number;
|
||||
xp: number;
|
||||
kills: number;
|
||||
deaths: number;
|
||||
assists: number;
|
||||
}
|
||||
|
||||
export interface LaneParticipantLike {
|
||||
teamPosition: string;
|
||||
checkpoints?: Partial<Record<LaneCheckpointKey, LaneCheckpoint>>;
|
||||
}
|
||||
|
||||
export interface LanePair<TParticipant extends LaneParticipantLike> {
|
||||
position: NormalizedLanePosition;
|
||||
blue: TParticipant | null;
|
||||
red: TParticipant | null;
|
||||
ambiguousBlue: boolean;
|
||||
ambiguousRed: boolean;
|
||||
}
|
||||
|
||||
export interface LaneCheckpointComparison {
|
||||
blue: LaneCheckpoint;
|
||||
red: LaneCheckpoint;
|
||||
goldDiff: number;
|
||||
csDiff: number;
|
||||
xpDiff: number;
|
||||
}
|
||||
|
||||
const LANE_ORDER: readonly NormalizedLanePosition[] = [
|
||||
"TOP",
|
||||
"JUNGLE",
|
||||
"MIDDLE",
|
||||
"BOTTOM",
|
||||
"UTILITY",
|
||||
];
|
||||
|
||||
const LANE_ALIASES: Readonly<Record<string, NormalizedLanePosition>> = {
|
||||
TOP: "TOP",
|
||||
JUNGLE: "JUNGLE",
|
||||
JGL: "JUNGLE",
|
||||
MIDDLE: "MIDDLE",
|
||||
MID: "MIDDLE",
|
||||
BOTTOM: "BOTTOM",
|
||||
ADC: "BOTTOM",
|
||||
UTILITY: "UTILITY",
|
||||
SUPPORT: "UTILITY",
|
||||
SUP: "UTILITY",
|
||||
};
|
||||
|
||||
export function normalizeLanePosition(
|
||||
value: string | undefined,
|
||||
): NormalizedLanePosition | null {
|
||||
if (!value) return null;
|
||||
return LANE_ALIASES[value.toUpperCase()] ?? null;
|
||||
}
|
||||
|
||||
export function pairLaneParticipants<TParticipant extends LaneParticipantLike>(
|
||||
blueParticipants: readonly TParticipant[],
|
||||
redParticipants: readonly TParticipant[],
|
||||
): Array<LanePair<TParticipant>> {
|
||||
const blueByPosition = groupByPosition(blueParticipants);
|
||||
const redByPosition = groupByPosition(redParticipants);
|
||||
|
||||
return LANE_ORDER.flatMap((position) => {
|
||||
const blue = blueByPosition.get(position) ?? [];
|
||||
const red = redByPosition.get(position) ?? [];
|
||||
if (blue.length === 0 && red.length === 0) return [];
|
||||
|
||||
return [
|
||||
{
|
||||
position,
|
||||
blue: blue.length === 1 ? blue[0] : null,
|
||||
red: red.length === 1 ? red[0] : null,
|
||||
ambiguousBlue: blue.length > 1,
|
||||
ambiguousRed: red.length > 1,
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveCheckpointComparison<
|
||||
TParticipant extends LaneParticipantLike,
|
||||
>(
|
||||
blueParticipant: TParticipant | null,
|
||||
redParticipant: TParticipant | null,
|
||||
checkpointKey: LaneCheckpointKey,
|
||||
): LaneCheckpointComparison | null {
|
||||
const blue = blueParticipant?.checkpoints?.[checkpointKey];
|
||||
const red = redParticipant?.checkpoints?.[checkpointKey];
|
||||
if (!blue || !red) return null;
|
||||
|
||||
return {
|
||||
blue,
|
||||
red,
|
||||
goldDiff: blue.gold - red.gold,
|
||||
csDiff: blue.cs - red.cs,
|
||||
xpDiff: blue.xp - red.xp,
|
||||
};
|
||||
}
|
||||
|
||||
function groupByPosition<TParticipant extends LaneParticipantLike>(
|
||||
participants: readonly TParticipant[],
|
||||
) {
|
||||
const grouped = new Map<NormalizedLanePosition, TParticipant[]>();
|
||||
for (const participant of participants) {
|
||||
const position = normalizeLanePosition(participant.teamPosition);
|
||||
if (!position) continue;
|
||||
const values = grouped.get(position) ?? [];
|
||||
values.push(participant);
|
||||
grouped.set(position, values);
|
||||
}
|
||||
return grouped;
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
export type InternalMatchTeamSide = "blue" | "red";
|
||||
|
||||
export type InternalMatchObjectiveType =
|
||||
| "dragon"
|
||||
| "elderDragon"
|
||||
| "baron"
|
||||
| "riftHerald"
|
||||
| "voidGrub";
|
||||
|
||||
export type InternalMatchTimelineEventType =
|
||||
| InternalMatchObjectiveType
|
||||
| "championKill"
|
||||
| "tower"
|
||||
| "inhibitor";
|
||||
|
||||
export type TimelineEventCategory = "objective" | "kill" | "structure";
|
||||
export type TimelineEventFilter = "all" | TimelineEventCategory;
|
||||
|
||||
export interface InternalMatchTimelineEvent {
|
||||
timestamp: number;
|
||||
side?: InternalMatchTeamSide;
|
||||
type: InternalMatchTimelineEventType;
|
||||
killerParticipantId?: number;
|
||||
victimParticipantId?: number;
|
||||
assistingParticipantIds?: number[];
|
||||
monsterSubType?: string;
|
||||
towerType?: string;
|
||||
}
|
||||
|
||||
export interface InternalMatchObjectiveEvent {
|
||||
timestamp: number;
|
||||
side: InternalMatchTeamSide;
|
||||
type: InternalMatchObjectiveType;
|
||||
monsterSubType?: string;
|
||||
}
|
||||
|
||||
export interface NormalizedObjectiveEvent extends InternalMatchObjectiveEvent {
|
||||
label: string;
|
||||
markerLabel: string;
|
||||
}
|
||||
|
||||
export interface NormalizedTimelineEvent extends InternalMatchTimelineEvent {
|
||||
category: TimelineEventCategory;
|
||||
label: string;
|
||||
markerLabel: string;
|
||||
}
|
||||
|
||||
const DRAGON_TYPE_LABELS: Readonly<Record<string, string>> = {
|
||||
AIR_DRAGON: "바람",
|
||||
EARTH_DRAGON: "대지",
|
||||
WATER_DRAGON: "바다",
|
||||
FIRE_DRAGON: "화염",
|
||||
HEXTECH_DRAGON: "마법공학",
|
||||
CHEMTECH_DRAGON: "화학공학",
|
||||
ELDER_DRAGON: "장로",
|
||||
};
|
||||
|
||||
const OBJECTIVE_LABELS: Readonly<
|
||||
Record<Exclude<InternalMatchObjectiveType, "dragon">, string>
|
||||
> = {
|
||||
elderDragon: "장로 드래곤",
|
||||
baron: "바론",
|
||||
riftHerald: "협곡의 전령",
|
||||
voidGrub: "공허 유충",
|
||||
};
|
||||
|
||||
const OBJECTIVE_MARKER_LABELS: Readonly<
|
||||
Record<Exclude<InternalMatchObjectiveType, "dragon">, string>
|
||||
> = {
|
||||
elderDragon: "장로",
|
||||
baron: "바론",
|
||||
riftHerald: "전령",
|
||||
voidGrub: "유충",
|
||||
};
|
||||
|
||||
export function dragonTypeLabel(
|
||||
monsterSubType: string | undefined,
|
||||
): string | null {
|
||||
if (!monsterSubType) return null;
|
||||
return DRAGON_TYPE_LABELS[monsterSubType] ?? null;
|
||||
}
|
||||
|
||||
export function normalizeObjectiveEvents(
|
||||
events: readonly InternalMatchObjectiveEvent[],
|
||||
): NormalizedObjectiveEvent[] {
|
||||
return events
|
||||
.map((event) => {
|
||||
if (event.type === "dragon") {
|
||||
const dragonLabel = dragonTypeLabel(event.monsterSubType);
|
||||
return {
|
||||
...event,
|
||||
label: dragonLabel ? `${dragonLabel} 드래곤` : "드래곤",
|
||||
markerLabel: dragonLabel ?? "용",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...event,
|
||||
label: OBJECTIVE_LABELS[event.type],
|
||||
markerLabel: OBJECTIVE_MARKER_LABELS[event.type],
|
||||
};
|
||||
})
|
||||
.sort((left, right) => left.timestamp - right.timestamp);
|
||||
}
|
||||
|
||||
export function normalizeTimelineEvents(
|
||||
events: readonly InternalMatchTimelineEvent[],
|
||||
): NormalizedTimelineEvent[] {
|
||||
return events
|
||||
.map((event): NormalizedTimelineEvent => {
|
||||
if (event.type === "championKill") {
|
||||
return {
|
||||
...event,
|
||||
category: "kill",
|
||||
label: "챔피언 처치",
|
||||
markerLabel: "킬",
|
||||
};
|
||||
}
|
||||
if (event.type === "tower") {
|
||||
return {
|
||||
...event,
|
||||
category: "structure",
|
||||
label: "포탑 파괴",
|
||||
markerLabel: "포탑",
|
||||
};
|
||||
}
|
||||
if (event.type === "inhibitor") {
|
||||
return {
|
||||
...event,
|
||||
category: "structure",
|
||||
label: "억제기 파괴",
|
||||
markerLabel: "억제기",
|
||||
};
|
||||
}
|
||||
if (event.type === "dragon") {
|
||||
const dragonLabel = dragonTypeLabel(event.monsterSubType);
|
||||
return {
|
||||
...event,
|
||||
category: "objective",
|
||||
label: dragonLabel ? `${dragonLabel} 드래곤` : "드래곤",
|
||||
markerLabel: dragonLabel ?? "용",
|
||||
};
|
||||
}
|
||||
return {
|
||||
...event,
|
||||
category: "objective",
|
||||
label: OBJECTIVE_LABELS[event.type],
|
||||
markerLabel: OBJECTIVE_MARKER_LABELS[event.type],
|
||||
};
|
||||
})
|
||||
.sort((left, right) => left.timestamp - right.timestamp);
|
||||
}
|
||||
|
||||
export function selectTimelineEventSource<
|
||||
TTimeline extends InternalMatchTimelineEvent,
|
||||
TObjective extends InternalMatchObjectiveEvent,
|
||||
>(
|
||||
timelineEvents: readonly TTimeline[] | undefined,
|
||||
objectiveEvents: readonly TObjective[],
|
||||
): readonly (TTimeline | TObjective)[] {
|
||||
return timelineEvents && timelineEvents.length > 0
|
||||
? timelineEvents
|
||||
: objectiveEvents;
|
||||
}
|
||||
|
||||
export function filterTimelineEvents<TEvent extends NormalizedTimelineEvent>(
|
||||
events: readonly TEvent[],
|
||||
filter: TimelineEventFilter,
|
||||
): TEvent[] {
|
||||
return filter === "all"
|
||||
? [...events]
|
||||
: events.filter((event) => event.category === filter);
|
||||
}
|
||||
|
||||
export function summarizeDragonTypes(
|
||||
events: readonly NormalizedObjectiveEvent[],
|
||||
side: InternalMatchTeamSide,
|
||||
): Array<{ label: string; count: number }> {
|
||||
const counts = new Map<string, number>();
|
||||
|
||||
for (const event of events) {
|
||||
if (event.side !== side || event.type !== "dragon") continue;
|
||||
const label = dragonTypeLabel(event.monsterSubType);
|
||||
if (!label) continue;
|
||||
counts.set(label, (counts.get(label) ?? 0) + 1);
|
||||
}
|
||||
|
||||
return [...counts.entries()].map(([label, count]) => ({ label, count }));
|
||||
}
|
||||
|
||||
export function projectObjectiveMarkers<
|
||||
TEvent extends NormalizedObjectiveEvent,
|
||||
>(
|
||||
events: readonly TEvent[],
|
||||
points: readonly { timestamp: number; value: number }[],
|
||||
): Array<TEvent & { value: number }> {
|
||||
return projectTimelineEventMarkers(events, points);
|
||||
}
|
||||
|
||||
export function projectTimelineEventMarkers<TEvent extends { timestamp: number }>(
|
||||
events: readonly TEvent[],
|
||||
points: readonly { timestamp: number; value: number }[],
|
||||
): Array<TEvent & { value: number }> {
|
||||
if (points.length === 0) return [];
|
||||
|
||||
const orderedPoints = [...points].sort(
|
||||
(left, right) => left.timestamp - right.timestamp,
|
||||
);
|
||||
|
||||
return events.map((event) => {
|
||||
let selected = orderedPoints[0];
|
||||
for (const point of orderedPoints) {
|
||||
if (point.timestamp > event.timestamp) break;
|
||||
selected = point;
|
||||
}
|
||||
return { ...event, value: selected.value };
|
||||
});
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
AreaChart,
|
||||
CartesianGrid,
|
||||
Line,
|
||||
ReferenceDot,
|
||||
ReferenceLine,
|
||||
ResponsiveContainer,
|
||||
Tooltip,
|
||||
@@ -28,6 +29,16 @@ import {
|
||||
internalMatchGamePath,
|
||||
} from "../lib/internal-match-routes";
|
||||
import { LANE_LABELS } from "../lib/riot-history";
|
||||
import {
|
||||
filterTimelineEvents,
|
||||
normalizeObjectiveEvents,
|
||||
normalizeTimelineEvents,
|
||||
projectTimelineEventMarkers,
|
||||
selectTimelineEventSource,
|
||||
summarizeDragonTypes,
|
||||
type NormalizedTimelineEvent,
|
||||
type TimelineEventFilter,
|
||||
} from "../lib/internal-match-timeline";
|
||||
import {
|
||||
InternalGameAnalysisPanel,
|
||||
InternalGameDetailTabBar,
|
||||
@@ -58,6 +69,16 @@ const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [
|
||||
{ id: "xp", label: "경험치" },
|
||||
];
|
||||
|
||||
const TIMELINE_EVENT_FILTERS: Array<{
|
||||
id: TimelineEventFilter;
|
||||
label: string;
|
||||
}> = [
|
||||
{ id: "all", label: "전체" },
|
||||
{ id: "objective", label: "오브젝트" },
|
||||
{ id: "kill", label: "킬" },
|
||||
{ id: "structure", label: "구조물" },
|
||||
];
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
@@ -142,6 +163,16 @@ function formatPercent(value: number) {
|
||||
return `${value}%`;
|
||||
}
|
||||
|
||||
function formatDragonTypeSummary(
|
||||
values: Array<{ label: string; count: number }>,
|
||||
total: number,
|
||||
) {
|
||||
if (values.length === 0) return total > 0 ? "유형 정보 없음" : "-";
|
||||
return values
|
||||
.map(({ label, count }) => (count > 1 ? `${label}×${count}` : label))
|
||||
.join(" · ");
|
||||
}
|
||||
|
||||
function barWidth(value: number, max: number) {
|
||||
return `${Math.max(0, Math.min(100, max > 0 ? (value / max) * 100 : 0))}%`;
|
||||
}
|
||||
@@ -411,13 +442,13 @@ function PlayerRow({
|
||||
{participant.assists}
|
||||
</div>
|
||||
<div className="text-xs font-bold tabular-nums text-base-content/40">
|
||||
{formatKda(
|
||||
KDA {formatKda(
|
||||
participant.kills,
|
||||
participant.deaths,
|
||||
participant.assists,
|
||||
)}
|
||||
<span className="ml-1 text-base-content/35">
|
||||
({participant.killParticipation}%)
|
||||
· KP {participant.killParticipation}%
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
@@ -451,6 +482,12 @@ function PlayerRow({
|
||||
<span className="block text-base-content/35">
|
||||
{participant.csPerMin}/m
|
||||
</span>
|
||||
<span className="mt-1 block font-bold text-base-content/55">
|
||||
{formatCompactNumber(participant.gold)}
|
||||
<span className="ml-1 font-normal text-base-content/30">
|
||||
{formatNumber(participant.gpm)} GPM
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-3 py-2.5">
|
||||
<ItemStrip participant={participant} manifest={manifest} />
|
||||
@@ -486,13 +523,13 @@ function PlayerCard({
|
||||
{participant.assists}
|
||||
</div>
|
||||
<div className="text-[11px] font-bold tabular-nums text-base-content/40">
|
||||
{formatKda(
|
||||
KDA {formatKda(
|
||||
participant.kills,
|
||||
participant.deaths,
|
||||
participant.assists,
|
||||
)}
|
||||
<span className="ml-1 text-base-content/35">
|
||||
({participant.killParticipation}%)
|
||||
· KP {participant.killParticipation}%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -527,13 +564,19 @@ function PlayerCard({
|
||||
</div>
|
||||
<div className="border border-base-content/8 px-2 py-1.5">
|
||||
<div className="text-[10px] font-bold uppercase tracking-wider text-base-content/30">
|
||||
CS
|
||||
CS · 경제
|
||||
</div>
|
||||
<div className="mt-0.5 font-black text-base-content/70">
|
||||
{participant.cs}
|
||||
<span className="ml-1 font-bold text-base-content/35">
|
||||
{participant.csPerMin}/m
|
||||
</span>
|
||||
<span className="mt-1 block text-base-content/60">
|
||||
{formatCompactNumber(participant.gold)}
|
||||
<span className="ml-1 font-bold text-base-content/35">
|
||||
{formatNumber(participant.gpm)} GPM
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="border border-base-content/8 px-2 py-1.5">
|
||||
@@ -701,11 +744,125 @@ function PostgameBreakdown({
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<ObjectiveComparisonStrip selectedGame={selectedGame} />
|
||||
<GoldComparisonStrip selectedGame={selectedGame} detail={detail} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function ObjectiveComparisonStrip({
|
||||
selectedGame,
|
||||
}: {
|
||||
selectedGame: MatchGameDetail;
|
||||
}) {
|
||||
const blueTeam = selectedGame.teams.find((team) => team.side === "blue");
|
||||
const redTeam = selectedGame.teams.find((team) => team.side === "red");
|
||||
if (!blueTeam || !redTeam) return null;
|
||||
|
||||
const events = normalizeObjectiveEvents(selectedGame.objectiveEvents ?? []);
|
||||
const blueDragonTypes = formatDragonTypeSummary(
|
||||
summarizeDragonTypes(events, "blue"),
|
||||
blueTeam.objectives.dragon,
|
||||
);
|
||||
const redDragonTypes = formatDragonTypeSummary(
|
||||
summarizeDragonTypes(events, "red"),
|
||||
redTeam.objectives.dragon,
|
||||
);
|
||||
const objectives = [
|
||||
{
|
||||
key: "tower",
|
||||
label: "포탑",
|
||||
blue: blueTeam.objectives.tower,
|
||||
red: redTeam.objectives.tower,
|
||||
},
|
||||
{
|
||||
key: "dragon",
|
||||
label: "드래곤",
|
||||
blue: blueTeam.objectives.dragon,
|
||||
red: redTeam.objectives.dragon,
|
||||
blueDetail: blueDragonTypes,
|
||||
redDetail: redDragonTypes,
|
||||
},
|
||||
{
|
||||
key: "inhibitor",
|
||||
label: "억제기",
|
||||
blue: blueTeam.objectives.inhibitor,
|
||||
red: redTeam.objectives.inhibitor,
|
||||
},
|
||||
{
|
||||
key: "baron",
|
||||
label: "바론",
|
||||
blue: blueTeam.objectives.baron,
|
||||
red: redTeam.objectives.baron,
|
||||
},
|
||||
{
|
||||
key: "riftHerald",
|
||||
label: "전령",
|
||||
blue: blueTeam.objectives.riftHerald,
|
||||
red: redTeam.objectives.riftHerald,
|
||||
},
|
||||
{
|
||||
key: "voidGrub",
|
||||
label: "공허 유충",
|
||||
blue: blueTeam.objectives.voidGrub,
|
||||
red: redTeam.objectives.voidGrub,
|
||||
},
|
||||
{
|
||||
key: "elderDragon",
|
||||
label: "장로",
|
||||
blue: blueTeam.objectives.elderDragon,
|
||||
red: redTeam.objectives.elderDragon,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="border-t border-base-content/8 bg-base-content/[0.01]">
|
||||
<h3 className="sr-only">오브젝트 비교</h3>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7">
|
||||
{objectives.map((objective) => (
|
||||
<div
|
||||
key={objective.key}
|
||||
className="border-b border-r border-base-content/8 px-3 py-2.5 last:border-r-0 lg:border-b-0"
|
||||
aria-label={`${objective.label}: 블루 ${objective.blue}, 레드 ${objective.red}`}
|
||||
>
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2 text-xs tabular-nums">
|
||||
<span
|
||||
className={`text-right font-black ${
|
||||
objective.blue > objective.red
|
||||
? "text-blue-400"
|
||||
: "text-base-content/50"
|
||||
}`}
|
||||
>
|
||||
{objective.blue}
|
||||
</span>
|
||||
<span className="text-[10px] font-bold text-base-content/35">
|
||||
{objective.label}
|
||||
</span>
|
||||
<span
|
||||
className={`font-black ${
|
||||
objective.red > objective.blue
|
||||
? "text-red-400"
|
||||
: "text-base-content/50"
|
||||
}`}
|
||||
>
|
||||
{objective.red}
|
||||
</span>
|
||||
</div>
|
||||
{objective.key === "dragon" ? (
|
||||
<div className="mt-1 grid grid-cols-2 gap-2 text-[9px] font-bold leading-tight">
|
||||
<span className="text-right text-blue-400/70">
|
||||
{objective.blueDetail}
|
||||
</span>
|
||||
<span className="text-red-400/70">{objective.redDetail}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function GoldComparisonStrip({
|
||||
selectedGame,
|
||||
detail,
|
||||
@@ -848,14 +1005,74 @@ function TimelineTooltip({
|
||||
);
|
||||
}
|
||||
|
||||
function timelineEventKey(event: NormalizedTimelineEvent, index: number) {
|
||||
return [
|
||||
event.timestamp,
|
||||
event.side ?? "unknown",
|
||||
event.type,
|
||||
event.killerParticipantId ?? "none",
|
||||
event.victimParticipantId ?? "none",
|
||||
index,
|
||||
].join(":");
|
||||
}
|
||||
|
||||
function timelineParticipantLabel(
|
||||
participant: MatchGameParticipant | undefined,
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"],
|
||||
) {
|
||||
if (!participant) return null;
|
||||
const championName =
|
||||
championDisplayName(manifest, participant.championId) ??
|
||||
String(participant.championId);
|
||||
return `${participant.summonerName} (${championName})`;
|
||||
}
|
||||
|
||||
function timelineEventActors(
|
||||
event: NormalizedTimelineEvent,
|
||||
participantById: ReadonlyMap<number, MatchGameParticipant>,
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"],
|
||||
) {
|
||||
const killer = timelineParticipantLabel(
|
||||
event.killerParticipantId === undefined
|
||||
? undefined
|
||||
: participantById.get(event.killerParticipantId),
|
||||
manifest,
|
||||
);
|
||||
const victim = timelineParticipantLabel(
|
||||
event.victimParticipantId === undefined
|
||||
? undefined
|
||||
: participantById.get(event.victimParticipantId),
|
||||
manifest,
|
||||
);
|
||||
const assistants = (event.assistingParticipantIds ?? [])
|
||||
.map((participantId) =>
|
||||
timelineParticipantLabel(participantById.get(participantId), manifest),
|
||||
)
|
||||
.filter((label): label is string => Boolean(label));
|
||||
const assistLabel =
|
||||
assistants.length > 0 ? ` · 도움 ${assistants.join(", ")}` : "";
|
||||
|
||||
if (event.type === "championKill") {
|
||||
if (killer && victim) return `${killer} → ${victim}${assistLabel}`;
|
||||
if (killer) return `${killer} 처치${assistLabel}`;
|
||||
if (victim) return `${victim} 사망`;
|
||||
}
|
||||
if (killer) return `${killer} 기여${assistLabel}`;
|
||||
return null;
|
||||
}
|
||||
|
||||
function TimelineGraph({
|
||||
selectedGame,
|
||||
detail,
|
||||
manifest,
|
||||
}: {
|
||||
selectedGame: MatchGameDetail;
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||
}) {
|
||||
const [metric, setMetric] = useState<TimelineMetric>("gold");
|
||||
const [eventFilter, setEventFilter] = useState<TimelineEventFilter>("all");
|
||||
const [selectedEventKey, setSelectedEventKey] = useState<string | null>(null);
|
||||
const blueTeam = selectedGame.teams.find((team) => team.side === "blue");
|
||||
const redTeam = selectedGame.teams.find((team) => team.side === "red");
|
||||
const blueTeamName = blueTeam
|
||||
@@ -883,6 +1100,41 @@ function TimelineGraph({
|
||||
...chartData.map((point) => Math.abs(point.value)),
|
||||
);
|
||||
const finalPoint = chartData[chartData.length - 1];
|
||||
const timelineEvents = normalizeTimelineEvents(
|
||||
selectTimelineEventSource(
|
||||
selectedGame.timelineEvents,
|
||||
selectedGame.objectiveEvents ?? [],
|
||||
),
|
||||
);
|
||||
const visibleEvents = filterTimelineEvents(timelineEvents, eventFilter);
|
||||
const visibleEventEntries = visibleEvents.map((event) => {
|
||||
const index = timelineEvents.indexOf(event);
|
||||
return {
|
||||
event,
|
||||
key: timelineEventKey(event, index),
|
||||
};
|
||||
});
|
||||
const selectedEvent = visibleEventEntries.find(
|
||||
(entry) => entry.key === selectedEventKey,
|
||||
);
|
||||
const selectedTimestamp = selectedEvent?.event.timestamp ?? null;
|
||||
const timelineMarkers = projectTimelineEventMarkers(
|
||||
visibleEventEntries.map(({ event, key }) => ({ ...event, eventKey: key })),
|
||||
chartData,
|
||||
);
|
||||
const participantById = new Map<number, MatchGameParticipant>();
|
||||
for (const team of selectedGame.teams) {
|
||||
for (const participant of team.participants) {
|
||||
if (participant.participantId !== undefined) {
|
||||
participantById.set(participant.participantId, participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
const chartMaxTimestamp = Math.max(
|
||||
selectedGame.gameDuration,
|
||||
finalPoint?.timestamp ?? 0,
|
||||
timelineEvents[timelineEvents.length - 1]?.timestamp ?? 0,
|
||||
);
|
||||
const finalLeader =
|
||||
finalPoint?.leaderSide === "blue"
|
||||
? blueTeamName
|
||||
@@ -901,11 +1153,16 @@ function TimelineGraph({
|
||||
: "타임라인 대기"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex w-full border border-base-content/10 bg-base-content/[0.02] sm:w-auto">
|
||||
<div
|
||||
className="flex w-full border border-base-content/10 bg-base-content/[0.02] sm:w-auto"
|
||||
role="group"
|
||||
aria-label="경기 흐름 지표"
|
||||
>
|
||||
{TIMELINE_METRICS.map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
type="button"
|
||||
aria-pressed={metric === item.id}
|
||||
onClick={() => setMetric(item.id)}
|
||||
className={`min-w-24 flex-1 border-r border-base-content/8 px-4 py-2 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 sm:flex-none ${
|
||||
metric === item.id
|
||||
@@ -921,7 +1178,11 @@ function TimelineGraph({
|
||||
{chartData.length > 0 ? (
|
||||
<div className="px-2 py-4 sm:px-4">
|
||||
<div className="h-[260px] min-w-0 w-full">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<ResponsiveContainer
|
||||
width="100%"
|
||||
height="100%"
|
||||
initialDimension={{ width: 800, height: 260 }}
|
||||
>
|
||||
<AreaChart
|
||||
data={chartData}
|
||||
margin={{ top: 12, right: 12, bottom: 0, left: 0 }}
|
||||
@@ -933,6 +1194,8 @@ function TimelineGraph({
|
||||
/>
|
||||
<XAxis
|
||||
dataKey="timestamp"
|
||||
type="number"
|
||||
domain={[0, chartMaxTimestamp]}
|
||||
minTickGap={28}
|
||||
tickFormatter={(value) =>
|
||||
`${Math.round(Number(value) / 60)}분`
|
||||
@@ -965,6 +1228,14 @@ function TimelineGraph({
|
||||
stroke="currentColor"
|
||||
strokeOpacity={0.25}
|
||||
/>
|
||||
{selectedTimestamp !== null ? (
|
||||
<ReferenceLine
|
||||
x={selectedTimestamp}
|
||||
stroke="currentColor"
|
||||
strokeDasharray="3 3"
|
||||
strokeOpacity={0.35}
|
||||
/>
|
||||
) : null}
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="positive"
|
||||
@@ -994,6 +1265,44 @@ function TimelineGraph({
|
||||
}}
|
||||
isAnimationActive={false}
|
||||
/>
|
||||
{timelineMarkers.map((event) => {
|
||||
const selected = event.eventKey === selectedEventKey;
|
||||
const markerRadius =
|
||||
event.category === "objective"
|
||||
? 4
|
||||
: event.category === "structure"
|
||||
? 3.5
|
||||
: 2.5;
|
||||
return (
|
||||
<ReferenceDot
|
||||
key={event.eventKey}
|
||||
x={event.timestamp}
|
||||
y={event.value}
|
||||
r={selected ? 5.5 : markerRadius}
|
||||
fill={
|
||||
event.side === "blue"
|
||||
? "#3b82f6"
|
||||
: event.side === "red"
|
||||
? "#ef4444"
|
||||
: "currentColor"
|
||||
}
|
||||
stroke="currentColor"
|
||||
strokeWidth={selected ? 2 : 1}
|
||||
ifOverflow="extendDomain"
|
||||
label={
|
||||
selected
|
||||
? {
|
||||
value: event.markerLabel,
|
||||
position: "top",
|
||||
fontSize: 10,
|
||||
fontWeight: 800,
|
||||
fill: "currentColor",
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
@@ -1008,6 +1317,106 @@ function TimelineGraph({
|
||||
타임라인 데이터가 아직 없습니다
|
||||
</div>
|
||||
)}
|
||||
{timelineEvents.length > 0 ? (
|
||||
<div className="border-t border-base-content/8 px-4 py-3">
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<h3 className="text-xs font-black text-base-content">주요 사건</h3>
|
||||
<p className="text-[11px] font-bold text-base-content/30">
|
||||
항목을 선택하면 그래프의 해당 시점을 강조합니다
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
className="mt-3 flex w-full overflow-x-auto border border-base-content/10 bg-base-content/[0.02] sm:w-fit"
|
||||
role="group"
|
||||
aria-label="사건 유형 필터"
|
||||
>
|
||||
{TIMELINE_EVENT_FILTERS.map((filter) => (
|
||||
<button
|
||||
key={filter.id}
|
||||
type="button"
|
||||
aria-pressed={eventFilter === filter.id}
|
||||
onClick={() => setEventFilter(filter.id)}
|
||||
className={`min-w-20 flex-1 border-r border-base-content/8 px-3 py-2 text-[11px] font-black transition-colors last:border-r-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary sm:flex-none ${
|
||||
eventFilter === filter.id
|
||||
? "bg-primary text-primary-content"
|
||||
: "text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
||||
}`}
|
||||
>
|
||||
{filter.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<ul
|
||||
className="m-0 mt-3 grid max-h-64 list-none gap-1.5 overflow-y-auto p-0 sm:grid-cols-2 lg:grid-cols-3"
|
||||
aria-label="시간순 주요 사건"
|
||||
>
|
||||
{visibleEventEntries.map(({ event, key }) => {
|
||||
const selected = key === selectedEventKey;
|
||||
const teamName =
|
||||
event.side === "blue"
|
||||
? blueTeamName
|
||||
: event.side === "red"
|
||||
? redTeamName
|
||||
: null;
|
||||
const actorLabel = timelineEventActors(
|
||||
event,
|
||||
participantById,
|
||||
manifest,
|
||||
);
|
||||
return (
|
||||
<li key={key} className="min-w-0">
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={selected}
|
||||
onClick={() => setSelectedEventKey(selected ? null : key)}
|
||||
className={`grid h-full w-full grid-cols-[3.25rem_3.25rem_minmax(0,1fr)] items-start gap-2 border px-2.5 py-2 text-left text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${
|
||||
selected
|
||||
? "border-primary bg-primary/8"
|
||||
: "border-base-content/8 hover:bg-base-content/[0.03]"
|
||||
}`}
|
||||
>
|
||||
<span className="font-mono font-black tabular-nums text-base-content/55">
|
||||
{formatDuration(event.timestamp)}
|
||||
</span>
|
||||
<span
|
||||
className={`text-[10px] font-black uppercase tracking-wider ${
|
||||
event.side === "blue"
|
||||
? "text-blue-400"
|
||||
: event.side === "red"
|
||||
? "text-red-400"
|
||||
: "text-base-content/35"
|
||||
}`}
|
||||
>
|
||||
{event.side ? sideLabel(event.side) : "-"}
|
||||
</span>
|
||||
<span className="min-w-0">
|
||||
<span className="block truncate font-bold text-base-content/75">
|
||||
{teamName ? (
|
||||
<span className="sr-only">{teamName} </span>
|
||||
) : null}
|
||||
{event.label}
|
||||
</span>
|
||||
{actorLabel ? (
|
||||
<span
|
||||
className="mt-0.5 block truncate text-[10px] font-bold text-base-content/35"
|
||||
title={actorLabel}
|
||||
>
|
||||
{actorLabel}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{visibleEventEntries.length === 0 ? (
|
||||
<p className="py-6 text-center text-xs font-bold text-base-content/35">
|
||||
이 유형의 사건이 없습니다
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1045,7 +1454,7 @@ function TeamTable({
|
||||
<th className="w-[120px] px-3 py-2.5 text-center">가한 피해량</th>
|
||||
<th className="w-[120px] px-3 py-2.5 text-center">받은 피해량</th>
|
||||
<th className="w-[80px] px-3 py-2.5 text-center">시야</th>
|
||||
<th className="w-[76px] px-3 py-2.5 text-center">CS</th>
|
||||
<th className="w-[96px] px-3 py-2.5 text-center">CS · 경제</th>
|
||||
<th className="w-[260px] px-3 py-2.5">아이템</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -1306,6 +1715,13 @@ export default function MatchGameDetailPage() {
|
||||
manifest={ddragon}
|
||||
/>
|
||||
|
||||
<TimelineGraph
|
||||
key={selectedGame.riotMatchId}
|
||||
selectedGame={selectedGame}
|
||||
detail={detail}
|
||||
manifest={ddragon}
|
||||
/>
|
||||
|
||||
<div className="mt-5 space-y-4">
|
||||
<InternalGameDetailTabBar
|
||||
activeTab={activeTab}
|
||||
@@ -1325,8 +1741,6 @@ export default function MatchGameDetailPage() {
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<TimelineGraph selectedGame={selectedGame} detail={detail} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user