새 게임 버건디의 성: 주사위 두 개로 육각 타일을 가져와 1번 공국을 채우는 2~4명 개인전 + 혼자 하기(2019년판 규칙), 시작 성 고르기·2011 수도원·추가 타일·여관·방패를 방 설정으로
- 데이터 packages/games/src/castles-of-burgundy/data.ts: 1번 공국 37칸(구역 13개 계산), 인원별 보급소 칸 색(3인 6번 보급소 B·D 광산), 타일 164장 + 추가 4장 + 여관 5장, 수도원 26+2종, 방패 18종, 점수표. 확인 안 된 데이터(가축 분포·검은 뒷면 수도원·장인 번호·2/3인 칸)는 UNCONFIRMED 주석으로 한 곳에 - 엔진(engine·moves·index): 페이즈 5 × 라운드 5, 일꾼 눈 바꾸기(6↔1, 수도원 8·9~12·방패 16), 가져오기·놓기·팔기·일꾼, 구역 완성·색 보너스·가축·건물 8종·배·성 연쇄를 pending 스택으로, 검은 보급소 구매(수도원 6번 2019/2011), 페이즈 끝 광산·방패 유지비·방패 14/15, 게임 끝 점수와 동점(빈칸 많은 사람 → 차례 트랙 뒤), 혼자 하기(강으로만 넓히기·목표 표시기·상품 5장 바꾸기·색 완성 보상), 시간 초과 자동 진행·자리 비움·기권 - 합법성은 actionError 하나, 합법 수는 후보를 그것으로 거름. view는 더미·다음 페이즈 상품·남의 판 상품 종류를 숨김 - 컴퓨터(bot.ts): 뷰를 상태로 되돌려 자기 차례를 미리 두고 주사위 A → B 묶음을 평가(1~20 한 수+잡음, 21~40 상위 3개, 41~60 상위 6개), 묶음은 차례 끝까지 기억. 한 수 평균 2~18ms - 화면 apps/web/src/games/castles-of-burgundy/: PC는 가운데 판(보급소 1~6·검은 보급소·여관·남은 상품·색 보너스) + 내 공국 SVG + 오른쪽에 다른 사람 요약·작은 공국, 휴대폰은 [내 공국]/[보급소]/[다른 사람] 탭 + 아래 고정 주사위 줄. 주사위를 고르면 가져올 타일·놓을 칸·팔 상품이 빛나고 "일꾼 n" 배지, 버릴 칸·확인·내는 방법 시트, 성 보너스·배·건물·방패 등 대기 효과는 배너와 버튼. 소리·배너(구역 완성·색 완성·페이즈), 도움말·30초 요약·타일 효과 표 - 등록: GAMES·BOT_STRATEGIES·BOT_GAMES·CATALOG·GAME_UI·GAME_ICON·판·주사위 탭, docs/games/README.md, docs/games/castles-of-burgundy.md(§2 나중에 표시, §13 구현 결정) - 나중에(데이터 필요): 팀전, 공국 2~10번(duchy), 흰 성, 무역로, 국경 초소 - 테스트: 규칙 48개(문서 §10), 무작위 대국 4가지 옵션(타일·상품 수 보존, JSON 왕복, 결정성) + 깊게 두기, 컴퓨터 3개(1단계 < 60단계), 방 통합 1개(연습 + 시간 넘김), e2e games.e2e.ts castles-of-burgundy(PC + 휴대폰 실제 행동 70번, 320px 넘침 없음, 기권으로 결과) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
145
e2e/games.e2e.ts
145
e2e/games.e2e.ts
@@ -1191,6 +1191,86 @@ async function magicalStep(p: Page, phone: boolean, st: { picks: number; selects
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 버건디의 성: one UI step for whoever must decide on page `p` (null = nothing to do here). */
|
||||
async function cobStep(p: Page, st: Record<string, number>): Promise<string | null> {
|
||||
const status = (await p.locator('.turn-status').innerText().catch(() => '')).trim();
|
||||
if (!/^내 차례|시작 성을 놓을/.test(status)) return null;
|
||||
const vis = (sel: string) => p.locator(`${sel}:visible`);
|
||||
const confirm = async () => {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const sheet = p.getByRole('dialog');
|
||||
if (!(await sheet.count())) return;
|
||||
const discard = sheet.getByRole('button', { name: /버리기$/ }).first();
|
||||
if (await discard.count()) {
|
||||
await discard.click();
|
||||
st.discard = (st.discard ?? 0) + 1;
|
||||
continue;
|
||||
}
|
||||
const yes = sheet.getByRole('button', { name: /^(네|놓기)$/ }).first();
|
||||
if (await yes.count()) await yes.click();
|
||||
const pick = sheet.locator('.cob-tile-sheet button').first();
|
||||
if (await pick.count()) await pick.click();
|
||||
await p.waitForTimeout(80);
|
||||
}
|
||||
};
|
||||
const space = vis('.cob-duchy .sp.on').first();
|
||||
// Castle choice / pendings with space targets (town hall) / die targets: prefer placing.
|
||||
if (/시작 성/.test(status) && (await space.count())) {
|
||||
await space.click();
|
||||
await confirm();
|
||||
return 'castle';
|
||||
}
|
||||
const banner = vis('.cob-banner.mine');
|
||||
if (await banner.count()) {
|
||||
if (await space.count()) {
|
||||
await space.click();
|
||||
await confirm();
|
||||
return 'pendingPlace';
|
||||
}
|
||||
const tile = vis('.cob-hexbtn.on:not(:disabled)').first();
|
||||
if ((await tile.count()) && !/성 보너스|목표/.test(await banner.innerText())) {
|
||||
await tile.click();
|
||||
await confirm();
|
||||
return 'pendingTile';
|
||||
}
|
||||
const choice = banner.locator('.cob-choices button').first();
|
||||
if (await choice.count()) {
|
||||
await choice.click();
|
||||
await confirm();
|
||||
return 'pending';
|
||||
}
|
||||
}
|
||||
const dice = vis('.cob-diebtn:not(:disabled)');
|
||||
if (await dice.count()) {
|
||||
await dice.first().click();
|
||||
await p.waitForTimeout(120);
|
||||
const target = vis('.cob-duchy .sp.on').first();
|
||||
if (await target.count()) {
|
||||
await target.click();
|
||||
await confirm();
|
||||
return 'place';
|
||||
}
|
||||
const take = vis('.cob-hexbtn.on:not(:disabled)').first();
|
||||
if (await take.count()) {
|
||||
await take.click();
|
||||
await confirm();
|
||||
return 'take';
|
||||
}
|
||||
const workers = vis('.cob-bar button').filter({ hasText: '일꾼 2개 받기' }).first();
|
||||
if (await workers.count()) {
|
||||
await workers.click();
|
||||
return 'workers';
|
||||
}
|
||||
}
|
||||
const end = vis('.cob-bar button').filter({ hasText: '차례 끝' }).first();
|
||||
if (await end.count()) {
|
||||
await end.click();
|
||||
await confirm();
|
||||
return 'end';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const PLANS: Record<string, Plan> = {
|
||||
blackjack: {
|
||||
// PC host + phone guest. Each hand: bet the minimum, stand (decline insurance), then press 다음 판, until the
|
||||
@@ -3190,6 +3270,71 @@ const PLANS: Record<string, Plan> = {
|
||||
console.log(` magical-athlete: ${st.picks} picks, ${st.selects} race picks, ${st.acts} turn choices (${st.second} second options), powers + wild track seen`);
|
||||
},
|
||||
},
|
||||
'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 +
|
||||
// dark, phone depot tab), then the guest concedes and both see the result. The rules are covered by the engine tests.
|
||||
drive: async (pages) => {
|
||||
const [host, guest] = pages as [Page, Page];
|
||||
const st: Record<string, number> = {};
|
||||
let steps = 0;
|
||||
const until = Date.now() + 300_000;
|
||||
while (Date.now() < until && steps < 70) {
|
||||
let acted: string | null = null;
|
||||
for (const p of pages) {
|
||||
const before = (await p.locator('.turn-status').innerText().catch(() => '')).trim();
|
||||
acted = await cobStep(p, st);
|
||||
if (acted) {
|
||||
st[acted] = (st[acted] ?? 0) + 1;
|
||||
steps++;
|
||||
await p
|
||||
.waitForFunction((b) => (document.querySelector('.turn-status')?.textContent ?? '').trim() !== b || !!document.querySelector('[role="dialog"]'), before, { timeout: 3000 })
|
||||
.catch(() => {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (steps === 30 && acted) {
|
||||
await host.waitForTimeout(500);
|
||||
await host.screenshot({ path: join(SHOTS, 'castles-of-burgundy-mid-pc.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'castles-of-burgundy-mid-phone.png'), fullPage: true });
|
||||
const tab = guest.getByRole('tab', { name: '보급소' });
|
||||
if (await tab.count()) {
|
||||
await tab.click();
|
||||
await guest.screenshot({ path: join(SHOTS, 'castles-of-burgundy-depots-phone.png'), fullPage: true });
|
||||
await guest.getByRole('tab', { name: '내 공국' }).click();
|
||||
}
|
||||
// Narrowest phone (320px): no sideways overflow.
|
||||
const vp = guest.viewportSize();
|
||||
await guest.setViewportSize({ width: 320, height: 640 });
|
||||
await guest.waitForTimeout(300);
|
||||
await guest.screenshot({ path: join(SHOTS, 'castles-of-burgundy-mid-phone-320.png'), fullPage: true });
|
||||
const overflow = await guest.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
||||
if (overflow > 1) throw new Error(`320px phone overflows sideways by ${overflow}px`);
|
||||
if (vp) await guest.setViewportSize(vp);
|
||||
await host.emulateMedia({ colorScheme: 'dark' });
|
||||
await guest.emulateMedia({ colorScheme: 'dark' });
|
||||
await host.waitForTimeout(300);
|
||||
await host.screenshot({ path: join(SHOTS, 'castles-of-burgundy-mid-pc-dark.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'castles-of-burgundy-mid-phone-dark.png'), fullPage: true });
|
||||
await host.emulateMedia({ colorScheme: 'light' });
|
||||
await guest.emulateMedia({ colorScheme: 'light' });
|
||||
}
|
||||
if (!acted) await host.waitForTimeout(150);
|
||||
}
|
||||
if ((st.place ?? 0) + (st.take ?? 0) < 6 || !st.end) throw new Error(`too few real actions: ${JSON.stringify(st)}`);
|
||||
// The guest concedes → 2-player game ends.
|
||||
const concede = guest.getByRole('button', { name: /기권$/ }).first();
|
||||
await concede.scrollIntoViewIfNeeded();
|
||||
await concede.click();
|
||||
await guest.getByRole('dialog').getByRole('button', { name: '기권하기' }).click();
|
||||
await host.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 10_000 });
|
||||
await guest.getByRole('dialog', { name: '게임 결과' }).waitFor();
|
||||
await host.waitForTimeout(500);
|
||||
await host.screenshot({ path: join(SHOTS, 'castles-of-burgundy-result-pc.png') });
|
||||
await guest.screenshot({ path: join(SHOTS, 'castles-of-burgundy-result-phone.png') });
|
||||
console.log(` castles-of-burgundy: ${steps} UI steps ${JSON.stringify(st)}`);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const games = process.argv.slice(2).length ? process.argv.slice(2) : Object.keys(PLANS);
|
||||
|
||||
Reference in New Issue
Block a user