새 게임 라이어 게임: 규칙 엔진·말하는 컴퓨터·화면·도움말·문서·E2E
- packages/games/src/liar: 주제 10개 제시어 은행, 설명(두 번째 바퀴 거꾸로)·자유 토론·투표(동점 재투표 한 번, 또 동점이면 라이어 승리)·라이어 정답 맞히기(띄어쓰기·다른 표기 무시), 바보 모드 - 컴퓨터: 마피아처럼 live 전략, 레벨 1~60을 LiveBotInput.level 로 받음(서버 BotDriver 가 넘김), BOT_CHAT_REQUIRED 에 추가 - 웹: 꾹 누르는 제시어 카드, 설명 기록·토론 채팅·투표 화면, 30초 요약, [?] 도움말 - 문서 docs/games/liar.md, 등록(GAMES·CATALOG·BOT_GAMES·registry·아이콘), 서버 방 테스트, E2E(거절 알림이 저절로 사라지는지 확인 포함) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
129
e2e/games.e2e.ts
129
e2e/games.e2e.ts
@@ -1042,6 +1042,39 @@ async function clueStep(p: Page, st: Record<string, number>, accuseAfter: number
|
||||
return 'end';
|
||||
}
|
||||
return null;
|
||||
|
||||
/** 라이어 게임: nicknames of the E2E pages (host first). */
|
||||
const LIAR_NICKS = ['방장', '친구', '친구2'];
|
||||
|
||||
/** 라이어 게임: shows the hold-to-see word card (keyboard Enter) and reads it: the word, or null for the liar. */
|
||||
async function liarWordOf(p: Page): Promise<string | null> {
|
||||
const card = p.locator('.lg-card');
|
||||
if (!(await card.getAttribute('aria-label'))!.startsWith('내 제시어 보기')) throw new Error('word card shows the word before it is held');
|
||||
await card.focus();
|
||||
await p.keyboard.press('Enter');
|
||||
const label = (await card.getAttribute('aria-label'))!;
|
||||
if (label.startsWith('나는 라이어')) return null;
|
||||
const m = /^내 제시어: (.+)\. 주제는/.exec(label);
|
||||
if (!m) throw new Error(`unexpected word card: ${label}`);
|
||||
return m[1]!;
|
||||
}
|
||||
|
||||
async function liarBanner(p: Page, phase: string | RegExp, timeout = 40_000) {
|
||||
await p.locator('.lg-banner .lg-ph strong', { hasText: phase }).waitFor({ timeout });
|
||||
}
|
||||
|
||||
async function liarShots(pages: Page[], name: string, dark = false) {
|
||||
const [host, phone] = pages as [Page, Page];
|
||||
await host.screenshot({ path: join(SHOTS, `liar-${name}-pc.png`) });
|
||||
await phone.screenshot({ path: join(SHOTS, `liar-${name}-phone.png`), fullPage: true });
|
||||
if (!dark) return;
|
||||
await host.emulateMedia({ colorScheme: 'dark' });
|
||||
await phone.emulateMedia({ colorScheme: 'dark' });
|
||||
await host.waitForTimeout(250);
|
||||
await host.screenshot({ path: join(SHOTS, `liar-${name}-pc-dark.png`) });
|
||||
await phone.screenshot({ path: join(SHOTS, `liar-${name}-phone-dark.png`), fullPage: true });
|
||||
await host.emulateMedia({ colorScheme: 'light' });
|
||||
await phone.emulateMedia({ colorScheme: 'light' });
|
||||
}
|
||||
|
||||
const PLANS: Record<string, Plan> = {
|
||||
@@ -2362,6 +2395,102 @@ const PLANS: Record<string, Plan> = {
|
||||
console.log(` catchmind: drew and guessed ${words.join(', ')}; both 12 points (10 + 2)`);
|
||||
},
|
||||
},
|
||||
liar: {
|
||||
// PC host + 2 phone guests, one round of descriptions. Real flow through the UI: hold-to-see word card (the liar
|
||||
// sees only "나는 라이어"), confirm, each describes in turn (a citizen saying the word is refused), discussion chat,
|
||||
// "토론 끝내기", the citizens vote the liar out, the liar names the word with spaces in it and wins.
|
||||
// Checks: the liar's screen never shows the word, the room chat is closed during the game.
|
||||
players: 3,
|
||||
lobby: async (host) => {
|
||||
await host.getByRole('group', { name: '설명 바퀴 수' }).getByRole('button', { name: '한 바퀴' }).click();
|
||||
await host.getByText(/한 바퀴 · 설명 30초/).first().waitFor();
|
||||
},
|
||||
drive: async (pages) => {
|
||||
const [host, phone] = pages as [Page, Page, Page];
|
||||
for (const p of pages) await liarBanner(p, '제시어 확인');
|
||||
if (await host.locator('.chat-panel').count()) throw new Error('room chat panel is visible during the game');
|
||||
if (await phone.getByRole('button', { name: /^채팅/ }).count()) throw new Error('room chat button is visible on the phone during the game');
|
||||
const words = await Promise.all(pages.map(liarWordOf));
|
||||
const L = words.indexOf(null);
|
||||
const word = words.find((w) => w !== null)!;
|
||||
if (L < 0 || words.filter((w) => w === null).length !== 1 || words.some((w) => w !== null && w !== word)) throw new Error(`unexpected words ${words.join(',')}`);
|
||||
console.log(` liar: word ${word}, liar ${LIAR_NICKS[L]}`);
|
||||
const liarClean = async (when: string) => {
|
||||
if ((await pages[L]!.content()).includes(word)) throw new Error(`the liar's screen shows the word (${when})`);
|
||||
};
|
||||
await liarClean('reveal');
|
||||
await liarShots(pages, '1-reveal');
|
||||
// The card hides again by itself (2.5 s after the key press).
|
||||
await host.waitForFunction(() => document.querySelector('.lg-card')?.getAttribute('aria-label')?.startsWith('내 제시어 보기'), null, { timeout: 5000 });
|
||||
for (const p of pages) await p.getByRole('button', { name: /^확인했어요/ }).click();
|
||||
|
||||
for (const p of pages) await liarBanner(p, '한 사람씩 설명');
|
||||
let refused = -1;
|
||||
for (let turn = 0; turn < 3; turn++) {
|
||||
let speaker = -1;
|
||||
for (let t = 0; t < 100 && speaker < 0; t++) {
|
||||
for (const [i, p] of pages.entries()) if (await p.getByLabel('내 설명 (한 문장)').count()) speaker = i;
|
||||
if (speaker < 0) await host.waitForTimeout(100);
|
||||
}
|
||||
if (speaker < 0) throw new Error(`nobody can describe (turn ${turn + 1})`);
|
||||
const p = pages[speaker]!;
|
||||
const input = p.getByLabel('내 설명 (한 문장)');
|
||||
if (refused < 0 && speaker !== L) {
|
||||
await input.fill(`${[...word].join(' ')} 맞죠`);
|
||||
await input.press('Enter');
|
||||
await p.getByText('제시어를 직접 말하면 안 돼요.').first().waitFor({ timeout: 10_000 });
|
||||
refused = speaker;
|
||||
}
|
||||
const text = speaker === L ? '저는 좋아하는 편이에요' : `${LIAR_NICKS[speaker]}의 설명이에요`;
|
||||
if (turn === 1) await liarShots(pages, '2-describe', true);
|
||||
await input.fill(text);
|
||||
await input.press('Enter');
|
||||
for (const q of pages) await q.locator('.lg-desc li', { hasText: text }).waitFor({ timeout: 15_000 });
|
||||
}
|
||||
if (refused < 0) throw new Error('saying the word was never tried');
|
||||
// The refusal toast goes away by itself (3 s).
|
||||
await pages[refused]!.locator('.toast', { hasText: '제시어를 직접 말하면 안 돼요.' }).waitFor({ state: 'detached', timeout: 6000 });
|
||||
await liarClean('describe');
|
||||
for (const [i, p] of pages.entries()) {
|
||||
const hidden = await p
|
||||
.waitForFunction(() => document.querySelector('.lg-card')?.getAttribute('aria-label')?.startsWith('내 제시어 보기'), null, { timeout: 4000 })
|
||||
.then(() => true, () => false);
|
||||
if (!hidden) throw new Error(`${LIAR_NICKS[i]}: word card stays open after the descriptions`);
|
||||
}
|
||||
|
||||
for (const p of pages) await liarBanner(p, '자유 토론');
|
||||
const citizen = (L + 1) % 3;
|
||||
await pages[citizen]!.getByLabel('토론 채팅 메시지').fill(`${LIAR_NICKS[L]}님이 수상해요`);
|
||||
await pages[citizen]!.getByLabel('토론 채팅 메시지').press('Enter');
|
||||
for (const p of pages) await p.locator('.lg-msgs .lg-msg', { hasText: '님이 수상해요' }).waitFor({ timeout: 15_000 });
|
||||
await liarShots(pages, '3-discussion', true);
|
||||
await liarClean('discussion');
|
||||
for (const p of pages) await p.getByRole('button', { name: /^토론 끝내기/ }).click();
|
||||
|
||||
for (const p of pages) await liarBanner(p, '라이어 지목 투표', 15_000);
|
||||
const pickTile = async (p: Page, nick: string) => {
|
||||
const name = p.locator('.nm', { hasText: new RegExp(`^${nick}( \\(나\\))?$`) });
|
||||
await p.locator('button.lg-tile[data-target="ok"]', { has: name }).click();
|
||||
};
|
||||
await liarShots(pages, '4-vote');
|
||||
for (const [i, p] of pages.entries()) await pickTile(p, LIAR_NICKS[i === L ? (L + 1) % 3 : L]!);
|
||||
|
||||
await liarBanner(pages[L]!, '라이어의 정답 맞히기', 15_000);
|
||||
for (const p of pages) await p.locator('.lg-news', { hasText: '라이어가 맞아요!' }).waitFor();
|
||||
await pages[citizen]!.locator('.lg-tag.liar').first().waitFor();
|
||||
await liarShots(pages, '5-guess');
|
||||
const guess = pages[L]!.getByLabel('제시어 맞히기');
|
||||
await guess.fill(` ${[...word].join(' ')} `);
|
||||
await guess.press('Enter');
|
||||
|
||||
for (const p of pages) await p.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 20_000 });
|
||||
for (const p of pages) await p.locator('.lg-final', { hasText: '라이어 승리' }).waitFor();
|
||||
await host.waitForTimeout(500);
|
||||
await host.screenshot({ path: join(SHOTS, 'liar-6-result-pc.png') });
|
||||
await phone.screenshot({ path: join(SHOTS, 'liar-6-result-phone.png') });
|
||||
console.log(' liar: describe (word refused) → discussion → vote → liar caught → named the word → liar won');
|
||||
},
|
||||
},
|
||||
mafia: {
|
||||
// PC host + 3 phone guests (마피아·경찰·의사·시민), short phases via the lobby. Real flow through the UI: role card,
|
||||
// greeting chat in 전체, night (mafia chat + target, police investigates the mafia, doctor guards themself), the
|
||||
|
||||
Reference in New Issue
Block a user