내 Riot 경기 기록 가져오기: 발로란트 match-history · 롤 LCU 기록을 게임 중이 아닐 때 30분마다 훑어 앱이 잡지 못한 경기를 source=history 로 저장 (처음은 끝까지, 다음부터 새 경기만, 상세 없는 경기는 건너뜀) · /api/matches has=timeline|voice 필터 · 경기 요약 source · voice · 녹음 없는 기록 경기의 킬 · 라운드는 타임라인 · 기록 관리에서 뺌
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,12 @@ export interface MockState {
|
||||
lolGameId: number;
|
||||
lolHistoryReady: boolean;
|
||||
lolStart: number;
|
||||
/** 발로란트 경기 기록 (새것부터): MatchID → 경기 시작 시각 */
|
||||
valHistory: { MatchID: string; GameStartTime: number }[];
|
||||
/** 롤 경기 기록 (LCU, 새것부터) */
|
||||
lolHistoryList: { gameId: number; gameCreation: number }[];
|
||||
/** 요청 기록 (경로) */
|
||||
hits: string[];
|
||||
}
|
||||
|
||||
export async function startMockRiot(dir: string) {
|
||||
@@ -38,6 +44,9 @@ export async function startMockRiot(dir: string) {
|
||||
lolGameId: 7001,
|
||||
lolHistoryReady: false,
|
||||
lolStart: 0,
|
||||
valHistory: [],
|
||||
lolHistoryList: [],
|
||||
hits: [],
|
||||
};
|
||||
const password = 'pw-test';
|
||||
const presence = () => {
|
||||
@@ -52,7 +61,7 @@ export async function startMockRiot(dir: string) {
|
||||
};
|
||||
return Buffer.from(JSON.stringify(priv)).toString('base64');
|
||||
};
|
||||
const routes: [RegExp, (m: RegExpMatchArray, auth: string) => [number, any]][] = [
|
||||
const routes: [RegExp, (m: RegExpMatchArray, auth: string, url: URL) => [number, any]][] = [
|
||||
// ---- Riot Client local
|
||||
[/^\/entitlements\/v1\/token$/, () => [200, { accessToken: 'acc-token', token: 'ent-token', subject: SELF, issuer: 'x' }]],
|
||||
[
|
||||
@@ -69,7 +78,23 @@ export async function startMockRiot(dir: string) {
|
||||
() => [200, { MatchID: st.valMatchId, MapID: ASCENT, Players: [{ Subject: SELF, TeamID: 'Blue', CharacterID: 'add6443a-41bd-e414-f6ad-e58d267f4e95' }] }],
|
||||
],
|
||||
// ---- pd
|
||||
[/^\/match-details\/v1\/matches\/(.+)$/, (_m, auth) => (auth.startsWith('Bearer ') && st.valState !== 'INGAME' ? [200, makeValDetails(st.valStart)] : [404, {}])],
|
||||
[
|
||||
/^\/match-history\/v1\/history\/(.+)$/,
|
||||
(_m, auth, url) => {
|
||||
if (!auth.startsWith('Bearer ')) return [401, {}];
|
||||
const s = Number(url.searchParams.get('startIndex') ?? 0);
|
||||
const e = Number(url.searchParams.get('endIndex') ?? 20);
|
||||
return [200, { Subject: SELF, BeginIndex: s, EndIndex: e, Total: st.valHistory.length, History: st.valHistory.slice(s, e).map((h) => ({ ...h, QueueID: 'competitive' })) }];
|
||||
},
|
||||
],
|
||||
[
|
||||
/^\/match-details\/v1\/matches\/(.+)$/,
|
||||
(m, auth) => {
|
||||
const h = st.valHistory.find((x) => x.MatchID === m[1]);
|
||||
if (h) return m[1].startsWith('gone') ? [404, {}] : [200, { ...makeValDetails(h.GameStartTime), matchInfo: { ...makeValDetails(h.GameStartTime).matchInfo, matchId: h.MatchID } }];
|
||||
return auth.startsWith('Bearer ') && st.valState !== 'INGAME' ? [200, makeValDetails(st.valStart)] : [404, {}];
|
||||
},
|
||||
],
|
||||
// ---- LoL Live Client Data
|
||||
[/^\/liveclientdata\/allgamedata$/, () => (st.lolLive ? [200, st.lolLive] : [404, {}])],
|
||||
// ---- LCU
|
||||
@@ -79,7 +104,23 @@ export async function startMockRiot(dir: string) {
|
||||
[/^\/lol-chat\/v1\/conversations$/, () => [200, st.lolPhase === 'ChampSelect' ? [{ id: 'cs1@champ-select.kr', type: 'championSelect' }] : []]],
|
||||
[/^\/lol-chat\/v1\/conversations\/(.+)\/messages$/, () => [200, [{ id: 'msg1', body: '정글 갱 갈게요', fromSummonerId: 11, timestamp: new Date(Date.now() - 5000).toISOString(), type: 'groupchat' }]]],
|
||||
[/^\/lol-summoner\/v1\/summoners\/(\d+)$/, () => [200, { gameName: '민수' }]],
|
||||
[/^\/lol-match-history\/v1\/games\/(\d+)$/, () => (st.lolHistoryReady ? [200, lolHistory()] : [404, {}])],
|
||||
[
|
||||
/^\/lol-match-history\/v1\/products\/lol\/current-summoner\/matches$/,
|
||||
(_m, _a, url) => {
|
||||
const s = Number(url.searchParams.get('begIndex') ?? 0);
|
||||
const e = Number(url.searchParams.get('endIndex') ?? 20);
|
||||
const games = st.lolHistoryList.slice(s, e);
|
||||
return [200, { games: { gameCount: games.length, gameIndexBegin: s, gameIndexEnd: e, games } }];
|
||||
},
|
||||
],
|
||||
[
|
||||
/^\/lol-match-history\/v1\/games\/(\d+)$/,
|
||||
(m) => {
|
||||
const h = st.lolHistoryList.find((x) => String(x.gameId) === m[1]);
|
||||
if (h) return [200, { ...lolHistory(), gameId: h.gameId, gameCreation: h.gameCreation }];
|
||||
return st.lolHistoryReady ? [200, lolHistory()] : [404, {}];
|
||||
},
|
||||
],
|
||||
[/^\/lol-match-history\/v1\/game-timelines\/(\d+)$/, () => (st.lolHistoryReady ? [200, lolTimeline()] : [404, {}])],
|
||||
];
|
||||
const server = https.createServer({ key: fs.readFileSync(key), cert: fs.readFileSync(cert) }, (req, res) => {
|
||||
@@ -87,7 +128,8 @@ export async function startMockRiot(dir: string) {
|
||||
for (const [re, fn] of routes) {
|
||||
const m = url.pathname.match(re);
|
||||
if (!m) continue;
|
||||
const [code, body] = fn(m, String(req.headers.authorization || ''));
|
||||
st.hits.push(url.pathname);
|
||||
const [code, body] = fn(m, String(req.headers.authorization || ''), url);
|
||||
res.writeHead(code, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify(body));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user