제작된 퀴즈 6단계: 플레이 통계 상세(문제마다 힌트 시간/투표, 정답이 아닌 입력 수·사람 수, 다시듣기, 제작된 퀴즈·곡; DB에 없는 퀴즈 곡도 기록 — song_plays.song_id nullable로 다시 만듦). 관리자 통계 곡별·퀴즈별(퀴즈 → 곡별 어려운 순) 탭. 난이도 제안이 힌트도 보고, 검토 대기 → 난이도 조정에 근거(출제·정답·힌트·오답·다시듣기)와 함께 승인/반영 안 함(5번 더 나온 뒤 다시). 메뉴 개수에 포함
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,6 +90,8 @@ export class Game {
|
||||
private runningSince: number | null = null;
|
||||
private limitMs: number | null = null;
|
||||
hint: string | null = null;
|
||||
/** 통계: how the hint came (null = none), chat lines that were not the answer and who sent them, replays. */
|
||||
private stat = { hint: null as 'auto' | 'vote' | null, wrong: 0, wrongBy: new Set<string>(), replays: 0 };
|
||||
private lyrics: string[] | null = null;
|
||||
votes = { skip: new Set<string>(), hint: new Set<string>(), replay: new Set<string>(), next: new Set<string>() };
|
||||
history: GameHistoryItem[] = [];
|
||||
@@ -194,6 +196,7 @@ export class Game {
|
||||
this.elapsedMs = 0;
|
||||
this.runningSince = null;
|
||||
this.hint = null;
|
||||
this.stat = { hint: null, wrong: 0, wrongBy: new Set(), replays: 0 };
|
||||
this.revealUntil = null;
|
||||
for (const v of Object.values(this.votes)) v.clear();
|
||||
if (this.listening) {
|
||||
@@ -285,8 +288,9 @@ export class Game {
|
||||
this.broadcast();
|
||||
}
|
||||
|
||||
private showHint(): void {
|
||||
private showHint(how: 'auto' | 'vote' = 'auto'): void {
|
||||
if (this.hint || !this.song) return;
|
||||
this.stat.hint = how;
|
||||
this.hint = hintText(this.song, this.room.config.answer);
|
||||
if (this.lyrics && this.song.lyrics) this.lyrics = lyricsCard(this.song.lyrics, this.song.title, 1);
|
||||
this.votes.hint.clear();
|
||||
@@ -296,6 +300,7 @@ export class Game {
|
||||
|
||||
private replay(): void {
|
||||
if (!this.listening || !this.song) return;
|
||||
this.stat.replays++;
|
||||
for (const v of Object.values(this.votes)) v.clear();
|
||||
this.clipDone.clear();
|
||||
this.clipOver = false;
|
||||
@@ -341,10 +346,28 @@ export class Game {
|
||||
this.asked.push(s.id);
|
||||
try {
|
||||
// 통계 (admin): never let a stats write break the game.
|
||||
if (s.dbSongId !== null)
|
||||
const quizId = this.room.config.quizId;
|
||||
if (s.dbSongId !== null || quizId)
|
||||
this.room.deps.db
|
||||
.query('INSERT INTO song_plays (song_id, game_id, played_at, players, winner_id, ms, how) VALUES (?, ?, ?, ?, ?, ?, ?)')
|
||||
.run(s.dbSongId, this.gameId, now, Math.max(1, this.active().length), winner, ms, how === 'end' ? 'timeout' : how);
|
||||
.query(
|
||||
`INSERT INTO song_plays (song_id, game_id, played_at, players, winner_id, ms, how, hint, wrong, wrong_players, replays, quiz_id, quiz_item_id)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
)
|
||||
.run(
|
||||
s.dbSongId,
|
||||
this.gameId,
|
||||
now,
|
||||
Math.max(1, this.active().length),
|
||||
winner,
|
||||
ms,
|
||||
how === 'end' ? 'timeout' : how,
|
||||
this.stat.hint,
|
||||
this.stat.wrong,
|
||||
this.stat.wrongBy.size,
|
||||
this.stat.replays,
|
||||
quizId,
|
||||
quizId ? s.id : null,
|
||||
);
|
||||
} catch {
|
||||
/* stats only */
|
||||
}
|
||||
@@ -455,7 +478,11 @@ export class Game {
|
||||
judge(userId: string, text: string, n?: string): boolean {
|
||||
if (this.phase !== 'play' || !this.song || this.firstStartAt === null || this.now() < this.firstStartAt) return false;
|
||||
if (!this.participants.has(userId) || this.excluded.has(userId)) return false;
|
||||
if (!isCorrect(text, this.song, this.room.config.answer, this.room.config.strict)) return false;
|
||||
if (!isCorrect(text, this.song, this.room.config.answer, this.room.config.strict)) {
|
||||
this.stat.wrong++;
|
||||
this.stat.wrongBy.add(userId);
|
||||
return false;
|
||||
}
|
||||
this.endQuestion(userId, 'correct', { text, n });
|
||||
return true;
|
||||
}
|
||||
@@ -504,7 +531,7 @@ export class Game {
|
||||
return need !== null && this.votes[k].size >= need;
|
||||
};
|
||||
if (pass('skip')) return this.endQuestion(null, 'skip');
|
||||
if (pass('hint') && this.phase === 'play') this.showHint();
|
||||
if (pass('hint') && this.phase === 'play') this.showHint('vote');
|
||||
if (pass('replay') && this.phase === 'play' && this.firstStartAt !== null) this.replay();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user