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 = {}) { 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}님이 라이어였어요`); });