diff --git a/apps/api/src/modules/community-stats/community-stats.service.spec.ts b/apps/api/src/modules/community-stats/community-stats.service.spec.ts index f6e84cc4..dd58fe4a 100644 --- a/apps/api/src/modules/community-stats/community-stats.service.spec.ts +++ b/apps/api/src/modules/community-stats/community-stats.service.spec.ts @@ -33,6 +33,7 @@ function record(matchId: mongoose.Types.ObjectId): InternalRecord { gameDuration: 1_800, userId: new mongoose.Types.ObjectId().toString(), summonerName: 'Player', + tagLine: 'KR1', profileIconId: 1, teamIndex: 1, side: 'blue', @@ -186,7 +187,7 @@ describe('CommunityStatsService', () => { }); expect(matchStatsService.buildAndUpsert).not.toHaveBeenCalled(); expect(cacheService.setDetail).toHaveBeenCalledWith( - expect.stringContaining(':r2:'), + expect.stringContaining(':r3:'), response, ); }); diff --git a/apps/api/src/modules/community-stats/community-stats.service.ts b/apps/api/src/modules/community-stats/community-stats.service.ts index 94655491..98179bd8 100644 --- a/apps/api/src/modules/community-stats/community-stats.service.ts +++ b/apps/api/src/modules/community-stats/community-stats.service.ts @@ -36,7 +36,7 @@ const DEFAULT_LIST_LIMIT = 20; const MAX_LIST_LIMIT = 50; const MAX_MATCH_SCAN = 300; const MIN_HIGHLIGHT_GAMES = 5; -const MATCH_DETAIL_RESPONSE_CACHE_VERSION = 2; +const MATCH_DETAIL_RESPONSE_CACHE_VERSION = 3; interface CommunityStatsContext { community: CommunityDocument; @@ -248,6 +248,7 @@ export class CommunityStatsService { participants: team.participants.map((record) => ({ userId: record.userId, summonerName: record.summonerName, + tagLine: record.tagLine, teamIndex: record.teamIndex, side: record.side, teamPosition: record.teamPosition, @@ -1027,6 +1028,7 @@ function isCompleteMatchDetailResponse( Array.isArray(team.bans) && team.participants.every( (participant) => + typeof participant.tagLine === 'string' && Array.isArray(participant.itemBuild) && Array.isArray(participant.skillBuild), ), diff --git a/apps/api/src/modules/community-stats/community-stats.types.ts b/apps/api/src/modules/community-stats/community-stats.types.ts index 5fcbf5fe..7fde72e2 100644 --- a/apps/api/src/modules/community-stats/community-stats.types.ts +++ b/apps/api/src/modules/community-stats/community-stats.types.ts @@ -145,6 +145,7 @@ export interface InternalMatchDetailResponse { participants: Array<{ userId: string | null; summonerName: string; + tagLine: string; teamIndex: number; side: TeamSide; teamPosition: string; diff --git a/apps/api/src/modules/community-stats/match-stats-fragment.builder.ts b/apps/api/src/modules/community-stats/match-stats-fragment.builder.ts index 2f49ea7b..dc7860e0 100644 --- a/apps/api/src/modules/community-stats/match-stats-fragment.builder.ts +++ b/apps/api/src/modules/community-stats/match-stats-fragment.builder.ts @@ -325,6 +325,7 @@ export class MatchStatsFragmentBuilder { rawParticipant?.riotIdGameName ?? rawParticipant?.summonerName ?? 'Unknown', + tagLine: snapshot?.tagLine ?? rawParticipant?.riotIdTagLine ?? '', profileIconId: snapshot?.profileIconId ?? 0, teamIndex: participant.teamIndex, side: participant.side, diff --git a/apps/api/src/modules/community-stats/match-stats.service.spec.ts b/apps/api/src/modules/community-stats/match-stats.service.spec.ts index 56b31069..f3a21de7 100644 --- a/apps/api/src/modules/community-stats/match-stats.service.spec.ts +++ b/apps/api/src/modules/community-stats/match-stats.service.spec.ts @@ -114,7 +114,7 @@ describe('MatchStatsService', () => { scheduledAt, gameCreationMin: 1_000, gameCreationMax: 2_000, - builderVersion: 8, + builderVersion: 9, }), ); }); diff --git a/apps/api/src/modules/community-stats/match-stats.types.ts b/apps/api/src/modules/community-stats/match-stats.types.ts index 0103e82d..d77cb8a1 100644 --- a/apps/api/src/modules/community-stats/match-stats.types.ts +++ b/apps/api/src/modules/community-stats/match-stats.types.ts @@ -4,7 +4,7 @@ import type { } from '../global/database/schema'; import type { InternalMatchCardView } from './community-stats.types'; -export const MATCH_STATS_BUILDER_VERSION = 8; +export const MATCH_STATS_BUILDER_VERSION = 9; export type InternalRecord = MatchStatsRecord; export type InternalGameDetail = MatchStatsGameDetail; diff --git a/apps/api/src/modules/global/database/schema.ts b/apps/api/src/modules/global/database/schema.ts index 39321434..61406ba0 100644 --- a/apps/api/src/modules/global/database/schema.ts +++ b/apps/api/src/modules/global/database/schema.ts @@ -711,6 +711,7 @@ export interface MatchStatsRecord { gameDuration: number; userId: string; summonerName: string; + tagLine: string; profileIconId: number; teamIndex: number; side: TeamSide; diff --git a/apps/web/src/api/types.ts b/apps/web/src/api/types.ts index 9473f226..20395d44 100644 --- a/apps/web/src/api/types.ts +++ b/apps/web/src/api/types.ts @@ -796,6 +796,7 @@ export interface ApiInternalMatchDetailResponse { participants: Array<{ userId: string | null; summonerName: string; + tagLine: string; teamIndex: number; side: TeamSide; teamPosition: string; diff --git a/apps/web/src/pages/MatchGameDetailPage.tsx b/apps/web/src/pages/MatchGameDetailPage.tsx index 5e739b13..5d626f90 100644 --- a/apps/web/src/pages/MatchGameDetailPage.tsx +++ b/apps/web/src/pages/MatchGameDetailPage.tsx @@ -35,20 +35,13 @@ type MatchGameTeam = MatchGameDetail["teams"][number]; type MatchGameParticipant = MatchGameTeam["participants"][number]; type DdragonManifestData = ReturnType["data"]; type RuneStyleEntry = NonNullable["runesReforged"][number]; -type DetailTab = - | "scoreboard" - | "matchup" - | "build" - | "damageDealt" - | "damageTaken"; +type DetailTab = "scoreboard" | "matchup" | "build"; type TimelineMetric = "gold" | "xp"; const DETAIL_TABS: Array<{ id: DetailTab; label: string }> = [ { id: "scoreboard", label: "스코어보드" }, { id: "matchup", label: "라인전" }, { id: "build", label: "룬 / 빌드" }, - { id: "damageDealt", label: "가한 데미지" }, - { id: "damageTaken", label: "받은 데미지" }, ]; const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [ @@ -154,9 +147,18 @@ function teamTotals(team: MatchGameTeam) { assists: totals.assists + participant.assists, gold: totals.gold + participant.gold, damage: totals.damage + participant.damageDealtToChampions, + damageTaken: totals.damageTaken + (participant.damageTaken ?? 0), vision: totals.vision + participant.visionScore, }), - { kills: 0, deaths: 0, assists: 0, gold: 0, damage: 0, vision: 0 }, + { + kills: 0, + deaths: 0, + assists: 0, + gold: 0, + damage: 0, + damageTaken: 0, + vision: 0, + }, ); } @@ -211,25 +213,6 @@ function runeStyleSelection( return participant.perks.styles?.find((style) => style.styleId === styleId); } -function StatBlock({ - label, - value, -}: { - label: string; - value: string | number; -}) { - return ( -
-
- {label} -
-
- {value} -
-
- ); -} - function WinBadge({ win }: { win: boolean }) { return win ? ( @@ -301,7 +284,7 @@ function SpellRuneStrip({ {[0, 1].map((index) => ( {spellIcons[index] ? ( ( {runeIcons[index] ? ( ["data"]; + avatarSize?: string; + nameMaxWidth?: string; }) { const location = useLocation(); const historyBackTo = `${location.pathname}${location.search}${location.hash}`; + const lane = + LANE_LABELS[participant.teamPosition] ?? participant.teamPosition ?? "-"; + const nameNode = ( + <> + {participant.summonerName} + {participant.tagLine ? ( + + {" "} + #{participant.tagLine} + + ) : null} + + ); return ( - - - - - - - - +
+ + +
{participant.userId ? ( - {participant.summonerName} + {nameNode} ) : ( - - {participant.summonerName} - - )} - {(participant.firstBloodKill || participant.firstBloodAssist) && ( - - {participant.firstBloodKill ? "FB" : "FBA"} + + {nameNode} )} +
+ {lane} + {(participant.firstBloodKill || participant.firstBloodAssist) && ( + + {participant.firstBloodKill ? "FB" : "FBA"} + + )} +
+
+
+ ); +} + +function PlayerRow({ + participant, + manifest, + teamDamageTaken, +}: { + participant: MatchGameParticipant; + manifest: ReturnType["data"]; + teamDamageTaken: number; +}) { + const takenShare = + teamDamageTaken > 0 + ? ((participant.damageTaken ?? 0) / teamDamageTaken) * 100 + : 0; + + return ( + + +
@@ -425,11 +453,13 @@ function PlayerRow({ participant.deaths, participant.assists, )} - {participant.deaths === 0 ? "" : " KDA"} + + ({participant.killParticipation}%) +
- {formatCompactNumber(participant.damageDealtToChampions)} + {formatNumber(participant.damageDealtToChampions)}
@@ -437,6 +467,13 @@ function PlayerRow({ {formatPercent(participant.damageShare)}
+ + {formatNumber(participant.damageTaken ?? 0)} +
+ +
+ {Math.round(takenShare)}% + {participant.visionScore} @@ -462,18 +499,22 @@ function PlayerRow({ function PlayerCard({ participant, manifest, + teamDamageTaken, }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; + teamDamageTaken: number; }) { - const location = useLocation(); - const historyBackTo = `${location.pathname}${location.search}${location.hash}`; + const takenShare = + teamDamageTaken > 0 + ? ((participant.damageTaken ?? 0) / teamDamageTaken) * 100 + : 0; return (
-
- -
+
+ +
{participant.kills} / @@ -487,49 +528,40 @@ function PlayerCard({ participant.deaths, participant.assists, )} - {participant.deaths === 0 ? "" : " KDA"} + + ({participant.killParticipation}%) +
-
-
- {participant.userId ? ( - - {participant.summonerName} - - ) : ( - - {participant.summonerName} - - )} - {(participant.firstBloodKill || participant.firstBloodAssist) && ( - - {participant.firstBloodKill ? "FB" : "FBA"} - - )} -
- -
-
+
- 피해량 + 가한 피해량
- {formatCompactNumber(participant.damageDealtToChampions)} + {formatNumber(participant.damageDealtToChampions)} {formatPercent(participant.damageShare)}
+
+
+ 받은 피해량 +
+
+ {formatNumber(participant.damageTaken ?? 0)} + + {Math.round(takenShare)}% + +
+ +
CS @@ -596,16 +628,23 @@ function TeamScoreHeader({
-
- - - - - - +
+
+ + KDA + + + {totals.kills} / {totals.deaths} / {totals.assists} + +
+
+ + Gold + + + {formatCompactNumber(totals.gold)} + +
@@ -1019,6 +1058,8 @@ function TeamTable({ detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { + const teamDamageTaken = teamTotals(team).damageTaken; + return (
@@ -1028,19 +1069,19 @@ function TeamTable({ key={`card-${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`} participant={participant} manifest={manifest} + teamDamageTaken={teamDamageTaken} /> ))}
- +
- - - - - - + + + + + @@ -1051,6 +1092,7 @@ function TeamTable({ key={`${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`} participant={participant} manifest={manifest} + teamDamageTaken={teamDamageTaken} /> ))} @@ -1550,83 +1592,6 @@ function SkillBuildPanel({ ); } -function DamagePanel({ - selectedGame, - detail, - manifest, - metric, -}: { - selectedGame: MatchGameDetail; - detail: ApiInternalMatchDetailResponse; - manifest: ReturnType["data"]; - metric: "dealt" | "taken"; -}) { - const participants = selectedGame.teams.flatMap((team) => team.participants); - const maxValue = Math.max( - 1, - ...participants.map((participant) => - metric === "dealt" - ? participant.damageDealtToChampions - : (participant.damageTaken ?? 0), - ), - ); - const orderedTeams = [...selectedGame.teams].sort((left, right) => - left.side === right.side ? 0 : left.side === "blue" ? -1 : 1, - ); - - return ( -
- {orderedTeams.map((team) => { - const tone = sideTone(team.side); - return ( -
-
-
- {getTeamName(detail, team.teamIndex)} · {sideLabel(team.side)} -
-
-
-
- {team.participants.map((participant) => { - const value = - metric === "dealt" - ? participant.damageDealtToChampions - : (participant.damageTaken ?? 0); - return ( -
- -
-
-
-
- {formatNumber(value)} -
-
- ); - })} -
-
-
- ); - })} -
- ); -} - const LANE_SORT_ORDER = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"]; function laneSortValue(position: string) { @@ -1755,16 +1720,16 @@ function LaneMatchupCard({ label: "골드", blueValue: blue.gold, redValue: red.gold, - blueText: formatCompactNumber(blue.gold), - redText: formatCompactNumber(red.gold), + blueText: formatNumber(blue.gold), + redText: formatNumber(red.gold), }, { key: "damage", label: "딜량", blueValue: blue.damageDealtToChampions, redValue: red.damageDealtToChampions, - blueText: formatCompactNumber(blue.damageDealtToChampions), - redText: formatCompactNumber(red.damageDealtToChampions), + blueText: formatNumber(blue.damageDealtToChampions), + redText: formatNumber(red.damageDealtToChampions), }, { key: "cs", @@ -1947,28 +1912,6 @@ function GameAnalysisPanel({ ); } - if (activeTab === "damageDealt") { - return ( - - ); - } - - if (activeTab === "damageTaken") { - return ( - - ); - } - return (
챔피언스펠/룬선수KDA피해량시야선수KDA가한 피해량받은 피해량시야 CS 아이템