From a5a1c8406a5a2c92bbfbc53179cd89c5525839ff Mon Sep 17 00:00:00 2001 From: EJClaw Date: Sun, 8 Nov 2026 22:54:41 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EC=8B=9C=EC=A0=90=20?= =?UTF-8?q?=C2=B7=20=EC=A0=90=EC=88=98=ED=8C=90=20=EB=B3=B4=EC=99=84:=20?= =?UTF-8?q?=EA=B6=81=EA=B7=B9=EA=B8=B0=20=EC=A0=90=EC=88=98=EB=8A=94=20?= =?UTF-8?q?=EA=B3=B5=EC=88=98=20=EA=B5=90=EB=8C=80(=EC=84=A0=EC=88=98=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=91=20=EC=9E=90=EB=A6=AC=EA=B0=80=2040m=20?= =?UTF-8?q?=EB=84=98=EA=B2=8C=20=EC=98=AE=EA=B2=A8=20=EA=B0=84=20=EB=9D=BC?= =?UTF-8?q?=EC=9A=B4=EB=93=9C)=20=EC=B4=88=EA=B8=B0=ED=99=94=EB=A5=BC=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EB=B3=B4=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=9D=8C=20(=ED=95=9C=20=EB=AA=85=EB=A7=8C=20?= =?UTF-8?q?=EC=A0=90=EC=88=98=EA=B0=80=20=EC=9E=88=EC=96=B4=EB=8F=84)=20?= =?UTF-8?q?=C2=B7=20=EC=A0=84=EB=9E=B5=20=EB=B3=B4=EA=B8=B0=20=EC=B9=B4?= =?UTF-8?q?=EB=A9=94=EB=9D=BC=20=EA=B1=B0=EB=A6=AC=EB=A5=BC=20=EC=8B=9C?= =?UTF-8?q?=EC=95=BC=EA=B0=81=20=C2=B7=20=ED=99=94=EB=A9=B4=EB=B9=84=20?= =?UTF-8?q?=C2=B7=20=EA=B8=B0=EC=9A=B8=EA=B8=B0=EB=A1=9C=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=ED=95=B4=20=EB=AA=A8=EB=93=A0=20=EC=84=A0=EC=88=98?= =?UTF-8?q?=EA=B0=80=20=ED=99=94=EB=A9=B4=20=EC=95=88=20(fitDistance)=20?= =?UTF-8?q?=C2=B7=20=EB=9D=BC=EC=9A=B4=EB=93=9C=EA=B0=80=20=EB=81=9D?= =?UTF-8?q?=EB=82=9C=20=EB=92=A4=20=EC=A0=90=EC=88=98=ED=8C=90=20=ED=8C=80?= =?UTF-8?q?=20=EC=A0=90=EC=88=98=EB=8A=94=20=EA=B7=B8=20=EB=9D=BC=EC=9A=B4?= =?UTF-8?q?=EB=93=9C=EA=B9=8C=EC=A7=80=20(=EC=B5=9C=EC=A2=85=20=EC=A0=90?= =?UTF-8?q?=EC=88=98)=20=C2=B7=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- docs/dev/replay-3d.md | 6 +-- site/server/test/replay-director.test.ts | 58 ++++++++++++++++++++++-- site/web/src/components/ReplayViewer.tsx | 20 ++++++-- site/web/src/lib/director.ts | 29 ++++++++++++ site/web/src/lib/scoreboard.ts | 36 ++++++++++++--- 5 files changed, 133 insertions(+), 16 deletions(-) diff --git a/docs/dev/replay-3d.md b/docs/dev/replay-3d.md index 1d20c7a..ab14518 100644 --- a/docs/dev/replay-3d.md +++ b/docs/dev/replay-3d.md @@ -110,10 +110,10 @@ ## 자동 시점 · Tab 점수판 (2026-11-08) - 변환기: `scoreboard` 행 `[t, 선수, 크레딧, 궁 점수, 킬, 데스, 어시, 전투 점수]` (바뀔 때마다 그 선수 전체 값, 모르는 값 -1). 크레딧은 `MoneyManagementComponent.Money`, 궁은 `BombPlayerState.NumUltimatePoints` (파서 기본 목록), 킬/데스/어시 · 전투 점수는 PlayerState 하위 객체 `BasicCombatStatsComponent` · `PlayerScoreComponent` 를 이름으로 목록에 더해 읽는다 (`Collector.Catalog`, 하위 객체 이름 → 클래스 `AddSubobjectClassPath` 가 없으면 그룹이 비어 온다). 게임은 기본값(0)과 다를 때만 보내므로 사이트는 안 온 숫자를 0 으로 본다. - 13.08 어비스: 행 1706개, 변환 6.8초(+0.2초). 체력 · 방어구(`ChildDamageSectionComponent`)는 리플레이에 값이 오지 않는다. - - 궁극기 점수는 리플레이에 없다: 사이트가 궁을 쓴 순간(0 으로 떨어지기 직전 값, 절반 넘는 선수가 3초 안에 같이 0 이 되는 공수 교대 초기화는 뺌)으로 정하고, 쓴 적이 없으면 요원 표(`lib/scoreboard.ts` ULT_COST)와 모은 최대값 중 큰 것. 13.08 실측 피닉스 7 · 나머지 8. -- 사이트 `lib/scoreboard.ts` · `components/ReplayScoreboard.tsx`: 재생기 위에 마우스가 있거나 재생기 안을 누른 뒤 Tab 을 누르고 있는 동안 (버튼으로 켜고 끌 수도). 팀 점수(그 라운드 전까지) · 궁극기 점 · K/D/A · 이 라운드 주무기 · 크레딧, 전투 점수 순, 죽은 선수 흐리게. 옛 JSON 은 킬 · 데스만 킬 기록으로. + - 궁극기 점수는 리플레이에 없다: 사이트가 궁을 쓴 순간(0 으로 떨어지기 직전 값)으로 정하고 (공수 교대 초기화는 뺀다: 교대 라운드 = 선수 시작 자리 중앙값이 40m 넘게 옮겨 간 라운드(13.08 실측 교대 93~109m · 평소 13m 이하), 그 앞 라운드 끝 ~ 교대 라운드 구매 3초 뒤에 0 이 된 것), 쓴 적이 없으면 요원 표(`lib/scoreboard.ts` ULT_COST)와 모은 최대값 중 큰 것. 13.08 실측 피닉스 7 · 나머지 8. +- 사이트 `lib/scoreboard.ts` · `components/ReplayScoreboard.tsx`: 재생기 위에 마우스가 있거나 재생기 안을 누른 뒤 Tab 을 누르고 있는 동안 (버튼으로 켜고 끌 수도). 팀 점수(그 라운드 전까지, 라운드가 끝난 뒤면 그 라운드까지) · 궁극기 점 · K/D/A · 이 라운드 주무기 · 크레딧, 전투 점수 순, 죽은 선수 흐리게. 옛 JSON 은 킬 · 데스만 킬 기록으로. - 자동 시점 `lib/director.ts` (카메라 "자동"): 시각만으로 장면을 정한다 (되감기 · 배속에도 같음). - 교전: 킬마다 죽인 선수 1인칭. 교전 시작(둘 사이 첫 맞은 기록 · 죽인 선수의 이어진 사격, 8초 안) 2.5초 전부터. 우리 팀이 낀 교전이면 교전 시작 6초 안에 시작한 대화(콜)부터 보여 주고 화면에 콜 글. 같은 선수가 이어 죽이면 한 장면, 다음 킬은 앞 킬 0.5초 뒤에 넘어가고 넘어간 뒤 0.7초 안에 킬이면 넘어가지 않는다 (맞킬). - - 빈 곳: 스파이크 설치 · 해체 > 킬 없는 교전(가장 많이 맞힌 산 선수) > 혼자 남은 선수(1 대 N) > 위에서 (구매 · 전략 보기 · 라운드 끝). 위에서는 살아 있는 선수가 모두 들어오게 부드럽게 따라간다. 2초보다 짧은 위에서 보기 · 0.9초보다 짧은 1인칭은 앞 장면에 붙인다. + - 빈 곳: 스파이크 설치 · 해체 > 킬 없는 교전(가장 많이 맞힌 산 선수) > 혼자 남은 선수(1 대 N) > 위에서 (구매 · 전략 보기 · 라운드 끝). 위에서는 살아 있는 선수가 모두 들어오게 부드럽게 따라간다 (거리 = 시야각 · 화면비 · 기울기로 가장 바깥 선수가 화면 85% 에 닿는 값, `fitDistance`). 2초보다 짧은 위에서 보기 · 0.9초보다 짧은 1인칭은 앞 장면에 붙인다. - 13.08 어비스: 장면 265개 · 계산 15ms, 상대 팀끼리 킬 145개 중 126개를 죽인 선수 1인칭으로 (나머지는 1초 안 맞킬). - 시험: `site/server/test/replay-director.test.ts`, 변환기 `gvr-replay --self-test` (점수판 줄 합치기). diff --git a/site/server/test/replay-director.test.ts b/site/server/test/replay-director.test.ts index 65b2e95..fea1b67 100644 --- a/site/server/test/replay-director.test.ts +++ b/site/server/test/replay-director.test.ts @@ -3,12 +3,14 @@ import { test } from 'node:test'; import assert from 'node:assert/strict'; import type { ReplayFile } from '../../web/src/lib/replay.ts'; import { buildDirector, shotIndexAt, FIGHT_LEAD, type Shot } from '../../web/src/lib/director.ts'; -import { boardAt, boardIndex, loadoutAt, teamScoreAt } from '../../web/src/lib/scoreboard.ts'; +import { boardAt, boardIndex, loadoutAt, sideSwaps, teamScoreAt } from '../../web/src/lib/scoreboard.ts'; +import { fitDistance } from '../../web/src/lib/director.ts'; +import * as THREE from '../../web/node_modules/three/build/three.module.js'; -// 선수 0·1·4 아군, 2·3·5 상대. 라운드 1: 구매 0~30초, 교전 30초~, 끝 90초. 라운드 2: 100초~ -const still = (n = 2000) => { +// 선수 0·1·4 아군, 2·3·5 상대. 라운드 1: 구매 0~30초, 교전 30초~, 끝 90초. 라운드 2: 100초~ (공수 교대: 시작 자리가 100m 옮겨 감) +const still = (n = 2000, swapAt = 100_000) => { const t = Array.from({ length: n }, (_, i) => i * 100); - return { t, x: t.map(() => 0), y: t.map(() => 0), z: t.map(() => 100), yaw: t.map(() => 0), pitch: t.map(() => 0) }; + return { t, x: t.map((v) => (v >= swapAt ? 10_000 : 0)), y: t.map(() => 0), z: t.map(() => 100), yaw: t.map(() => 0), pitch: t.map(() => 0) }; }; function replay(extra: Partial = {}): ReplayFile { return { @@ -130,3 +132,51 @@ test('점수판: 예전 리플레이(값 없음)는 킬 · 데스를 킬 기록 assert.deepEqual(teamScoreAt(r, rounds, 50_000), { round: 1, ally: 0, enemy: 0 }); assert.deepEqual(teamScoreAt(r, rounds, 150_000), { round: 2, ally: 1, enemy: 0 }); }); + +test('점수판: 한 명만 궁 점수가 있어도 공수 교대 초기화는 궁 사용이 아니다 · 교대가 없으면 라운드 끝 0 은 사용', () => { + // 선수 1(피닉스)만 3점을 모은 채 1라운드가 끝나고(90초) 2라운드 구매 시작(100초) 직전에 0 + const sb = [[20_000, 1, 800, 3, -1, -1, -1, -1], [99_000, 1, 800, 0, -1, -1, -1, -1]]; + const r = replay({ scoreboard: sb }); + assert.deepEqual([...sideSwaps(r)], [1]); + const ix = boardIndex(r); + assert.equal(ix.ultMax[1], 7); // 요원 표 (피닉스 7), 3 이 아니다 + assert.equal(boardAt(r, ix, 1, 50_000).ult, 3); + // 같은 기록이라도 교대가 아니면(시작 자리 그대로) 쓴 것으로 본다 + const same = replay({ scoreboard: sb, players: [0, 1, 2, 3, 4, 5].map((i) => ({ puuid: `p${i}`, character: 'Phoenix_PC_C', track: still(2000, Infinity) })) }); + assert.deepEqual([...sideSwaps(same)], []); + assert.equal(boardIndex(same).ultMax[1], 3); +}); + +test('점수판: 마지막 라운드가 끝난 뒤에는 최종 점수', () => { + const r = replay({ rounds: [{ num: 1, buy: 0, combat: 30_000, end: 90_000 }, { num: 2, buy: 100_000, combat: 130_000, end: 180_000 }] }); + const rounds = [{ num: 1, score: { ally: 1, enemy: 0 } }, { num: 2, score: { ally: 2, enemy: 0 } }]; + assert.deepEqual(teamScoreAt(r, rounds, 170_000), { round: 2, ally: 1, enemy: 0 }); + assert.deepEqual(teamScoreAt(r, rounds, 190_000), { round: 2, ally: 2, enemy: 0 }); + // 1라운드 끝 ~ 2라운드 구매 사이도 그 라운드 결과까지 + assert.deepEqual(teamScoreAt(r, rounds, 95_000), { round: 1, ally: 1, enemy: 0 }); +}); + +test('전략 보기 카메라: 시야각 · 화면비 · 기울기를 넣어 구한 거리면 모든 선수가 화면 안 (three.js 투영으로 확인)', () => { + const dir: [number, number, number] = [0, 0.92 / Math.hypot(0.92, 0.42), 0.42 / Math.hypot(0.92, 0.42)]; + const cases: { pts: [number, number, number][]; aspect: number }[] = [ + { pts: [[-35, 0, -40], [35, 0, 40]], aspect: 1 }, + { pts: [[-45, 2, 10], [40, 8, -45], [0, 0, 48]], aspect: 16 / 9 }, + { pts: [[-10, 0, -45], [10, 0, 45]], aspect: 0.6 }, + ]; + for (const { pts, aspect } of cases) { + const c = pts.reduce((a, p) => [a[0] + p[0] / pts.length, a[1] + p[1] / pts.length, a[2] + p[2] / pts.length], [0, 0, 0]) as [number, number, number]; + const d = fitDistance(pts, c, dir, 45, aspect); + const cam = new THREE.PerspectiveCamera(45, aspect, 0.5, 2000); + cam.position.set(c[0] + dir[0] * d, c[1] + dir[1] * d, c[2] + dir[2] * d); + cam.lookAt(c[0], c[1], c[2]); + cam.updateMatrixWorld(); + let edge = 0; + for (const p of pts) { + const v = new THREE.Vector3(...p).project(cam); + assert.ok(Math.abs(v.x) <= 0.86 && Math.abs(v.y) <= 0.86, `화면 밖 ${p} → ${v.x.toFixed(3)},${v.y.toFixed(3)} (화면비 ${aspect})`); + edge = Math.max(edge, Math.abs(v.x), Math.abs(v.y)); + } + // 가장 짧은 거리: 가장 바깥 선수가 가장자리(0.85)에 닿는다 + assert.ok(edge > 0.84, `너무 멀다 ${edge}`); + } +}); diff --git a/site/web/src/components/ReplayViewer.tsx b/site/web/src/components/ReplayViewer.tsx index 00cfcff..e2b1420 100644 --- a/site/web/src/components/ReplayViewer.tsx +++ b/site/web/src/components/ReplayViewer.tsx @@ -15,7 +15,7 @@ import CrosshairPanel from './CrosshairPanel'; import { buildAnimIndex, rigInput } from '../lib/replayAnim'; import { abilityLook, type AbilityLook } from '../lib/abilities'; import { loadVfxDb, vfxCoverage, VfxObject, type Place, type VfxDb } from '../lib/vfx'; -import { buildDirector, shotIndexAt, SHOT_LABEL } from '../lib/director'; +import { buildDirector, fitDistance, shotIndexAt, SHOT_LABEL } from '../lib/director'; import { boardIndex } from '../lib/scoreboard'; import ReplayScoreboard from './ReplayScoreboard'; @@ -50,6 +50,11 @@ type View = Exclude; const CAM_LABEL: Record = { auto: '자동', top: '위에서', fp: '1인칭', free: '자유시점' }; /** 자동 · 위에서 볼 때 카메라가 따라가는 빠르기 (1초에 남은 거리의 이만큼) */ const AUTO_EASE = 2.2; +/** 자동 · 위에서: 보는 곳에서 카메라 쪽 방향 (위로 많이 · 앞으로 조금, 단위 벡터) */ +const AUTO_DIR: [number, number, number] = (() => { + const l = Math.hypot(0.92, 0.42); + return [0, 0.92 / l, 0.42 / l]; +})(); type MapState = { state: 'none' | 'loading' | 'ready' | 'error'; progress?: number }; /** 천장 자르기: 자동 · 끔 · 직접(가장 낮은 층에서 cm) */ @@ -1044,6 +1049,7 @@ export default function ReplayViewer({ m, replay, sync }: Props) { } else if (auto) { // 전략 보기: 살아 있는 선수(없으면 모두)가 다 들어오게 내려다본다 let n = 0; + let aliveN = 0; let x0 = Infinity, x1 = -Infinity, z0 = Infinity, z1 = -Infinity, ySum = 0; for (const pass of [0, 1]) { for (const v of views) { @@ -1053,15 +1059,23 @@ export default function ReplayViewer({ m, replay, sync }: Props) { ySum += q.y; n++; } + if (pass === 0) aliveN = n; if (n) break; } if (n) { autoGoal.set((x0 + x1) / 2, ySum / n, (z0 + z1) / 2); - autoDist = Math.max(36, Math.min(125, Math.max(x1 - x0, (z1 - z0) * camera.aspect * 0.8) * 0.95 + 26)); + // 시야각 · 화면비 · 기울기로 모두가 들어오는 거리 (선수 몸 · 이름표 높이만큼 위아래로 넉넉히) + const pts: [number, number, number][] = []; + for (const v of views) { + if (!v.group.visible || (aliveN > 0 && isDead(replay, v.idx, t))) continue; + const q = v.group.position; + pts.push([q.x, q.y, q.z], [q.x, q.y + 6, q.z]); + } + autoDist = Math.max(36, Math.min(400, fitDistance(pts, [autoGoal.x, autoGoal.y, autoGoal.z], AUTO_DIR, camera.fov, camera.aspect))); } const k = 1 - Math.exp(-dt * AUTO_EASE); autoTarget.lerp(autoGoal, k); - tmp.set(autoTarget.x, autoTarget.y + autoDist * 0.92, autoTarget.z + autoDist * 0.42); + tmp.set(autoTarget.x + AUTO_DIR[0] * autoDist, autoTarget.y + AUTO_DIR[1] * autoDist, autoTarget.z + AUTO_DIR[2] * autoDist); camera.position.lerp(tmp, k); camera.lookAt(autoTarget); } else controls.update(); diff --git a/site/web/src/lib/director.ts b/site/web/src/lib/director.ts index 2d0f045..ade6518 100644 --- a/site/web/src/lib/director.ts +++ b/site/web/src/lib/director.ts @@ -270,3 +270,32 @@ export const SHOT_LABEL: Record = { overview: '전략 보기', post: '라운드 끝', }; + +type V3 = [number, number, number]; +const dot = (a: V3, b: V3) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +const cross = (a: V3, b: V3): V3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]; +const unit = (a: V3): V3 => { + const l = Math.hypot(...a) || 1; + return [a[0] / l, a[1] / l, a[2] / l]; +}; + +/** + * 전략 보기 카메라 거리: 카메라를 target + dir × 거리 에 두고 target 을 볼 때 모든 점이 화면(가장자리 margin 남김) 안에 들어오는 가장 짧은 거리. + * 카메라 공간에서 점의 깊이 = dot(q, f) + 거리 (f = -dir), 가로 · 세로 = dot(q, 오른쪽) · dot(q, 위). |가로| ≤ tan(가로 시야/2) × 깊이 를 거리로 푼다. + * dir 은 위쪽(y) 성분이 있어야 한다 (내려다보기) + */ +export function fitDistance(points: V3[], target: V3, dir: V3, fovDeg: number, aspect: number, margin = 0.85): number { + const d = unit(dir); + const f: V3 = [-d[0], -d[1], -d[2]]; + const right = unit(cross(f, [0, 1, 0])); + const up = cross(right, f); + const tv = Math.tan(((fovDeg / 2) * Math.PI) / 180) * margin; + const th = tv * aspect; + let need = 0; + for (const p of points) { + const q: V3 = [p[0] - target[0], p[1] - target[1], p[2] - target[2]]; + const z = dot(q, f); + need = Math.max(need, Math.abs(dot(q, right)) / th - z, Math.abs(dot(q, up)) / tv - z); + } + return need; +} diff --git a/site/web/src/lib/scoreboard.ts b/site/web/src/lib/scoreboard.ts index dc94ff5..8ca5fe6 100644 --- a/site/web/src/lib/scoreboard.ts +++ b/site/web/src/lib/scoreboard.ts @@ -1,4 +1,4 @@ -import { indexAt, isDead, roundAt, type ReplayFile } from './replay'; +import { indexAt, isDead, roundAt, samplePlayer, type ReplayFile } from './replay'; /** * 리플레이 점수판 (게임에서 Tab 을 누른 화면): 크레딧 · 궁극기 점수 · 킬/데스/어시 · 전투 점수. @@ -40,8 +40,27 @@ export function boardIndex(r: ReplayFile): BoardIndex { return { rows, times, ultMax: ultCosts(r, rows), has: rows.some((a) => a.length > 0) }; } +/** 공수 교대로 시작한 라운드 번호 (rounds 의 순번): 선수들 시작 자리가 크게 바뀐 라운드 (같은 편이면 13m 안, 교대하면 90m 넘게, 13.08 어비스 실측) */ +const SWAP_CM = 4000; +export function sideSwaps(r: ReplayFile): Set { + const out = new Set(); + const spawn = (p: number, k: number) => samplePlayer(r.players[p].track, r.rounds[k].buy + 1500, r.sampleMs * 30); + for (let k = 1; k < r.rounds.length; k++) { + const d: number[] = []; + for (let p = 0; p < r.players.length; p++) { + const a = spawn(p, k - 1); + const b = spawn(p, k); + if (a && b) d.push(Math.hypot(a.x - b.x, a.y - b.y)); + } + d.sort((x, y) => x - y); + if (d.length && d[Math.floor(d.length / 2)] > SWAP_CM) out.add(k); + } + return out; +} + /** - * 궁극기 점수: 궁을 쓴 순간(점수가 0 으로 떨어짐) 바로 앞 점수. 모두가 같은 때 0 이 되는 것(공수 교대 초기화)은 쓴 것이 아니다. + * 궁극기 점수: 궁을 쓴 순간(점수가 0 으로 떨어짐) 바로 앞 점수. + * 공수 교대 초기화(교대 직전 라운드가 끝난 뒤 ~ 교대 라운드 구매 시작 3초 뒤 사이에 0 이 된 것)는 쓴 것이 아니다. 한 명만 점수가 있어도 같다. * 쓴 기록이 없으면 요원 표 값과 경기에서 모은 가장 큰 점수 중 큰 것 */ export function ultCosts(r: ReplayFile, rows: number[][][]): number[] { @@ -57,10 +76,13 @@ export function ultCosts(r: ReplayFile, rows: number[][][]): number[] { last = v; } }); + const resets = [...sideSwaps(r)].map((k) => { + const prev = r.rounds[k - 1]; + return [prev.end >= 0 ? prev.end : prev.combat >= 0 ? prev.combat : prev.buy, r.rounds[k].buy + 3000]; + }); const used: number[][] = rows.map(() => []); for (const d of drops) { - const same = drops.filter((x) => Math.abs(x.t - d.t) <= 3000).length; - if (same >= Math.max(3, Math.ceil(r.players.length / 2))) continue; // 초기화 + if (resets.some(([a, b]) => d.t >= a && d.t <= b)) continue; // 공수 교대 초기화 used[d.p].push(d.from); } return r.players.map((pl, p) => { @@ -132,11 +154,13 @@ export function loadoutAt(r: ReplayFile, p: number, t: number): string | null { return primary ?? side; } -/** 라운드 · 팀 점수: t 가 속한 라운드 번호와 그 라운드 전까지 이긴 수 */ +/** 라운드 · 팀 점수: t 가 속한 라운드 번호와 그 라운드 전까지 이긴 수 (라운드가 끝난 뒤면 그 라운드까지) */ export function teamScoreAt(r: ReplayFile, rounds: { num: number; score: { ally: number; enemy: number } }[] | undefined, t: number) { const rd = roundAt(r, t); const num = rd?.num ?? 1; - const before = rounds?.filter((x) => x.num < num).sort((a, b) => b.num - a.num)[0]; + // 라운드가 끝났으면(승패 확정) 그 라운드까지 (마지막 라운드가 끝난 뒤 최종 점수) + const done = !!rd && rd.end >= 0 && t >= rd.end; + const before = rounds?.filter((x) => (done ? x.num <= num : x.num < num)).sort((a, b) => b.num - a.num)[0]; return { round: num, ally: before?.score.ally ?? 0, enemy: before?.score.enemy ?? 0 }; }