feat(stats): best-move word, moves & hint-share, and a hint-count fix (#81)
The statistics screen gains real depth, plus a hint-count bug fix found along the way. - Best move per variant: the screen shows the actual best-move word (drawn as game tiles; a wildcard shows its letter but no value), broken down by game variant, empty variants omitted. New account_best_move table, written at game finish. - Moves & hint share: two new lifetime tiles — the player's play count and the share of plays that used a hint — from summed account_stats counters (moves, hints_used). Honest-AI games are excluded, like the rest of the stats. - Hint-count fix: the in-game hint badge no longer goes stale across games. The global wallet now rides the wire apart from the per-game allowance (wallet_balance on StateView/HintResult/StatsView), so the client reads the live wallet rather than a per-game snapshot; game_players.hints_used now counts every hint (allowance + wallet), its true per-game total. - Account merge: sums the new moves/hints_used counters and merges the per-variant best moves (higher score kept), which it previously dropped. - Admin: the user card shows Moves and Hints used. - UI polish: tab/label wording, game-over text, and e2e selectors hardened against label changes. All wire additions are trailing (backward-compatible). Docs (ARCHITECTURE, FUNCTIONAL +ru, UISN_DESIGN) updated in step.
This commit was merged in pull request #81.
This commit is contained in:
+2
-2
@@ -66,7 +66,7 @@ test('a placed tile is saved as a draft and restored on reopening the game', asy
|
||||
test('new game: variant buttons show a rules summary and the move-limit', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click(); // lobby tab bar -> auto-match
|
||||
await page.getByRole('button', { name: /🎲/ }).click(); // lobby tab bar -> auto-match
|
||||
await expect(page.locator('.vrules').first()).toBeVisible(); // per-variant rules summary
|
||||
await expect(page.locator('.movelimit')).toBeVisible(); // turn-time under the buttons
|
||||
});
|
||||
@@ -74,7 +74,7 @@ test('new game: variant buttons show a rules summary and the move-limit', async
|
||||
test('new game: auto-match shows the off-by-default rule toggle from the start (no layout jump on selection)', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click(); // auto-match
|
||||
await page.getByRole('button', { name: /🎲/ }).click(); // auto-match
|
||||
// Several variants are offered, so nothing is selected: Start is disabled. The rule toggle is shown
|
||||
// from the start (a Russian variant is available), so selecting one does not shift the layout.
|
||||
const start = page.getByRole('button', { name: /Start game/i });
|
||||
|
||||
@@ -11,7 +11,7 @@ test('lobby: New Game disables and a notice shows at the simultaneous-game limit
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
|
||||
// Below the limit: the New Game tab is enabled and no notice is shown.
|
||||
const newGame = page.getByRole('button', { name: /New/ });
|
||||
const newGame = page.getByRole('button', { name: /🎲/ });
|
||||
await expect(newGame).toBeEnabled();
|
||||
await expect(page.getByText(/reached the simultaneous games limit/i)).toHaveCount(0);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { expect, test } from './fixtures';
|
||||
test('quick game: enter immediately, wait for an opponent, then it joins', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click(); // lobby tab bar -> auto-match
|
||||
await page.getByRole('button', { name: /🎲/ }).click(); // lobby tab bar -> auto-match
|
||||
|
||||
// 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).
|
||||
@@ -38,7 +38,7 @@ test('quick game: enter immediately, wait for an opponent, then it joins', async
|
||||
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();
|
||||
await page.getByRole('button', { name: /🎲/ }).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();
|
||||
@@ -64,7 +64,7 @@ test('AI game: 🤖 opponent, no wait, chat disabled, dictionary still works', a
|
||||
test('AI game: no GCG export offered after it ends', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click();
|
||||
await page.getByRole('button', { name: /🎲/ }).click();
|
||||
await page.locator('.variant').first().click(); // AI is the default opponent
|
||||
await page.getByRole('button', { name: /Start game/i }).click();
|
||||
await expect(page.locator('.scoreboard').getByText('🤖')).toBeVisible();
|
||||
@@ -90,7 +90,7 @@ test('AI game: no GCG export offered after it ends', async ({ page }) => {
|
||||
async function enterOpenGame(page: import('@playwright/test').Page): Promise<void> {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: /guest/i }).click();
|
||||
await page.getByRole('button', { name: /New/ }).click();
|
||||
await page.getByRole('button', { name: /🎲/ }).click();
|
||||
await page.getByRole('button', { name: 'Random player' }).click();
|
||||
await page.locator('.variant').first().click();
|
||||
await page.getByRole('button', { name: /Start game/i }).click();
|
||||
|
||||
+10
-2
@@ -53,11 +53,19 @@ test('invitations: the lobby shows an invitation and accepting clears it', async
|
||||
await expect(page.getByText(/From Kaya/)).toBeHidden();
|
||||
});
|
||||
|
||||
test('stats screen shows the metrics', async ({ page }) => {
|
||||
test('stats screen shows the metrics and the per-variant best move', async ({ page }) => {
|
||||
await loginLobby(page);
|
||||
await page.getByRole('button', { name: /Stats/ }).click();
|
||||
await expect(page.getByText('Win rate')).toBeVisible();
|
||||
await expect(page.getByText('Best move')).toBeVisible();
|
||||
// The Moves count and the derived Hint share (12 hints / 248 plays = 4.8%, one decimal).
|
||||
await expect(page.getByText('Moves', { exact: true })).toBeVisible();
|
||||
await expect(page.getByText('Hint share')).toBeVisible();
|
||||
await expect(page.getByText('4.8%')).toBeVisible();
|
||||
// The best move breaks down per played variant, each row labelled by the variant and
|
||||
// ending in the play's score (the word itself renders as game tiles).
|
||||
await expect(page.getByText('Scrabble', { exact: true })).toBeVisible();
|
||||
await expect(page.getByText('134')).toBeVisible();
|
||||
});
|
||||
|
||||
test('settings hub: tabs switch in place and back returns to the lobby', async ({ page }) => {
|
||||
@@ -158,7 +166,7 @@ test('lobby ⚙️ tab shows the pending friend-request count', async ({ page })
|
||||
|
||||
test('play with friends: a game type is required to send an invitation', async ({ page }) => {
|
||||
await loginLobby(page);
|
||||
await page.getByRole('button', { name: /New/ }).click(); // lobby tab bar
|
||||
await page.getByRole('button', { name: /🎲/ }).click(); // lobby tab bar (New Game tab, by its 🎲 icon — the label is themeable)
|
||||
await page.getByRole('button', { name: 'Play with friends' }).click();
|
||||
|
||||
const send = page.getByRole('button', { name: 'Send invitation' });
|
||||
|
||||
Reference in New Issue
Block a user