도둑잡기(old-maid): 규칙·화면·컴퓨터 상대·테스트·문서·E2E
- 규칙 모듈 packages/games/src/old-maid: 2~8명, 트럼프 52장 + 조커 1장을 첫 사람(무작위)부터 한 장씩 나누고 같은 숫자 짝은 자동으로 버림. 차례에는 다음 자리(왼쪽)의 카드 있는 사람 손패에서 자리(index)로 한 장 뽑기(from 함께 보내 대상이 바뀌면 거절), 짝이 없으면 내 손패 무작위 자리에 숨김. 다 턴 순서대로 순위, 마지막 조커를 든 사람이 도둑(꼴찌). 결과 scoreText 에 "🃏 도둑"/"다 털었어요"/"나감" 표시. - 내 손패 섞기: 남은 사람 누구나 언제든, 차례마다 3번까지, 시계는 그대로. 남에게 보이는 자리는 실제 손패 순서이고, view 에는 남의 손패 장수만(뽑은 카드는 뽑은 사람에게만). - 시간 초과는 무작위 한 장 뽑기(3번 연속이면 5초), 카드를 든 채 나가면 그 카드를 섞어 다음 자리부터 한 장씩 나눠 주고 짝을 버림, 나간 사람은 맨 아래. 둘만 남았을 때 나가면 도둑 없이 끝. - 컴퓨터 상대(BOT_GAMES): 단계와 관계없이 무작위로 뽑고 가끔(15%) 자기 손패를 먼저 섞음. - 화면 apps/web/src/games/old-maid: 뽑힐 사람의 뒷면 카드를 펼쳐 고르기(tapConfirm 이면 두 번 눌러 확인, PC 한 번, 키보드 방향키+Enter), 섞으면 흔들림, 지난 뽑기·버린 짝, 내 손패(조커 표시)와 [🔀 섞기], 조커를 넘기면 알림. 30초 요약, 지금 할 수 있는 것, 규칙. - 등록(GAMES, 카탈로그, BOT_GAMES·전략, 화면 레지스트리, 아이콘·카드 탭), 도움말 테스트 게임 수 27, 문서 docs/games/old-maid.md, E2E 계획(PC 1 + 휴대폰 2, 끝까지). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
101
e2e/games.e2e.ts
101
e2e/games.e2e.ts
@@ -646,6 +646,56 @@ async function ninetyNineStep(p: Page, stats: Record<string, number>): Promise<b
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 도둑잡기: whoever shows "내 차례예요" draws one face-down card from the fan. PC: mouse click (one click draws) or now and
|
||||
* then the keyboard (focus, → , Enter); phones: tap to pick (the card lifts), tap again to draw (tapConfirm).
|
||||
*/
|
||||
async function oldMaidStep(p: Page, stats: Record<string, number>): Promise<boolean> {
|
||||
const status = (await p.locator('.turn-status').innerText().catch(() => '')).trim();
|
||||
if (!status.includes('내 차례예요')) return false;
|
||||
const cards = p.locator('.om-fan button.om-back');
|
||||
const n = await cards.count();
|
||||
if (!n) return false;
|
||||
const draws = stats.draws ?? 0;
|
||||
const card = cards.nth((draws * 7) % n);
|
||||
if (tag(p) === 'phone') {
|
||||
await card.tap();
|
||||
if ((await card.getAttribute('aria-pressed')) === 'true') {
|
||||
if (!stats[`shot-pick-${tag(p)}`]) {
|
||||
stats[`shot-pick-${tag(p)}`] = 1;
|
||||
await p.screenshot({ path: join(SHOTS, 'old-maid-pick-phone.png'), fullPage: true });
|
||||
}
|
||||
await card.tap();
|
||||
stats.confirm = (stats.confirm ?? 0) + 1;
|
||||
}
|
||||
} else if ((stats.pc = (stats.pc ?? 0) + 1) % 3 === 2 && n > 1) {
|
||||
await cards.first().focus();
|
||||
await p.keyboard.press('ArrowRight');
|
||||
await p.keyboard.press('Enter');
|
||||
stats.keyboard = (stats.keyboard ?? 0) + 1;
|
||||
} else {
|
||||
await card.click();
|
||||
stats.click = (stats.click ?? 0) + 1;
|
||||
}
|
||||
stats.draws = draws + 1;
|
||||
await p.waitForFunction((s) => document.querySelector('.turn-status')?.textContent?.trim() !== s, status, { timeout: 5000 }).catch(() => {});
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 도둑잡기: a player whose cards are being picked from shuffles them (button), a few times per game. */
|
||||
async function oldMaidShuffle(p: Page, stats: Record<string, number>): Promise<boolean> {
|
||||
if ((stats.shuffle ?? 0) >= 4) return false;
|
||||
const status = (await p.locator('.turn-status').innerText().catch(() => '')).trim();
|
||||
if (!status.includes('내 카드를 고르는 중')) return false;
|
||||
const btn = p.getByRole('button', { name: /^🔀 섞기/ });
|
||||
if (!(await btn.isEnabled().catch(() => false))) return false;
|
||||
const before = await p.locator('.om-hand').getAttribute('aria-label');
|
||||
await btn.click();
|
||||
await p.waitForFunction((b) => document.querySelector('.om-hand')?.getAttribute('aria-label') !== b || !document.querySelector('.om-hand'), before, { timeout: 3000 }).catch(() => {});
|
||||
stats.shuffle = (stats.shuffle ?? 0) + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 도블: one real tap on `p`'s own screen. Reads the pictures of the two compared cards from the DOM (data-art), taps the shared one
|
||||
* (or, when `wrong`, a picture of my card that is not on the other). PC: focus + Enter, phone: tap. Returns the judgement shown.
|
||||
@@ -2071,6 +2121,57 @@ const PLANS: Record<string, Plan> = {
|
||||
console.log(` ninety-nine: finished after ${turns} UI turns ${JSON.stringify(stats)}, ${outs} eliminations in the log`);
|
||||
},
|
||||
},
|
||||
'old-maid': {
|
||||
// PC host + 2 phones, real draws through the UI until only the joker is left: PC clicks (sometimes keyboard), phones tap
|
||||
// twice (pick, then draw). Whoever is being drawn from sometimes shuffles their hand. Screens: mid-game (light/dark), result.
|
||||
players: 3,
|
||||
drive: async (pages) => {
|
||||
const [host, guest] = pages as [Page, Page, Page];
|
||||
const stats: Record<string, number> = {};
|
||||
let shot = false;
|
||||
const until = Date.now() + 300_000;
|
||||
const over = () => host.getByRole('dialog', { name: '게임 결과' }).count();
|
||||
while (Date.now() < until && !(await over())) {
|
||||
let acted = false;
|
||||
for (const p of pages) if (await oldMaidShuffle(p, stats)) acted = true;
|
||||
for (const p of pages) {
|
||||
if (await oldMaidStep(p, stats)) {
|
||||
acted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!shot && (stats.draws ?? 0) >= 6) {
|
||||
shot = true;
|
||||
await host.waitForTimeout(500);
|
||||
await host.screenshot({ path: join(SHOTS, 'old-maid-mid-pc.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'old-maid-mid-phone.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'old-maid-mid-phone-full.png'), fullPage: true });
|
||||
// Narrowest supported phone.
|
||||
await guest.setViewportSize({ width: 320, height: 700 });
|
||||
await guest.waitForTimeout(300);
|
||||
await guest.screenshot({ path: join(SHOTS, 'old-maid-mid-phone-320.png'), fullPage: true });
|
||||
await guest.setViewportSize({ width: 390, height: 844 });
|
||||
await host.emulateMedia({ colorScheme: 'dark' });
|
||||
await guest.emulateMedia({ colorScheme: 'dark' });
|
||||
await host.waitForTimeout(400);
|
||||
await host.screenshot({ path: join(SHOTS, 'old-maid-mid-pc-dark.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'old-maid-mid-phone-dark.png'), fullPage: true });
|
||||
await host.emulateMedia({ colorScheme: 'light' });
|
||||
await guest.emulateMedia({ colorScheme: 'light' });
|
||||
}
|
||||
if (!acted) await host.waitForTimeout(120);
|
||||
}
|
||||
if (!(await over())) throw new Error(`game did not finish (${JSON.stringify(stats)})`);
|
||||
for (const p of pages) await p.getByRole('dialog', { name: '게임 결과' }).waitFor();
|
||||
const dialog = host.getByRole('dialog', { name: '게임 결과' });
|
||||
await dialog.getByText('🃏 도둑').first().waitFor({ timeout: 3000 });
|
||||
await host.waitForTimeout(600);
|
||||
await host.screenshot({ path: join(SHOTS, 'old-maid-result-pc.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'old-maid-result-phone.png') });
|
||||
if ((stats.draws ?? 0) < 6 || !stats.confirm || !stats.click || !stats.keyboard) throw new Error(`too few real turns: ${JSON.stringify(stats)}`);
|
||||
console.log(` old-maid: finished after ${JSON.stringify(Object.fromEntries(Object.entries(stats).filter(([k]) => !k.startsWith('shot'))))}`);
|
||||
},
|
||||
},
|
||||
dobble: {
|
||||
// PC host + phone guest, 탑 쌓기 with the 55-card deck and a 1-second lock. Both players find the shared picture of their own card and the centre
|
||||
// card on their own screen (PC: keyboard focus + Enter, phone: tap), one deliberate wrong tap (shake + lock), until the draw pile runs out.
|
||||
|
||||
Reference in New Issue
Block a user