- 제시어 1,519개를 주제별 '비슷한 단어 묶음' 391개로 정리(bank/*.ts groups). 바보 모드 라이어는 제시어와 같은 묶음의 다른 단어를 받음 - 관리자 → 라이어 제시어(/admin/liar): 주제 추가·이름 변경·삭제(내장 주제는 다시 살리기/처음 값으로), 제시어·묶음·다른 표기·컴퓨터 설명 편집, 저장 시 topicProblems 검사 - 저장: liar_topics(바뀐 주제), liar_bank_versions(판본). 새 판 옵션에 bank 판본을 붙여(prepareOptions) 다시 보기·복구가 같은 은행 사용 - 판 상태에 주제 이름·단어 목록·다른 표기를 복사해 진행 중 판은 관리자 수정의 영향을 받지 않음 - 대기실 주제 목록은 GET /api/liar/topics, 관리자 API /api/admin/liar/topics, 기록 liar.topic.* - 테스트: 엔진(묶음·바보 모드·판본·검사), 서버(관리자 API·새 판·재시작), E2E(관리자 편집 → 대기실 새 주제) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.6 KiB
TypeScript
31 lines
1.6 KiB
TypeScript
/** Checks the 비슷한 단어 묶음 (`groups`) of the 라이어 게임 word bank: bun scripts/liar-groups-check.ts [topicId...] */
|
|
import { readdirSync } from 'node:fs';
|
|
const dir = new URL('../packages/games/src/liar/bank/', import.meta.url).pathname;
|
|
const want = process.argv.slice(2);
|
|
let bad = 0;
|
|
for (const f of readdirSync(dir).filter((f) => f.endsWith('.ts') && f !== 'w.ts')) {
|
|
const mod = await import(dir + f);
|
|
const t = Object.values(mod)[0] as { id: string; words: { word: string }[]; groups?: Record<string, string[]> };
|
|
if (want.length && !want.includes(t.id)) continue;
|
|
const errs: string[] = [];
|
|
if (!t.groups) errs.push('groups 없음');
|
|
else {
|
|
const seen = new Map<string, string>();
|
|
const words = new Set(t.words.map((x) => x.word));
|
|
for (const [g, ws] of Object.entries(t.groups)) {
|
|
if (ws.length < 2) errs.push(`'${g}' 묶음이 ${ws.length}개(2개 이상 필요)`);
|
|
for (const x of ws) {
|
|
if (!words.has(x)) errs.push(`'${g}'의 '${x}'는 주제에 없는 단어`);
|
|
if (seen.has(x)) errs.push(`'${x}'가 '${seen.get(x)}'와 '${g}' 두 묶음에 있음`);
|
|
seen.set(x, g);
|
|
}
|
|
}
|
|
for (const x of words) if (!seen.has(x)) errs.push(`'${x}'가 어느 묶음에도 없음`);
|
|
const sizes = Object.values(t.groups).map((x) => x.length);
|
|
console.log(`${t.id}: 단어 ${words.size}, 묶음 ${sizes.length}개 (크기 ${Math.min(...sizes)}~${Math.max(...sizes)})${errs.length ? ' ❌' : ' ✅'}`);
|
|
}
|
|
for (const e of errs) console.log(' - ' + e);
|
|
bad += errs.length;
|
|
}
|
|
process.exit(bad ? 1 : 0);
|