새 게임 젬블로: 육각 보석 블록 땅따먹기(2~6명), 원작 인원별 구역·시작점과 5인 장애물, 변형 규칙을 방 설정으로
- 엔진 packages/games/src/gemblo/(board·options·types·index·bot): 463칸 판(3인 241·4인 295·듀오 157칸), 블록 18개 72칸(방향 74/뒤집기 포함 92개 미리 계산), 같은 색 변 맞댐 금지, 꼭짓점 이음선(한 블록이 사이 두 칸을 덮으면 막힘, 두 블록 틈은 통과), 놓을 곳 없는 색 자동 끝남, 남은 칸 점수·공동 순위 - 방 설정 §2 전부: 자리, 2명 2색/3색/듀오, 3명 1색/2색, 5명 장애물 자동/직접 고르기/없음, 이음선 막힘, 뒤집기(기본 허용), 점수(남은 칸/블로커스 보너스), 팀전(2명씩·3명씩), 금색 방해 블록 0/3/6, 이음점 표시, 시간(한 번당·피셔), 시간 초과 처리(자동 배치/넘김/끝), 연속 자동 한도, 무르기 - 합법 배치: 이음점 × 블록 × 방향 × 맞출 칸, (블록·방향·기준 칸) 도장으로 중복 제거, apply·legalActions 수 ms - 컴퓨터: 큰 블록 + 내 이음점 늘리기 + 남의 이음점 막기 + 초반 가운데로, 상위 80개만 자세히, humanBest 1~60단계, 한 수 10ms 안팎 - 화면 apps/web/src/games/gemblo/: 납작한 육각 SVG 판(안 쓰는 칸 흐리게, 보석 색 + 색약용 무늬), 마우스 미리보기·휠/R 돌리기·F 뒤집기, 휴대폰 칸 누르기·끌어 옮기기·[놓기], 이음점을 누르면 그 점을 덮는 합법 배치를 차례로, 두 손가락 확대·이동과 [확대]/[전체], 키보드 조작, 5인 장애물 고르기·놓기, 무르기·기권, 끝나면 색별 남은 블록, 소리·애니메이션, 도움말·30초 요약 - 등록: GAMES·BOT_STRATEGIES·BOT_GAMES·CATALOG·GAME_UI·GAME_ICON·판·주사위 탭, 운 제외(NO_LUCK), docs/games/README.md, docs/games/gemblo.md(구현 결정 13장) - 테스트: 규칙 30개(문서 §10 전부, 5인 장애물 시드 100개, 클라이언트 판정 = validate 1만 개, 무작위 대국 11가지 모드), 컴퓨터 4개, 도움말 2개, 방 통합 2개(연습 한 판, 5명 직접 고르기 + 시간 초과만 하는 사람), e2e games.e2e.ts gemblo Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
130
e2e/games.e2e.ts
130
e2e/games.e2e.ts
@@ -3190,6 +3190,136 @@ const PLANS: Record<string, Plan> = {
|
||||
console.log(` magical-athlete: ${st.picks} picks, ${st.selects} race picks, ${st.acts} turn choices (${st.second} second options), powers + wild track seen`);
|
||||
},
|
||||
},
|
||||
gemblo: {
|
||||
// PC 방장 + 휴대폰 친구(2명 → 2색씩, 4인 구역). PC 첫 수는 키보드(N으로 이음점의 놓는 방법 → Enter), 그다음은 마우스로
|
||||
// 이음점 누르기 → [놓기]. 휴대폰은 블록 고르기 → 칸 누르기(안 되는 자리는 빨간 미리보기·이유, [놓기] 꺼짐) → 이음점을 두 번
|
||||
// 눌러 다음 방법으로 바꾸기 → [놓기]. 16수 뒤 320px 화면·어두운 화면 확인, 휴대폰 쪽이 기권해 결과까지.
|
||||
lobby: async (host) => {
|
||||
await host.getByRole('group', { name: '시간' }).getByRole('button', { name: '시간 제한 없음' }).click();
|
||||
await host.getByText(/^시간 제한 없음/).first().waitFor();
|
||||
},
|
||||
drive: async (pages) => {
|
||||
const [host, guest] = pages as [Page, Page];
|
||||
const svg = (p: Page) => p.locator('svg.gm-board');
|
||||
await svg(host).waitFor();
|
||||
await svg(guest).waitFor();
|
||||
const placed = async (p: Page) => Number(await svg(p).getAttribute('data-placements'));
|
||||
const mine = async (p: Page) => (await svg(p).getAttribute('data-my-turn')) === '1';
|
||||
const center = async (p: Page, sel: string) => {
|
||||
const b = await p.locator(sel).first().boundingBox();
|
||||
if (!b) throw new Error(`no box for ${sel}`);
|
||||
return { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
||||
};
|
||||
const tapAt = async (p: Page, sel: string) => {
|
||||
const { x, y } = await center(p, sel);
|
||||
if (tag(p) === 'phone') await p.touchscreen.tap(x, y);
|
||||
else await p.mouse.click(x, y);
|
||||
};
|
||||
const st = { keyboard: false, mouse: 0, phone: 0, refused: false, cycled: false };
|
||||
let turns = 0;
|
||||
for (let t = 0; t < 400 && turns < 16; t++) {
|
||||
const p = (await mine(host)) ? host : (await mine(guest)) ? guest : null;
|
||||
if (!p) {
|
||||
await host.waitForTimeout(150);
|
||||
continue;
|
||||
}
|
||||
const before = await placed(p);
|
||||
if (p === host && !st.keyboard) {
|
||||
await keys(host, ['n']);
|
||||
await host.waitForFunction(() => document.querySelector('svg.gm-board')?.getAttribute('data-preview') === 'ok', null, { timeout: 5000 });
|
||||
await host.screenshot({ path: join(SHOTS, 'gemblo-preview-pc.png') });
|
||||
await host.keyboard.press('Enter');
|
||||
st.keyboard = true;
|
||||
} else if (p === host) {
|
||||
if (st.mouse === 1) {
|
||||
// A spot that doesn't work: red preview with the reason while hovering.
|
||||
await host.locator('.gm-tray [data-piece]:not([disabled]):not([data-locked])').first().click();
|
||||
// Over my own block: "다른 블록과 겹쳐요".
|
||||
const { x, y } = await center(host, `[data-block][data-color="${await host.locator('[data-chip].turn, .gm-chip.turn').first().getAttribute('data-chip')}"] polygon`);
|
||||
await host.mouse.move(x, y);
|
||||
await host.waitForFunction(() => document.querySelector('svg.gm-board')?.getAttribute('data-preview') === 'bad', null, { timeout: 5000 });
|
||||
await host.screenshot({ path: join(SHOTS, 'gemblo-refused-pc.png') });
|
||||
await host.keyboard.press('Escape');
|
||||
await svg(host).focus();
|
||||
await host.keyboard.press('Escape');
|
||||
await host.mouse.move(5, 5);
|
||||
}
|
||||
await tapAt(host, '[data-link]');
|
||||
await host.waitForFunction(() => document.querySelector('svg.gm-board')?.getAttribute('data-preview') === 'ok', null, { timeout: 5000 });
|
||||
await host.getByRole('button', { name: /^놓기 · / }).click();
|
||||
st.mouse++;
|
||||
} else {
|
||||
if (!st.refused) {
|
||||
// Pick a block, tap a cell next to my own colour (or anywhere that doesn't work): red preview, [놓기] off.
|
||||
await guest.locator('.gm-tray [data-piece]:not([disabled])').first().tap();
|
||||
const cells = await guest.locator('polygon[data-free]').evaluateAll((els) => els.map((e) => e.getAttribute('data-cell')!));
|
||||
for (const c of cells.slice(0, 40)) {
|
||||
const box = await guest.locator(`[data-cell="${c}"]`).boundingBox();
|
||||
if (!box || box.y < 0) continue;
|
||||
await guest.touchscreen.tap(box.x + box.width / 2, box.y + box.height / 2);
|
||||
if ((await svg(guest).getAttribute('data-preview')) === 'bad') break;
|
||||
}
|
||||
if ((await svg(guest).getAttribute('data-preview')) !== 'bad') throw new Error('no refused preview on the phone');
|
||||
if (await guest.getByRole('button', { name: /^놓기/ }).isEnabled()) throw new Error('[놓기] enabled for a refused spot');
|
||||
await guest.waitForTimeout(300);
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-refused-phone.png') });
|
||||
await guest.getByRole('button', { name: '취소' }).tap();
|
||||
st.refused = true;
|
||||
}
|
||||
await tapAt(guest, '[data-link]');
|
||||
await guest.waitForFunction(() => document.querySelector('svg.gm-board')?.getAttribute('data-preview') === 'ok', null, { timeout: 5000 });
|
||||
const first = await svg(guest).locator('[data-preview-cells]').getAttribute('data-preview-cells');
|
||||
await tapAt(guest, '[data-link]');
|
||||
await guest.waitForTimeout(150);
|
||||
const second = await svg(guest).locator('[data-preview-cells]').getAttribute('data-preview-cells');
|
||||
if (first !== second) st.cycled = true;
|
||||
if (st.phone === 0) await guest.screenshot({ path: join(SHOTS, 'gemblo-cycle-phone.png') });
|
||||
await guest.getByRole('button', { name: /^놓기 · / }).tap();
|
||||
st.phone++;
|
||||
}
|
||||
await p.waitForFunction((n) => Number(document.querySelector('svg.gm-board')?.getAttribute('data-placements')) > n, before, { timeout: 5000 });
|
||||
turns++;
|
||||
await host.waitForTimeout(120);
|
||||
}
|
||||
if (turns < 16) throw new Error(`only ${turns} turns (${JSON.stringify(st)})`);
|
||||
if (!st.cycled) throw new Error('tapping the same link point twice never changed the placement');
|
||||
await host.waitForTimeout(400);
|
||||
await host.screenshot({ path: join(SHOTS, 'gemblo-mid-pc.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-mid-phone.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-mid-phone-full.png'), fullPage: true });
|
||||
await guest.setViewportSize({ width: 320, height: 640 });
|
||||
await guest.waitForTimeout(400);
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-mid-phone-320.png'), fullPage: true });
|
||||
const wide = await guest.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 1);
|
||||
if (wide) throw new Error('board screen overflows at 320px');
|
||||
await host.emulateMedia({ colorScheme: 'dark' });
|
||||
await guest.emulateMedia({ colorScheme: 'dark' });
|
||||
await host.waitForTimeout(300);
|
||||
await host.screenshot({ path: join(SHOTS, 'gemblo-mid-pc-dark.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-mid-phone-320-dark.png') });
|
||||
await host.emulateMedia({ colorScheme: 'light' });
|
||||
await guest.emulateMedia({ colorScheme: 'light' });
|
||||
await guest.setViewportSize({ width: 390, height: 844 });
|
||||
// Zoom in and back (phone).
|
||||
await guest.getByRole('button', { name: '내 블록 근처 확대' }).tap();
|
||||
if (Number(await svg(guest).getAttribute('data-zoom')) <= 1) throw new Error('zoom did not change');
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-zoom-phone.png') });
|
||||
await guest.getByRole('button', { name: '판 전체 보기' }).tap();
|
||||
await guest.getByRole('button', { name: '🏳 기권' }).tap();
|
||||
await guest.getByRole('button', { name: '기권하기' }).tap();
|
||||
await host.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 10_000 });
|
||||
await guest.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 10_000 });
|
||||
await host.waitForTimeout(600);
|
||||
await host.screenshot({ path: join(SHOTS, 'gemblo-result-pc.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'gemblo-result-phone.png') });
|
||||
const summary = await host.getByRole('dialog', { name: '게임 결과' }).innerText();
|
||||
if (!/기권으로 .+ 승리/.test(summary)) throw new Error(`unexpected result: ${summary.slice(0, 120)}`);
|
||||
await host.keyboard.press('Escape');
|
||||
await host.locator('section[aria-label="남은 블록"]').waitFor();
|
||||
await host.screenshot({ path: join(SHOTS, 'gemblo-final-pc.png'), fullPage: true });
|
||||
console.log(` gemblo: ${turns} placements ${JSON.stringify(st)}, ${summary.split('\n').find((l) => l.includes('승리'))}`);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const games = process.argv.slice(2).length ? process.argv.slice(2) : Object.keys(PLANS);
|
||||
|
||||
Reference in New Issue
Block a user