feat: honest AI opponent in quick game
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Successful in 49s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m12s
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Successful in 49s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m12s
New Game's quick game gains an explicit opponent selector — 🤖 AI (default) or 👤 Random player. AI starts a game seated with a pooled robot that joins and moves at once: no per-move timeout (a 7-day inactivity loss reusing the turn-timeout sweeper), chat/nudge disabled, no statistics, the opponent shown as 🤖 everywhere. The random path (disguised robot) is unchanged. Driven by one game flag (games.vs_ai), set only on AI-started games so the disguised path is never revealed; Matchmaker.StartVsAI seats the robot directly (no open pool); the robot replies event-driven via the game service's after-commit/after-create hook. Wire: vs_ai on EnqueueRequest + GameView.
This commit is contained in:
@@ -10,7 +10,9 @@ test('quick game: enter immediately, wait for an opponent, then it joins', async
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click(); // lobby tab bar -> auto-match
|
||||
|
||||
// Pick a variant and start; the player lands in the game at once (no "searching" screen).
|
||||
// Choose a random human opponent (the default is the AI); pick a variant and start. The player
|
||||
// lands in an open game at once (no "searching" screen).
|
||||
await page.getByRole('button', { name: 'Random player' }).click();
|
||||
await page.locator('.variant').first().click();
|
||||
await page.getByRole('button', { name: /Start game/i }).click();
|
||||
await expect(page.locator('[data-cell]').first()).toBeVisible();
|
||||
@@ -30,6 +32,33 @@ test('quick game: enter immediately, wait for an opponent, then it joins', async
|
||||
await expect(page.getByRole('button', { name: 'Drop game' })).toBeEnabled();
|
||||
});
|
||||
|
||||
// The honest-AI quick game is the default opponent: the player starts a game already seated with a
|
||||
// robot shown as 🤖, with no "searching" wait. Chat and nudge are disabled (the opponent is a robot),
|
||||
// add-friend is never offered, and the dictionary word-check stays available. Mock transport only.
|
||||
test('AI game: 🤖 opponent, no wait, chat disabled, dictionary still works', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click();
|
||||
|
||||
// AI is the default opponent: the move-clock line is replaced by the 7-day inactivity rule.
|
||||
await expect(page.getByText(/Loss after 7 days of inactivity/)).toBeVisible();
|
||||
await page.locator('.variant').first().click();
|
||||
await page.getByRole('button', { name: /Start game/i }).click();
|
||||
|
||||
// The player lands in an active game at once (no "searching" wait); the opponent shows as 🤖.
|
||||
await expect(page.locator('[data-cell]').first()).toBeVisible();
|
||||
await expect(page.locator('.scoreboard').getByText('🤖')).toBeVisible();
|
||||
await expect(page.getByText(/Searching for opponent/)).toHaveCount(0);
|
||||
|
||||
// Chat is disabled (the message field), while the dictionary word-check stays usable.
|
||||
await page.locator('.scoreboard').click(); // open the history
|
||||
await page.getByRole('button', { name: 'Chat' }).click(); // 💬 -> comms hub
|
||||
await expect(page).toHaveURL(/\/game\/.+\/chat$/);
|
||||
await expect(page.locator('.chat input')).toBeDisabled();
|
||||
await page.getByRole('button', { name: 'Dictionary' }).click();
|
||||
await expect(page.locator('.check input')).toBeEnabled();
|
||||
});
|
||||
|
||||
// The opponent_joined push is best-effort and never replayed, so a join that lands while the live
|
||||
// stream is down is lost. The waiting game screen recovers it without a push: a poll while the
|
||||
// stream is down, and a refetch on stream reconnect. The __stream hook (lib/app.svelte.ts) drops /
|
||||
@@ -39,6 +68,7 @@ async function enterOpenGame(page: import('@playwright/test').Page): Promise<voi
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click();
|
||||
await page.getByRole('button', { name: 'Random player' }).click();
|
||||
await page.locator('.variant').first().click();
|
||||
await page.getByRole('button', { name: /Start game/i }).click();
|
||||
await expect(page.getByText(/Searching for opponent/)).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user