방 설정 "다음 문제까지"(5/10/15/30초, 기본 5초)와 "다음문제인원(이상)" 투표: 정답 공개 시간을 방마다 고르고, 공개 중 ⏭ 다음 문제(Ctrl+K) 표가 기준 이상이면 바로 넘어감(마지막 문제는 결과로). 공개 화면에 남은 초, 방 카드 요약에 '공개 N초', 관리자 기본값·잠금

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 23:35:33 +09:00
parent c81b6b8c9a
commit a1507e5b95
12 changed files with 146 additions and 25 deletions

View File

@@ -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[];

View File

@@ -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']),
});

View File

@@ -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;
}