5~7단계 게임: 숨긴 유튜브 동기화 재생(전원 준비·버퍼링이면 모두 멈춤·30초 늦은 사람 제외·재생 오류 곡 교체), 정답 판정·점수·정답 블록, 입력 중·단축키, 힌트·스킵·다시듣기 투표, 3모드, 결과·이어풀기·다시 하기, 퀴즈 저장·불러오기 + 마지막 사람이 나가면 방 바로 닫기
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
100
packages/shared/src/answer.test.ts
Normal file
100
packages/shared/src/answer.test.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { artistCandidates, chosung, hintText, isCorrect, titleCandidates, type Strictness } from './answer';
|
||||
|
||||
const STRICT: Strictness = { space: true, number: true, symbol: true };
|
||||
const LOOSE: Strictness = { space: false, number: false, symbol: false };
|
||||
const st = (p: Partial<Strictness>): Strictness => ({ ...STRICT, ...p });
|
||||
const song = (title: string, artist = '가수', extra: { titleAliases?: string[]; artistAliases?: string[] } = {}) => ({ title, artist, ...extra });
|
||||
|
||||
describe('answer candidates (docs/05 정규화)', () => {
|
||||
test('brackets split into each part and the joined form', () => {
|
||||
expect(titleCandidates('사랑을 했다(LOVE SCENARIO)')).toEqual(expect.arrayContaining(['사랑을 했다', 'love scenario', '사랑을 했다 love scenario']));
|
||||
});
|
||||
test('feat./prod./OST/원곡 tails are dropped', () => {
|
||||
expect(titleCandidates('Love wins all (Prod. 누군가)')).toContain('love wins all');
|
||||
expect(titleCandidates('취중고백 (feat. 누구)')).toContain('취중고백');
|
||||
expect(titleCandidates('Stay With Me [도깨비 OST]')).toContain('stay with me');
|
||||
expect(titleCandidates('밤양갱 feat. 누구')).toContain('밤양갱');
|
||||
});
|
||||
test('multi-artist credits accept any one name, `A (B)` both names', () => {
|
||||
expect(artistCandidates('허각, 정은지')).toEqual(expect.arrayContaining(['허각', '정은지']));
|
||||
expect(artistCandidates('RESCENE (리센느)')).toEqual(expect.arrayContaining(['rescene', '리센느']));
|
||||
expect(artistCandidates('아이유', ['IU'])).toContain('iu');
|
||||
});
|
||||
});
|
||||
|
||||
describe('정답인식 toggles (docs/12 Q2): on = must match, off = ignored', () => {
|
||||
test('case and outer spaces never matter', () => {
|
||||
expect(isCorrect(' bubble pop! ', song('Bubble Pop!'), 'title', STRICT)).toBe(true);
|
||||
expect(isCorrect('BUBBLE POP!', song('Bubble Pop!'), 'title', STRICT)).toBe(true);
|
||||
});
|
||||
test('띄어쓰기', () => {
|
||||
expect(isCorrect('사건의지평선', song('사건의 지평선'), 'title', STRICT)).toBe(false);
|
||||
expect(isCorrect('사건의지평선', song('사건의 지평선'), 'title', st({ space: false }))).toBe(true);
|
||||
expect(isCorrect('사건 의지 평선', song('사건의 지평선'), 'title', st({ space: false }))).toBe(true);
|
||||
});
|
||||
test('특수문자', () => {
|
||||
expect(isCorrect('bubble pop', song('Bubble Pop!'), 'title', STRICT)).toBe(false);
|
||||
expect(isCorrect('bubble pop', song('Bubble Pop!'), 'title', st({ symbol: false }))).toBe(true);
|
||||
});
|
||||
test('숫자', () => {
|
||||
expect(isCorrect('24시간이 모자라', song('24시간이 모자라'), 'title', STRICT)).toBe(true);
|
||||
expect(isCorrect('시간이 모자라', song('24시간이 모자라'), 'title', STRICT)).toBe(false);
|
||||
expect(isCorrect('시간이 모자라', song('24시간이 모자라'), 'title', st({ number: false }))).toBe(true);
|
||||
});
|
||||
test('no fuzzy matching', () => {
|
||||
expect(isCorrect('사건의 지평산', song('사건의 지평선'), 'title', LOOSE)).toBe(false);
|
||||
expect(isCorrect('사건의', song('사건의 지평선'), 'title', LOOSE)).toBe(false);
|
||||
});
|
||||
test('admin aliases absorb common spellings', () => {
|
||||
expect(isCorrect('good day', song('좋은 날', '아이유', { titleAliases: ['Good Day'] }), 'title', STRICT)).toBe(true);
|
||||
expect(isCorrect('광', song('광 (狂)', 'SG워너비'), 'title', STRICT)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('empty-key guard (docs/05 빈 비교 키 방지): sta_songs number/symbol titles', () => {
|
||||
const titles = ['0+0', '160', '365', '365일', '3! 4!', '3!4!', '11:11', '2 L0VE', 'A', 'Y'];
|
||||
test('every fixed title is answerable by typing it exactly, under every toggle combination', () => {
|
||||
for (const t of titles)
|
||||
for (const space of [true, false])
|
||||
for (const number of [true, false])
|
||||
for (const symbol of [true, false]) expect([t, isCorrect(t, song(t), 'title', { space, number, symbol })]).toEqual([t, true]);
|
||||
});
|
||||
test('an empty chat or a chat that only loses its digits never matches', () => {
|
||||
expect(isCorrect('', song('160'), 'title', LOOSE)).toBe(false);
|
||||
expect(isCorrect('!!!', song('160'), 'title', LOOSE)).toBe(false);
|
||||
expect(isCorrect('+', song('0+0'), 'title', st({ number: false }))).toBe(false);
|
||||
expect(isCorrect('일', song('365일'), 'title', st({ number: false }))).toBe(false);
|
||||
expect(isCorrect('365', song('160'), 'title', LOOSE)).toBe(false);
|
||||
});
|
||||
test('kept digits stay strict but other toggles still apply', () => {
|
||||
expect(isCorrect('0 + 0', song('0+0'), 'title', LOOSE)).toBe(true);
|
||||
expect(isCorrect('00', song('0+0'), 'title', LOOSE)).toBe(true);
|
||||
expect(isCorrect('34', song('3! 4!'), 'title', LOOSE)).toBe(true);
|
||||
expect(isCorrect('3 4', song('3! 4!'), 'title', st({ symbol: false }))).toBe(true);
|
||||
expect(isCorrect('1111', song('11:11'), 'title', LOOSE)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('정답방식', () => {
|
||||
const gwang = song('광 (狂)', 'SG워너비');
|
||||
test('가수만: one of several artists is enough', () => {
|
||||
expect(isCorrect('정은지', song('짝사랑', '허각, 정은지'), 'artist', STRICT)).toBe(true);
|
||||
expect(isCorrect('짝사랑', song('짝사랑', '허각, 정은지'), 'artist', STRICT)).toBe(false);
|
||||
});
|
||||
test('제목+가수: either order, separators - / , or space, or none', () => {
|
||||
for (const t of ['광 sg워너비', 'sg워너비 광', 'sg워너비-광', '광/sg워너비', '광 - SG워너비', '광, sg워너비', '광sg워너비']) expect([t, isCorrect(t, gwang, 'both', STRICT)]).toEqual([t, true]);
|
||||
expect(isCorrect('광', gwang, 'both', STRICT)).toBe(false);
|
||||
expect(isCorrect('sg워너비', gwang, 'both', STRICT)).toBe(false);
|
||||
expect(isCorrect('광 sg워너비 짱', gwang, 'both', STRICT)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('초성 hint', () => {
|
||||
test('Hangul initials, other words first letter, spaces kept', () => {
|
||||
expect(chosung('사건의 지평선')).toBe('ㅅㄱㅇ ㅈㅍㅅ');
|
||||
expect(chosung('Love wins all')).toBe('L___ W___ A__');
|
||||
expect(hintText({ title: '광 (狂)', artist: 'SG워너비' }, 'both')).toBe('ㄱ (狂) - S_ㅇㄴㅂ');
|
||||
expect(hintText({ title: '취중고백 (feat. 누구)', artist: '김민석' }, 'title')).toBe('ㅊㅈㄱㅂ');
|
||||
});
|
||||
});
|
||||
183
packages/shared/src/answer.ts
Normal file
183
packages/shared/src/answer.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* Quiz answer judge (docs/05 정답 판정, docs/12 Q2). Shared by the server (the judge) and the browser (nothing secret here).
|
||||
* - Candidates: the title as is, without feat/prod/OST tails, without brackets, each bracketed part alone, admin aliases
|
||||
* - 정답인식 toggles: on = that element must match too, off = ignored. Case and outer spaces never matter
|
||||
* - Empty keys never match; a candidate that loses all its letters keeps digits, then symbols (`0+0`, `160`, `11:11`)
|
||||
* - No fuzzy matching (유즈맵처럼 정확히)
|
||||
*/
|
||||
|
||||
export interface Strictness {
|
||||
space: boolean;
|
||||
number: boolean;
|
||||
symbol: boolean;
|
||||
}
|
||||
export type AnswerMode = 'title' | 'artist' | 'both';
|
||||
|
||||
export interface AnswerSong {
|
||||
title: string;
|
||||
/** Display artist ("허각, 정은지"). */
|
||||
artist: string;
|
||||
/** Admin aliases (song_aliases) for each part; artist aliases from artist_aliases go in artistAliases too. */
|
||||
titleAliases?: string[];
|
||||
artistAliases?: string[];
|
||||
}
|
||||
|
||||
const BRACKET = /[([{【「『<]([^)\]}】」』>]*)[)\]}】」』>]/g;
|
||||
/** Tails that are not part of the name people say: feat., (Prod. …), [… OST], (원곡: …), (inst), (Remastered)… */
|
||||
const TAIL_WORD = /^(feat\.?|ft\.?|prod\.?|with|from|원곡|inst\.?|instrumental|remaster(ed)?|bonus|explicit|clean|sped up|live|ver\.?|version|mr)\b/i;
|
||||
|
||||
function base(s: string): string {
|
||||
return s.normalize('NFKC').toLowerCase().replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
function isTail(inner: string): boolean {
|
||||
const t = inner.trim();
|
||||
return TAIL_WORD.test(t) || /\bost\b/i.test(t) || /\b(ver|version)\.?$/i.test(t);
|
||||
}
|
||||
|
||||
/** Title spellings that count (docs/05 정규화 2~4). */
|
||||
export function titleCandidates(title: string, aliases: string[] = []): string[] {
|
||||
const out = new Set<string>();
|
||||
const add = (s: string) => {
|
||||
const b = base(s);
|
||||
if (b) out.add(b);
|
||||
};
|
||||
add(title);
|
||||
// drop tails: `(feat. X)`, `[태양의 후예 OST]`, and bare `feat. X` at the end
|
||||
const noTail = title.replace(BRACKET, (m, inner: string) => (isTail(inner) ? ' ' : m)).replace(/\s+(feat\.?|ft\.?|prod\.?)\s.*$/i, ' ');
|
||||
add(noTail);
|
||||
const parts = [...noTail.matchAll(BRACKET)].map((m) => m[1]!).filter((x) => x.trim());
|
||||
const outside = noTail.replace(BRACKET, ' ');
|
||||
add(outside);
|
||||
for (const p of parts) add(p);
|
||||
// `사랑을 했다(LOVE SCENARIO)` → also `사랑을 했다 LOVE SCENARIO`
|
||||
if (parts.length) add(`${outside} ${parts.join(' ')}`);
|
||||
for (const a of aliases) add(a);
|
||||
return [...out];
|
||||
}
|
||||
|
||||
/** Artist spellings: the whole credit, each name of a multi-artist credit, `RESCENE (리센느)` → both names, aliases. */
|
||||
export function artistCandidates(artist: string, aliases: string[] = []): string[] {
|
||||
const out = new Set<string>();
|
||||
const add = (s: string) => {
|
||||
const b = base(s);
|
||||
if (b) out.add(b);
|
||||
};
|
||||
const names = [artist, ...artist.split(/\s*(?:,|&|\/|\bx\b|\band\b|·|\bfeat\.?|\bft\.?|\bwith\b)\s*/i)];
|
||||
for (const n of names) {
|
||||
add(n);
|
||||
const inner = /^(.*?)\s*[((]([^))]+)[))]\s*$/.exec(n.trim());
|
||||
if (inner) (add(inner[1]!), add(inner[2]!));
|
||||
}
|
||||
for (const a of aliases) add(a);
|
||||
return [...out];
|
||||
}
|
||||
|
||||
const LETTER = /\p{L}/u;
|
||||
const DIGIT = /\p{N}/gu;
|
||||
/** Symbols = anything that is not a letter, digit or space. */
|
||||
const SYMBOL = /[^\p{L}\p{N}\s]/gu;
|
||||
|
||||
/** Comparison key at a preserve level: 0 = apply the toggles, 1 = keep digits, 2 = keep digits and symbols. */
|
||||
function keyAt(s: string, st: Strictness, level: 0 | 1 | 2): string {
|
||||
let k = base(s);
|
||||
if (!st.symbol && level < 2) k = k.replace(SYMBOL, ' ');
|
||||
if (!st.number && level < 1) k = k.replace(DIGIT, ' ');
|
||||
k = k.replace(/\s+/g, ' ').trim();
|
||||
if (!st.space) k = k.replace(/\s/g, '');
|
||||
return k;
|
||||
}
|
||||
|
||||
/** The preserve level a candidate needs so it does not vanish (docs/05 빈 비교 키 방지). */
|
||||
function levelFor(cand: string, st: Strictness): 0 | 1 | 2 {
|
||||
const raw = base(cand).replace(/\s/g, '');
|
||||
for (const lv of [0, 1] as const) {
|
||||
const k = keyAt(cand, st, lv).replace(/\s/g, '');
|
||||
if (!k) continue;
|
||||
if (!LETTER.test(k) && lv === 0 && /\p{N}/u.test(raw)) continue; // only symbols left: keep the digits
|
||||
if (raw.length >= 2 && k.length < 2) continue;
|
||||
return lv;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
/** Does `text` equal one of the candidates under the room's 정답인식? */
|
||||
export function matchesAny(text: string, candidates: string[], st: Strictness): boolean {
|
||||
for (const c of candidates) {
|
||||
const lv = levelFor(c, st);
|
||||
const ck = keyAt(c, st, lv);
|
||||
if (!ck) continue;
|
||||
const tk = keyAt(text, st, lv);
|
||||
if (tk && tk === ck) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Separators allowed between title and artist in 제목+가수 (docs/05): `- / , ·` and spaces. */
|
||||
const SEP = /^[\s\-/,·:|~]*$/;
|
||||
|
||||
/**
|
||||
* Judge one chat line (docs/05 정답방식별 판정). 제목+가수: both in one line, either order, split anywhere
|
||||
* (`광 sg워너비`, `sg워너비-광`, `광/sg워너비`, `광sg워너비`).
|
||||
*/
|
||||
export function isCorrect(text: string, song: AnswerSong, mode: AnswerMode, st: Strictness): boolean {
|
||||
const t = base(text);
|
||||
if (!t) return false;
|
||||
const titles = titleCandidates(song.title, song.titleAliases);
|
||||
const artists = artistCandidates(song.artist, song.artistAliases);
|
||||
if (mode === 'title') return matchesAny(t, titles, st);
|
||||
if (mode === 'artist') return matchesAny(t, artists, st);
|
||||
const chars = [...t];
|
||||
for (let i = 1; i < chars.length; i++) {
|
||||
// try every split, allowing separator runs around it
|
||||
const left = chars.slice(0, i).join('');
|
||||
for (let j = i; j < chars.length; j++) {
|
||||
const mid = chars.slice(i, j).join('');
|
||||
if (!SEP.test(mid)) break;
|
||||
const right = chars.slice(j).join('');
|
||||
const l = left.replace(/[\s\-/,·:|~]+$/, '');
|
||||
const r = right.replace(/^[\s\-/,·:|~]+/, '');
|
||||
if (!l || !r) continue;
|
||||
if ((matchesAny(l, titles, st) && matchesAny(r, artists, st)) || (matchesAny(l, artists, st) && matchesAny(r, titles, st))) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const CHO = ['ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ'];
|
||||
|
||||
/** 초성 hint (docs/05 힌트): Hangul → initial consonant, other words → first letter + `_`, spaces and symbols kept. */
|
||||
export function chosung(s: string): string {
|
||||
return s
|
||||
.normalize('NFC')
|
||||
.split(/(\s+)/)
|
||||
.map((w) => {
|
||||
if (/^\s+$/.test(w)) return w;
|
||||
let seenLatin = false;
|
||||
return [...w]
|
||||
.map((ch) => {
|
||||
const code = ch.charCodeAt(0);
|
||||
if (code >= 0xac00 && code <= 0xd7a3) {
|
||||
seenLatin = false;
|
||||
return CHO[Math.floor((code - 0xac00) / 588)]!;
|
||||
}
|
||||
if (/\p{L}/u.test(ch)) {
|
||||
if (seenLatin) return '_';
|
||||
seenLatin = true;
|
||||
return ch.toUpperCase();
|
||||
}
|
||||
seenLatin = false;
|
||||
return ch;
|
||||
})
|
||||
.join('');
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
/** What the hint shows for the room's 정답방식: `ㄱ (ㄱ) - ㅅㄱㅇㄴㅂ` style. */
|
||||
export function hintText(song: { title: string; artist: string }, mode: AnswerMode): string {
|
||||
const title = song.title.replace(BRACKET, (m, inner: string) => (isTail(inner) ? '' : m)).trim();
|
||||
if (mode === 'title') return chosung(title);
|
||||
if (mode === 'artist') return chosung(song.artist);
|
||||
return `${chosung(title)} - ${chosung(song.artist)}`;
|
||||
}
|
||||
@@ -4,3 +4,4 @@ export * from './types';
|
||||
export * from './match-key';
|
||||
export * from './room-config';
|
||||
export * from './room-config-schema';
|
||||
export * from './answer';
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
export * from './nickname';
|
||||
export * from './types';
|
||||
export * from './room-config';
|
||||
export type { ChatLine, RoomView, RoomPlayerView, ServerMessage } from './protocol';
|
||||
export type { ChatLine, RoomView, RoomPlayerView, ServerMessage, GameView, GameScore, GameHistoryItem, GamePhase } from './protocol';
|
||||
|
||||
@@ -23,6 +23,21 @@ export const ClientMessage = z.discriminatedUnion('t', [
|
||||
z.object({ t: z.literal('host'), userId: z.string().max(40) }),
|
||||
/** Room chat (docs/06; stage 4 = waiting room only). `n` echoes back so the sender can confirm its optimistic line. */
|
||||
z.object({ t: z.literal('chat'), text: z.string().min(1).max(CHAT_MAX), n: z.string().max(24).optional() }),
|
||||
// ---- game (docs/05, stage 5~7)
|
||||
/** Host: start a game from the waiting room. */
|
||||
z.object({ t: z.literal('start') }),
|
||||
/** Playback report for question `n` (docs/12 Q1): ready = buffered at the position, blocked = no sound, stall = buffering, clipEnd, error = player error code. */
|
||||
z.object({ t: z.literal('audio'), n: z.number().int().min(1), ev: z.enum(['ready', 'blocked', 'stall', 'clipEnd', 'error']), code: z.number().int().optional() }),
|
||||
/** Vote toggles (docs/05 스킵·힌트, docs/12 Q3·Q4). */
|
||||
z.object({ t: z.literal('vote'), kind: z.enum(['skip', 'hint', 'replay']) }),
|
||||
z.object({ t: z.literal('typing'), on: z.boolean() }),
|
||||
/** Host game controls: pause/resume, end now, 이어풀기, 다시 하기 (back to the waiting room). */
|
||||
z.object({ t: z.literal('game'), action: z.enum(['pause', 'resume', 'end', 'continue', 'again']) }),
|
||||
/** Host: leave this player out of this question only (not ready for 30s, docs/12 Q1). */
|
||||
z.object({ t: z.literal('exclude'), userId: z.string().max(40) }),
|
||||
/** Host (Discord account): save / load the quiz (docs/12 Q8). */
|
||||
z.object({ t: z.literal('save'), name: z.string().trim().min(1).max(40) }),
|
||||
z.object({ t: z.literal('load'), id: z.number().int().positive() }),
|
||||
]);
|
||||
export type ClientMessage = z.infer<typeof ClientMessage>;
|
||||
|
||||
@@ -56,6 +71,72 @@ export interface ChatLine {
|
||||
text: string;
|
||||
/** Sender's nonce for its optimistic line. */
|
||||
n?: string;
|
||||
/**
|
||||
* 정답 줄 + 5줄 블록 as one item (docs/06): the correct chat (or a system line when nobody got it) and `노래제목 - 가수`.
|
||||
* none = skipped / time over (grey block).
|
||||
*/
|
||||
answer?: { text: string; none?: boolean };
|
||||
}
|
||||
|
||||
export type GamePhase = 'prepare' | 'play' | 'reveal' | 'result';
|
||||
|
||||
export interface GameScore {
|
||||
id: string;
|
||||
nickname: string;
|
||||
score: number;
|
||||
correct: number;
|
||||
/** Average answer time of the questions this player got (tie-break, docs/05 점수). */
|
||||
avgMs: number | null;
|
||||
online: boolean;
|
||||
}
|
||||
|
||||
export interface GameHistoryItem {
|
||||
n: number;
|
||||
title: string;
|
||||
artist: string;
|
||||
year: number | null;
|
||||
level: number | null;
|
||||
genres: string[];
|
||||
videoId: string | null;
|
||||
winnerId: string | null;
|
||||
winner: string | null;
|
||||
ms: number | null;
|
||||
how: 'correct' | 'skip' | 'timeout' | 'end';
|
||||
}
|
||||
|
||||
/** Game state for everyone (docs/05). Never has the video id or the answer of the running question. */
|
||||
export interface GameView {
|
||||
phase: GamePhase;
|
||||
n: number;
|
||||
total: number;
|
||||
mode: import('./room-config').Mode;
|
||||
/** This question's players (heard it from the start); others join at the next one. */
|
||||
participants: string[];
|
||||
excluded: string[];
|
||||
/** Not ready yet (prepare, or re-prepare after a pause), with the server time they started waiting. */
|
||||
waiting: { id: string; since: number }[];
|
||||
/** Everyone stopped (docs/12 Q1): buffering / no sound / the host paused. Timers do not run meanwhile. */
|
||||
paused: null | { reason: 'stall' | 'blocked' | 'host'; who: string[] };
|
||||
/** Server time the music (re)starts: before it the screen counts 3·2·1. */
|
||||
startAt: number | null;
|
||||
/** Question clock: elapsedMs + (runningSince ? serverNow - runningSince : 0); limitMs null = no limit. */
|
||||
clock: { elapsedMs: number; runningSince: number | null; limitMs: number | null };
|
||||
/** Seconds of the clip (null = 끝까지 with unknown length) for the progress bar. */
|
||||
clipSec: number | null;
|
||||
clipOver: boolean;
|
||||
hint: string | null;
|
||||
/** 자동 공개 at this many seconds (null = none / 직접선택). */
|
||||
hintAtSec: number | null;
|
||||
lyrics: string[] | null;
|
||||
votes: { skip: string[]; hint: string[]; replay: string[] };
|
||||
need: { skip: number | null; hint: number | null; replay: number | null };
|
||||
scores: GameScore[];
|
||||
/** Questions of this game so far, newest last; during reveal the last one is the current question. */
|
||||
history: GameHistoryItem[];
|
||||
/** Server time the reveal ends. */
|
||||
revealUntil: number | null;
|
||||
/** 이어풀기 possible: songs left that this quiz has not played. */
|
||||
left: number;
|
||||
}
|
||||
|
||||
export type ServerMessage =
|
||||
@@ -63,6 +144,17 @@ export type ServerMessage =
|
||||
| { t: 'room'; room: RoomView }
|
||||
| { t: 'left'; code: string; reason: 'leave' | 'kicked' | 'closed' | 'elsewhere' }
|
||||
| { t: 'chat'; code: string; line: ChatLine }
|
||||
/** 정답 줄 + 5줄 블록 in one message (docs/06). */
|
||||
| { t: 'answer'; code: string; line: ChatLine }
|
||||
| { t: 'game'; code: string; game: GameView | null }
|
||||
/** Load the video muted at `startSec`, buffer, report audio ready (docs/12 Q1). */
|
||||
| { t: 'prepare'; code: string; n: number; videoId: string; startSec: number; endSec: number | null }
|
||||
/** Everyone unmutes and plays from `atSec` at server time `startAt`; stop at `endSec` by playback position. */
|
||||
| { t: 'play'; code: string; n: number; startAt: number; atSec: number; endSec: number | null }
|
||||
/** Stop now (someone is buffering / the host paused / the clip is over). */
|
||||
| { t: 'pause'; code: string; n: number }
|
||||
| { t: 'typing'; code: string; ids: string[] }
|
||||
| { t: 'saved'; id: number; name: string }
|
||||
/** Recent lines for someone who just joined (or came back). */
|
||||
| { t: 'chatlog'; code: string; lines: ChatLine[] }
|
||||
| { t: 'notice'; text: string }
|
||||
|
||||
Reference in New Issue
Block a user