diff --git a/e2e/games.e2e.ts b/e2e/games.e2e.ts index 00e8784..a7ba936 100644 --- a/e2e/games.e2e.ts +++ b/e2e/games.e2e.ts @@ -1234,6 +1234,8 @@ async function sixStep(p: Page, phone: boolean, st: { selects: number; taps: num return false; } return false; +} + /** * 티츄: one UI step for `p` — grand tichu "안 함", the exchange (추천대로 채우기 → 보내기), dragon gift, "폭탄 없음", @@ -1298,6 +1300,9 @@ async function tichuStep(p: Page, isHost: boolean, st: Record): return press(play, 'play'); } if (await on(pass)) return press(pass, 'pass'); + return null; +} + /** 버건디의 성: one UI step for whoever must decide on page `p` (null = nothing to do here). */ async function cobStep(p: Page, st: Record): Promise { const status = (await p.locator('.turn-status').innerText().catch(() => '')).trim(); @@ -3491,63 +3496,6 @@ const PLANS: Record = { let acted = false; for (const [i, p] of pages.entries()) { if (await sixStep(p, i > 0, st)) { - 'hot-streak': { - // PC host + phone guest, one race (so it is also the last one: 두 배 티켓), cards every 1.2 s. Real draft (one risky - // face), secret cards (2 each with 2 players), a few cards flipped by the server clock, then both press 빨리 보기, - // payout table, final result. The put-in cards stay private. - players: 2, - lobby: async (host) => { - await host.getByRole('group', { name: '경주 수' }).getByRole('button', { name: '1번(맛보기)' }).click(); - await host.getByRole('group', { name: '카드 넘기는 간격' }).getByRole('button', { name: '1.2초' }).click(); - await host.getByText('경주 1번').first().waitFor(); - }, - drive: async (pages) => { - const [host, guest] = pages as [Page, Page]; - const st = { drafts: 0, risky: 0, doubles: 0, puts: 0, flips: 0, hurried: false, payout: false }; - const shots = new Set(); - const over = () => host.getByRole('dialog', { name: '게임 결과' }).count(); - const shot = async (name: string) => { - if (shots.has(name)) return; - shots.add(name); - await host.screenshot({ path: join(SHOTS, `hot-streak-${name}-pc.png`) }); - await guest.screenshot({ path: join(SHOTS, `hot-streak-${name}-phone.png`), fullPage: true }); - await guest.setViewportSize({ width: 320, height: 720 }); - await guest.waitForTimeout(300); - await guest.screenshot({ path: join(SHOTS, `hot-streak-${name}-phone320.png`), fullPage: true }); - const wide = await guest.evaluate(() => document.documentElement.scrollWidth); - if (wide > 322) throw new Error(`hot-streak ${name}: page is ${wide}px wide at 320px`); - await guest.setViewportSize({ width: 390, height: 844 }); - }; - const tryClick = (l: Locator) => l.click({ timeout: 2000 }).then(() => true, () => false); - const until = Date.now() + 240_000; - while (Date.now() < until && !(await over())) { - let acted = false; - for (const p of pages) { - const stack = p.locator('section[aria-label="티켓 뽑기"] button.hs-stack:not([disabled])').first(); - if (await stack.count()) { - if (st.drafts === 1) await shot('draft'); - if (!(await stack.click({ timeout: 2000 }).then(() => true, () => false))) continue; - const risky = st.risky === 0; - if (!(await tryClick(p.getByRole('button', { name: risky ? /위험으로/ : /안전으로/ }).first()))) continue; - st.drafts++; - if (risky) st.risky++; - acted = true; - break; - } - const dbl = p.locator('section[aria-label="두 배 티켓 고르기"] button.btn:not([disabled])').first(); - // The panel goes away once the server answers: a click that finds nothing is just retried next round. - if ((await dbl.count()) && (await dbl.click({ timeout: 2000 }).then(() => true, () => false))) { - st.doubles++; - acted = true; - break; - } - const cards = p.locator('section[aria-label="비밀 카드 넣기"] button.hs-hcard:not([disabled])'); - if ((await cards.count()) && (await p.getByRole('button', { name: /몰래 넣기/ }).count())) { - await shot('submit'); - if (!(await tryClick(cards.nth(0))) || !(await tryClick(cards.nth(1))) || !(await tryClick(p.getByRole('button', { name: /몰래 넣기/ })))) continue; - // The first one sees their own card while waiting; the last one starts the race at once. - if (st.puts === 0) await p.getByText('넣은 카드:').waitFor({ timeout: 5000 }); - st.puts++; acted = true; break; } @@ -3579,29 +3527,6 @@ const PLANS: Record = { const wide = await guest.evaluate(() => document.documentElement.scrollWidth); if (wide > 322) throw new Error(`page is ${wide}px wide at 320px`); await guest.setViewportSize({ width: 390, height: 844 }); - const flips = await host.locator('.hs-flipped .hs-card').count(); - st.flips = Math.max(st.flips, flips); - if (flips >= 3 && !shots.has('race')) { - await shot('race'); - await host.emulateMedia({ colorScheme: 'dark' }); - await host.waitForTimeout(250); - await host.screenshot({ path: join(SHOTS, 'hot-streak-race-pc-dark.png') }); - await host.emulateMedia({ colorScheme: 'light' }); - // Secret cards: each sees only their own. - const mineH = await host.getByText('넣은 카드:').count(); - const mineG = await guest.getByText('넣은 카드:').count(); - if (mineH || mineG) throw new Error('put-in cards still shown during the race'); - } - if (shots.has('race') && !st.hurried) { - for (const p of pages) await p.getByRole('button', { name: /빨리 보기/ }).click(); - st.hurried = true; - } - const next = host.getByRole('button', { name: /최종 결과 보기|다음 경주로/ }); - if (await next.count()) { - st.payout = true; - await host.waitForTimeout(300); - await shot('payout'); - acted = await tryClick(next); } if (!acted) await host.waitForTimeout(150); } @@ -3655,6 +3580,8 @@ const PLANS: Record = { 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), 그다음은 마우스로 // 이음점 누르기 → [놓기]. 휴대폰은 블록 고르기 → 칸 누르기(안 되는 자리는 빨간 미리보기·이유, [놓기] 꺼짐) → 이음점을 두 번 @@ -3783,6 +3710,97 @@ const PLANS: Record = { 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('승리'))}`); + }, + }, + 'hot-streak': { + // PC host + phone guest, one race (so it is also the last one: 두 배 티켓), cards every 1.2 s. Real draft (one risky + // face), secret cards (2 each with 2 players), a few cards flipped by the server clock, then both press 빨리 보기, + // payout table, final result. The put-in cards stay private. + players: 2, + lobby: async (host) => { + await host.getByRole('group', { name: '경주 수' }).getByRole('button', { name: '1번(맛보기)' }).click(); + await host.getByRole('group', { name: '카드 넘기는 간격' }).getByRole('button', { name: '1.2초' }).click(); + await host.getByText('경주 1번').first().waitFor(); + }, + drive: async (pages) => { + const [host, guest] = pages as [Page, Page]; + const st = { drafts: 0, risky: 0, doubles: 0, puts: 0, flips: 0, hurried: false, payout: false }; + const shots = new Set(); + const over = () => host.getByRole('dialog', { name: '게임 결과' }).count(); + const shot = async (name: string) => { + if (shots.has(name)) return; + shots.add(name); + await host.screenshot({ path: join(SHOTS, `hot-streak-${name}-pc.png`) }); + await guest.screenshot({ path: join(SHOTS, `hot-streak-${name}-phone.png`), fullPage: true }); + await guest.setViewportSize({ width: 320, height: 720 }); + await guest.waitForTimeout(300); + await guest.screenshot({ path: join(SHOTS, `hot-streak-${name}-phone320.png`), fullPage: true }); + const wide = await guest.evaluate(() => document.documentElement.scrollWidth); + if (wide > 322) throw new Error(`hot-streak ${name}: page is ${wide}px wide at 320px`); + await guest.setViewportSize({ width: 390, height: 844 }); + }; + const tryClick = (l: Locator) => l.click({ timeout: 2000 }).then(() => true, () => false); + const until = Date.now() + 240_000; + while (Date.now() < until && !(await over())) { + let acted = false; + for (const p of pages) { + const stack = p.locator('section[aria-label="티켓 뽑기"] button.hs-stack:not([disabled])').first(); + if (await stack.count()) { + if (st.drafts === 1) await shot('draft'); + if (!(await stack.click({ timeout: 2000 }).then(() => true, () => false))) continue; + const risky = st.risky === 0; + if (!(await tryClick(p.getByRole('button', { name: risky ? /위험으로/ : /안전으로/ }).first()))) continue; + st.drafts++; + if (risky) st.risky++; + acted = true; + break; + } + const dbl = p.locator('section[aria-label="두 배 티켓 고르기"] button.btn:not([disabled])').first(); + // The panel goes away once the server answers: a click that finds nothing is just retried next round. + if ((await dbl.count()) && (await dbl.click({ timeout: 2000 }).then(() => true, () => false))) { + st.doubles++; + acted = true; + break; + } + const cards = p.locator('section[aria-label="비밀 카드 넣기"] button.hs-hcard:not([disabled])'); + if ((await cards.count()) && (await p.getByRole('button', { name: /몰래 넣기/ }).count())) { + await shot('submit'); + if (!(await tryClick(cards.nth(0))) || !(await tryClick(cards.nth(1))) || !(await tryClick(p.getByRole('button', { name: /몰래 넣기/ })))) continue; + // The first one sees their own card while waiting; the last one starts the race at once. + if (st.puts === 0) await p.getByText('넣은 카드:').waitFor({ timeout: 5000 }); + st.puts++; + acted = true; + break; + } + } + const flips = await host.locator('.hs-flipped .hs-card').count(); + st.flips = Math.max(st.flips, flips); + if (flips >= 3 && !shots.has('race')) { + await shot('race'); + await host.emulateMedia({ colorScheme: 'dark' }); + await host.waitForTimeout(250); + await host.screenshot({ path: join(SHOTS, 'hot-streak-race-pc-dark.png') }); + await host.emulateMedia({ colorScheme: 'light' }); + // Secret cards: each sees only their own. + const mineH = await host.getByText('넣은 카드:').count(); + const mineG = await guest.getByText('넣은 카드:').count(); + if (mineH || mineG) throw new Error('put-in cards still shown during the race'); + } + if (shots.has('race') && !st.hurried) { + for (const p of pages) await p.getByRole('button', { name: /빨리 보기/ }).click(); + st.hurried = true; + } + const next = host.getByRole('button', { name: /최종 결과 보기|다음 경주로/ }); + if (await next.count()) { + st.payout = true; + await host.waitForTimeout(300); + await shot('payout'); + acted = await tryClick(next); + } + if (!acted) await host.waitForTimeout(150); + } + if (!(await over())) throw new Error(`game did not finish (${JSON.stringify(st)})`); + await guest.getByRole('dialog', { name: '게임 결과' }).waitFor(); await host.waitForTimeout(500); await host.screenshot({ path: join(SHOTS, 'hot-streak-result-pc.png') }); await guest.screenshot({ path: join(SHOTS, 'hot-streak-result-phone.png') }); @@ -3791,6 +3809,8 @@ const PLANS: Record = { await host.screenshot({ path: join(SHOTS, 'hot-streak-final-pc.png'), fullPage: true }); if (st.drafts !== 6 || st.doubles !== 2 || st.puts !== 2 || st.flips < 3 || !st.hurried || !st.payout) throw new Error(`too few real steps: ${JSON.stringify(st)}`); console.log(` hot-streak: ${st.drafts} tickets (${st.risky} risky), ${st.doubles} doubles, ${st.puts} secret puts, ${st.flips}+ cards flipped on the clock, 빨리 보기, payout`); + }, + }, tichu: { // PC host + 3 phone guests, 4인 팀전 to 300 points with 45-second turns: real grand / exchange / plays (card taps, // suggestion chips, keyboard on PC) through the UI until round 1 is scored and round 2 is being played. @@ -3847,6 +3867,8 @@ const PLANS: Record = { if ((st.play ?? 0) < 10 || !st.exchange || !st.grand || !st.tapped || !st.keys) throw new Error(`too few real steps: ${JSON.stringify(st)}`); await host.screenshot({ path: join(SHOTS, 'tichu-round2-pc.png') }); console.log(` tichu: ${JSON.stringify(Object.fromEntries(Object.entries(st).filter(([k]) => !k.includes('shot'))))}`); + }, + }, 'castles-of-burgundy': { // PC host + phone guest. Real turns through the UI (pick a die → highlighted space / depot tile / workers, // pendings from the banner, discard and confirm sheets) for both players, screenshots on PC and phone (light +