범인찾기 C3: 사이트 🔍 범인찾기 탭 · 결과 화면 · 경기 화면 버튼
- 경기 목록(분석 가능 · 분석 완료 · 준비 중 · 기록 부족 + 이유), 분석에 쓰는 기록 · 참가자(음성 표시) · 예상 비용 · 남은 예산 · 오늘 남은 횟수 - 진행 단계(기록 모으기 → AI가 읽는 중 → 근거 확인 → 완료) 실시간 표시, 실패 이유 표시 - 결과: 한 줄 요약 · 확신도, 팀별 범인 카드(이유 + 근거: 대화 ▶ 듣기 · 킬/라운드 → 타임라인 · 스탯 → 스코어보드), 10명 평점 · 태그 · 한 줄 평, 휴대폰 한 줄 배치 - 다시 분석은 관리자에게만 버튼, 예전 앱이면 "앱을 업데이트해 주세요" - app/scripts/culprit-shots.mts: 실제 앱 코어 + 사이트 서버 + 헤드리스 브라우저로 화면 확인 (CSP 위반 · 오류 없음) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
12
README.md
12
README.md
@@ -6,7 +6,7 @@
|
||||
- 게임 PC: 포터블 `GameVoiceRecorder.exe` 하나로 디스코드 봇, STT 엔진, 기록 저장소, 설정 화면이 돈다
|
||||
- 사이트 서버: 디스코드 로그인(서버 멤버만), 게임 PC 연결 확인·잠금 화면, 기록 중계 (기록은 게임 PC 에만 있음)
|
||||
- 설계·계획: [`docs/gemnoki-project-plan.pdf`](docs/gemnoki-project-plan.pdf), 개발 구조·인터페이스: [`docs/dev/ARCHITECTURE.md`](docs/dev/ARCHITECTURE.md)
|
||||
- 범인찾기 · 리플레이 동기화 계획서 v1.1 (코드 작성 전 검토용): [`docs/culprit-finder-plan.pdf`](docs/culprit-finder-plan.pdf) · 원본 · 비용 계산 · 범인찾기 프롬프트 초안: `docs/report/culprit/` (`prompt/`)
|
||||
- 범인찾기 · 리플레이 동기화 계획서 v1.1: [`docs/culprit-finder-plan.pdf`](docs/culprit-finder-plan.pdf) · 원본 · 비용 계산 · 프롬프트 초안: `docs/report/culprit/` (실제로 쓰는 프롬프트는 `site/server/prompt/`)
|
||||
- **제작 완료 보고서 (M0~M8)**: [`docs/gemnoki-final-report.pdf`](docs/gemnoki-final-report.pdf) · 단계별 테스트 기록: [`docs/dev/test-results.md`](docs/dev/test-results.md)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0) (`GameVoiceRecorder-1.0.0-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.0.0-portable.exe`)
|
||||
|
||||
@@ -37,6 +37,16 @@
|
||||
- 사이트 서버: 보안 정책(CSP)으로 이 사이트 스크립트와 이 사이트로의 접속만 허용, 실시간 WebSocket 은 이 사이트에서 온 연결만, 로그인 세션 · 앱 토큰 · 기기 키는 해시로만 저장, 로그에서 로그인 code · state · 검색어를 지운다. 등록 코드 대입 · 로그인 요청 폭주는 IP 별로 막는다. HSTS · http→https 이동 · TLS 1.2 미만 차단은 앞단 프록시(NPMplus)가 한다.
|
||||
- 디스코드 음성은 디스코드 자체 암호화(DAVE 종단간 암호화)로 간다.
|
||||
|
||||
## 🔍 범인찾기 (개발 중, 다음 버전)
|
||||
|
||||
끝난 경기를 고르고 "범인 분석"을 누르면 AI(Claude)가 그 경기의 음성 대화 · 킬 · 라운드/오브젝트 · 경제 · 채팅 · 10명 스탯을 읽고 10명 평점 · 태그 · 한 줄 평과 팀별 범인 1명(이유 + 근거)을 만든다. 근거를 누르면 그 순간의 음성 · 타임라인으로 간다. 계획서: [`docs/culprit-finder-plan.pdf`](docs/culprit-finder-plan.pdf)
|
||||
|
||||
- 정한 것 (2026-10-15): 범인 = 가장 못함 + 가장 발목 + 결과의 원인을 종합해 팀마다 1명 · 분석 버튼은 등록된 앱 유저 이상(다시 분석은 관리자) · Claude Opus 5.5(생각 high) · 말투 중간맛 · 녹음 안내(TTS)에 "녹음된 대화는 AI 경기 분석에 쓰일 수 있어요" 추가
|
||||
- 리플레이 동기화: 공식 · 비공식 API 로 리플레이 시간을 읽을 수 있을 때만 넣는다 (화면 글자 인식(OCR) · 게임 설정 파일 고치기는 하지 않음). Windows 실기 확인 전이라 아직 없다
|
||||
- 앱: 경기 상세에서 추가 지표 저장(발로란트 피해량 · 첫킬 · 설치/해체 · 라운드별 장비, 롤 포지션 · 딜량 · 시야 · 10/15분 CS), "분석할 수 있는 경기" 판정(경기 결과 · 녹음 공백 1분 · 음성 변환), 근거 번호가 달린 AI 자료 만들기, 결과 저장(`culprit_analyses`). `app/src/core/culprit.ts`
|
||||
- 사이트 서버: Claude API 키는 서버 환경 변수 `ANTHROPIC_API_KEY` 에만 (`deploy/site/set-anthropic-key.sh`). 권한 · 월 $100 · 하루 20회 · 중복 잠금, 구조화 출력, 근거 번호 확인, 비용 장부(토큰 · 비용만, 대화 내용 없음). `site/server/src/culprit.ts`, 지시문 · 지식 묶음 `site/server/prompt/` (지식 묶음의 요원 · 챔피언 목록은 공식 데이터로 하루 한 번 갱신)
|
||||
- 화면: 사이트 🔍 범인찾기 탭 (`site/web/src/pages/CulpritPage.tsx`), 경기 화면의 "🔍 범인 보기". 화면 확인: `node --import tsx app/scripts/culprit-shots.mts`
|
||||
|
||||
## 진행 현황
|
||||
|
||||
| 단계 | 내용 | 상태 |
|
||||
|
||||
133
app/scripts/culprit-shots.mts
Normal file
133
app/scripts/culprit-shots.mts
Normal file
@@ -0,0 +1,133 @@
|
||||
// 범인찾기 화면 확인: 실제 앱 코어(범인찾기 · 기록 DB) + 실제 사이트 서버 + 헤드리스 브라우저.
|
||||
// AI 는 부르지 않는다: CULPRIT_ANSWER(JSON 파일)를 AI 답으로 돌려준다 (없으면 기본 답 생성).
|
||||
// node --import tsx scripts/culprit-shots.mts [답.json] [스크린샷 폴더]
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import type { CulpritInput } from '@gvr/shared';
|
||||
import { makeDemoLol } from '../test/fixtures/demo-matches.ts';
|
||||
import { culpritApi, MIN, seedValorant, setup } from '../test/fixtures/culprit-seed.ts';
|
||||
|
||||
const answerFile = process.argv[2];
|
||||
const shotDir = process.argv[3] || path.join(os.homedir(), '.tmp', 'culprit-shots');
|
||||
const root = path.resolve(import.meta.dirname, '..', '..');
|
||||
const core = setup();
|
||||
await core.assets.refresh(true);
|
||||
const { id: valId } = seedValorant(core);
|
||||
// 롤 경기 (음성 2명)
|
||||
const LS = Date.now() - 80 * MIN;
|
||||
const lol = makeDemoLol();
|
||||
core.store.setMeta('riot_self_puuid', 'l-sh');
|
||||
core.store.setAccounts('u1', [{ puuid: 'p-sh', riotId: '승한#V' }, { puuid: 'l-sh', riotId: '승한#L' }]);
|
||||
core.store.setAccounts('u2', [{ puuid: 'p-ms', riotId: '민수#V' }, { puuid: 'l-ms', riotId: '민수#L' }]);
|
||||
core.store.startSession('s2', 'g', 'c', '음성', LS - MIN);
|
||||
core.games.matchStarted({ id: 'lol-demo', game: 'lol', startedAt: LS, map: 'Map11', mode: 'CLASSIC', queue: '420', detail: { live: true } });
|
||||
core.games.matchEnded('lol-demo', LS + lol.durationMs);
|
||||
(core.games.adapters[1] as any).applyHistory('lol-demo', lol.game, lol.timeline, LS);
|
||||
for (const [uid, min, text] of [['u2', 8.1, '용 같이 하자 바텀 밀었어'], ['u1', 8.3, '아니 탑 갱 각이야 잠깐만']] as const) {
|
||||
const ts = LS + min * MIN;
|
||||
const id = `lol-${uid}-${min}`;
|
||||
core.store.insertUtterance({ id, session_id: 's2', user_id: uid, started_at: ts, ended_at: ts + 1500, audio_path: null, match_id: 'lol-demo' });
|
||||
core.store.updateUtteranceResult(id, { text, raw_text: text, words: [], noise: false, noise_reason: null, confidence: 0.9, lufs: -20, gain_db: 0, model: 'small', status: 'precise' });
|
||||
}
|
||||
core.store.endSession('s2', LS + lol.durationMs + MIN);
|
||||
// 녹음이 늦게 시작한 경기 (기록 부족 표시용)
|
||||
core.store.upsertMatch({ id: 'val-late', game: 'valorant', started_at: Date.now() - 30 * 3600_000, ended_at: Date.now() - 29.3 * 3600_000, status: 'complete', map: '/Game/Maps/Bonsai/Bonsai', queue: 'competitive', mode: 'competitive', result: JSON.stringify({ win: true, score: { ally: 13, enemy: 10 } }), detail: JSON.stringify({ players: [{}, {}], roundsDetail: [{}] }) });
|
||||
core.store.startSession('s3', 'g', 'c', null, Date.now() - 30 * 3600_000 + 12 * MIN);
|
||||
core.store.endSession('s3', Date.now() - 29 * 3600_000);
|
||||
|
||||
const local = await culpritApi(core);
|
||||
const saved = answerFile && fs.existsSync(answerFile) ? JSON.parse(fs.readFileSync(answerFile, 'utf8')) : null;
|
||||
const fakeAnswer = (input: CulpritInput) => ({
|
||||
summary: '초반 드래곤 세 개를 내줘 끌려갔지만 바론 앞 한타를 뒤집어 이겼다.',
|
||||
confidence: 'medium',
|
||||
confidence_note: '시연 데이터라 기록이 단순하다.',
|
||||
teams: [
|
||||
{ team: 'ally', culprit: 'P2', reason: '드래곤 앞 교전에서 시야 없이 싸우다 내줬고, 용 콜이 있었는데 탑 갱을 고집했다.', evidence: Object.keys(input.refs).filter((k) => k.startsWith('u') || k === 'e3').slice(0, 3).map((ref) => ({ ref, note: '근거' })).concat([{ ref: 's:P2', note: '킬 관여 낮음' }]) },
|
||||
{ team: 'enemy', culprit: 'P10', reason: '레오나로 이니시를 열지 못하고 한타 직전에 먼저 잡혔다.', evidence: [{ ref: 's:P10', note: '데스 많음' }] },
|
||||
],
|
||||
players: input.players.map((p, i) => ({ id: p.id, score: p.id === 'P2' ? 4 : p.id === 'P10' ? 3 : 6 + (i % 4), tag: p.id === 'P2' || p.id === 'P10' ? '범인' : i === 0 ? '캐리' : '무난', comment: '한 줄 평 예시.', evidence: [] })),
|
||||
});
|
||||
const { buildServer } = await import('../../site/server/src/app.ts');
|
||||
const { KnowledgeAuto } = await import('../../site/server/src/culprit-prompt.ts');
|
||||
const port = 18960;
|
||||
const site = await buildServer(
|
||||
{
|
||||
port, host: '127.0.0.1', publicUrl: `http://127.0.0.1:${port}`, clientId: 'x', clientSecret: 'x', botToken: 'x', allowedGuilds: [], owners: ['u1'], superAdmins: ['u1'],
|
||||
sessionSecret: 'demo-secret-'.repeat(3), dataDir: fs.mkdtempSync(path.join(os.tmpdir(), 'gvr-cs-')), webDir: path.join(root, 'site', 'web', 'dist'), version: 't', discordApi: 'http://127.0.0.1:1',
|
||||
assetUpstream: { valmedia: 'https://media.valorant-api.com/', ddragon: 'https://ddragon.leagueoflegends.com/', cdragon: 'https://raw.communitydragon.org/' },
|
||||
culprit: { apiKey: 'x', model: 'claude-opus-5-5', effort: 'high', monthLimitUsd: 100, dailyLimit: 20, tone: 'medium' },
|
||||
},
|
||||
{
|
||||
culpritKnowledge: new KnowledgeAuto(async () => { throw new Error('offline'); }),
|
||||
culpritCall: async (req) => {
|
||||
await new Promise((r) => setTimeout(r, 2500));
|
||||
const isVal = req.user.includes('# 경기 발로란트');
|
||||
const input = (await local.inject({ url: `/api/culprit/internal/${isVal ? valId : 'lol-demo'}/input`, headers: { 'x-gvr-internal': '1' } })).json().input;
|
||||
return { text: JSON.stringify(isVal && saved ? saved : fakeAnswer(input)), stopReason: 'end_turn', usages: [{ model: 'claude-opus-5-5', input: 26077, output: 13997, cacheRead: 0, cacheWrite: 0 }], fallback: false };
|
||||
},
|
||||
},
|
||||
);
|
||||
site.app.log.level = 'warn';
|
||||
await site.app.listen({ host: '127.0.0.1', port });
|
||||
const base = `http://127.0.0.1:${port}`;
|
||||
const code = site.store.createCode('demo');
|
||||
const reg = site.store.redeem(code.code, 'GAME-PC')!;
|
||||
const { RelayClient } = await import('../src/core/relay/client.ts');
|
||||
const rc = new RelayClient(local as any, core.bus, () => ({ serverUrl: base, deviceId: reg.deviceId, deviceKey: reg.deviceKey, name: 'GAME-PC', version: 't', guildId: 'g' }));
|
||||
rc.start();
|
||||
// 사이트 화면은 /api/overview · /api/users 도 부른다
|
||||
while (!site.hub.status().online) await new Promise((r) => setTimeout(r, 100));
|
||||
const sess = site.store.createSession({ id: 'u1', name: '승한', avatar: null });
|
||||
const cookie = { name: 'gvr_sid', value: site.app.signCookie(sess.token), url: base };
|
||||
|
||||
const puppeteer = (await import(path.join(os.homedir(), '.tmp/gvr-shot/node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js'))).default;
|
||||
const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: true, args: ['--no-sandbox', '--lang=ko-KR'] });
|
||||
const page = await browser.newPage();
|
||||
await page.setCookie(cookie);
|
||||
const errs: string[] = [];
|
||||
page.on('pageerror', (e: any) => errs.push(e.message));
|
||||
page.on('console', (m: any) => m.type() === 'error' && errs.push(m.text()));
|
||||
const csp: string[] = [];
|
||||
await page.exposeFunction('__csp', (v: string) => csp.push(v));
|
||||
await page.evaluateOnNewDocument(() => document.addEventListener('securitypolicyviolation', (e) => (window as any).__csp(`${e.violatedDirective} ${e.blockedURI}`)));
|
||||
fs.mkdirSync(shotDir, { recursive: true });
|
||||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
const shot = async (name: string, w = 1440, h = 900, full = false) => {
|
||||
await page.setViewport({ width: w, height: h });
|
||||
await sleep(600);
|
||||
await page.screenshot({ path: path.join(shotDir, name), fullPage: full });
|
||||
console.log('screenshot', name);
|
||||
};
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
await page.goto(`${base}/culprit/${valId}`, { waitUntil: 'networkidle2' });
|
||||
await sleep(1500);
|
||||
await shot('1-list.png', 1440, 1100);
|
||||
await page.click('.cu-btn');
|
||||
await sleep(1200);
|
||||
await shot('2-progress.png');
|
||||
await page.waitForSelector('.cu-card', { timeout: 20000 });
|
||||
await sleep(1200);
|
||||
await shot('3-result-val.png', 1440, 1900);
|
||||
await shot('4-result-mobile.png', 390, 3200);
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
await page.goto(`${base}/culprit/lol-demo`, { waitUntil: 'networkidle2' });
|
||||
await sleep(1200);
|
||||
await page.click('.cu-btn');
|
||||
await page.waitForSelector('.cu-card', { timeout: 20000 });
|
||||
await sleep(1200);
|
||||
await shot('5-result-lol.png', 1440, 1900);
|
||||
await page.goto(`${base}/culprit/val-late`, { waitUntil: 'networkidle2' });
|
||||
await sleep(1200);
|
||||
await shot('6-blocked.png');
|
||||
await page.goto(`${base}/matches/${valId}`, { waitUntil: 'networkidle2' });
|
||||
await sleep(800);
|
||||
const hasBtn = await page.evaluate(() => [...document.querySelectorAll('.crumbs a')].some((a) => a.textContent?.includes('범인 보기')));
|
||||
console.log('경기 화면 범인 보기 버튼', hasBtn);
|
||||
console.log('브라우저 오류:', errs.filter((e) => !/favicon/.test(e)));
|
||||
console.log('CSP 위반:', csp.length ? csp : '없음');
|
||||
await browser.close();
|
||||
rc.stop();
|
||||
await site.app.close();
|
||||
await local.close();
|
||||
process.exit(0);
|
||||
@@ -13,6 +13,7 @@ import { PlayerBar } from './components/PlayerBar';
|
||||
import { Spinner } from './components/common';
|
||||
import { TimelinePage } from './pages/TimelinePage';
|
||||
import { MatchPage } from './pages/MatchPage';
|
||||
import { CulpritPage } from './pages/CulpritPage';
|
||||
import { MatchesPage, UserPage, UsersPage } from './pages/UserPages';
|
||||
|
||||
/** Space 재생/일시정지 · ←/→ 이전/다음 발화 · / 검색 */
|
||||
@@ -66,6 +67,8 @@ function Shell() {
|
||||
<Route path="/users" element={<UsersPage />} />
|
||||
<Route path="/users/:id" element={<UserPage />} />
|
||||
<Route path="/dictionary" element={<DictionaryPage />} />
|
||||
<Route path="/culprit" element={<CulpritPage />} />
|
||||
<Route path="/culprit/:id" element={<CulpritPage />} />
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
@@ -148,6 +148,7 @@ export function Header() {
|
||||
['/matches', '경기'],
|
||||
['/users', '유저'],
|
||||
['/dictionary', '단어사전'],
|
||||
['/culprit', '🔍 범인찾기'],
|
||||
] as const;
|
||||
return (
|
||||
<header className="topbar">
|
||||
@@ -156,7 +157,7 @@ export function Header() {
|
||||
</NavLink>
|
||||
<nav className="nav">
|
||||
{nav.map(([to, label]) => (
|
||||
<NavLink key={to} to={to} end={to === '/'} className={({ isActive }) => `chip${isActive ? ' on' : ''}`} onClick={() => sfx('click')}>
|
||||
<NavLink key={to} to={to} end={to === '/'} className={({ isActive }) => `chip${isActive ? ' on' : ''}${to === '/culprit' ? ' new' : ''}`} onClick={() => sfx('click')}>
|
||||
{label}
|
||||
</NavLink>
|
||||
))}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import type {
|
||||
CulpritBudget,
|
||||
CulpritMatchInfo,
|
||||
CulpritMatchItem,
|
||||
DeviceStatus,
|
||||
MatchDetail,
|
||||
MatchSummary,
|
||||
@@ -122,6 +125,33 @@ export const api = {
|
||||
),
|
||||
matches: (o: { game?: GameType; limit?: number; before?: number } = {}) => request<MatchSummary[]>(`/api/matches${qs(o)}`),
|
||||
match: (id: string) => request<MatchDetail>(`/api/matches/${encodeURIComponent(id)}`),
|
||||
culpritMatches: (o: { game?: GameType; limit?: number } = {}) => request<CulpritMatchItem[]>(`/api/culprit/matches${qs(o)}`),
|
||||
culpritMatch: (id: string) => request<CulpritMatchInfo>(`/api/culprit/matches/${encodeURIComponent(id)}`),
|
||||
culpritBudget: () => request<CulpritBudget>('/api/culprit/budget'),
|
||||
/** 범인 분석 시작 (202). 실패하면 { error, message } 를 그대로 돌려준다 */
|
||||
async culpritAnalyze(id: string, reanalyze = false): Promise<{ ok: true } | { ok: false; status: number; error: string; message: string }> {
|
||||
let res: Response;
|
||||
try {
|
||||
res = await fetch(`/api/culprit/matches/${encodeURIComponent(id)}/analyze`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { accept: 'application/json', 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ reanalyze }),
|
||||
});
|
||||
} catch {
|
||||
return { ok: false, status: 0, error: 'network', message: '네트워크 오류' };
|
||||
}
|
||||
if (res.status === 202) return { ok: true };
|
||||
let b: { error?: string; message?: string } = {};
|
||||
try {
|
||||
b = await res.json();
|
||||
} catch {
|
||||
/* 본문 없음 */
|
||||
}
|
||||
if (res.status === 401) emit('unauthorized');
|
||||
if (res.status === 503 && b.error === 'device_offline') emit('device_offline');
|
||||
return { ok: false, status: res.status, error: b.error ?? 'error', message: b.message ?? '분석을 시작하지 못했습니다' };
|
||||
},
|
||||
correct: (id: string, text: string) =>
|
||||
request<UtteranceItem>(`/api/utterances/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify({ text }) }),
|
||||
};
|
||||
|
||||
600
site/web/src/pages/CulpritPage.tsx
Normal file
600
site/web/src/pages/CulpritPage.tsx
Normal file
@@ -0,0 +1,600 @@
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||
import { Link, useNavigate, useParams } from 'react-router';
|
||||
import type {
|
||||
CulpritBudget,
|
||||
CulpritEvidence,
|
||||
CulpritMatchInfo,
|
||||
CulpritMatchItem,
|
||||
CulpritPlayer,
|
||||
CulpritStage,
|
||||
EventItem,
|
||||
GameType,
|
||||
MatchDetail,
|
||||
MatchPlayer,
|
||||
UtteranceItem,
|
||||
} from '@gvr/shared';
|
||||
import { api } from '../lib/api';
|
||||
import { useData, useLive, useStatus } from '../store/app';
|
||||
import { player } from '../store/player';
|
||||
import { fmtDuration, fmtWhen } from '../lib/format';
|
||||
import { CHANNEL_KO } from '../lib/game';
|
||||
import { sfx } from '../lib/sfx';
|
||||
import { CharIcon, ErrorBox, Spinner } from '../components/common';
|
||||
|
||||
/**
|
||||
* 🔍 범인찾기 (계획서 v1.1 2장): 끝난 경기를 고르고 "범인 분석" → AI 가 10명 평가 · 팀별 범인 · 근거.
|
||||
* 근거를 누르면 그 순간의 음성을 듣거나 타임라인으로 간다.
|
||||
*/
|
||||
|
||||
const STAGES: { id: CulpritStage; label: string }[] = [
|
||||
{ id: 'collect', label: '기록 모으기' },
|
||||
{ id: 'thinking', label: 'AI가 읽는 중' },
|
||||
{ id: 'verify', label: '근거 확인' },
|
||||
{ id: 'done', label: '완료' },
|
||||
];
|
||||
const STATE_LABEL: Record<string, string> = { ready: '분석 가능', done: '분석 완료', pending: '준비 중', blocked: '기록 부족' };
|
||||
const TAG_CLASS: Record<string, string> = { 캐리: 'carry', '숨은 MVP': 'mvp', 클러치: 'mvp', 무난: 'plain', 아쉬움: 'meh', 범인: 'bad' };
|
||||
const usd = (n: number) => `$${n.toFixed(2)}`;
|
||||
|
||||
type Progress = { stage: CulpritStage; message?: string };
|
||||
|
||||
export function CulpritPage() {
|
||||
const { id } = useParams();
|
||||
const nav = useNavigate();
|
||||
const { epoch } = useStatus();
|
||||
const [game, setGame] = useState<GameType | 'ready' | null>(null);
|
||||
const [list, setList] = useState<CulpritMatchItem[] | null>(null);
|
||||
const [listErr, setListErr] = useState<unknown>(null);
|
||||
const [budget, setBudget] = useState<CulpritBudget | null>(null);
|
||||
const [info, setInfo] = useState<CulpritMatchInfo | null>(null);
|
||||
const [infoErr, setInfoErr] = useState<unknown>(null);
|
||||
const [progress, setProgress] = useState<Record<string, Progress>>({});
|
||||
const [n, setN] = useState(0);
|
||||
const reload = useCallback(() => setN((x) => x + 1), []);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
setListErr(null);
|
||||
api
|
||||
.culpritMatches({ game: game === 'valorant' || game === 'lol' ? game : undefined, limit: 60 })
|
||||
.then((d) => alive && setList(d))
|
||||
.catch((e) => alive && setListErr(e));
|
||||
api
|
||||
.culpritBudget()
|
||||
.then((b) => {
|
||||
if (!alive) return;
|
||||
setBudget(b);
|
||||
// 다른 사람이 이미 돌리고 있는 분석
|
||||
setProgress((p) => {
|
||||
const next = { ...p };
|
||||
for (const m of b.running) next[m] ??= { stage: 'thinking' };
|
||||
return next;
|
||||
});
|
||||
})
|
||||
.catch(() => undefined);
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [game, epoch, n]);
|
||||
|
||||
const shown = useMemo(() => (list ?? []).filter((x) => game !== 'ready' || x.eligibility.state === 'ready'), [list, game]);
|
||||
const selected = id ?? shown.find((x) => x.eligibility.state === 'ready')?.match.id ?? shown[0]?.match.id ?? null;
|
||||
|
||||
useEffect(() => {
|
||||
if (!selected) return;
|
||||
let alive = true;
|
||||
setInfoErr(null);
|
||||
api
|
||||
.culpritMatch(selected)
|
||||
.then((d) => alive && setInfo(d))
|
||||
.catch((e) => alive && setInfoErr(e));
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [selected, epoch, n]);
|
||||
|
||||
useLive((e) => {
|
||||
if (e.type !== 'culprit.progress') return;
|
||||
const { matchId, stage, message } = e.data;
|
||||
setProgress((p) => ({ ...p, [matchId]: { stage, message } }));
|
||||
if (stage === 'done') {
|
||||
sfx('play');
|
||||
reload();
|
||||
}
|
||||
if (stage === 'failed') reload();
|
||||
});
|
||||
|
||||
const start = async (matchId: string, reanalyze = false) => {
|
||||
setProgress((p) => ({ ...p, [matchId]: { stage: 'collect' } }));
|
||||
const r = await api.culpritAnalyze(matchId, reanalyze);
|
||||
if (!r.ok) setProgress((p) => ({ ...p, [matchId]: { stage: 'failed', message: r.message } }));
|
||||
else setProgress((p) => (p[matchId]?.stage === 'collect' ? { ...p, [matchId]: { stage: 'thinking' } } : p));
|
||||
sfx('click');
|
||||
};
|
||||
|
||||
const cur = info && info.match.id === selected ? info : null;
|
||||
const prog = selected ? progress[selected] : undefined;
|
||||
const busy = !!prog && prog.stage !== 'done' && prog.stage !== 'failed';
|
||||
|
||||
// 결과 화면 (분석이 끝난 경기를 주소로 열었을 때)
|
||||
if (id && cur?.analysis && !busy)
|
||||
return (
|
||||
<ResultView
|
||||
info={cur}
|
||||
budget={budget}
|
||||
onBack={() => nav('/culprit')}
|
||||
onReanalyze={() => {
|
||||
if (window.confirm('이 경기를 다시 분석할까요? 비용이 한 번 더 듭니다. 이전 결과는 기록으로 남습니다.')) void start(cur.match.id, true);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<main className="page-pad culprit">
|
||||
<div className="page-h-row">
|
||||
<h2 className="page-h h">🔍 범인찾기</h2>
|
||||
<div className="chips-wrap">
|
||||
{(
|
||||
[
|
||||
[null, '전체'],
|
||||
['valorant', '발로란트'],
|
||||
['lol', '롤'],
|
||||
['ready', '분석 가능만'],
|
||||
] as const
|
||||
).map(([g, label]) => (
|
||||
<button key={label} className={`chip${g === 'valorant' ? ' val' : g === 'lol' ? ' lol' : ''}${game === g ? ' on' : ''}`} onClick={() => setGame(g)}>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cu-split">
|
||||
<section className="panel cu-list">
|
||||
<h4>
|
||||
<span>끝난 경기 · 범인 분석할 경기를 고르세요</span>
|
||||
</h4>
|
||||
{listErr != null &&
|
||||
((listErr as { status?: number }).status === 404 ? (
|
||||
<div className="empty">게임 PC 앱을 업데이트해 주세요. 범인찾기는 새 버전 앱에서 됩니다.</div>
|
||||
) : (
|
||||
<ErrorBox error={listErr} onRetry={reload} />
|
||||
))}
|
||||
{!list && !listErr && <Spinner />}
|
||||
{list && shown.length === 0 && <div className="empty">{game === 'ready' ? '지금 분석할 수 있는 경기가 없습니다.' : '끝난 경기가 없습니다.'}</div>}
|
||||
{shown.map((x) => (
|
||||
<MatchRow key={x.match.id} x={x} on={x.match.id === selected} running={!!progress[x.match.id] && !['done', 'failed'].includes(progress[x.match.id].stage)} onClick={() => nav(`/culprit/${encodeURIComponent(x.match.id)}`)} />
|
||||
))}
|
||||
</section>
|
||||
<div className="cu-main">
|
||||
{infoErr != null && (infoErr as { status?: number }).status !== 404 && <ErrorBox error={infoErr} onRetry={reload} />}
|
||||
{selected && !cur && !infoErr && <Spinner label="경기 기록 확인 중" />}
|
||||
{cur && <PrepPanel info={cur} budget={budget} progress={prog} onStart={() => void start(cur.match.id)} onOpen={() => nav(`/culprit/${encodeURIComponent(cur.match.id)}`)} />}
|
||||
<RecentVerdicts items={(list ?? []).filter((x) => x.culprits.length)} />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function MatchRow({ x, on, running, onClick }: { x: CulpritMatchItem; on: boolean; running: boolean; onClick: () => void }) {
|
||||
const m = x.match;
|
||||
const st = running ? 'running' : x.eligibility.state;
|
||||
const score = m.score ? (m.game === 'valorant' ? `${m.score.ally} : ${m.score.enemy}` : m.win === null ? '' : m.win ? '승' : '패') : '';
|
||||
return (
|
||||
<button className={`cu-row ${m.game}${on ? ' on' : ''} st-${st}`} onClick={onClick}>
|
||||
<span className={`gtag ${m.game}`}>{m.game === 'valorant' ? 'VAL' : 'LoL'}</span>
|
||||
<span className="cu-row-main">
|
||||
<b>{m.map.name}</b>
|
||||
<small>
|
||||
{m.mode} · {fmtWhen(m.startedAt)}
|
||||
{m.endedAt ? ` · ${fmtDuration(m.endedAt - m.startedAt)}` : ''}
|
||||
{x.eligibility.reasons[0] ? ` · ${x.eligibility.reasons[0]}` : ''}
|
||||
</small>
|
||||
</span>
|
||||
<span className={`cu-score ${m.win === null ? '' : m.win ? 'win' : 'loss'}`}>{score}</span>
|
||||
<span className={`cu-st ${st}`}>{running ? '분석 중' : STATE_LABEL[st]}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function Steps({ progress }: { progress: Progress }) {
|
||||
const at = STAGES.findIndex((s) => s.id === progress.stage);
|
||||
return (
|
||||
<div className="cu-steps" role="status">
|
||||
{STAGES.map((s, i) => (
|
||||
<span key={s.id} className={i < at ? 'did' : i === at ? 'now' : ''}>
|
||||
{i === at && progress.stage !== 'done' ? <i className="cu-spin" /> : i <= at ? '✓' : '·'} {s.label}
|
||||
</span>
|
||||
))}
|
||||
{progress.message && <em>{progress.message}</em>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PrepPanel({ info, budget, progress, onStart, onOpen }: { info: CulpritMatchInfo; budget: CulpritBudget | null; progress?: Progress; onStart: () => void; onOpen: () => void }) {
|
||||
const m = info.match;
|
||||
const e = info.eligibility;
|
||||
const s = info.sources;
|
||||
const busy = !!progress && progress.stage !== 'done' && progress.stage !== 'failed';
|
||||
const left = budget ? budget.monthLimitUsd - budget.monthSpentUsd : 0;
|
||||
const canPress = !!budget && budget.enabled && budget.canAnalyze && e.state === 'ready' && !busy && budget.todayCount < budget.dailyLimit && left >= budget.estimateUsd;
|
||||
const why = !budget
|
||||
? ''
|
||||
: !budget.enabled
|
||||
? '범인찾기가 아직 설정되지 않았습니다'
|
||||
: !budget.canAnalyze
|
||||
? '분석 버튼은 등록된 앱 유저만 누를 수 있습니다 (결과는 모두 볼 수 있어요)'
|
||||
: budget.todayCount >= budget.dailyLimit
|
||||
? `오늘 분석 횟수(${budget.dailyLimit}회)를 다 썼습니다`
|
||||
: left < budget.estimateUsd
|
||||
? '이번 달 분석 예산을 다 썼습니다'
|
||||
: e.state !== 'ready' && e.state !== 'done'
|
||||
? e.reasons.join(' · ')
|
||||
: '';
|
||||
const checks: [boolean, string, string][] = [
|
||||
[e.state !== 'blocked' || !e.reasons.includes('경기 결과를 받지 못했습니다'), `경기 결과 · ${m.game === 'valorant' ? '10명 스탯 · 라운드별 경제' : '10명 스탯 · 골드 차'}`, s.rounds !== null ? `${s.rounds}라운드` : ''],
|
||||
[true, m.game === 'valorant' ? '킬 · 스파이크 · 라운드 결과 이벤트' : '킬 · 오브젝트 이벤트', `${s.events}개`],
|
||||
[e.state !== 'pending' || !e.reasons[0]?.startsWith('음성 변환'), '음성 대화 (텍스트 변환 완료)', `${s.utterances}문장`],
|
||||
[true, '인게임 채팅 (팀 · 전체)', `${s.chats}개`],
|
||||
[!e.reasons.some((r) => r.startsWith('녹음')), '녹음이 경기 시작부터 끝까지 이어짐', ''],
|
||||
];
|
||||
return (
|
||||
<>
|
||||
<section className={`cu-hero ${m.game}`}>
|
||||
<img src={m.map.image ?? undefined} alt="" className="cu-map" />
|
||||
<div>
|
||||
<div className="cu-kicker">
|
||||
{m.game === 'valorant' ? 'VALORANT' : 'LEAGUE OF LEGENDS'} · {m.mode}
|
||||
</div>
|
||||
<div className="cu-title h">
|
||||
{m.map.name} {m.score && m.game === 'valorant' && <span className="mono">{`${m.score.ally} : ${m.score.enemy}`}</span>}
|
||||
{m.win !== null && <span className={`cu-res ${m.win ? 'win' : 'loss'}`}>{m.win ? '승리' : '패배'}</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cu-when">
|
||||
{fmtWhen(m.startedAt)} 시작{m.endedAt ? ` · ${fmtDuration(m.endedAt - m.startedAt)}` : ''}
|
||||
<br />
|
||||
음성 {info.players.filter((p) => p.voice).length}명 녹음
|
||||
</div>
|
||||
</section>
|
||||
<div className="cu-two">
|
||||
<section className="panel">
|
||||
<h4>
|
||||
<span>분석에 쓰는 기록</span>
|
||||
<span className={`cu-st ${e.state}`}>{e.state === 'ready' || e.state === 'done' ? '모두 있음' : STATE_LABEL[e.state]}</span>
|
||||
</h4>
|
||||
{checks.map(([ok, label, val]) => (
|
||||
<div key={label} className={`cu-check${ok ? '' : ' no'}`}>
|
||||
<i>{ok ? '✓' : '✕'}</i>
|
||||
<span>{label}</span>
|
||||
<small>{val}</small>
|
||||
</div>
|
||||
))}
|
||||
{!s.extraStats && <div className="dim small cu-note">이 경기는 피해량 · 시야 같은 추가 지표가 없어 기본 기록으로 분석합니다.</div>}
|
||||
{e.reasons.length > 0 && <div className="cu-reason">{e.reasons.join(' · ')}</div>}
|
||||
<div className="dim small cu-note">음성 파일은 7일 뒤 지워져도 괜찮습니다. 분석은 텍스트로 합니다.</div>
|
||||
</section>
|
||||
<section className="panel">
|
||||
<h4>
|
||||
<span>참가자 {info.players.length}명</span>
|
||||
<span className="ph-right">음성 = 대화 기록 있음</span>
|
||||
</h4>
|
||||
{info.players.map((p) => (
|
||||
<div key={p.id} className="cu-pl">
|
||||
<CharIcon c={p.character} size={26} />
|
||||
<b>{p.name}</b>
|
||||
{p.voice && <span className="cu-voice">음성</span>}
|
||||
<span className="dim small">
|
||||
{p.team === 'ally' ? '우리 팀' : '상대 팀'} · {p.character?.name ?? '?'}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
</div>
|
||||
<section className="panel cu-go">
|
||||
{e.state === 'done' && !busy ? (
|
||||
<button className="cu-btn" onClick={onOpen}>
|
||||
🔍 결과 보기
|
||||
</button>
|
||||
) : (
|
||||
<button className="cu-btn" disabled={!canPress} onClick={onStart}>
|
||||
{busy ? '분석 중…' : '🔍 범인 분석'}
|
||||
</button>
|
||||
)}
|
||||
<div className="cu-go-info">
|
||||
{progress ? (
|
||||
<Steps progress={progress} />
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
예상 비용 <b>약 {usd(budget?.estimateUsd ?? 0.45)}</b> · 1~2분 걸림
|
||||
</div>
|
||||
{budget && (
|
||||
<div className="dim small">
|
||||
이번 달 남은 분석 예산 <b>{usd(Math.max(0, budget.monthLimitUsd - budget.monthSpentUsd))}</b> / {usd(budget.monthLimitUsd)} · 오늘 남은 횟수 <b>{Math.max(0, budget.dailyLimit - budget.todayCount)}회</b>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{why && !progress && <div className="cu-why">{why}</div>}
|
||||
</div>
|
||||
<div className="dim small cu-go-note">
|
||||
한 경기는 한 번만 분석하고
|
||||
<br />
|
||||
결과는 모두가 같이 봅니다
|
||||
</div>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function RecentVerdicts({ items }: { items: CulpritMatchItem[] }) {
|
||||
if (!items.length) return null;
|
||||
return (
|
||||
<section className="panel cu-recent">
|
||||
<h4>
|
||||
<span>최근 범인 판정</span>
|
||||
</h4>
|
||||
{items.slice(0, 6).map((x) => (
|
||||
<Link key={x.match.id} to={`/culprit/${encodeURIComponent(x.match.id)}`} className="cu-recent-row">
|
||||
<span className={`gtag ${x.match.game}`}>{x.match.game === 'valorant' ? 'VAL' : 'LoL'}</span>
|
||||
<span>
|
||||
{x.match.map.name} · {fmtWhen(x.match.startedAt)}
|
||||
{x.match.win !== null ? ` · ${x.match.win ? '승' : '패'}` : ''}
|
||||
</span>
|
||||
<span className="cu-recent-who">
|
||||
{x.culprits.map((c) => (
|
||||
<span key={c.team}>
|
||||
{c.team === 'ally' ? '우리 팀' : '상대 팀'} <b>{c.name}</b>
|
||||
{c.character ? ` (${c.character.name})` : ''}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ 결과
|
||||
function ResultView({ info, budget, onBack, onReanalyze }: { info: CulpritMatchInfo; budget: CulpritBudget | null; onBack: () => void; onReanalyze: () => void }) {
|
||||
const a = info.analysis!;
|
||||
const m = info.match;
|
||||
const [detail, setDetail] = useState<MatchDetail | null>(null);
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
api
|
||||
.match(m.id)
|
||||
.then((d) => alive && setDetail(d))
|
||||
.catch(() => undefined);
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [m.id]);
|
||||
const playerOf = (pid: string) => a.players.find((p) => p.id === pid);
|
||||
const statOf = (p: CulpritPlayer | undefined) => (p && detail ? detail.players.find((x) => x.puuid === p.puuid) : undefined);
|
||||
const scoreOf = (pid: string) => a.result.players.find((p) => p.id === pid);
|
||||
const rounds = detail?.rounds?.length || 1;
|
||||
const kda = (s: MatchPlayer | undefined) => (s ? `${s.kills} / ${s.deaths} / ${s.assists}` : '');
|
||||
const sub = (s: MatchPlayer | undefined) => (!s ? '' : m.game === 'valorant' ? `ACS ${Math.round((s.score ?? 0) / rounds)}` : `CS ${s.cs ?? '?'}`);
|
||||
const teams = (['ally', 'enemy'] as const).filter((t) => a.players.some((p) => p.team === t));
|
||||
return (
|
||||
<main className="page-pad culprit result">
|
||||
<div className="crumbs cu-crumbs">
|
||||
<button className="link" onClick={onBack}>
|
||||
← 범인찾기
|
||||
</button>
|
||||
<Link to={`/matches/${encodeURIComponent(m.id)}`}>경기 기록</Link>
|
||||
<Link to={`/?match=${encodeURIComponent(m.id)}&order=asc`}>타임라인</Link>
|
||||
</div>
|
||||
<section className={`cu-hero ${m.game}`}>
|
||||
<img src={m.map.image ?? undefined} alt="" className="cu-map" />
|
||||
<div>
|
||||
<div className="cu-kicker">범인 분석 · {m.game === 'valorant' ? 'VALORANT' : 'LEAGUE OF LEGENDS'}</div>
|
||||
<div className="cu-title h">
|
||||
{m.map.name} {m.score && <span className="mono">{m.game === 'valorant' ? `${m.score.ally} : ${m.score.enemy}` : `킬 ${m.score.ally} : ${m.score.enemy}`}</span>}
|
||||
{m.win !== null && <span className={`cu-res ${m.win ? 'win' : 'loss'}`}>{m.win ? '승리' : '패배'}</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cu-sum">
|
||||
<small>한 줄 요약</small>
|
||||
{a.result.summary}
|
||||
{a.result.confidence !== 'high' && (
|
||||
<div className={`cu-conf ${a.result.confidence}`}>
|
||||
확신도 {a.result.confidence === 'medium' ? '보통' : '낮음'}
|
||||
{a.result.confidence_note ? ` · ${a.result.confidence_note}` : ''}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="cu-when">
|
||||
분석 {fmtWhen(a.createdAt)} · {a.createdBy.name}
|
||||
<br />
|
||||
{a.meta.inputStats ? `${a.meta.inputStats.utterances}문장 · 이벤트 ${a.meta.inputStats.events}개` : ''}
|
||||
<br />
|
||||
{modelName(a.model)}
|
||||
{a.meta.costUsd !== undefined ? ` · 비용 ${usd(a.meta.costUsd)}` : ''}
|
||||
{a.meta.inputStats?.basic && (
|
||||
<>
|
||||
<br />
|
||||
기본 기록으로 분석
|
||||
</>
|
||||
)}
|
||||
{budget?.canReanalyze && (
|
||||
<>
|
||||
<br />
|
||||
<button className="btn mini" onClick={onReanalyze}>
|
||||
↻ 다시 분석 (관리자)
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
<div className="cu-culprits">
|
||||
{a.result.teams.map((t) => {
|
||||
const p = playerOf(t.culprit);
|
||||
const s = statOf(p);
|
||||
const sc = scoreOf(t.culprit);
|
||||
return (
|
||||
<section key={t.team} className="cu-card">
|
||||
<div className="cu-lab">{t.team === 'ally' ? '우리 팀 범인' : '상대 팀 범인'}</div>
|
||||
<div className="cu-who">
|
||||
<CharIcon c={p?.character} size={60} className="cu-face" />
|
||||
<div>
|
||||
<div className="cu-nm">
|
||||
{p?.name ?? t.culprit}
|
||||
<small>
|
||||
{p?.character?.name}
|
||||
{s ? ` · ${kda(s)} · ${sub(s)}` : ''}
|
||||
</small>
|
||||
</div>
|
||||
<div className="dim small">
|
||||
평점 {sc?.score.toFixed(1)} / 10{p && !p.voice ? ' · 음성 없음, 게임 기록으로 판단' : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cu-stamp">범인</div>
|
||||
</div>
|
||||
<p className="cu-why-text">{t.reason}</p>
|
||||
{t.evidence.map((e) => (
|
||||
<Evidence key={e.ref} e={e} detail={detail} players={a.players} />
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="cu-teams">
|
||||
{teams.map((team) => (
|
||||
<section key={team} className="panel">
|
||||
<h4>
|
||||
<span>
|
||||
{team === 'ally' ? '우리 팀' : '상대 팀'} {a.players.filter((p) => p.team === team).length}명 평가
|
||||
</span>
|
||||
<span className="ph-right">{a.players.filter((p) => p.team === team).some((p) => p.voice) ? '평점 · 한 줄 평' : '음성 없음 · 게임 기록 + 채팅'}</span>
|
||||
</h4>
|
||||
{a.result.players
|
||||
.filter((r) => playerOf(r.id)?.team === team)
|
||||
.sort((x, y) => y.score - x.score)
|
||||
.map((r) => {
|
||||
const p = playerOf(r.id)!;
|
||||
const s = statOf(p);
|
||||
return (
|
||||
<div key={r.id} className={`cu-prow${r.tag === '범인' ? ' bad' : ''}`}>
|
||||
<CharIcon c={p.character} size={30} />
|
||||
<div className="cu-pn">
|
||||
<b>{p.name}</b>
|
||||
<span>
|
||||
{p.character?.name ?? '?'} · 음성 {p.voice ? 'O' : 'X'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="cu-kda">
|
||||
<b>{kda(s)}</b>
|
||||
<br />
|
||||
{sub(s)}
|
||||
</div>
|
||||
<div>
|
||||
<div className="cu-sc">
|
||||
<span className="num">{r.score.toFixed(1)}</span>
|
||||
<span className="bar">
|
||||
<i style={{ width: `${r.score * 10}%` }} />
|
||||
</span>
|
||||
<span className={`cu-tag ${TAG_CLASS[r.tag] ?? 'plain'}`}>{r.tag}</span>
|
||||
</div>
|
||||
<div className="cu-cm">{r.comment}</div>
|
||||
{r.tag !== '범인' && r.evidence.length > 0 && (
|
||||
<div className="cu-mini-ev">
|
||||
{r.evidence.map((e) => (
|
||||
<Evidence key={e.ref} e={e} detail={detail} players={a.players} compact />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
<div className="cu-foot">
|
||||
<span>⚠ 재미로 보는 AI 분석입니다. 음성 인식 오류나 기록에 없는 상황 때문에 틀릴 수 있어요.</span>
|
||||
<span>근거를 누르면 그 순간의 대화를 듣거나 타임라인으로 갑니다</span>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function modelName(id: string): string {
|
||||
const m = /^claude-(opus|sonnet|haiku|fable)-(\d+)(?:-(\d+))?/.exec(id);
|
||||
if (!m) return id;
|
||||
return `Claude ${m[1][0].toUpperCase()}${m[1].slice(1)} ${m[2]}${m[3] ? `.${m[3]}` : ''}`;
|
||||
}
|
||||
|
||||
function Evidence({ e, detail, players, compact = false }: { e: CulpritEvidence; detail: MatchDetail | null; players: CulpritPlayer[]; compact?: boolean }) {
|
||||
const nav = useNavigate();
|
||||
const { userById } = useData();
|
||||
const t = e.target;
|
||||
const pName = (puuid?: string, fallback?: string) => players.find((p) => p.puuid && p.puuid === puuid)?.name ?? fallback ?? '?';
|
||||
let time = '';
|
||||
let kind: { cls: string; label: string } = { cls: 's', label: '스탯' };
|
||||
let body: ReactNode = e.note;
|
||||
let action: { label: string; run: () => void } | null = null;
|
||||
const toTimeline = (ts: number) => nav(`/?match=${encodeURIComponent(detail?.id ?? '')}&from=${Math.max(0, ts - 15000)}&order=asc`);
|
||||
if (t?.kind === 'utterance') {
|
||||
const u = detail?.utterances.find((x) => x.id === t.id) as UtteranceItem | undefined;
|
||||
kind = { cls: 'v', label: '대화' };
|
||||
time = u?.time.primary ?? '';
|
||||
const user = userById(u?.userId);
|
||||
body = (
|
||||
<>
|
||||
<b style={{ color: user?.color }}>{user?.name ?? ''}</b> {u?.text ?? e.note}
|
||||
</>
|
||||
);
|
||||
if (u) action = { label: u.audio ? '▶ 듣기' : '타임라인 →', run: () => (u.audio ? void player.play(u) : toTimeline(u.ts)) };
|
||||
} else if (t?.kind === 'event') {
|
||||
const ev = detail?.events.find((x) => x.id === t.id) as EventItem | undefined;
|
||||
time = ev?.time.primary ?? (t.round ? `R${t.round}` : '');
|
||||
const d = (ev?.data ?? {}) as any;
|
||||
if (ev?.type === 'chat') {
|
||||
kind = { cls: 'c', label: '채팅' };
|
||||
body = (
|
||||
<>
|
||||
<span className="cu-chan">{CHANNEL_KO[d.channel] ?? d.channel}</span> <b>{pName(d.sender?.puuid, d.sender?.name)}</b> {d.text}
|
||||
</>
|
||||
);
|
||||
} else if (ev?.type === 'kill') {
|
||||
kind = { cls: 'k', label: '킬' };
|
||||
body = (
|
||||
<>
|
||||
{pName(d.killer?.puuid, d.killer?.name)} ▶ {pName(d.victim?.puuid, d.victim?.name)} <span className="dim">· {e.note}</span>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
kind = { cls: 'k', label: ev?.type === 'object' ? '오브젝트' : ev?.type === 'spike' ? '스파이크' : '이벤트' };
|
||||
}
|
||||
if (ev) action = { label: '타임라인 →', run: () => toTimeline(ev.ts) };
|
||||
} else if (t?.kind === 'round') {
|
||||
kind = { cls: 's', label: '라운드' };
|
||||
time = `R${t.round}`;
|
||||
action = { label: '라운드 →', run: () => toTimeline(t.ts) };
|
||||
} else if (t?.kind === 'stat') {
|
||||
time = '경기 전체';
|
||||
action = detail ? { label: '스코어보드 →', run: () => nav(`/matches/${encodeURIComponent(detail.id)}`) } : null;
|
||||
}
|
||||
if (compact)
|
||||
return (
|
||||
<button className="cu-evchip" onClick={action?.run} disabled={!action} title={action?.label}>
|
||||
{time && <span className="mono">{time}</span>}
|
||||
{e.note}
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<div className="cu-ev">
|
||||
<span className="t mono">{time}</span>
|
||||
<span className={`ty ${kind.cls}`}>{kind.label}</span>
|
||||
<span className="cu-ev-body">{body}</span>
|
||||
{action && (
|
||||
<button className="pl" onClick={action.run}>
|
||||
{action.label}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -54,6 +54,7 @@ export function MatchPage() {
|
||||
<div className="crumbs">
|
||||
<Link to="/matches">← 경기 목록</Link>
|
||||
<Link to={`/?match=${encodeURIComponent(m.id)}`}>타임라인에서 보기</Link>
|
||||
{m.status === 'complete' && <Link to={`/culprit/${encodeURIComponent(m.id)}`}>🔍 범인 보기</Link>}
|
||||
</div>
|
||||
{m.game === 'lol' ? <LolMatch m={m} /> : <ValorantMatch m={m} />}
|
||||
</>
|
||||
|
||||
@@ -3227,3 +3227,198 @@ button.match:hover {
|
||||
.dict-table .badge.src-user { background: rgba(200, 170, 110, 0.15); color: #c8aa6e; }
|
||||
.dict-table .link { background: none; border: 0; color: #8696a6; cursor: pointer; font-size: 12px; }
|
||||
.dict-table .link:hover { color: #ff4655; }
|
||||
|
||||
/* ── 🔍 범인찾기 ───────────────────────────────────── */
|
||||
.chip.new { position: relative; }
|
||||
.chip.new::after {
|
||||
content: 'NEW';
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
right: -8px;
|
||||
font-size: 9px;
|
||||
font-weight: 800;
|
||||
background: var(--gold);
|
||||
color: #1b1f27;
|
||||
border-radius: 5px;
|
||||
padding: 0 4px;
|
||||
line-height: 14px;
|
||||
}
|
||||
.culprit .panel h4 .cu-st { font-size: 11px; }
|
||||
.cu-split { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 14px; align-items: start; }
|
||||
.cu-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 190px); overflow: auto; }
|
||||
.cu-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
|
||||
.cu-row {
|
||||
display: grid;
|
||||
grid-template-columns: 38px 1fr auto auto;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
text-align: left;
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
background: var(--panel2);
|
||||
border: 1px solid var(--line);
|
||||
border-left: 3px solid #5a6b7b;
|
||||
color: var(--ink);
|
||||
}
|
||||
.cu-row.valorant { border-left-color: var(--accent); }
|
||||
.cu-row.lol { border-left-color: var(--lol); }
|
||||
.cu-row:hover { border-color: #35506a; }
|
||||
.cu-row.on { box-shadow: 0 0 0 2px var(--accent) inset; }
|
||||
.cu-row.st-blocked, .cu-row.st-pending { opacity: 0.6; }
|
||||
.cu-row-main { display: flex; flex-direction: column; min-width: 0; }
|
||||
.cu-row-main b { font-size: 14px; }
|
||||
.cu-row-main small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.gtag { font-size: 10.5px; font-weight: 800; border-radius: 5px; padding: 2px 5px; text-align: center; }
|
||||
.gtag.valorant { background: #3a141a; color: #ff8a94; }
|
||||
.gtag.lol { background: #2a2414; color: var(--lol); }
|
||||
.cu-score { font-family: var(--font-mono); font-weight: 800; font-size: 15px; }
|
||||
.cu-score.win { color: var(--mint); }
|
||||
.cu-score.loss { color: #c8d0d8; }
|
||||
.cu-st { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
|
||||
.cu-st.ready { background: #0f2a22; color: #7fe0b8; border: 1px solid #1d5141; }
|
||||
.cu-st.done { background: #2a2410; color: var(--gold); border: 1px solid #5a4a1d; }
|
||||
.cu-st.blocked { background: #2a1418; color: #ff8a94; border: 1px solid #5a2029; }
|
||||
.cu-st.pending, .cu-st.running { background: #182634; color: #9fb0c0; border: 1px solid var(--line); }
|
||||
.cu-st.running { color: #7fe9e1; }
|
||||
.cu-hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18px;
|
||||
background: linear-gradient(100deg, #13222f, #1a1420);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
padding: 14px 20px;
|
||||
}
|
||||
.cu-hero.lol { background: linear-gradient(100deg, #10202a, #1c1a12); }
|
||||
.cu-map { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: #16293a; flex: none; }
|
||||
.cu-kicker { font-size: 11px; color: var(--accent); font-weight: 800; letter-spacing: 2px; }
|
||||
.cu-hero.lol .cu-kicker { color: var(--lol); }
|
||||
.cu-title { font-size: 26px; font-weight: 800; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||
.cu-title .mono { color: #c8d0d8; }
|
||||
.cu-res { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
|
||||
.cu-res.win { background: #0f2a22; color: #7fe0b8; }
|
||||
.cu-res.loss { background: #2a1418; color: #ff8a94; }
|
||||
.cu-when { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; line-height: 1.7; flex: none; }
|
||||
.cu-sum { flex: 1; font-size: 15px; line-height: 1.6; padding-left: 18px; border-left: 1px solid var(--line); min-width: 0; }
|
||||
.cu-sum small { display: block; color: var(--muted); font-size: 12px; }
|
||||
.cu-conf { margin-top: 6px; font-size: 12px; color: var(--gold); }
|
||||
.cu-conf.low { color: #ff9aa3; }
|
||||
.cu-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
||||
.cu-check { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid #1c2b39; font-size: 13.5px; }
|
||||
.cu-check i { font-style: normal; color: var(--good); font-weight: 800; width: 14px; }
|
||||
.cu-check.no i { color: var(--accent); }
|
||||
.cu-check small { margin-left: auto; color: var(--muted); font-size: 12px; }
|
||||
.cu-note { margin-top: 8px; }
|
||||
.cu-reason { margin-top: 8px; color: #ff9aa3; font-size: 13px; }
|
||||
.cu-pl { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 13.5px; }
|
||||
.cu-pl .dim { margin-left: auto; }
|
||||
.cu-voice { font-size: 10.5px; font-weight: 700; color: #7fe0b8; background: #0f2a22; border: 1px solid #1d5141; border-radius: 5px; padding: 0 5px; }
|
||||
.cu-go { display: flex; align-items: center; gap: 22px; }
|
||||
.cu-btn {
|
||||
padding: 14px 26px;
|
||||
border-radius: 10px;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: #fff;
|
||||
background: linear-gradient(180deg, #ff5a68, #e23a4a);
|
||||
border: none;
|
||||
box-shadow: 0 6px 24px rgba(255, 70, 85, 0.35);
|
||||
flex: none;
|
||||
}
|
||||
.cu-btn:hover:not(:disabled) { filter: brightness(1.08); }
|
||||
.cu-btn:disabled { background: #3a4654; box-shadow: none; color: #9fb0c0; cursor: not-allowed; }
|
||||
.cu-go-info { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; min-width: 0; }
|
||||
.cu-why { color: #ff9aa3; font-size: 12.5px; }
|
||||
.cu-go-note { text-align: right; line-height: 1.5; flex: none; }
|
||||
.cu-steps { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 13px; color: var(--dim); }
|
||||
.cu-steps .did { color: var(--good); }
|
||||
.cu-steps .now { color: #fff; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
|
||||
.cu-steps em { font-style: normal; color: #ff9aa3; flex-basis: 100%; }
|
||||
.cu-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #35506a; border-top-color: var(--mint); animation: cu-spin 0.9s linear infinite; display: inline-block; }
|
||||
@keyframes cu-spin { to { transform: rotate(360deg); } }
|
||||
.cu-recent-row { display: grid; grid-template-columns: 38px auto 1fr; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid #1c2b39; font-size: 13px; }
|
||||
.cu-recent-row:hover { background: var(--panel2); }
|
||||
.cu-recent-who { text-align: right; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; color: var(--muted); }
|
||||
.cu-recent-who b { color: #ff8a94; }
|
||||
.culprit.result { display: flex; flex-direction: column; gap: 14px; }
|
||||
.cu-crumbs { padding: 0; }
|
||||
.link { background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
|
||||
.link:hover { color: #fff; }
|
||||
.btn.mini { padding: 4px 10px; font-size: 12px; margin-top: 4px; }
|
||||
.cu-culprits { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
||||
.cu-card {
|
||||
border-radius: 14px;
|
||||
padding: 16px 18px;
|
||||
background: linear-gradient(160deg, #2a1219, #141e29 55%);
|
||||
border: 1px solid #6a2430;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
}
|
||||
.cu-card::before { content: ''; position: absolute; right: -30px; top: -30px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(rgba(255, 70, 85, 0.25), transparent 70%); pointer-events: none; }
|
||||
.cu-lab { font-size: 12px; letter-spacing: 2px; color: var(--accent); font-weight: 800; }
|
||||
.cu-who { display: flex; align-items: center; gap: 14px; margin: 8px 0 10px; }
|
||||
.cu-face { border-radius: 12px; border: 2px solid var(--accent); }
|
||||
.cu-nm { font-size: 24px; font-weight: 800; }
|
||||
.cu-nm small { font-size: 13.5px; color: var(--muted); font-weight: 500; margin-left: 6px; }
|
||||
.cu-stamp { margin-left: auto; transform: rotate(-8deg); border: 3px solid var(--accent); color: var(--accent); font-weight: 900; font-size: 20px; padding: 4px 12px; border-radius: 8px; letter-spacing: 3px; flex: none; }
|
||||
.cu-why-text { font-size: 14.5px; line-height: 1.65; margin-bottom: 10px; }
|
||||
.cu-ev { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; background: rgba(11, 20, 28, 0.55); margin-bottom: 5px; font-size: 13.5px; }
|
||||
.cu-ev .t { color: var(--mint); font-size: 12px; width: 70px; flex: none; }
|
||||
.cu-ev .ty { font-size: 11px; padding: 1px 6px; border-radius: 5px; flex: none; }
|
||||
.cu-ev .ty.v { background: #1d2f45; color: #8cc4ff; }
|
||||
.cu-ev .ty.k { background: #3a141a; color: #ff8a94; }
|
||||
.cu-ev .ty.s { background: #2a2410; color: var(--gold); }
|
||||
.cu-ev .ty.c { background: #1b2e2a; color: #7fe0b8; }
|
||||
.cu-ev-body { min-width: 0; flex: 1; }
|
||||
.cu-ev .pl { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; background: none; border: none; cursor: pointer; }
|
||||
.cu-ev .pl:hover { color: #fff; }
|
||||
.cu-mini-ev { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
|
||||
.cu-evchip { display: inline-flex; gap: 6px; align-items: baseline; max-width: 100%; text-align: left; font-size: 11.5px; color: #9fb0c0; background: rgba(11, 20, 28, 0.55); border: 1px solid #1c2b39; border-radius: 6px; padding: 2px 7px; cursor: pointer; }
|
||||
.cu-evchip:hover:not(:disabled) { color: #fff; border-color: #35506a; }
|
||||
.cu-evchip .mono { color: var(--mint); flex: none; }
|
||||
.cu-chan { font-size: 10.5px; color: #9fb0c0; background: #182634; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
|
||||
.cu-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
||||
.cu-prow { display: grid; grid-template-columns: 34px 140px 92px 1fr; gap: 10px; align-items: start; padding: 10px 6px; border-bottom: 1px solid #1c2b39; }
|
||||
.cu-prow > .ag { margin-top: 2px; }
|
||||
.cu-prow:last-child { border-bottom: none; }
|
||||
.cu-prow.bad { background: rgba(255, 70, 85, 0.08); border-radius: 8px; }
|
||||
.cu-pn b { font-size: 14.5px; display: block; }
|
||||
.cu-pn span { font-size: 12px; color: var(--muted); }
|
||||
.cu-kda { font-size: 12px; color: var(--muted); line-height: 1.5; }
|
||||
.cu-kda b { color: var(--ink); font-size: 13px; }
|
||||
.cu-sc { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
|
||||
.cu-sc .num { font-weight: 800; font-size: 14px; width: 30px; }
|
||||
.cu-sc .bar { width: 110px; height: 7px; border-radius: 4px; background: #22303e; overflow: hidden; }
|
||||
.cu-sc .bar i { display: block; height: 100%; border-radius: 4px; background: var(--mint); }
|
||||
.cu-prow.bad .cu-sc .bar i { background: var(--accent); }
|
||||
.cu-tag { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
|
||||
.cu-tag.carry { background: #2a2410; color: var(--gold); border: 1px solid #5a4a1d; }
|
||||
.cu-tag.mvp { background: #0f2a22; color: #7fe0b8; border: 1px solid #1d5141; }
|
||||
.cu-tag.plain { background: #182634; color: #9fb0c0; border: 1px solid var(--line); }
|
||||
.cu-tag.meh { background: #22202a; color: #c3b3e0; border: 1px solid #3a3450; }
|
||||
.cu-tag.bad { background: #2a1418; color: #ff8a94; border: 1px solid #5a2029; }
|
||||
.cu-cm { font-size: 13px; line-height: 1.5; color: #c9d3dc; }
|
||||
.cu-foot { font-size: 12px; color: var(--dim); display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
|
||||
@media (max-width: 1200px) {
|
||||
.cu-split { grid-template-columns: 1fr; }
|
||||
.cu-list { max-height: 360px; }
|
||||
}
|
||||
@media (max-width: 980px) {
|
||||
.cu-two, .cu-culprits, .cu-teams { grid-template-columns: 1fr; }
|
||||
.cu-hero { flex-wrap: wrap; }
|
||||
.cu-sum { flex-basis: 100%; border-left: none; padding-left: 0; order: 3; }
|
||||
.cu-when { margin-left: 0; text-align: left; }
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.cu-go { flex-direction: column; align-items: stretch; }
|
||||
.cu-go-note { text-align: left; }
|
||||
.cu-prow { grid-template-columns: 30px 1fr; }
|
||||
.cu-prow .cu-kda { display: none; }
|
||||
.cu-prow > div:last-child { grid-column: 1 / -1; }
|
||||
.cu-nm { font-size: 20px; }
|
||||
.cu-stamp { font-size: 15px; padding: 3px 8px; }
|
||||
.cu-ev .t { width: auto; }
|
||||
.cu-row { grid-template-columns: 34px 1fr auto; }
|
||||
.cu-row .cu-st { grid-column: 2 / -1; justify-self: start; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user