M9: 게임 26종 30초 요약 카드·[?] 지금 할 수 있는 것 내용
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
53
apps/web/src/games/chess/help.test.ts
Normal file
53
apps/web/src/games/chess/help.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { expect, test } from 'bun:test';
|
||||
import { SeededRng } from '../../../../../packages/engine/src/rng';
|
||||
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.chess!.view(s, who) as any;
|
||||
// Act a second after the previous action so the first-move limit (대국 취소) never fires.
|
||||
let clock = 1_700_000_000_000;
|
||||
const act = (s: any, who: string, a: unknown) => applyAction('chess', s, who, a, SeededRng.fromSeed([9, 9, 9, 9]), (clock += 1000));
|
||||
const move = (s: any, who: string, from: string, to: string) => act(s, who, { type: 'move', from, to });
|
||||
|
||||
test('체스: 내 차례(첫 수) / 상대 차례 / 관전', () => {
|
||||
const { state } = setupGame('chess', 2, { colorAssignment: 'hostWhite', hints: 'moves' });
|
||||
const mine = helpNow(view(state, 'A'), 'A', users);
|
||||
expect(mine).toContain('내 차례예요(백)');
|
||||
expect(mine).toContain('점이 찍혀요');
|
||||
expect(mine).toContain('대국이 취소돼요');
|
||||
expect(helpNow(view(state, 'B'), 'B', users)).toContain('상대(호랑이님) 차례예요');
|
||||
expect(helpNow(view(state, null), null, users)).toContain('호랑이님(백) 차례예요');
|
||||
});
|
||||
|
||||
test('체스: 체크를 받은 쪽과 건 쪽, 관전자', () => {
|
||||
const { state } = setupGame('chess', 2, { colorAssignment: 'hostWhite' });
|
||||
let s = move(state, 'A', 'e2', 'e4');
|
||||
s = move(s, 'B', 'f7', 'f6');
|
||||
s = move(s, 'A', 'd1', 'h5');
|
||||
expect(helpNow(view(s, 'B'), 'B', users)).toContain('체크예요!');
|
||||
expect(helpNow(view(s, 'A'), 'A', users)).toContain('체크를 걸었어요');
|
||||
expect(helpNow(view(s, null), null, users)).toContain('흑 킹이 체크');
|
||||
});
|
||||
|
||||
test('체스: 승진 안내(선택 창 / 자동 퀸)와 기물 점수', () => {
|
||||
for (const autoQueen of [false, true]) {
|
||||
const { state } = setupGame('chess', 2, { colorAssignment: 'hostWhite', autoQueen });
|
||||
const s = structuredClone(state);
|
||||
s.fen = '4k3/P7/8/8/8/8/8/4K3 w - - 0 1';
|
||||
const t = helpNow(view(s, 'A'), 'A', users);
|
||||
expect(t).toContain(autoQueen ? '자동으로 퀸' : '고르는 창');
|
||||
expect(t).toContain('백이 1점 앞서요');
|
||||
}
|
||||
});
|
||||
|
||||
test('체스: 무승부 제안을 받으면 수락/거절, 끝나면 결과', () => {
|
||||
const { state } = setupGame('chess', 2, { colorAssignment: 'hostWhite', drawOffer: true });
|
||||
let s = move(state, 'A', 'e2', 'e4');
|
||||
s = act(s, 'A', { type: 'offerDraw' });
|
||||
expect(helpNow(view(s, 'B'), 'B', users)).toContain('무승부를 제안');
|
||||
expect(helpNow(view(s, 'A'), 'A', users)).toContain('[요청 취소]');
|
||||
s = act(s, 'B', { type: 'respondDraw', accept: true });
|
||||
expect(helpNow(view(s, null), null, users)).toContain('게임이 끝났어요. 무승부');
|
||||
});
|
||||
Reference in New Issue
Block a user