import { expect, test } from 'bun:test'; import { applyAction, setupGame, usersOf } from '../help-kit.test-util'; import { GAMES } from '@bg/games'; import { helpNow } from './help'; const users = usersOf(['A', 'B']); const view = (s: unknown, who: string | null) => GAMES.baduk!.view(s, who) as any; const opts = { colorAssignment: 'hostBlack', boardSize: 9 }; test('바둑: 내 차례 / 상대 차례 / 관전 / 덤 안내', () => { const { state } = setupGame('baduk', 2, opts); const a = helpNow(view(state, 'A'), 'A', users); expect(a).toContain('내 차례예요(흑)'); expect(a).toContain('[✋ 패스]'); expect(a).toContain('덤'); expect(helpNow(view(state, 'B'), 'B', users)).toContain('상대(호랑이님) 차례예요'); expect(helpNow(view(state, null), null, users)).toContain('호랑이님(흑) 차례예요'); const s2 = applyAction('baduk', state, 'A', { type: 'place', x: 4, y: 4 }); const b = helpNow(view(s2, 'B'), 'B', users); expect(b).toContain('내 차례예요(백)'); expect(b).toContain('따낸 돌은 흑 0개, 백 0개'); }); test('바둑: 접바둑이면 백이 먼저 둬요', () => { const { state } = setupGame('baduk', 2, { ...opts, handicap: 2 }); expect(helpNow(view(state, 'B'), 'B', users)).toContain('접바둑이라 흑 돌 2개'); }); test('바둑: 패스 → 사석 확인 → 동의', () => { const { state } = setupGame('baduk', 2, opts); let s = applyAction('baduk', state, 'A', { type: 'place', x: 4, y: 4 }); s = applyAction('baduk', s, 'B', { type: 'pass' }); expect(helpNow(view(s, 'A'), 'A', users)).toContain('상대가 패스했어요'); expect(helpNow(view(s, 'B'), 'B', users)).toContain('내가 패스했어요'); s = applyAction('baduk', s, 'A', { type: 'pass' }); const a = helpNow(view(s, 'A'), 'A', users); expect(a).toContain('[✕ 사석 표시]'); expect(a).toContain('[✔ 이 표시대로 동의]'); expect(a).toContain('흑 '); s = applyAction('baduk', s, 'A', { type: 'agreeScore' }); expect(helpNow(view(s, 'A'), 'A', users)).toContain('나는 동의했어요'); expect(helpNow(view(s, null), null, users)).toContain('고양이님이 확인 중'); s = applyAction('baduk', s, 'B', { type: 'agreeScore' }); expect(helpNow(view(s, 'A'), 'A', users)).toContain('대국이 끝났어요'); }); test('바둑: 무르기 요청을 받으면 수락/거절 안내', () => { const { state } = setupGame('baduk', 2, opts); let s = applyAction('baduk', state, 'A', { type: 'place', x: 4, y: 4 }); s = applyAction('baduk', s, 'A', { type: 'requestUndo' }); expect(helpNow(view(s, 'B'), 'B', users)).toContain('[수락]'); expect(helpNow(view(s, 'A'), 'A', users)).toContain('[요청 취소]'); });