diff --git a/web-client/docs/viewer-publishing.md b/web-client/docs/viewer-publishing.md index 38ff417d..94890fcf 100644 --- a/web-client/docs/viewer-publishing.md +++ b/web-client/docs/viewer-publishing.md @@ -1630,3 +1630,17 @@ Verify installer-owned revision 7 in public and admin metadata against the exact and all 58 existing named assets; upload no artwork. Preserve gallery, Standard length default and unrelated metadata. No backfill, live-game changes, history repair or Fossil refresh. Historical fixtures and activation receipts remain untouched. + +# Viewer 0.1.227 / engine unchanged (0.4.159) + +Exhausted terrain retains its underlying trees, mountains and terrain colors in +3D, with small foreground depletion hatches. Strategy tiles keep the original +terrain icon and prominence with corner hatches; inspection explicitly names the +exhausted terrain, including beneath cities. A real-engine local preview and +regression/smoke coverage distinguish visual identity from engine legality. + +This is a visual-only release: the pending exhausted-terrain movement rules bug +is not fixed. Preserve the deployed engine bytes, revision-7 achievement catalog +(46 definitions), all artwork, gallery and unrelated metadata. Require main-branch +Check and Web viewer CI before publishing the tested viewer bundle. No live-game +moves, saved-game migration, history repair, achievement backfill or Fossil refresh. diff --git a/web-client/package-lock.json b/web-client/package-lock.json index 9f882037..6af0c37e 100644 --- a/web-client/package-lock.json +++ b/web-client/package-lock.json @@ -1,12 +1,12 @@ { "name": "@boardgamers/clash-web-client", - "version": "0.1.226", + "version": "0.1.227", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@boardgamers/clash-web-client", - "version": "0.1.226", + "version": "0.1.227", "dependencies": { "@boardgamers/protocol": "0.11.0", "lucide-svelte": "^0.577.0", diff --git a/web-client/package.json b/web-client/package.json index 6260482c..66d27d57 100644 --- a/web-client/package.json +++ b/web-client/package.json @@ -1,6 +1,6 @@ { "name": "@boardgamers/clash-web-client", - "version": "0.1.226", + "version": "0.1.227", "private": true, "type": "module", "scripts": { @@ -16,7 +16,8 @@ "test:locales": "node ../scripts/check-locales.mjs src/localization && node --test scripts/localization-source.test.mjs && npm run localization:check", "localization:check": "node scripts/extract-localization.mjs --check", "localization:extract": "node scripts/extract-localization.mjs", - "tutorial:fixtures": "node scripts/build-tutorial-fixtures.mjs" + "tutorial:fixtures": "node scripts/build-tutorial-fixtures.mjs", + "test:exhausted-terrain": "npm run build && node scripts/exhausted-terrain-smoke.mjs" }, "dependencies": { "@boardgamers/protocol": "0.11.0", diff --git a/web-client/release/achievement-assets.json b/web-client/release/achievement-assets.json index 1ba97488..e89ff4d2 100644 --- a/web-client/release/achievement-assets.json +++ b/web-client/release/achievement-assets.json @@ -13,7 +13,7 @@ "web-client/src/civilization-emblems.ts": "01b0cbf3fa77a8466532ccd73d63c1a3ddc9bbc79fc06ce7224b425322a9c9f0", "web-client/src/civilization-flags.ts": "cd176076bfe05b3059093b80c88596b7ae46b77898695c6c7406cbe1a3a0f78b", "server/src/content/civilizations.rs": "73602f3db506f3dc2dbc6de43d01179440fd3bb034c997ff209336faaef2a332", - "web-client/package-lock.json": "3105337a05dc96f7ef1c1ffa8094c44ca12d18d4004bbafe834b11c024d5a29a", + "web-client/package-lock.json": "2cdcaffa337d237e0f0e281251f85ffc15d5f9bce0c12863f29ec46b1f37c719", "web-client/node_modules/lucide-svelte/dist/Icon.svelte": "f7b49ab842c143fa680fa8bd9a54a9efdc48c2e2d49fa574bd5ccf8f6cfca5be", "web-client/node_modules/lucide-svelte/dist/defaultAttributes.js": "5b8981c6e3434ae6538716af9e0403554e7708c4087f18d060950a7bef00d96a", "web-client/node_modules/lucide-svelte/LICENSE": "668dcc52803480e0a026b31140a4cae668772663cd764e5991d252eef03f98db" diff --git a/web-client/scripts/exhausted-terrain-fixture.mjs b/web-client/scripts/exhausted-terrain-fixture.mjs new file mode 100644 index 00000000..866b3c93 --- /dev/null +++ b/web-client/scripts/exhausted-terrain-fixture.mjs @@ -0,0 +1,27 @@ +/** Real engine state for comparing normal and exhausted terrain in the normal viewer. */ +export async function exhaustedTerrainFixture(engine) { + const game = JSON.parse(await engine.init(2, [], {}, 'exhausted-terrain-preview', {})); + const occupied = new Set( + game.players.flatMap((p) => [ + ...(p.cities ?? []).map((c) => c.position), + ...(p.units ?? []).map((u) => u.position), + ]), + ); + const tiles = game.map.tiles.filter(([p]) => !occupied.has(p)); + const kinds = ['Forest', 'Mountain', 'Fertile', 'Barren']; + game.map.unexplored_blocks = []; + for (const tile of game.map.tiles) if (tile[1] === 'Unexplored') tile[1] = 'Barren'; + const examples = []; + for (let i = 0; i < kinds.length; i++) { + const normal = tiles[i * 2], + exhausted = tiles[i * 2 + 1]; + normal[1] = kinds[i]; + exhausted[1] = { Exhausted: kinds[i] }; + examples.push({ kind: kinds[i], normal: normal[0], exhausted: exhausted[0] }); + } + delete game.board_history; + const state = JSON.stringify(game), + seat = game.current_player_index; + engine.webView(engine.stripSecret(state, seat), seat); + return { state, seat, examples }; +} diff --git a/web-client/scripts/exhausted-terrain-smoke.mjs b/web-client/scripts/exhausted-terrain-smoke.mjs new file mode 100644 index 00000000..83244825 --- /dev/null +++ b/web-client/scripts/exhausted-terrain-smoke.mjs @@ -0,0 +1,89 @@ +import assert from 'node:assert/strict'; +import { createRequire } from 'node:module'; +import { readFile } from 'node:fs/promises'; +import { chromium } from 'playwright'; +import { exhaustedTerrainFixture } from './exhausted-terrain-fixture.mjs'; +const engine = createRequire(import.meta.url)('../.engine/server.js'); +const { state, seat, examples } = await exhaustedTerrainFixture(engine); +const raw = engine.stripSecret(state, seat); +const browser = await chromium.launch({ + headless: true, + args: ['--use-gl=angle', '--use-angle=swiftshader'], +}); +try { + for (const [width, height] of [ + [1400, 1000], + [390, 780], + [320, 640], + ]) { + const page = await browser.newPage({ viewport: { width, height } }); + const errors = [], + sent = []; + page.on('pageerror', (error) => errors.push(error.message)); + await page.exposeFunction('moveSent', (action) => sent.push(action)); + await page.route('**/*', async (route) => { + const pathname = new URL(route.request().url()).pathname; + if (pathname === '/') + return route.fulfill({ + contentType: 'text/html', + body: '
', + }); + if (!['/viewer.js', '/server_bg.wasm'].includes(pathname)) return route.abort(); + return route.fulfill({ + contentType: pathname.endsWith('.wasm') ? 'application/wasm' : 'text/javascript', + body: await readFile(new URL('../dist' + pathname, import.meta.url)), + }); + }); + await page.goto('http://clash.test/'); + assert.deepEqual(errors, []); + await page.evaluate( + ({ raw, seat }) => { + const host = clash3d.launch('#app'); + const preferences = { sound: false, mapView: '3d', homeAtBottom: false }; + host.on('move', (action) => window.moveSent(action)); + host.on('update:preference', ({ name, value }) => { + preferences[name] = value; + host.receive('preferences', preferences); + }); + host.receive('player', { index: seat }); + host.receive('preferences', preferences); + host.receive('theme', { dark: false }); + host.receive('state', raw); + }, + { raw, seat }, + ); + const mode = page.getByRole('button', { name: 'Strategy map', exact: true }); + await mode.waitFor(); + await page.waitForTimeout(1500); + await page.screenshot({ path: `/tmp/clash-exhausted-3d-${width}.png` }); + await mode.click(); + await page.keyboard.press('Tab'); + for (const example of examples) { + const tile = page.locator(`.strategy-map-tile[data-position="${example.exhausted}"]`); + await tile.waitFor(); + assert.equal(await tile.getAttribute('aria-label'), `Exhausted ${example.kind.toLowerCase()}`); + const icon = tile.locator('.terrain-icon'); + assert.equal( + await icon.getAttribute('width'), + ['Forest', 'Mountain'].includes(example.kind) ? '30' : '18', + ); + assert.equal(await icon.locator(':scope > path').count(), 1, 'exhaustion hatch remains visible'); + assert.equal(await tile.locator('svg.lucide').count(), 1, 'underlying terrain icon remains'); + // Keyboard focus inspects even map tiles visually behind floating mobile controls. + await tile.focus(); + await page + .locator('.tile-hover-terrain') + .filter({ hasText: `Exhausted ${example.kind.toLowerCase()}` }) + .waitFor(); + } + await page.mouse.move(0, 0); + await page.screenshot({ path: `/tmp/clash-exhausted-strategy-${width}.png` }); + assert.deepEqual(errors, []); + assert.deepEqual(sent, [], 'visual inspection must never submit moves'); + assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)); + console.log('Exhausted terrain 3D/Strategy viewer smoke passed', { width, examples }); + await page.close(); + } +} finally { + await browser.close(); +} diff --git a/web-client/scripts/preview-scenarios.ts b/web-client/scripts/preview-scenarios.ts index be5621ea..ba416657 100644 --- a/web-client/scripts/preview-scenarios.ts +++ b/web-client/scripts/preview-scenarios.ts @@ -1,6 +1,8 @@ import { readFileSync } from 'node:fs'; +import { exhaustedTerrainFixture } from './exhausted-terrain-fixture.mjs'; export const previewScenarios = [ + { id: 'exhausted-terrain', label: 'Exhausted terrain', note: 'Compare normal and exhausted Forest, Mountain, Fertile and Barren terrain in 3D and Strategy map.' }, { id: 'tactics', label: 'Tactics ยท Steel Weapons', note: 'Local asynchronous sequence: attacker Steel Weapons and tactics, then defender Steel Weapons and tactics, then reveal.' }, { id: 'advance', label: 'Free advance', note: 'Research lets you save an early choice.' }, { id: 'raze', label: 'Raze city', note: 'Cities lets you save an early choice.' }, @@ -12,6 +14,7 @@ export const previewScenarios = [ ]; export async function createPreviewScenario(engine: any, id: string) { + if (id === 'exhausted-terrain') return exhaustedTerrainFixture(engine); if (!previewScenarios.some(s => s.id === id)) throw Error('Unknown preview scenario'); const names: Record