Merge branch 'wip/game-gemblo' into codex/owner/grp_discord_joke-app

# Conflicts:
#	apps/web/src/games/registry.ts
#	apps/web/src/lib/catalog-ui.ts
#	docs/games/README.md
#	e2e/games.e2e.ts
#	packages/games/package.json
#	packages/games/src/bots/index.ts
#	packages/games/src/index.ts
#	packages/shared/src/bots.ts
#	packages/shared/src/catalog.ts
This commit is contained in:
EJClaw
2026-10-15 19:41:49 +09:00
27 changed files with 3961 additions and 25 deletions

View File

@@ -3345,6 +3345,134 @@ const PLANS: Record<string, Plan> = {
await host.screenshot({ path: join(SHOTS, 'six-nimmt-pro-result-pc.png') });
if (st.drafts !== 20 || st.selects < 19) throw new Error(`too few real steps: ${JSON.stringify(st)}`);
console.log(` six-nimmt-pro: ${st.drafts} draft picks, ${st.selects} card picks, ${st.rows} row choices, ${st.spots} spot choices`);
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('승리'))}`);
},
},
};