635 lines
37 KiB
JavaScript
635 lines
37 KiB
JavaScript
// 목 데이터 생성기. 서버 시작 시각(NOW) 기준으로 오늘 저녁 세션을 만든다.
|
|
// 롤 1판(19:40 무렵) → 발로란트 바인드(패) → 발로란트 어센트(13:9 승) → 경기 후 잡담.
|
|
// 이미지 URL 은 실제 사이트 서버 캐시 경로 형식(/game-assets/...)을 흉내 낸 /game-assets/mock/...
|
|
|
|
import fs from 'node:fs';
|
|
|
|
export const A = (p) => `/game-assets/mock/${p}`;
|
|
|
|
function mulberry32(a) {
|
|
return function () {
|
|
a |= 0;
|
|
a = (a + 0x6d2b79f5) | 0;
|
|
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
};
|
|
}
|
|
const rnd = mulberry32(20261015);
|
|
const pick = (arr) => arr[Math.floor(rnd() * arr.length)];
|
|
const range = (a, b) => a + rnd() * (b - a);
|
|
const irange = (a, b) => Math.floor(range(a, b + 1));
|
|
|
|
export function fmtClock(ms) {
|
|
const neg = ms < 0;
|
|
let s = Math.floor(Math.abs(ms) / 1000);
|
|
const h = Math.floor(s / 3600);
|
|
s -= h * 3600;
|
|
const m = Math.floor(s / 60);
|
|
s -= m * 60;
|
|
const body = h > 0 ? `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}` : `${m}:${String(s).padStart(2, '0')}`;
|
|
return neg ? `-${body}` : body;
|
|
}
|
|
export function fmtReal(ts) {
|
|
return new Intl.DateTimeFormat('ko-KR', { timeZone: 'Asia/Seoul', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).format(ts);
|
|
}
|
|
|
|
// ── 유저 ──────────────────────────────────────────────
|
|
export const USERS = [
|
|
{ id: '310482915522101248', name: '하늘', color: '#3987e5', avatar: null, excluded: false, riot: [{ puuid: 'p-sh', riotId: '하늘#KR1' }] },
|
|
{ id: '310482915522101249', name: '민수', color: '#e5743f', avatar: null, excluded: false, riot: [{ puuid: 'p-ms', riotId: '민수#0707' }] },
|
|
{ id: '310482915522101250', name: '지우', color: '#1fb383', avatar: null, excluded: false, riot: [{ puuid: 'p-jw', riotId: '지우#KR2' }] },
|
|
{ id: '310482915522101251', name: '현우', color: '#9085e9', avatar: null, excluded: false, riot: [{ puuid: 'p-hw', riotId: '현우#HW1' }] },
|
|
{ id: '310482915522101252', name: '도윤', color: '#c98500', avatar: null, excluded: true, riot: [] },
|
|
];
|
|
const [SH, MS, JW, HW] = USERS;
|
|
const SPEAKERS = [SH, MS, JW, HW];
|
|
// 유저별 평소 음량 → 재생 게인. 지우는 마이크가 작아서 +13dB
|
|
export const USER_GAIN = { [SH.id]: 4.1, [MS.id]: -1.5, [JW.id]: 13.2, [HW.id]: 6.8 };
|
|
|
|
// ── 문장 풀 ───────────────────────────────────────────
|
|
const VAL_LINES = [
|
|
'B 쪽 조용한데 로테 도는 거 같아', '미드 하나 있어 체력 낮아', '스파이크 내가 들게', '에코 라운드야 아끼자', '풀바이 가자',
|
|
'나 오퍼 사줄 사람', '나 셰리프만 살게', '레이즈 궁 빠졌어', '제트 대시 썼어', '연막 깔아줘', '플래시 간다 셋 둘 하나',
|
|
'시간 끌어 수비 오고 있어', '해체 해 내가 커버할게', 'B 롱 하나 죽였어', '킬조이 터렛 있어 조심', '드론 날린다',
|
|
'정찰 화살 쏠게 A 사이트', '뒤에 하나 남았어', '나 죽었어 미안', '와 에이스 각이었는데', '다음 라운드 B로 가자',
|
|
'체력 30이야 뒤로 빠질게', '궁 찼다 이번 판 쓴다', '세이지 벽 칠게', '부활 해줄게 잠깐만', '오멘 텔레포트 탄다',
|
|
'적 셋이 A로 온다', '포지션 바꿔 너무 뻔해', '고마워 덕분에 살았다', '잘했다 이거 이겼어', '마켓 쪽 발소리 들려',
|
|
'헤븐에 하나 있어', '스파이크 떨궜어 주워줘', '나 이번엔 미드 볼게',
|
|
];
|
|
const LOL_LINES = [
|
|
'탑 갱 간다 점멸 없어', '미드 미아 미아', '와드 박아줘 강가에', '바론 치자 지금 다 죽었어', '정글 동선 봤어 위쪽이야',
|
|
'나 귀환할게 템 사고 올게', '포탑 다이브 하지 마', '유충 먹으러 가자', '쓰레쉬 랜턴 줘', '점멸 빠졌다 상대 미드',
|
|
'궁 쿨 30초 남았어', '봇 듀오 둘 다 체력 낮아', '르블랑 사라졌어 조심해', '세주아니 궁 맞으면 끝이야', '억제기 밀고 빠지자',
|
|
'용 영혼 각이다', '가렌 스플릿 가줘', '이즈 뒤에서 딜 넣어', '한 명만 잡고 빠지자', '킬 따줘서 고마워', '전령 먹고 미드 박자',
|
|
];
|
|
const REAL_LINES = [
|
|
'오늘 몇 판 할 거야', '잠깐 물 좀 떠올게', '롤 한 판 더 할까 발로 갈까', '아까 그 한타 진짜 미쳤다',
|
|
'다음 판은 내가 감시자 할게', '배고프다 치킨 시킬까', '마이크 소리 너무 작아', '아 렉 걸렸어 잠깐만', '녹음 잘 되고 있지?',
|
|
'내일도 이 시간에 모여', '랭크 점수 얼마나 올랐어', '새 요원 써볼까', '오늘 컨디션 좋다', '디코 잠깐 나갔다 올게',
|
|
];
|
|
const CHAT_VAL = ['스파이크 설치함 B로 돌지마', 'ㄱㄱ', '에코', '오퍼 드랍 부탁', 'A 3명', 'gg', '나이스'];
|
|
const CHAT_LOL = ['용 치자 바론 말고', '미드 미아', '점멸 없음 바텀', '귀환 ㄱ', '바론 ㄱㄱ', 'ㅈㅅ'];
|
|
|
|
// ── 공통 생성 ─────────────────────────────────────────
|
|
const utterances = [];
|
|
const events = [];
|
|
const matches = [];
|
|
let seq = 1;
|
|
const nid = (p) => `${p}${String(seq++).padStart(5, '0')}`;
|
|
|
|
function makeWords(text, durSec) {
|
|
const toks = text.split(/\s+/).filter(Boolean);
|
|
const chars = toks.reduce((n, t) => n + t.length, 0) || 1;
|
|
const lead = 0.12;
|
|
const usable = Math.max(0.3, durSec - lead - 0.15);
|
|
let t = lead;
|
|
return toks.map((w) => {
|
|
const len = (usable * w.length) / chars;
|
|
const s = +t.toFixed(2);
|
|
const e = +(t + len * 0.86).toFixed(2);
|
|
t += len;
|
|
return { w, s, e, p: +range(0.62, 0.99).toFixed(2) };
|
|
});
|
|
}
|
|
|
|
/** 발화 하나 생성. game 컨텍스트와 time 라벨을 받는다. */
|
|
function addUtt({ user, ts, text, game = null, time, noise = false, status = 'precise', audio = true }) {
|
|
const syll = text ? text.replace(/\s/g, '').length : 4;
|
|
const durMs = Math.round((noise ? range(0.6, 1.4) : syll * range(0.17, 0.22) + 0.5) * 1000);
|
|
const id = nid('ut_');
|
|
const gainDb = +(USER_GAIN[user.id] + range(-0.8, 0.8)).toFixed(1);
|
|
const it = {
|
|
kind: 'utterance',
|
|
id,
|
|
ts,
|
|
endTs: ts + durMs,
|
|
userId: user.id,
|
|
text: noise || status === 'pending' ? null : text,
|
|
words: noise || status === 'pending' ? [] : makeWords(text, durMs / 1000),
|
|
noise,
|
|
status,
|
|
corrected: false,
|
|
confidence: noise || status === 'pending' ? null : +range(0.74, 0.97).toFixed(2),
|
|
model: status === 'pending' ? null : status === 'precise' ? 'large-v3' : 'large-v3-turbo',
|
|
audio: audio ? { url: `/api/audio/${id}`, durationMs: durMs, gainDb } : null,
|
|
game,
|
|
time,
|
|
_pendingText: status === 'pending' ? text : undefined,
|
|
};
|
|
utterances.push(it);
|
|
return it;
|
|
}
|
|
const realLabel = (ts) => ({ primary: fmtReal(ts), real: ts });
|
|
|
|
// ── 발로란트 ─────────────────────────────────────────
|
|
const AG = {
|
|
jett: { id: 'add6443a-41bd-e414-f6ad-e58d267f4e95', name: '제트', icon: A('val/a-jett.png') },
|
|
sova: { id: '320b2a48-4d9b-a075-30f1-1f93a9b638fa', name: '소바', icon: A('val/a-sova.png') },
|
|
sage: { id: '569fdd95-4d10-43ab-ca70-79becc718b46', name: '세이지', icon: A('val/a-sage.png') },
|
|
omen: { id: '8e253930-4c05-31dd-1b6c-968525494517', name: '오멘', icon: A('val/a-omen.png') },
|
|
killjoy: { id: '1e58de9c-4950-5125-93e9-a0aee9f98746', name: '킬조이', icon: A('val/a-killjoy.png') },
|
|
raze: { id: 'f94c3b30-42be-e959-889c-5aa313dba261', name: '레이즈', icon: A('val/a-raze.png') },
|
|
reyna: { id: 'a3bfb853-43b2-7238-a4f1-ad90e9e46bcc', name: '레이나', icon: A('val/a-reyna.png') },
|
|
};
|
|
const WP = {
|
|
vandal: { id: '9c82e19d-4575-0200-1a81-3eacf00cf872', name: '밴달', icon: A('val/w-vandal-kill.png') },
|
|
phantom: { id: 'ee8e8d15-496b-07ac-e5f6-8fae5d4c7b1a', name: '팬텀', icon: A('val/w-phantom-kill.png') },
|
|
operator: { id: 'a03b24d3-4319-996d-0f8c-94bbfba1dfc7', name: '오퍼레이터', icon: A('val/w-operator-kill.png') },
|
|
sheriff: { id: 'e336c6b8-418d-9340-d77f-7a9e4cfe0702', name: '셰리프', icon: A('val/w-sheriff-kill.png') },
|
|
};
|
|
// 어센트 미니맵 위 플레이 가능한 지점(이미지 비율 u,v) → 게임 좌표 역변환
|
|
const ASCENT_T = { xMultiplier: 7e-5, yMultiplier: -7e-5, xScalarToAdd: 0.813895, yScalarToAdd: 0.573242 };
|
|
const ASCENT_SPOTS = [
|
|
[320, 150], [300, 190], [400, 140], [410, 300], [480, 130], [500, 250], [330, 290], [200, 350], [500, 500], [540, 520],
|
|
[420, 500], [300, 480], [310, 570], [180, 640], [160, 450], [100, 450], [280, 800], [240, 770], [300, 700], [420, 750],
|
|
[560, 740], [800, 580], [900, 580], [790, 420], [600, 270], [690, 400], [560, 450],
|
|
];
|
|
function valLoc(T, spot) {
|
|
const u = (spot[0] + range(-14, 14)) / 1024;
|
|
const v = (spot[1] + range(-14, 14)) / 1024;
|
|
return { x: Math.round((v - T.yScalarToAdd) / T.yMultiplier), y: Math.round((u - T.xScalarToAdd) / T.xMultiplier) };
|
|
}
|
|
const ROUND_RESULT = ['Elimination', 'Bomb detonated', 'Bomb defused', 'Round timer expired'];
|
|
|
|
function genValorant({ id, mapName, mapId, image, T, start, results, mode = '경쟁전', linesPerRound = [3, 5], scripted = {} }) {
|
|
const ally = [
|
|
{ puuid: 'p-sh', name: '하늘', tag: 'KR1', team: 'Blue', ally: true, character: AG.jett, userId: SH.id },
|
|
{ puuid: 'p-ms', name: '민수', tag: '0707', team: 'Blue', ally: true, character: AG.sova, userId: MS.id },
|
|
{ puuid: 'p-jw', name: '지우', tag: 'KR2', team: 'Blue', ally: true, character: AG.sage, userId: JW.id },
|
|
{ puuid: 'p-hw', name: '현우', tag: 'HW1', team: 'Blue', ally: true, character: AG.omen, userId: HW.id },
|
|
{ puuid: 'p-r1', name: 'Duck', tag: 'KR3', team: 'Blue', ally: true, character: AG.killjoy },
|
|
];
|
|
const enemy = [
|
|
{ puuid: 'e-1', name: 'Lumi', tag: 'KR1', team: 'Red', ally: false, character: AG.raze },
|
|
{ puuid: 'e-2', name: 'Nox', tag: '0420', team: 'Red', ally: false, character: AG.killjoy },
|
|
{ puuid: 'e-3', name: 'Haru', tag: 'KR2', team: 'Red', ally: false, character: AG.reyna },
|
|
{ puuid: 'e-4', name: 'Mint', tag: '7777', team: 'Red', ally: false, character: AG.omen },
|
|
{ puuid: 'e-5', name: 'Kiwi', tag: 'KR9', team: 'Red', ally: false, character: AG.sova },
|
|
];
|
|
const players = [...ally, ...enemy].map((p) => ({ ...p, kills: 0, deaths: 0, assists: 0, score: 0, rank: null }));
|
|
const byPuuid = Object.fromEntries(players.map((p) => [p.puuid, p]));
|
|
const ref = (p) => ({ puuid: p.puuid, name: `${p.name}#${p.tag}`, team: p.team, character: p.character, userId: p.userId });
|
|
const refUserName = (p) => (p.userId ? p.name : `${p.name}#${p.tag}`);
|
|
const ROUND_LEN = 112000;
|
|
const BUY = 30000;
|
|
const rounds = [];
|
|
const mEvents = [];
|
|
const mUtts = [];
|
|
let score = { ally: 0, enemy: 0 };
|
|
const label = (ts, rStart, num) => {
|
|
const inRound = ts - rStart;
|
|
const primary = inRound < BUY ? `R${num} · 구매` : `R${num} · ${fmtClock(inRound - BUY)}`;
|
|
return { primary, secondary: fmtClock(ts - start), real: ts };
|
|
};
|
|
const ecoPattern = [4, 12, 9, 20, 8, 22, 25, 14, 6, 21, 24, 26, 15, 4, 11, 22, 18, 24, 12, 23, 25, 26];
|
|
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: start, game: 'valorant', matchId: id, type: 'match_start', data: { map: mapName, mode }, time: { primary: 'R1 · 구매', secondary: '0:00', real: start } });
|
|
|
|
results.split('').forEach((rc, i) => {
|
|
const num = i + 1;
|
|
const win = rc === 'W';
|
|
const rStart = start + i * ROUND_LEN;
|
|
const combatLen = irange(55, 80) * 1000;
|
|
const rEnd = rStart + BUY + combatLen;
|
|
// 경제
|
|
const teamCred = ecoPattern[i % ecoPattern.length] * 1000 + irange(0, 900);
|
|
const economy = {};
|
|
for (const p of ally) {
|
|
const total = Math.round(teamCred / 5 + range(-500, 500));
|
|
const spent = Math.max(0, Math.min(total, Math.round(total * range(0.55, 0.95))));
|
|
economy[p.puuid] = { spent, remaining: total - spent, weapon: spent > 3500 ? (p.character === AG.jett && spent > 4500 ? '오퍼레이터' : '밴달') : spent > 1500 ? '셰리프' : '클래식' };
|
|
}
|
|
// 킬
|
|
const nKills = irange(5, 9);
|
|
const allyDead = new Set();
|
|
const enemyDead = new Set();
|
|
const kills = [];
|
|
for (let k = 0; k < nKills; k++) {
|
|
const allyKills = win ? rnd() < 0.62 : rnd() < 0.4;
|
|
const killers = (allyKills ? ally : enemy).filter((p) => !(allyKills ? allyDead : enemyDead).has(p.puuid));
|
|
const victims = (allyKills ? enemy : ally).filter((p) => !(allyKills ? enemyDead : allyDead).has(p.puuid));
|
|
if (!killers.length || !victims.length) break;
|
|
const killer = pick(killers);
|
|
const victim = pick(victims);
|
|
(allyKills ? enemyDead : allyDead).add(victim.puuid);
|
|
kills.push({ killer, victim, allyKills });
|
|
}
|
|
let t = rStart + BUY + irange(8, 20) * 1000;
|
|
const step = (combatLen - 15000) / Math.max(1, kills.length);
|
|
for (const k of kills) {
|
|
t += Math.round(step * range(0.5, 1.3));
|
|
if (t > rEnd - 2000) t = rEnd - 2000 - irange(0, 3000);
|
|
const killer = byPuuid[k.killer.puuid];
|
|
const victim = byPuuid[k.victim.puuid];
|
|
killer.kills++;
|
|
victim.deaths++;
|
|
killer.score += irange(150, 260);
|
|
const mates = (k.allyKills ? ally : enemy).filter((p) => p !== k.killer);
|
|
const assists = rnd() < 0.5 ? [pick(mates)] : [];
|
|
assists.forEach((a) => {
|
|
byPuuid[a.puuid].assists++;
|
|
byPuuid[a.puuid].score += 50;
|
|
});
|
|
const weapon = killer.character === AG.jett && rnd() < 0.4 ? WP.operator : pick([WP.vandal, WP.vandal, WP.phantom, WP.sheriff]);
|
|
mEvents.push({
|
|
kind: 'event', id: nid('ev_'), ts: t, game: 'valorant', matchId: id, type: 'kill', round: num,
|
|
data: { killer: ref(killer), victim: ref(victim), assists: assists.map(ref), weapon, headshot: rnd() < 0.35, location: valLoc(T, pick(ASCENT_SPOTS)), ally: k.allyKills },
|
|
time: label(t, rStart, num), userId: killer.userId ?? victim.userId,
|
|
});
|
|
}
|
|
// 스파이크
|
|
if (rnd() < 0.55) {
|
|
const ts = rStart + BUY + Math.round(combatLen * range(0.35, 0.6));
|
|
const planter = pick(win ? ally : enemy);
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts, game: 'valorant', matchId: id, type: 'spike', round: num, data: { action: 'plant', site: pick(['A', 'B']), player: ref(planter), location: valLoc(T, pick([[320, 150], [280, 800]])) }, time: label(ts, rStart, num), userId: planter.userId });
|
|
}
|
|
// 발화
|
|
const nLines = scripted[num] ? 0 : irange(linesPerRound[0], linesPerRound[1]);
|
|
for (let l = 0; l < nLines; l++) {
|
|
const ts = rStart + irange(4, Math.floor((BUY + combatLen) / 1000) - 3) * 1000 + irange(0, 900);
|
|
const user = pick(SPEAKERS);
|
|
const noise = rnd() < 0.08;
|
|
mUtts.push(addUtt({ user, ts, text: pick(VAL_LINES), noise, game: { type: 'valorant', matchId: id, round: num }, time: label(ts, rStart, num) }));
|
|
}
|
|
for (const s of scripted[num] ?? []) {
|
|
const ts = rStart + BUY + s.at * 1000;
|
|
if (s.chat) {
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts, game: 'valorant', matchId: id, type: 'chat', round: num, data: { sender: { name: s.user.name, puuid: s.user.riot[0]?.puuid, userId: s.user.id }, channel: 'team', text: s.chat, source: 'log' }, time: label(ts, rStart, num), userId: s.user.id });
|
|
} else {
|
|
mUtts.push(addUtt({ user: s.user, ts, text: s.text ?? '', noise: !!s.noise, game: { type: 'valorant', matchId: id, round: num }, time: label(ts, rStart, num) }));
|
|
}
|
|
}
|
|
if (!scripted[num] && rnd() < 0.3) {
|
|
const ts = rStart + irange(5, 25) * 1000;
|
|
const u = pick(SPEAKERS);
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts, game: 'valorant', matchId: id, type: 'chat', round: num, data: { sender: { name: u.name, puuid: u.riot[0]?.puuid, userId: u.id }, channel: pick(['team', 'team', 'all', 'party']), text: pick(CHAT_VAL), source: 'log' }, time: label(ts, rStart, num), userId: u.id });
|
|
}
|
|
if (win) score = { ...score, ally: score.ally + 1 };
|
|
else score = { ...score, enemy: score.enemy + 1 };
|
|
const result = enemyDead.size === 5 || allyDead.size === 5 ? 'Elimination' : pick(ROUND_RESULT.slice(1));
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: rEnd, game: 'valorant', matchId: id, type: 'round_end', round: num, data: { round: num, win, result, score: { ...score } }, time: label(rEnd, rStart, num) });
|
|
rounds.push({ num, startedAt: rStart, endedAt: rEnd, win, result, score: { ...score }, economy });
|
|
});
|
|
const endedAt = rounds[rounds.length - 1].endedAt + 8000;
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: endedAt, game: 'valorant', matchId: id, type: 'match_end', data: { win: score.ally > score.enemy, score }, time: { primary: fmtClock(endedAt - start), real: endedAt } });
|
|
for (const e of mEvents) delete e.round;
|
|
events.push(...mEvents);
|
|
const summary = {
|
|
id, game: 'valorant', startedAt: start, endedAt, map: { id: mapId, name: mapName, image }, mode,
|
|
win: score.ally > score.enemy, score, status: 'complete', participants: [SH.id, MS.id, JW.id, HW.id],
|
|
};
|
|
matches.push({ ...summary, players, rounds, events: mEvents, utterances: mUtts, mapTransform: { valorant: T } });
|
|
}
|
|
|
|
// ── 롤 ───────────────────────────────────────────────
|
|
const CH = {
|
|
Ahri: { id: 'Ahri', name: '아리', icon: A('lol/c-Ahri.png') },
|
|
LeeSin: { id: 'LeeSin', name: '리 신', icon: A('lol/c-LeeSin.png') },
|
|
Garen: { id: 'Garen', name: '가렌', icon: A('lol/c-Garen.png') },
|
|
Ezreal: { id: 'Ezreal', name: '이즈리얼', icon: A('lol/c-Ezreal.png') },
|
|
Thresh: { id: 'Thresh', name: '쓰레쉬', icon: A('lol/c-Thresh.png') },
|
|
Leblanc: { id: 'Leblanc', name: '르블랑', icon: A('lol/c-Leblanc.png') },
|
|
Sejuani: { id: 'Sejuani', name: '세주아니', icon: A('lol/c-Sejuani.png') },
|
|
Darius: { id: 'Darius', name: '다리우스', icon: null },
|
|
Caitlyn: { id: 'Caitlyn', name: '케이틀린', icon: null },
|
|
Lulu: { id: 'Lulu', name: '룰루', icon: null },
|
|
};
|
|
const OBJ_ICON = {
|
|
dragon_infernal: A('lol/o-dragon_infernal.png'), dragon_ocean: A('lol/o-dragon_ocean.png'), dragon_mountain: A('lol/o-dragon_mountain.png'),
|
|
baron: A('lol/o-baron.png'), grub: A('lol/o-grub.png'), tower: A('lol/o-tower.png'),
|
|
};
|
|
const LOL_T = { minX: -120, minY: -120, maxX: 14870, maxY: 14980 };
|
|
|
|
function genLol({ id, start }) {
|
|
const DUR = (32 * 60 + 14) * 1000;
|
|
const endedAt = start + DUR;
|
|
const ally = [
|
|
{ puuid: 'p-sh', name: '하늘', tag: 'KR1', team: '100', ally: true, character: CH.Ahri, userId: SH.id, lane: 'mid' },
|
|
{ puuid: 'p-ms', name: '민수', tag: '0707', team: '100', ally: true, character: CH.LeeSin, userId: MS.id, lane: 'jg' },
|
|
{ puuid: 'p-hw', name: '현우', tag: 'HW1', team: '100', ally: true, character: CH.Garen, userId: HW.id, lane: 'top' },
|
|
{ puuid: 'p-ez', name: 'Ezreal', tag: 'KR7', team: '100', ally: true, character: CH.Ezreal, lane: 'bot' },
|
|
{ puuid: 'p-jw', name: '지우', tag: 'KR2', team: '100', ally: true, character: CH.Thresh, userId: JW.id, lane: 'sup' },
|
|
];
|
|
const enemy = [
|
|
{ puuid: 'l-1', name: 'Velvet', tag: 'KR1', team: '200', ally: false, character: CH.Leblanc },
|
|
{ puuid: 'l-2', name: 'IceQ', tag: 'KR5', team: '200', ally: false, character: CH.Sejuani },
|
|
{ puuid: 'l-3', name: 'Axe', tag: 'NOX', team: '200', ally: false, character: CH.Darius },
|
|
{ puuid: 'l-4', name: 'Piltie', tag: 'KR3', team: '200', ally: false, character: CH.Caitlyn },
|
|
{ puuid: 'l-5', name: 'Pix', tag: 'KR8', team: '200', ally: false, character: CH.Lulu },
|
|
];
|
|
const players = [...ally, ...enemy].map(({ lane, ...p }) => ({ ...p, kills: 0, deaths: 0, assists: 0, cs: 0, gold: 0, level: 1, items: [], rank: null }));
|
|
const byPuuid = Object.fromEntries(players.map((p) => [p.puuid, p]));
|
|
const ref = (p) => ({ puuid: p.puuid, name: p.userId ? p.name : p.character.name, team: p.team, character: p.character, userId: p.userId });
|
|
const label = (ts) => ({ primary: fmtClock(ts - start), real: ts });
|
|
const mEvents = [];
|
|
const mUtts = [];
|
|
const at = (mm, ss) => start + (mm * 60 + ss) * 1000;
|
|
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: start, game: 'lol', matchId: id, type: 'match_start', data: { map: '소환사의 협곡', mode: '개인/2인 랭크' }, time: label(start) });
|
|
|
|
// 골드 차이 (분 단위)
|
|
const curve = [0, -100, 200, -300, -500, -150, 300, 500, 250, 900, 1200, 1500, 2100, 1900, 2600, 3200, 2800, 3500, 4100, 3900, 4600, 5200, 4800, 5600, 6100, 5800, 6900, 7400, 7100, 7800, 8000, 8100, 8200];
|
|
const goldDiff = curve.map((d, m) => ({ t: m * 60000, diff: d + (m ? irange(-150, 150) : 0) }));
|
|
goldDiff[goldDiff.length - 1] = { t: DUR, diff: 8200 };
|
|
|
|
// 오브젝트
|
|
const objs = [
|
|
{ t: at(5, 55), object: 'grub', icon: OBJ_ICON.grub, ally: true, loc: { x: 4950, y: 10400 }, killer: 'p-ms' },
|
|
{ t: at(6, 10), object: 'dragon', subtype: 'infernal', icon: OBJ_ICON.dragon_infernal, ally: true, loc: { x: 9866, y: 4414 }, killer: 'p-ms' },
|
|
{ t: at(10, 40), object: 'tower', subtype: 'outer_bot', icon: OBJ_ICON.tower, ally: false, loc: { x: 13866, y: 4505 } },
|
|
{ t: at(12, 30), object: 'dragon', subtype: 'ocean', icon: OBJ_ICON.dragon_ocean, ally: true, loc: { x: 9866, y: 4414 }, killer: 'p-ms' },
|
|
{ t: at(14, 2), object: 'tower', subtype: 'outer_top', icon: OBJ_ICON.tower, ally: true, loc: { x: 4318, y: 13875 } },
|
|
{ t: at(17, 20), object: 'tower', subtype: 'outer_mid', icon: OBJ_ICON.tower, ally: true, loc: { x: 8955, y: 8510 } },
|
|
{ t: at(21, 38), object: 'dragon', subtype: 'ocean', icon: OBJ_ICON.dragon_ocean, ally: true, loc: { x: 9866, y: 4414 }, killer: 'p-ms' },
|
|
{ t: at(22, 5), object: 'tower', subtype: 'outer_mid', icon: OBJ_ICON.tower, ally: true, loc: { x: 9767, y: 10113 } },
|
|
{ t: at(24, 50), object: 'tower', subtype: 'inner_bot', icon: OBJ_ICON.tower, ally: false, loc: { x: 8955, y: 1600 } },
|
|
{ t: at(26, 40), object: 'baron', icon: OBJ_ICON.baron, ally: true, loc: { x: 4942, y: 10395 }, killer: 'p-ms' },
|
|
{ t: at(28, 12), object: 'dragon', subtype: 'mountain', icon: OBJ_ICON.dragon_mountain, ally: true, loc: { x: 9866, y: 4414 }, killer: 'p-ms' },
|
|
{ t: at(29, 30), object: 'inhibitor', subtype: 'mid', icon: OBJ_ICON.tower, ally: true, loc: { x: 11598, y: 11667 } },
|
|
{ t: at(31, 50), object: 'tower', subtype: 'nexus', icon: OBJ_ICON.tower, ally: true, loc: { x: 13052, y: 12612 } },
|
|
];
|
|
for (const o of objs) {
|
|
const killer = o.killer ? byPuuid[o.killer] : null;
|
|
mEvents.push({
|
|
kind: 'event', id: nid('ev_'), ts: o.t, game: 'lol', matchId: id, type: 'object',
|
|
data: { object: o.object, subtype: o.subtype, team: o.ally ? '100' : '200', killer: killer ? ref(killer) : null, ally: o.ally, icon: o.icon, location: o.loc },
|
|
time: label(o.t), userId: killer?.userId,
|
|
});
|
|
}
|
|
// 킬 45개 (우리 27 : 18)
|
|
const killTimes = [];
|
|
for (let i = 0; i < 45; i++) killTimes.push(irange(150, DUR / 1000 - 60));
|
|
killTimes.sort((a, b) => a - b);
|
|
// 21:14 한타 장면 고정
|
|
const scriptedKills = [
|
|
{ s: 21 * 60 + 16, killer: 'p-sh', victim: 'l-1', assists: ['p-ms', 'p-jw'], loc: { x: 9300, y: 4300 } },
|
|
{ s: 21 * 60 + 19, killer: 'p-ms', victim: 'l-2', assists: ['p-jw'], loc: { x: 10100, y: 4900 }, multi: 2 },
|
|
];
|
|
let allyLeft = 25;
|
|
let enemyLeft = 18;
|
|
killTimes.forEach((s, i) => {
|
|
if (s > 20 * 60 + 50 && s < 21 * 60 + 40) s += 60;
|
|
const allyKills = allyLeft && (rnd() < allyLeft / (allyLeft + enemyLeft) || !enemyLeft);
|
|
if (allyKills) allyLeft--;
|
|
else if (enemyLeft) enemyLeft--;
|
|
else return;
|
|
const killer = pick(allyKills ? ally : enemy);
|
|
const victim = pick(allyKills ? enemy : ally);
|
|
const mates = (allyKills ? ally : enemy).filter((p) => p !== killer);
|
|
const asg = mates.filter(() => rnd() < 0.35);
|
|
scriptedKills.push({ s, killer: killer.puuid, victim: victim.puuid, assists: asg.map((a) => a.puuid), loc: { x: irange(1200, 13600), y: irange(1200, 13600) }, i });
|
|
});
|
|
for (const k of scriptedKills) {
|
|
const ts = start + k.s * 1000;
|
|
const killer = byPuuid[k.killer];
|
|
const victim = byPuuid[k.victim];
|
|
killer.kills++;
|
|
victim.deaths++;
|
|
k.assists.forEach((a) => byPuuid[a].assists++);
|
|
mEvents.push({
|
|
kind: 'event', id: nid('ev_'), ts, game: 'lol', matchId: id, type: 'kill',
|
|
data: { killer: ref(killer), victim: ref(victim), assists: k.assists.map((a) => ref(byPuuid[a])), weapon: null, location: k.loc, ally: killer.ally },
|
|
time: label(ts), userId: killer.userId ?? victim.userId,
|
|
});
|
|
if (k.multi) {
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: ts + 10, game: 'lol', matchId: id, type: 'multikill', data: { player: ref(killer), count: k.multi, ally: killer.ally }, time: label(ts), userId: killer.userId });
|
|
}
|
|
}
|
|
// 스탯 마무리
|
|
const csBase = { 'p-sh': 188, 'p-ms': 132, 'p-hw': 170, 'p-ez': 201, 'p-jw': 31, 'l-1': 176, 'l-2': 120, 'l-3': 160, 'l-4': 214, 'l-5': 28 };
|
|
const goldBase = { 'p-sh': 13900, 'p-ms': 12100, 'p-hw': 11800, 'p-ez': 13400, 'p-jw': 8700, 'l-1': 11200, 'l-2': 9600, 'l-3': 10100, 'l-4': 11900, 'l-5': 7300 };
|
|
const ITEMS = [
|
|
[3157, '존야의 모래시계'], [6655, '루덴의 동반자'], [3089, '라바돈의 죽음모자'], [3071, '칠흑의 양날 도끼'], [6631, '선체파괴자'],
|
|
[3190, '강철의 솔라리 펜던트'], [3047, '판금 장화'], [3111, '헤르메스의 발걸음'], [3020, '마법사의 신발'], [3508, '정수 약탈자'],
|
|
];
|
|
for (const p of players) {
|
|
p.cs = csBase[p.puuid];
|
|
p.gold = goldBase[p.puuid];
|
|
p.level = irange(14, 18);
|
|
p.items = Array.from({ length: irange(4, 6) }, () => pick(ITEMS)).map(([iid, name]) => ({ id: iid, name, icon: null }));
|
|
}
|
|
// 발화
|
|
const scriptedUtt = [
|
|
{ m: 20, s: 41, user: MS, text: '드래곤 30초 남았어 바텀 웨이브 밀고 와' },
|
|
{ m: 21, s: 14, user: SH, text: '지금 이니시 걸어 내가 매혹 맞췄어' },
|
|
{ m: 21, s: 24, user: JW, text: '한타 이겼다 용 먹자 용' },
|
|
{ m: 21, s: 50, user: HW, text: '', noise: true },
|
|
];
|
|
for (const u of scriptedUtt) {
|
|
const ts = at(u.m, u.s);
|
|
mUtts.push(addUtt({ user: u.user, ts, text: u.text, noise: !!u.noise, game: { type: 'lol', matchId: id }, time: label(ts) }));
|
|
}
|
|
for (let i = 0; i < 64; i++) {
|
|
let s = irange(30, DUR / 1000 - 20);
|
|
if (s > 20 * 60 + 30 && s < 22 * 60 + 10) s += 120;
|
|
const ts = start + s * 1000 + irange(0, 900);
|
|
mUtts.push(addUtt({ user: pick(SPEAKERS), ts, text: pick(LOL_LINES), noise: rnd() < 0.07, game: { type: 'lol', matchId: id }, time: label(ts) }));
|
|
}
|
|
// 채팅 (OCR / LCU)
|
|
const chats = [{ ts: at(21, 31), user: MS, text: '용 치자 바론 말고', source: 'ocr', ch: CH.LeeSin }];
|
|
for (let i = 0; i < 7; i++) chats.push({ ts: start + irange(60, DUR / 1000 - 30) * 1000, user: pick(SPEAKERS), text: pick(CHAT_LOL), source: pick(['ocr', 'lcu']) });
|
|
for (const c of chats) {
|
|
const p = players.find((pp) => pp.userId === c.user.id);
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: c.ts, game: 'lol', matchId: id, type: 'chat', data: { sender: { name: c.user.name, puuid: p?.puuid, userId: c.user.id, character: p?.character }, channel: 'team', text: c.text, source: c.source }, time: label(c.ts), userId: c.user.id });
|
|
}
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: endedAt, game: 'lol', matchId: id, type: 'match_end', data: { win: true, score: { ally: 27, enemy: 18 } }, time: label(endedAt) });
|
|
events.push(...mEvents);
|
|
const ak = players.filter((p) => p.ally).reduce((n, p) => n + p.kills, 0);
|
|
const ek = players.filter((p) => !p.ally).reduce((n, p) => n + p.kills, 0);
|
|
const summary = {
|
|
id, game: 'lol', startedAt: start, endedAt, map: { id: '11', name: '소환사의 협곡', image: A('lol/map11.png') }, mode: '개인/2인 랭크',
|
|
win: true, score: { ally: ak, enemy: ek }, status: 'complete', participants: [SH.id, MS.id, JW.id, HW.id],
|
|
};
|
|
matches.push({ ...summary, players, goldDiff, events: mEvents, utterances: mUtts, mapTransform: { lol: LOL_T } });
|
|
}
|
|
|
|
// ── 일정 ─────────────────────────────────────────────
|
|
export const NOW = Date.now();
|
|
const MIN = 60000;
|
|
const lolStart = NOW - 140 * MIN;
|
|
const bindStart = NOW - 99 * MIN;
|
|
const ascentStart = NOW - 50 * MIN;
|
|
|
|
// 8일 전 세션: 음성 삭제됨
|
|
for (let i = 0; i < 6; i++) {
|
|
const ts = NOW - 8 * 24 * 60 * MIN + i * 47000;
|
|
addUtt({ user: pick(SPEAKERS), ts, text: pick(REAL_LINES), time: realLabel(ts), audio: false });
|
|
}
|
|
// 롤 전
|
|
for (let i = 0; i < 5; i++) {
|
|
const ts = lolStart - (6 - i) * 52000 - irange(0, 9000);
|
|
addUtt({ user: pick(SPEAKERS), ts, text: i === 4 ? '롤 한 판 하고 발로 가자' : pick(REAL_LINES), time: realLabel(ts) });
|
|
}
|
|
genLol({ id: 'lol-KR_7712093344', start: lolStart });
|
|
// 롤 → 바인드 사이
|
|
for (let i = 0; i < 4; i++) {
|
|
const ts = lolStart + 33 * MIN + i * 60000 + irange(0, 20000);
|
|
addUtt({ user: pick(SPEAKERS), ts, text: pick(REAL_LINES), time: realLabel(ts) });
|
|
}
|
|
genValorant({ id: 'val-5d1c0a7e-bind', mapName: '바인드', mapId: '2c9d57ec-4431-9c5e-2939-8f9ef6dd5cba', image: null, T: { xMultiplier: 5.9e-5, yMultiplier: -5.9e-5, xScalarToAdd: 0.576941, yScalarToAdd: 0.967566 }, start: bindStart, results: 'LWLLWLWWLLWLWLLWWLLWWLL', linesPerRound: [1, 2] });
|
|
// 바인드 → 어센트
|
|
const preAscent = [
|
|
[SH, '아 바인드 아쉽다 한 판 더 하자'],
|
|
[JW, '이번엔 내가 세이지 할게'],
|
|
[MS, '큐 돌리자 이번 판은 어센트 나왔으면 좋겠다'],
|
|
];
|
|
preAscent.forEach(([u, text], i) => {
|
|
const ts = ascentStart - (4 - i) * 50000;
|
|
addUtt({ user: u, ts, text, time: realLabel(ts) });
|
|
});
|
|
genValorant({
|
|
id: 'val-9f2e7b10-ascent', mapName: '어센트', mapId: '7eaecc1b-4337-bbf6-6ab9-04b8f06b3319', image: A('val/map-ascent.png'), T: ASCENT_T, start: ascentStart,
|
|
results: 'WWLWLWWLLWWLWLWLWLWLWW',
|
|
scripted: {
|
|
7: [
|
|
{ at: 31, user: SH, text: 'A 메인 둘 봤어 하나 체력 낮아' },
|
|
{ at: 38, user: JW, text: '내가 스모크 깔게 들어가 들어가' },
|
|
{ at: 41, user: MS, text: '나이스 원탭!' },
|
|
{ at: 44, user: MS, noise: true },
|
|
{ at: 51, user: MS, chat: '스파이크 설치함 B로 돌지마' },
|
|
{ at: 62, user: SH, text: '레이즈 하나 남았어 메인 쪽에서 와 시간 끌어' },
|
|
{ at: 69, user: MS, text: '아 미안 셰리프 맞았다' },
|
|
],
|
|
},
|
|
});
|
|
// 경기 후 잡담 (최근 것은 STT 처리 중)
|
|
const post = [
|
|
[SH, '13 대 9 깔끔하다 오늘 폼 좋네', 'precise'],
|
|
[HW, '오멘 궁 타이밍 좋았지?', 'realtime'],
|
|
[MS, '나 마지막 라운드 셰리프 원탭 봤어?', 'realtime'],
|
|
[JW, '잠깐 쉬었다가 롤 한 판 더 하자', 'pending'],
|
|
[SH, '나 물 좀 마시고 올게', 'pending'],
|
|
];
|
|
const lastMatch = matches[matches.length - 1];
|
|
post.forEach(([u, text, status], i) => {
|
|
const ts = lastMatch.endedAt + 40000 + i * 70000;
|
|
addUtt({ user: u, ts, text, status, time: realLabel(ts) });
|
|
});
|
|
|
|
// ── 3D 리플레이 데모 (선택) ─────────────────────────────
|
|
// GVR_MOCK_REPLAY=<gvr-replay JSON 경로> (+ GVR_MOCK_REPLAY_MAP_FILE=<어비스 미니맵 png>) 를 주면 그 리플레이로 경기 하나를 만든다 (실제 리플레이는 저장소에 넣지 않는다).
|
|
// 경기 기록(킬 시각)은 리플레이보다 MOCK_SYNC_OFFSET 만큼 늦게 찍어, 사이트가 그 차이를 맞추는지 본다.
|
|
export const MOCK_SYNC_OFFSET = 1234;
|
|
function genReplayDemo(file) {
|
|
const r = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
const id = 'val-replay-demo';
|
|
const base = r.recordedAt + MOCK_SYNC_OFFSET;
|
|
// 팀: 같은 팀끼리는 (거의) 안 죽이므로 킬 관계로 두 편을 나눈다 (실제 사이트는 경기 기록의 팀을 쓴다)
|
|
const adj = r.players.map(() => new Set());
|
|
for (const [, k, v] of r.kills) if (k >= 0 && v >= 0 && k !== v) (adj[k].add(v), adj[v].add(k));
|
|
const side = new Map([[0, 0]]);
|
|
const stack = [0];
|
|
while (stack.length) {
|
|
const x = stack.pop();
|
|
for (const y of adj[x]) if (!side.has(y)) (side.set(y, 1 - side.get(x)), stack.push(y));
|
|
}
|
|
const allyIdx = new Set(r.players.map((_, i) => i).filter((i) => side.get(i) === 0));
|
|
const AGK = { Wushu_PC_C: AG.jett, Hunter_PC_C: AG.sova, Thorne_PC_C: AG.sage, Wraith_PC_C: AG.omen, Killjoy_PC_C: AG.killjoy, Clay_PC_C: AG.raze, Vampire_PC_C: AG.reyna };
|
|
let si = 0;
|
|
let an = 0;
|
|
let en = 0;
|
|
const players = r.players.map((p, i) => {
|
|
const ally = allyIdx.has(i);
|
|
const user = ally && si < SPEAKERS.length ? SPEAKERS[si++] : null;
|
|
const name = user ? user.name : ally ? `아군${++an}` : `상대${++en}`;
|
|
const cls = (p.character ?? '').replace(/_PC_C$/, '');
|
|
return { puuid: p.puuid, name, tag: 'KR1', team: ally ? 'Blue' : 'Red', ally, character: AGK[p.character] ?? { id: cls, name: cls, icon: null }, userId: user?.id, kills: 0, deaths: 0, assists: 0, score: 0, rank: null };
|
|
});
|
|
const ref = (i) => (i >= 0 ? { puuid: players[i].puuid, name: players[i].name, team: players[i].team, character: players[i].character, userId: players[i].userId } : null);
|
|
const mEvents = [];
|
|
const mUtts = [];
|
|
const rounds = [];
|
|
let score = { ally: 0, enemy: 0 };
|
|
r.rounds.forEach((rd, k) => {
|
|
const next = r.rounds[k + 1];
|
|
const startedAt = base + (rd.combat >= 0 ? rd.combat - 30000 : rd.buy);
|
|
const endedAt = base + (next ? (next.combat >= 0 ? next.combat - 30000 : next.buy) : r.durationMs);
|
|
const kills = r.kills.filter(([t]) => t >= rd.buy && (!next || t < next.buy));
|
|
const allyDead = kills.filter(([, , v]) => allyIdx.has(v)).length;
|
|
const enemyDead = kills.filter(([, , v]) => !allyIdx.has(v)).length;
|
|
const win = enemyDead >= allyDead;
|
|
win ? score.ally++ : score.enemy++;
|
|
rounds.push({ num: rd.num, startedAt, endedAt, win, result: 'Elimination', score: { ...score }, economy: {}, players: {} });
|
|
const label = (ts) => {
|
|
const inRound = ts - startedAt;
|
|
return { primary: inRound < 30000 ? `R${rd.num} · 구매` : `R${rd.num} · ${fmtClock(inRound - 30000)}`, secondary: fmtClock(ts - base), real: ts };
|
|
};
|
|
for (const [t, ki, vi] of kills) {
|
|
const ts = base + t;
|
|
if (ki >= 0) players[ki].kills++;
|
|
if (vi >= 0) players[vi].deaths++;
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts, game: 'valorant', matchId: id, type: 'kill', round: rd.num, data: { killer: ref(ki), victim: ref(vi), assists: [], weapon: null, location: null, ally: ki >= 0 && allyIdx.has(ki) }, time: label(ts) });
|
|
}
|
|
mEvents.push({ kind: 'event', id: nid('ev_'), ts: endedAt - 1, game: 'valorant', matchId: id, type: 'round_end', round: rd.num, data: { round: rd.num, win, result: 'Elimination', score: { ...score } }, time: label(endedAt - 1) });
|
|
// 대화: 라운드마다 3~5개
|
|
const n = irange(3, 5);
|
|
for (let j = 0; j < n; j++) {
|
|
const ts = startedAt + irange(5, Math.max(6, Math.floor((endedAt - startedAt) / 1000) - 3)) * 1000;
|
|
mUtts.push(addUtt({ user: pick(SPEAKERS), ts, text: pick(VAL_LINES), game: { type: 'valorant', matchId: id, round: rd.num }, time: label(ts) }));
|
|
}
|
|
});
|
|
const endedAt = base + r.durationMs;
|
|
events.push(...mEvents);
|
|
const T = { xMultiplier: 8.1e-5, yMultiplier: -8.1e-5, xScalarToAdd: 0.5, yScalarToAdd: 0.5 };
|
|
const summary = {
|
|
id, game: 'valorant', startedAt: base, endedAt, map: { id: '/Game/Maps/Infinity/Infinity', name: '어비스', image: process.env.GVR_MOCK_REPLAY_MAP_FILE ? A('replay-map.png') : null },
|
|
mode: '경쟁전', win: score.ally > score.enemy, score, status: 'complete', participants: SPEAKERS.map((u) => u.id),
|
|
};
|
|
matches.push({ ...summary, players, rounds, events: mEvents, utterances: mUtts, mapTransform: { valorant: T }, replayPath: file });
|
|
}
|
|
if (process.env.GVR_MOCK_REPLAY) genReplayDemo(process.env.GVR_MOCK_REPLAY);
|
|
|
|
// Riot 경기 기록에서 가져온 경기 (v1.9.0, 겜녹이가 꺼져 있을 때 한 경기): 녹음 · 타임라인 없음
|
|
{
|
|
const base = matches.find((m) => m.game === 'valorant');
|
|
const MAPS = ['어센트', '바인드', '헤이븐', '로터스', '선셋'];
|
|
for (let i = 0; i < 70; i++) {
|
|
const start = NOW - (1 + i * 0.37) * 24 * 60 * MIN;
|
|
const ally = 13;
|
|
const enemy = (i * 5) % 12;
|
|
const win = i % 3 !== 0;
|
|
matches.push({
|
|
...base,
|
|
id: `val-hist-${i}`,
|
|
startedAt: start,
|
|
endedAt: start + 38 * MIN,
|
|
map: { ...base.map, name: MAPS[i % MAPS.length] },
|
|
mode: i % 7 === 3 ? '데스매치' : i % 4 === 0 ? '일반전' : '경쟁전',
|
|
win,
|
|
score: win ? { ally, enemy } : { ally: enemy, enemy: ally },
|
|
status: 'complete',
|
|
participants: [],
|
|
source: 'history',
|
|
utterances: [],
|
|
events: [],
|
|
replayPath: undefined,
|
|
});
|
|
}
|
|
}
|
|
|
|
// ── 내보내기 ─────────────────────────────────────────
|
|
export const db = {
|
|
users: USERS,
|
|
utterances,
|
|
events,
|
|
matches,
|
|
sortAll() {
|
|
utterances.sort((a, b) => a.ts - b.ts);
|
|
events.sort((a, b) => a.ts - b.ts);
|
|
for (const m of matches) {
|
|
m.utterances.sort((a, b) => a.ts - b.ts);
|
|
m.events.sort((a, b) => a.ts - b.ts);
|
|
}
|
|
},
|
|
nextId: (p) => nid(p),
|
|
makeWords,
|
|
addLiveUtterance(user, text) {
|
|
const ts = Date.now();
|
|
return addUtt({ user, ts, text, status: 'pending', time: realLabel(ts) });
|
|
},
|
|
REAL_LINES,
|
|
SPEAKERS,
|
|
};
|
|
db.sortAll();
|