병합: wt2/one-card
This commit is contained in:
@@ -1225,12 +1225,18 @@ const PLANS: Record<string, Plan> = {
|
||||
'one-card': {
|
||||
// 3 players, default 원카드: whoever has the turn plays a highlighted card (tap to lift, tap again to play,
|
||||
// pick a suit for 7) or draws; the 원카드 button is pressed whenever it lights up. 60 turns or until the game ends.
|
||||
// Checks on the way: playing down to one card never calls by itself (the separate round button is still lit for
|
||||
// the owner, the others count down "잡기 N초" first), cards fly from the deck when someone draws.
|
||||
players: 3,
|
||||
drive: async (pages) => {
|
||||
const statusOf = (p: Page) => p.locator('.turn-status').innerText().catch(() => '');
|
||||
const handCount = (p: Page) => p.locator('.oc-hand button.oc-card').count();
|
||||
const shot = (p: Page, name: string) => p.screenshot({ path: join(SHOTS, `one-card-${name}-${tag(p)}.png`), fullPage: tag(p) === 'phone' });
|
||||
let turns = 0;
|
||||
let plays = 0;
|
||||
let draws = 0;
|
||||
let flown = 0;
|
||||
let separateCall = 0;
|
||||
let finished = false;
|
||||
for (let t = 0; t < 600 && turns < 60; t++) {
|
||||
if (await pages[0]!.getByRole('dialog', { name: '게임 결과' }).count()) {
|
||||
@@ -1247,16 +1253,43 @@ const PLANS: Record<string, Plan> = {
|
||||
const card = p.locator('button.oc-card[data-legal="true"]').first();
|
||||
if (await accept.count()) await accept.click();
|
||||
else if (await card.count()) {
|
||||
const leavesOne = (await handCount(p)) === 2;
|
||||
await card.click();
|
||||
if (leavesOne && !separateCall) {
|
||||
await p.getByText('낸 다음 [원카드!]를 따로 눌러요').waitFor({ timeout: 2000 });
|
||||
await shot(p, 'before-last');
|
||||
}
|
||||
await card.click();
|
||||
const pick = p.locator('.oc-pick button').first();
|
||||
if (await pick.waitFor({ timeout: 400 }).then(() => true, () => false)) await pick.click();
|
||||
plays++;
|
||||
if (leavesOne && !separateCall && (await p.locator('.oc-onebtn.urgent').waitFor({ timeout: 3000 }).then(() => true, () => false))) {
|
||||
// Not called by the play: the owner's button pulses, another player waits out the protection time.
|
||||
const other = pages.find((q) => q !== p)!;
|
||||
await other.locator('.oc-onebtn.wait').waitFor({ timeout: 2000 });
|
||||
if (!(await other.locator('.oc-onebtn').isDisabled())) throw new Error('catch button lit during the protection time');
|
||||
await shot(p, 'call');
|
||||
await shot(other, 'catch-wait');
|
||||
await p.emulateMedia({ colorScheme: 'dark' });
|
||||
await p.waitForTimeout(300);
|
||||
await shot(p, 'call-dark');
|
||||
await p.emulateMedia({ colorScheme: 'light' });
|
||||
separateCall++;
|
||||
}
|
||||
} else {
|
||||
const pass = p.getByRole('button', { name: '넘기기' });
|
||||
if (await pass.count()) await pass.click();
|
||||
else await p.getByRole('button', { name: /장 먹기$/ }).first().click();
|
||||
draws++;
|
||||
// Cards fly from the deck to whoever draws, on every screen.
|
||||
const watcher = pages.find((q) => q !== p)!;
|
||||
if (flown < 2 && (await watcher.locator('.oc-fly').first().waitFor({ timeout: 1500 }).then(() => true, () => false))) {
|
||||
flown++;
|
||||
if (flown === 1) {
|
||||
await shot(watcher, 'draw-fly');
|
||||
await shot(p, 'draw-fly');
|
||||
}
|
||||
}
|
||||
}
|
||||
await p.waitForFunction((s) => document.querySelector('.turn-status')?.textContent?.trim() !== s, before.trim(), { timeout: 5000 }).catch(() => {});
|
||||
turns++;
|
||||
@@ -1267,7 +1300,8 @@ const PLANS: Record<string, Plan> = {
|
||||
}
|
||||
if (!finished && turns < 30) throw new Error(`only ${turns} turns were played`);
|
||||
if (finished) await pages[0]!.screenshot({ path: join(SHOTS, 'one-card-3-result-pc.png') });
|
||||
console.log(` one-card: ${turns} turns (${plays} plays, ${draws} draws)${finished ? ', game finished' : ''}`);
|
||||
if (draws > 0 && !flown) throw new Error('no flying cards seen when someone drew');
|
||||
console.log(` one-card: ${turns} turns (${plays} plays, ${draws} draws, separate 원카드 checked ${separateCall}×, draw flights seen ${flown}×)${finished ? ', game finished' : ''}`);
|
||||
},
|
||||
},
|
||||
uno: {
|
||||
|
||||
Reference in New Issue
Block a user