- packages/games/src/liar: 주제 10개 제시어 은행, 설명(두 번째 바퀴 거꾸로)·자유 토론·투표(동점 재투표 한 번, 또 동점이면 라이어 승리)·라이어 정답 맞히기(띄어쓰기·다른 표기 무시), 바보 모드 - 컴퓨터: 마피아처럼 live 전략, 레벨 1~60을 LiveBotInput.level 로 받음(서버 BotDriver 가 넘김), BOT_CHAT_REQUIRED 에 추가 - 웹: 꾹 누르는 제시어 카드, 설명 기록·토론 채팅·투표 화면, 30초 요약, [?] 도움말 - 문서 docs/games/liar.md, 등록(GAMES·CATALOG·BOT_GAMES·registry·아이콘), 서버 방 테스트, E2E(거절 알림이 저절로 사라지는지 확인 포함) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
2.5 KiB
TypeScript
50 lines
2.5 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { applyAction, seatIds, setupGame, usersOf } from '../help-kit.test-util';
|
|
import { GAMES } from '@bg/games';
|
|
import { helpNow } from './help';
|
|
|
|
const ids = seatIds(4);
|
|
const users = usersOf(ids);
|
|
const view = (s: unknown, who: string | null) => GAMES.liar!.view(s, who) as any;
|
|
const T = 1_700_000_000_000;
|
|
|
|
function game(options: Record<string, unknown> = {}) {
|
|
const { state } = setupGame('liar', 4, { topic: 'fruit', ...options });
|
|
state.word = '수박';
|
|
state.liar = 'D';
|
|
state.order = [...ids];
|
|
if (state.options.foolMode) state.liarWord = '참외';
|
|
return state;
|
|
}
|
|
const tick = (s: any) => GAMES.liar!.apply(s, 'A', { type: 'phaseTimeout' }, { rng: undefined as never, now: s.phase.endsAt }).state;
|
|
|
|
test('라이어 게임: 제시어 확인 — 시민·라이어·관전자에게 맞는 안내, 제시어는 새지 않아요', () => {
|
|
const s = game();
|
|
const c = helpNow(view(s, 'A'), 'A', users);
|
|
expect(c).toContain('[내 제시어] 카드를 꾹');
|
|
expect(c).toContain('주제는 과일이에요');
|
|
const l = helpNow(view(s, 'D'), 'D', users);
|
|
expect(l).toContain('나는 라이어예요');
|
|
const spec = helpNow(view(s, null), null, users);
|
|
expect(spec).toContain('관전 중에는 제시어가 보이지 않아요');
|
|
for (const t of [c, l, spec]) expect(t).not.toContain('수박');
|
|
});
|
|
|
|
test('라이어 게임: 바보 모드 라이어는 시민과 같은 안내를 받아요', () => {
|
|
const s = game({ foolMode: true });
|
|
expect(helpNow(view(s, 'D'), 'D', users)).toBe(helpNow(view(s, 'A'), 'A', users));
|
|
});
|
|
|
|
test('라이어 게임: 설명 차례, 투표, 정답 맞히기', () => {
|
|
let s = tick(game());
|
|
expect(helpNow(view(s, 'A'), 'A', users)).toContain('내 차례예요');
|
|
expect(helpNow(view(s, 'B'), 'B', users)).toContain(`${users.A!.nickname}님이 설명하는 중`);
|
|
s = { ...s, phase: { kind: 'vote', startedAt: T, endsAt: T + 30_000, round: 1, candidates: [...ids], votes: {} } };
|
|
expect(helpNow(view(s, 'A'), 'A', users)).toContain('동점이면 동점인 사람끼리');
|
|
s = applyAction('liar', s, 'A', { type: 'vote', target: 'D' }, undefined, T + 1000);
|
|
expect(helpNow(view(s, 'A'), 'A', users)).toContain(`${users.D!.nickname}님을 골랐어요`);
|
|
s = { ...s, phase: { kind: 'guess', startedAt: T, endsAt: T + 30_000 } };
|
|
expect(helpNow(view(s, 'D'), 'D', users)).toContain('[정답!]');
|
|
expect(helpNow(view(s, 'A'), 'A', users)).toContain(`${users.D!.nickname}님이 라이어였어요`);
|
|
});
|