방 설정 "다음 문제까지"(5/10/15/30초, 기본 5초)와 "다음문제인원(이상)" 투표: 정답 공개 시간을 방마다 고르고, 공개 중 ⏭ 다음 문제(Ctrl+K) 표가 기준 이상이면 바로 넘어감(마지막 문제는 결과로). 공개 화면에 남은 초, 방 카드 요약에 '공개 N초', 관리자 기본값·잠금
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -260,7 +260,7 @@ describe('game flow', () => {
|
||||
const p = await nextOf(a, 'play', 0);
|
||||
await sleep(p.startAt - Date.now() + 80);
|
||||
let g = await gameWhere(a, (x) => x.phase === 'play');
|
||||
expect(g.need).toEqual({ skip: 2, hint: 1, replay: 1 });
|
||||
expect(g.need).toEqual({ skip: 2, hint: 1, replay: 1, next: 1 });
|
||||
a.send({ t: 'vote', kind: 'hint' });
|
||||
g = await gameWhere(a, (x) => !!x.hint);
|
||||
expect(g.hint).toMatch(/^ㄴㄹ\d+$/);
|
||||
@@ -296,6 +296,53 @@ describe('game flow', () => {
|
||||
stop();
|
||||
});
|
||||
|
||||
test('다음 문제까지: the reveal lasts the room revealSec; 다음 문제 votes (all online) move on at once, the last one to the results', async () => {
|
||||
seedLater(() => seed(2));
|
||||
const { cls } = await room(['방장', '철수'], { skipVotes: '1', nextVotes: 'all', revealSec: 30, listenSec: 10 }, { revealMs: undefined } as unknown as Record<string, number>);
|
||||
const [a, b] = cls as [Client, Client];
|
||||
const stop = autoReady(cls);
|
||||
a.send({ t: 'start' });
|
||||
await nextOf(a, 'play', 0);
|
||||
a.send({ t: 'vote', kind: 'next' });
|
||||
expect(((await a.waitFor((m) => m.t === 'error')) as Msg<'error'>).message).toBe('정답이 공개된 뒤에 누를 수 있어요.');
|
||||
a.send({ t: 'vote', kind: 'skip' });
|
||||
let g = await gameWhere(a, (x) => x.phase === 'reveal');
|
||||
expect(g.revealUntil! - Date.now()).toBeGreaterThan(29_000);
|
||||
expect(g.revealUntil! - Date.now()).toBeLessThanOrEqual(30_000);
|
||||
expect(g.need.next).toBe(2);
|
||||
a.send({ t: 'vote', kind: 'next' });
|
||||
g = await gameWhere(a, (x) => x.votes.next.length === 1);
|
||||
expect(g.phase).toBe('reveal');
|
||||
b.send({ t: 'vote', kind: 'next' });
|
||||
g = await gameWhere(a, (x) => x.n === 2 && x.phase !== 'reveal');
|
||||
expect(g.votes.next).toEqual([]);
|
||||
await nextOf(a, 'play', 0, (m) => m.n === 2);
|
||||
a.send({ t: 'vote', kind: 'skip' });
|
||||
await gameWhere(a, (x) => x.n === 2 && x.phase === 'reveal');
|
||||
a.send({ t: 'vote', kind: 'next' });
|
||||
await gameWhere(a, (x) => x.votes.next.length === 1);
|
||||
// The other voter leaves: everyone still online has voted, so it moves on (to the results after the last one).
|
||||
b.close();
|
||||
g = await gameWhere(a, (x) => x.phase === 'result');
|
||||
expect(g.history.map((h) => h.how)).toEqual(['skip', 'skip']);
|
||||
stop();
|
||||
});
|
||||
|
||||
test('다음 문제 off: the server explains', async () => {
|
||||
seedLater(() => seed(2));
|
||||
const { cls } = await room(['방장'], { skipVotes: '1', nextVotes: 'none' });
|
||||
const [a] = cls as [Client];
|
||||
const stop = autoReady(cls);
|
||||
a.send({ t: 'start' });
|
||||
await nextOf(a, 'play', 0);
|
||||
a.send({ t: 'vote', kind: 'skip' });
|
||||
await gameWhere(a, (x) => x.phase === 'reveal');
|
||||
a.send({ t: 'vote', kind: 'next' });
|
||||
expect(((await a.waitFor((m) => m.t === 'error')) as Msg<'error'>).message).toBe('이 방은 바로 다음 문제가 꺼져 있어요.');
|
||||
expect(last(a, 'game')!.game!.need.next).toBeNull();
|
||||
stop();
|
||||
});
|
||||
|
||||
test('somebody joining mid-game plays from the next question', async () => {
|
||||
seedLater(() => seed(3));
|
||||
const { cls, code } = await room(['방장']);
|
||||
|
||||
@@ -15,7 +15,8 @@ import type { Room } from '../rooms/manager';
|
||||
export interface GameTiming {
|
||||
/** 3·2·1 before the first play of a question. */
|
||||
countdownMs: number;
|
||||
revealMs: number;
|
||||
/** Tests only: replaces the room's 다음 문제까지 (revealSec). */
|
||||
revealMs?: number;
|
||||
/** Lead time for a resume / replay so every client starts together (docs/12 Q1: now + 800ms). */
|
||||
resumeLeadMs: number;
|
||||
/** A client that has not reported the clip end this long after the expected end gets one more stop (docs/12 Q1). */
|
||||
@@ -26,7 +27,7 @@ export interface GameTiming {
|
||||
/** Tests only: replaces the site's question time limit for short clips. */
|
||||
limitMs?: number;
|
||||
}
|
||||
export const DEFAULT_TIMING: GameTiming = { countdownMs: 3000, revealMs: 5000, resumeLeadMs: 800, clipGraceMs: 3000, lateMs: 30_000, tickMs: 200 };
|
||||
export const DEFAULT_TIMING: GameTiming = { countdownMs: 3000, resumeLeadMs: 800, clipGraceMs: 3000, lateMs: 30_000, tickMs: 200 };
|
||||
|
||||
export interface Score {
|
||||
nickname: string;
|
||||
@@ -79,7 +80,7 @@ export class Game {
|
||||
private limitMs: number | null = null;
|
||||
hint: string | null = null;
|
||||
private lyrics: string[] | null = null;
|
||||
votes = { skip: new Set<string>(), hint: new Set<string>(), replay: new Set<string>() };
|
||||
votes = { skip: new Set<string>(), hint: new Set<string>(), replay: new Set<string>(), next: new Set<string>() };
|
||||
history: GameHistoryItem[] = [];
|
||||
private revealUntil: number | null = null;
|
||||
private timer: ReturnType<typeof setInterval> | null = null;
|
||||
@@ -135,8 +136,10 @@ export class Game {
|
||||
const p = this.audioAtSec + Math.max(0, now - this.audioStartAt) / 1000;
|
||||
return this.clip.endSec !== null ? Math.min(p, this.clip.endSec) : p;
|
||||
}
|
||||
private need(kind: 'skip' | 'hint' | 'replay'): number | null {
|
||||
private need(kind: 'skip' | 'hint' | 'replay' | 'next'): number | null {
|
||||
const c = this.room.config;
|
||||
// 다음 문제: everyone in the room plays the next question, so everyone online counts.
|
||||
if (kind === 'next') return voteThreshold(c.nextVotes, this.room.online().length);
|
||||
const rule = kind === 'skip' ? c.skipVotes : kind === 'hint' ? (c.hint === 'manual' ? c.hintVotes : 'none') : this.listening ? c.replayVotes : 'none';
|
||||
return voteThreshold(rule, this.active().length);
|
||||
}
|
||||
@@ -332,10 +335,18 @@ export class Game {
|
||||
this.paused = null;
|
||||
this.playing = false;
|
||||
this.phase = 'reveal';
|
||||
this.revealUntil = now + this.timing.revealMs;
|
||||
this.votes.next.clear();
|
||||
this.revealUntil = now + (this.timing.revealMs ?? this.room.config.revealSec * 1000);
|
||||
this.broadcast();
|
||||
}
|
||||
|
||||
/** Reveal over (time or 다음 문제 votes): the next question, or the results after the last one. */
|
||||
private afterReveal(): void {
|
||||
if (this.phase !== 'reveal') return;
|
||||
if (this.n >= this.total) this.finish();
|
||||
else this.next();
|
||||
}
|
||||
|
||||
finish(): void {
|
||||
if (this.phase === 'result') return;
|
||||
this.phase = 'result';
|
||||
@@ -355,10 +366,7 @@ export class Game {
|
||||
|
||||
tick(now = this.now()): void {
|
||||
if (this.phase === 'reveal') {
|
||||
if (this.revealUntil !== null && now >= this.revealUntil) {
|
||||
if (this.n >= this.total) this.finish();
|
||||
else this.next();
|
||||
}
|
||||
if (this.revealUntil !== null && now >= this.revealUntil) this.afterReveal();
|
||||
return;
|
||||
}
|
||||
if (this.phase !== 'play') return;
|
||||
@@ -423,7 +431,17 @@ export class Game {
|
||||
return true;
|
||||
}
|
||||
|
||||
vote(userId: string, kind: 'skip' | 'hint' | 'replay'): string | null {
|
||||
vote(userId: string, kind: 'skip' | 'hint' | 'replay' | 'next'): string | null {
|
||||
if (kind === 'next') {
|
||||
if (this.phase !== 'reveal') return '정답이 공개된 뒤에 누를 수 있어요.';
|
||||
if (this.room.config.nextVotes === 'none') return '이 방은 바로 다음 문제가 꺼져 있어요.';
|
||||
if (!this.online(userId)) return '방에 접속해 있지 않아요.';
|
||||
if (this.votes.next.has(userId)) this.votes.next.delete(userId);
|
||||
else this.votes.next.add(userId);
|
||||
this.checkNext();
|
||||
if (this.phase === 'reveal') this.broadcast();
|
||||
return null;
|
||||
}
|
||||
if (this.phase !== 'play' && this.phase !== 'prepare') return '지금은 투표할 수 없어요.';
|
||||
if (!this.active().includes(userId)) return '이번 문제에 참가하고 있지 않아요.';
|
||||
const c = this.room.config;
|
||||
@@ -451,7 +469,7 @@ export class Game {
|
||||
|
||||
private checkVotes(): void {
|
||||
const act = new Set(this.active());
|
||||
for (const v of Object.values(this.votes)) for (const id of v) if (!act.has(id)) v.delete(id);
|
||||
for (const k of ['skip', 'hint', 'replay'] as const) for (const id of this.votes[k]) if (!act.has(id)) this.votes[k].delete(id);
|
||||
const pass = (k: 'skip' | 'hint' | 'replay') => {
|
||||
const need = this.need(k);
|
||||
return need !== null && this.votes[k].size >= need;
|
||||
@@ -461,8 +479,21 @@ export class Game {
|
||||
if (pass('replay') && this.phase === 'play' && this.firstStartAt !== null) this.replay();
|
||||
}
|
||||
|
||||
/** 다음 문제 votes: drop people who left, move on when enough are in. */
|
||||
private checkNext(): void {
|
||||
if (this.phase !== 'reveal') return;
|
||||
for (const id of this.votes.next) if (!this.online(id)) this.votes.next.delete(id);
|
||||
const need = this.need('next');
|
||||
if (need !== null && this.votes.next.size >= need) this.afterReveal();
|
||||
}
|
||||
|
||||
/** A player went offline or left: do not wait for them, drop their votes (docs/05 진행 중 나간 사람). */
|
||||
onGone(userId: string): void {
|
||||
if (this.phase === 'reveal') {
|
||||
this.checkNext();
|
||||
if ((this.phase as GamePhase) === 'reveal') this.broadcast();
|
||||
return;
|
||||
}
|
||||
if (this.phase !== 'prepare' && this.phase !== 'play') return this.broadcast();
|
||||
this.waitingSince.delete(userId);
|
||||
if (this.paused?.who.includes(userId)) this.paused = { ...this.paused, who: this.paused.who.filter((x) => x !== userId) };
|
||||
@@ -533,8 +564,8 @@ export class Game {
|
||||
hint: this.hint,
|
||||
hintAtSec: typeof c.hint === 'number' ? c.hint : null,
|
||||
lyrics: this.lyrics,
|
||||
votes: { skip: [...this.votes.skip], hint: [...this.votes.hint], replay: [...this.votes.replay] },
|
||||
need: { skip: this.need('skip'), hint: this.need('hint'), replay: this.need('replay') },
|
||||
votes: { skip: [...this.votes.skip], hint: [...this.votes.hint], replay: [...this.votes.replay], next: [...this.votes.next] },
|
||||
need: { skip: this.need('skip'), hint: this.need('hint'), replay: this.need('replay'), next: this.need('next') },
|
||||
scores: [...ids]
|
||||
.map((id) => {
|
||||
const s = scores.get(id);
|
||||
|
||||
@@ -403,7 +403,7 @@ export class RoomManager {
|
||||
this.inRoom(ws)?.game?.onAudio(ws.data.userId, n, ev, code);
|
||||
}
|
||||
|
||||
vote(ws: ServerWebSocket<WsData>, kind: 'skip' | 'hint' | 'replay'): string | null {
|
||||
vote(ws: ServerWebSocket<WsData>, kind: 'skip' | 'hint' | 'replay' | 'next'): string | null {
|
||||
const room = this.inRoom(ws);
|
||||
if (!room?.game) return '게임 중이 아니에요.';
|
||||
return room.game.vote(ws.data.userId, kind);
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
LISTEN_SECS,
|
||||
LYRICS_SECS,
|
||||
MODES,
|
||||
REVEAL_SECS,
|
||||
VOTE_RULES,
|
||||
listenLabel,
|
||||
voteLabel,
|
||||
@@ -394,6 +395,12 @@ export function RoomSettings({
|
||||
<Seg label="다시듣기인원" value={c.replayVotes} disabled={ro} onChange={(replayVotes) => onPatch({ replayVotes })} options={vote(VOTE_RULES)} />
|
||||
</Section>
|
||||
)}
|
||||
<Section title="다음 문제까지" tip="정답을 공개한 뒤 다음 문제로 넘어가기까지 기다리는 시간. 그동안 노래는 계속 나와요">
|
||||
<Seg label="다음 문제까지" value={c.revealSec} disabled={ro} onChange={(revealSec) => onPatch({ revealSec })} options={REVEAL_SECS.map((v) => ({ v, label: `${v}초` }))} />
|
||||
</Section>
|
||||
<Section title="다음문제인원(이상)" tip="정답 공개 중에 바로 다음 문제로 넘어가려면 다음 문제를 눌러야하는 인원 설정">
|
||||
<Seg label="다음문제인원" value={c.nextVotes} disabled={ro} onChange={(nextVotes) => onPatch({ nextVotes })} options={vote(VOTE_RULES)} />
|
||||
</Section>
|
||||
<Section title="문제 수">
|
||||
<Seg
|
||||
label="문제 수"
|
||||
|
||||
@@ -49,7 +49,10 @@ export function GameScreen({ room, game }: { room: RoomView; game: GameView }) {
|
||||
const isHost = room.hostId === me.id;
|
||||
const c = room.config;
|
||||
const send = (m: unknown) => socket.send(m);
|
||||
const vote = (kind: 'skip' | 'hint' | 'replay') => send({ t: 'vote', kind });
|
||||
const vote = (kind: 'skip' | 'hint' | 'replay' | 'next') => send({ t: 'vote', kind });
|
||||
// Ctrl+K during the reveal = 다음 문제 (the shortcut handler is set up once, so it reads the phase from a ref).
|
||||
const phaseRef = useRef(game.phase);
|
||||
phaseRef.current = game.phase;
|
||||
const name = (id: string) => room.players.find((x) => x.id === id)?.nickname ?? game.scores.find((x) => x.id === id)?.nickname ?? '?';
|
||||
const inQuestion = game.participants.includes(me.id) && !game.excluded.includes(me.id);
|
||||
const listening = game.mode !== 'lyrics';
|
||||
@@ -62,7 +65,7 @@ export function GameScreen({ room, game }: { room: RoomView; game: GameView }) {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey) {
|
||||
const k = e.key.toLowerCase();
|
||||
const kind = k === 'i' ? 'hint' : k === 'k' ? 'skip' : k === 'r' ? 'replay' : null;
|
||||
const kind = k === 'i' ? 'hint' : k === 'k' ? (phaseRef.current === 'reveal' ? 'next' : 'skip') : k === 'r' ? 'replay' : null;
|
||||
if (kind) {
|
||||
e.preventDefault();
|
||||
vote(kind);
|
||||
@@ -83,7 +86,7 @@ export function GameScreen({ room, game }: { room: RoomView; game: GameView }) {
|
||||
const elapsed = game.clock.elapsedMs + (game.clock.runningSince !== null ? Math.max(0, now - game.clock.runningSince) : 0);
|
||||
const countdown = game.startAt !== null && now < game.startAt && !game.paused ? Math.ceil((game.startAt - now) / 1000) : 0;
|
||||
const reveal = game.phase === 'reveal' ? game.history.at(-1) : undefined;
|
||||
const voteBtn = (kind: 'skip' | 'hint' | 'replay', icon: string, label: string, key: string) => {
|
||||
const voteBtn = (kind: 'skip' | 'hint' | 'replay' | 'next', icon: string, label: string, key: string) => {
|
||||
const need = game.need[kind];
|
||||
const n = game.votes[kind].length;
|
||||
const on = game.votes[kind].includes(me.id);
|
||||
@@ -121,7 +124,7 @@ export function GameScreen({ room, game }: { room: RoomView; game: GameView }) {
|
||||
<span className="badge dark">★{c.level}</span>
|
||||
<div className="grow" />
|
||||
{voteBtn('hint', '💡', '힌트', 'Ctrl+I')}
|
||||
{voteBtn('skip', '⏭', '스킵', 'Ctrl+K')}
|
||||
{reveal ? voteBtn('next', '⏭', '다음 문제', 'Ctrl+K') : voteBtn('skip', '⏭', '스킵', 'Ctrl+K')}
|
||||
{listening && voteBtn('replay', '🔁', '다시듣기', 'Ctrl+R')}
|
||||
{listening && (
|
||||
<label className="vol" title="볼륨">
|
||||
@@ -166,7 +169,7 @@ export function GameScreen({ room, game }: { room: RoomView; game: GameView }) {
|
||||
<div className="gcenter">
|
||||
<section className={`stage ${reveal ? 'revealed' : ''}`} aria-live="polite">
|
||||
{reveal ? (
|
||||
<RevealCard item={reveal} />
|
||||
<RevealCard item={reveal} left={Math.max(0, Math.ceil(((game.revealUntil ?? now) - now) / 1000))} last={game.n >= game.total} />
|
||||
) : (
|
||||
<>
|
||||
{listening ? <div className={`lp ${p.playing && !game.paused ? 'spin' : ''}`} aria-hidden /> : null}
|
||||
@@ -278,7 +281,7 @@ export function GameScreen({ room, game }: { room: RoomView; game: GameView }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RevealCard({ item }: { item: GameHistoryItem }) {
|
||||
function RevealCard({ item, left, last }: { item: GameHistoryItem; left: number; last: boolean }) {
|
||||
return (
|
||||
<div className="reveal">
|
||||
{item.videoId ? <img className="art" src={`https://i.ytimg.com/vi/${item.videoId}/hqdefault.jpg`} alt="" /> : <div className="art lp" aria-hidden />}
|
||||
@@ -290,6 +293,9 @@ function RevealCard({ item }: { item: GameHistoryItem }) {
|
||||
<div className="small muted">
|
||||
{[item.year, ...item.genres].filter(Boolean).join(' · ')} <Stars n={item.level} />
|
||||
</div>
|
||||
<div className="small muted next-in">
|
||||
{last ? '결과까지' : '다음 문제까지'} <b className="mono">{left}초</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -195,6 +195,8 @@ const LOCKABLE: [keyof RoomConfig, string][] = [
|
||||
['hint', '힌트공개'],
|
||||
['skipVotes', '스킵인원'],
|
||||
['replayVotes', '다시듣기인원'],
|
||||
['revealSec', '다음 문제까지'],
|
||||
['nextVotes', '다음문제인원'],
|
||||
['count', '문제 수'],
|
||||
['visibility', '방 공개'],
|
||||
];
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
| └ 힌트인원(이상) (직접선택일 때) | 1명, 2명, 1/3명, 1/2명, 2/3명, 전체 | 1/3명 (Q3) |
|
||||
| 스킵인원(이상) | 없음, 1명, 2명, 1/3명, 1/2명, 2/3명, 전체 | 1/3명 |
|
||||
| 다시듣기인원(이상) (듣기 모드) | 없음, 1명, 2명, 1/3명, 1/2명, 2/3명, 전체 | 1/3명 (Q4) |
|
||||
| 다음 문제까지 | 5초, 10초, 15초, 30초 | 5초 |
|
||||
| 다음문제인원(이상) | 없음, 1명, 2명, 1/3명, 1/2명, 2/3명, 전체 | 1/3명 |
|
||||
| 문제 수 | 10, 20, 30, 50, 100, 무제한(조건에 맞는 곡 수) | 30 (Q8) |
|
||||
| 방 공개 (제안) | 공개 / 비공개(코드·링크로만) / 비밀번호 | 공개 |
|
||||
|
||||
@@ -112,6 +114,11 @@
|
||||
## 다시듣기인원(이상)
|
||||
- 듣기 모드에서 다시듣기 투표(Ctrl+R)가 이 인원 이상이면 모두 같이 같은 구간을 처음부터 다시 듣는다. 없음 = 다시듣기 불가 (12 문서 Q4)
|
||||
|
||||
## 다음 문제까지 · 다음문제인원(이상)
|
||||
- 정답 공개(맞힘·스킵·시간 초과 모두) 뒤 다음 문제로 넘어가기까지 기다리는 시간. 그동안 노래는 이어서 나온다. 마지막 문제도 같은 시간 뒤 결과 화면
|
||||
- 정답 공개 중 `⏭ 다음 문제`(Ctrl+K) 표가 다음문제인원 이상이면 바로 넘어간다. 기준은 **방에 접속 중인 사람 수**(다음 문제는 모두가 같이 하므로), 올림. 없음 = 버튼 꺼짐
|
||||
- 정답 공개 화면에 `다음 문제까지 N초`(마지막 문제는 `결과까지 N초`), 방 목록 카드 요약에 `공개 N초`
|
||||
|
||||
## 스킵인원(이상)
|
||||
- 글자 오른쪽 위에 동그라미 속 느낌표 아이콘 ⓘ(!) — 마우스를 올리면 말풍선:
|
||||
**"이번문제 스킵을 위해 스킵을 눌러야하는 인원 설정"**
|
||||
|
||||
@@ -146,3 +146,9 @@
|
||||
12. 퀴즈 저장: 결과 화면(또는 방장이 일시정지한 동안), 저장하면 설정·나온 곡·점수(계정별). 불러오면 방 이름·공개 설정은 지금 방 것을 유지
|
||||
13. 남은 사람 검증(사람 손으로): 광고가 붙는 곡, 아이폰 사파리, 안드로이드 크롬, 클릭 없이 들어온 경우 — Q1 "남은 검증" 그대로
|
||||
|
||||
|
||||
## 다음 문제까지 (2026-10-18, 사용자: "바로 다음문제 버튼도 스킵처럼 인원설정, 나머지는 추천대로")
|
||||
1. 방 설정 `다음 문제까지` 5/10/15/30초(기본 5초)가 서버 고정 5초를 대신한다. 맞힘·스킵·시간 초과·마지막 문제 모두 같은 시간
|
||||
2. 정답 공개 동안 노래는 계속 나온다(5~7단계 6번 그대로, 길이만 방 설정)
|
||||
3. `다음문제인원(이상)`(기본 1/3명): 정답 공개 중 `⏭ 다음 문제`(Ctrl+K) 표가 이 인원 이상이면 바로 넘어감. 방장 전용이 아니라 스킵처럼 투표, 기준은 방에 접속 중인 사람 수
|
||||
4. 관리자 사이트의 새 방 기본값·잠금, 퀴즈 저장·불러오기에 같이 들어간다(예전 저장본은 기본값 5초·1/3명)
|
||||
|
||||
@@ -88,6 +88,10 @@ try {
|
||||
await p.getByLabel('채팅 입력').press('Enter');
|
||||
await p.locator('.reveal').waitFor();
|
||||
await audit(p, `${label}/${theme} 정답 공개`);
|
||||
// 다음 문제까지 N초, and 다음 문제 (1명 방: 1/3 → 1) moves on before the 4s reveal ends
|
||||
if (!/다음 문제까지 \d초/.test(await p.locator('.reveal .next-in').innerText())) throw new Error('다음 문제까지 표시 없음');
|
||||
await p.locator('.gbtn', { hasText: '다음 문제' }).click();
|
||||
await p.locator('.gbar .q', { hasText: '문제 2' }).waitFor({ timeout: 2500 });
|
||||
await p.getByRole('button', { name: '⏹ 끝내기' }).click();
|
||||
await p.getByRole('button', { name: '끝내기', exact: true }).click();
|
||||
await p.getByRole('heading', { name: '🏁 게임 결과' }).waitFor();
|
||||
|
||||
@@ -29,7 +29,7 @@ export const ClientMessage = z.discriminatedUnion('t', [
|
||||
/** 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('vote'), kind: z.enum(['skip', 'hint', 'replay', 'next']) }),
|
||||
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']) }),
|
||||
@@ -128,8 +128,9 @@ export interface GameView {
|
||||
/** 자동 공개 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 };
|
||||
/** next = 바로 다음 문제, only during the reveal. */
|
||||
votes: { skip: string[]; hint: string[]; replay: string[]; next: string[] };
|
||||
need: { skip: number | null; hint: number | null; replay: number | null; next: number | null };
|
||||
scores: GameScore[];
|
||||
/** Questions of this game so far, newest last; during reveal the last one is the current question. */
|
||||
history: GameHistoryItem[];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { COUNTS, DEFAULT_ROOM_CONFIG, HINT_TIMES, LISTEN_SECS, LYRICS_SECS, VOTE_RULES, type RoomConfig } from './room-config';
|
||||
import { COUNTS, DEFAULT_ROOM_CONFIG, HINT_TIMES, LISTEN_SECS, LYRICS_SECS, REVEAL_SECS, VOTE_RULES, type RoomConfig } from './room-config';
|
||||
|
||||
const lit = <T extends readonly (string | number)[]>(xs: T) => z.union(xs.map((x) => z.literal(x)) as unknown as [z.ZodLiteral<T[number]>, z.ZodLiteral<T[number]>]);
|
||||
|
||||
@@ -20,6 +20,8 @@ export const RoomConfigSchema = z.object({
|
||||
hintVotes: z.enum(VOTE_RULES.filter((v) => v !== 'none') as ['1', '2', '1/3', '1/2', '2/3', 'all']),
|
||||
skipVotes: z.enum(VOTE_RULES),
|
||||
replayVotes: z.enum(VOTE_RULES),
|
||||
revealSec: lit(REVEAL_SECS),
|
||||
nextVotes: z.enum(VOTE_RULES),
|
||||
count: lit(COUNTS),
|
||||
visibility: z.enum(['public', 'private', 'password']),
|
||||
});
|
||||
|
||||
@@ -20,6 +20,8 @@ export const VOTE_RULES = ['none', '1', '2', '1/3', '1/2', '2/3', 'all'] as cons
|
||||
export type VoteRule = (typeof VOTE_RULES)[number];
|
||||
/** 문제 수, 0 = 무제한(조건에 맞는 곡 전부). */
|
||||
export const COUNTS = [10, 20, 30, 50, 100, 0] as const;
|
||||
/** 다음 문제까지: seconds the answer stays on screen (the music goes on) before the next question. */
|
||||
export const REVEAL_SECS = [5, 10, 15, 30] as const;
|
||||
|
||||
export interface RoomConfig {
|
||||
title: string;
|
||||
@@ -42,6 +44,9 @@ export interface RoomConfig {
|
||||
hintVotes: Exclude<VoteRule, 'none'>;
|
||||
skipVotes: VoteRule;
|
||||
replayVotes: VoteRule;
|
||||
revealSec: (typeof REVEAL_SECS)[number];
|
||||
/** 다음문제인원: votes during the answer reveal that move on at once. */
|
||||
nextVotes: VoteRule;
|
||||
count: (typeof COUNTS)[number];
|
||||
visibility: 'public' | 'private' | 'password';
|
||||
}
|
||||
@@ -63,6 +68,8 @@ export const DEFAULT_ROOM_CONFIG: RoomConfig = {
|
||||
hintVotes: '1/3',
|
||||
skipVotes: '1/3',
|
||||
replayVotes: '1/3',
|
||||
revealSec: 5,
|
||||
nextVotes: '1/3',
|
||||
count: 30,
|
||||
visibility: 'public',
|
||||
};
|
||||
@@ -106,5 +113,6 @@ export function configSummary(c: RoomConfig, genreName: (id: string) => string =
|
||||
out.push(c.genres.length ? c.genres.map(genreName).join(' · ') : '전체 장르');
|
||||
out.push(`★${c.level}`);
|
||||
if (c.answer !== 'title') out.push(c.answer === 'both' ? '제목+가수' : '가수만');
|
||||
out.push(`공개 ${c.revealSec}초`);
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user