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

# Conflicts:
#	apps/web/src/games/help.test.ts
#	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 23:29:17 +09:00
26 changed files with 5216 additions and 2 deletions

View File

@@ -3261,6 +3261,63 @@ const PLANS: Record<string, Plan> = {
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<string>();
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;
}
@@ -3292,6 +3349,29 @@ const PLANS: Record<string, Plan> = {
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);
}
@@ -3473,6 +3553,14 @@ const PLANS: Record<string, Plan> = {
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('승리'))}`);
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') });
await host.keyboard.press('Escape');
await host.locator('section[aria-label="최종 결과"]').waitFor();
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`);
},
},
};