From 63a896d466a03ea15e3694cdd845ecd058afc84d Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Mon, 28 Sep 2026 08:11:51 +0200 Subject: [PATCH] Draw crisp vector ocean tiles with subtle accessible water motion --- test/browser.mjs | 45 +++++++++++++++++++++++++++++++++--------- viewer/board-assets.js | 4 +--- viewer/board.js | 7 ++++--- viewer/ocean.js | 36 +++++++++++++++++++++++++++++++++ viewer/style.css | 36 +++++++++++++++++++++++---------- viewer/ui.js | 4 ++-- 6 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 viewer/ocean.js diff --git a/test/browser.mjs b/test/browser.mjs index e0eaee0..c28cb46 100644 --- a/test/browser.mjs +++ b/test/browser.mjs @@ -44,6 +44,31 @@ const page = await browser.newPage({ page.on("pageerror", (e) => errors.push(e.message)); await page.goto(base + "/?new&hotseat"); await page.waitForSelector("[data-character-choice]"); +// Decorative motion must never move a tile's clickable/focusable SVG bounds. +await page.emulateMedia({ reducedMotion: "no-preference" }); +assert.equal( + await page.evaluate(() => { + const cells = [...document.querySelectorAll(".archipelago .map-cell")]; + const bounds = () => + cells.map((cell) => JSON.stringify(cell.getBoundingClientRect())); + const before = bounds(); + const reflection = document.querySelector(".archipelago .water-shimmer"); + const animation = reflection.getAnimations()[0]; + animation.currentTime = 14000; + const unchanged = JSON.stringify(before) === JSON.stringify(bounds()); + animation.currentTime = 0; + return unchanged; + }), + true, +); +await page.emulateMedia({ reducedMotion: "reduce" }); +assert.equal( + await page + .locator(".archipelago .water-shimmer") + .evaluate((el) => getComputedStyle(el).animationName), + "none", +); +await page.emulateMedia({ reducedMotion: "no-preference" }); // Every supported locale must render translated action tooltips, not English fallbacks. const tooltipSource = "Sail 1–3 ocean spaces, paying 1 vatu per space."; for (const locale of [ @@ -460,15 +485,17 @@ for (const width of [1440, 390]) { assert.ok( await page.locator(".sea-board").evaluate((board) => { const upcoming = board.querySelector(".upcoming").getBoundingClientRect(); - return [...board.querySelectorAll(".cell-surface")].every((path) => { - const cell = path.getBoundingClientRect(); - return ( - cell.bottom <= upcoming.top || - cell.right <= upcoming.left || - cell.top >= upcoming.bottom || - cell.left >= upcoming.right - ); - }); + return [...board.querySelectorAll(".archipelago .cell-surface")].every( + (path) => { + const cell = path.getBoundingClientRect(); + return ( + cell.bottom <= upcoming.top || + cell.right <= upcoming.left || + cell.top >= upcoming.bottom || + cell.left >= upcoming.right + ); + }, + ); }), "Overview spaces must stay clear of the upcoming tiles", ); diff --git a/viewer/board-assets.js b/viewer/board-assets.js index 09c5ba7..b14c536 100644 --- a/viewer/board-assets.js +++ b/viewer/board-assets.js @@ -1,4 +1,3 @@ -import { assets } from "./assets.js"; import efate from "./assets/efate-board.webp"; import a1 from "./assets/tile-7-board.webp"; import a2 from "./assets/tile-9-board.webp"; @@ -13,5 +12,4 @@ const islands = { "tile-19": d1, "tile-21": d2, }; -export const boardArt = (tile) => - tile.type === "sea" ? assets.ocean : islands[tile.art]; +export const boardArt = (tile) => islands[tile.art]; diff --git a/viewer/board.js b/viewer/board.js index e9fb515..f6879bc 100644 --- a/viewer/board.js +++ b/viewer/board.js @@ -1,6 +1,7 @@ import { boardCells, tileState, TILES, COLORS } from "../engine/catalog.js"; import { esc, svgIcon, iconLabel } from "./art.js"; import { boardArt } from "./board-assets.js"; +import { oceanDefs, oceanSurface } from "./ocean.js"; const tilt = (20 * Math.PI) / 180; const rotate = (x, y) => ({ x: x * Math.cos(tilt) - y * Math.sin(tilt), @@ -40,10 +41,10 @@ function tilePath(x, y) { const symbols = ["●", "◆", "▲", "■", "✦"]; function tileImage(spec, c, ghost = false, prefix = "board") { const clip = `url(#${prefix}-cell-${c.q + 2}-${c.r})`; - const ocean = ``; + const ocean = oceanSurface(c, prefix); const art = spec.type === "island" - ? `` + ? `` : ""; return `${ocean}${art}`; } @@ -92,7 +93,7 @@ export function boardSvg( ``, ) .join(""); - let svg = `${defs}`; + let svg = `${defs}${oceanDefs(prefix)}`; let dikes = ""; for (const c of all) { const legal = targetSet.has(c.id), diff --git a/viewer/ocean.js b/viewer/ocean.js new file mode 100644 index 0000000..8d3f552 --- /dev/null +++ b/viewer/ocean.js @@ -0,0 +1,36 @@ +// Vector water stays crisp at board zoom and in the full-size tile previews. +// All tiles sample the same pattern coordinates, so the currents join at edges. +export function oceanDefs(prefix) { + return ` + + + + + + + + + + + + + + + + + + + + + + `; +} + +export function oceanSurface(c, prefix) { + const bounds = `x="${c.x - 112}" y="${c.y - 112}" width="224" height="224"`; + return ``; +} diff --git a/viewer/style.css b/viewer/style.css index e1c7a87..668e065 100644 --- a/viewer/style.css +++ b/viewer/style.css @@ -301,9 +301,9 @@ content: ""; position: absolute; inset: 0; - background-image: var(--ocean); - background-size: 850px; - opacity: 0.75; + background: + radial-gradient(ellipse at 18% 15%, #b6e7db70, transparent 65%), + linear-gradient(145deg, #80c7c5, #71b6c5); pointer-events: none; } .vanuatu .map-scroll { @@ -522,7 +522,7 @@ height: 260px; min-height: 0; } -.vanuatu .upcoming img { +.vanuatu .upcoming .tile-art { width: 57px; height: 57px; object-fit: contain; @@ -666,7 +666,7 @@ border-color: #b17734; background: #f8e1ad; } -.vanuatu .tile-choices img { +.vanuatu .tile-choices .tile-art { width: 57px; height: 57px; object-fit: contain; @@ -1337,7 +1337,7 @@ body:has(.vanuatu) { bottom: calc(var(--tray-height, 95px) + 11px); right: 7px; } - .vanuatu .upcoming img { + .vanuatu .upcoming .tile-art { width: 37px; height: 37px; } @@ -1402,10 +1402,6 @@ body:has(.vanuatu) { scroll-behavior: auto !important; } } -.vanuatu .sea-board:before { - opacity: 0.21; - background-size: 520px; -} .vanuatu .archipelago { overflow: hidden; } @@ -1741,3 +1737,23 @@ body:has(.vanuatu) { align-items: center; gap: 4px; } + +/* Animate the paint inside the pattern, keeping tile geometry and hit areas fixed. */ +.vanuatu .water-shimmer { + opacity: 0.2; +} +@media (prefers-reduced-motion: no-preference) { + .vanuatu .archipelago .water-shimmer { + animation: vanuatu-water-shimmer 14s ease-in-out infinite alternate; + } +} +@keyframes vanuatu-water-shimmer { + from { + opacity: 0.12; + transform: translate(-1px, 0); + } + to { + opacity: 0.3; + transform: translate(1px, 1px); + } +} diff --git a/viewer/ui.js b/viewer/ui.js index ea26577..9d56377 100644 --- a/viewer/ui.js +++ b/viewer/ui.js @@ -321,7 +321,7 @@ export function mountGame(target, options = {}) { const m = moves.find( (m) => m.type === "place" && m.tile === tile && m.cell === selected, ); - return `
${t("expand")} ${esc(translateText(REMAINING_TILES, lang))}: ${s.upcoming.length}
${t("help")}

${esc(t(EXTEND_WHO))}

${esc(t(EXTEND_HOW))}

${tileChoices.map((id) => btn(`${TILES[id].type === `, `data-tile="${id}" aria-pressed="${tile === id}"`)).join("")}
${m ? moveButton(m, true) : ""}
`; + return `
${t("expand")} ${esc(translateText(REMAINING_TILES, lang))}: ${s.upcoming.length}
${t("help")}

${esc(t(EXTEND_WHO))}

${esc(t(EXTEND_HOW))}

${tileChoices.map((id) => btn(tilePreviewSvg(id, { t, colorBlind, language: lang, prefix: "choice-" + id }), `data-tile="${id}" aria-pressed="${tile === id}"`)).join("")}
${m ? moveButton(m, true) : ""}
`; } if (s.phase === "rest") return `
${t("restChoice")}${moves @@ -411,7 +411,7 @@ export function mountGame(target, options = {}) { .map((m) => m.cell) : actualTargets(); const html = `
${btn("🏝️ Vanuatu", "data-boardgame", "wordmark")}
Designed by Alain EpronPublished by Quined Games
${Array.from({ length: 8 }, (_, i) => `${i + 1}`).join("")}
-
${dock()}
${icon("fish", marketHelp)} = ${token("coin", s.market, marketHelp)}${token("tourist", s.tourists, `${"Tourists available this round"}: ${s.tourists}`)}${s.waterCountdown !== null ? `${token("water", s.waterCountdown, `${t("waterLeft")}: ${s.waterCountdown}`)}` : ""}
${tradeShips()}
${boardSvg(s, { player, colorBlind, overview, language: lang, selected, targets, hoverTile: s.phase === "expand" ? tile : null, t })}
${titled(overview ? "Focus on placed tiles" : "Show full board", icon("overview"), `data-overview aria-pressed="${overview}"`, "icon-button")}${titled(zoom ? t("fit") : t("zoom"), icon(zoom ? "eye" : "zoom"), "data-zoom", "icon-button")}
${s.upcoming.length && s.phase !== "expand" ? titled(t("next"), `${s.upcoming.map((id) => ``).join("")}${icon("zoom", t("next"))}`, "data-upcoming", "upcoming") : ""}${trayHtml}
${s.players.map(playerCard).join("")}
${token("coin", 10)} → ${token("point", 5)}${btn(t("help"), "data-help", "text-button")}
`; +
${dock()}
${icon("fish", marketHelp)} = ${token("coin", s.market, marketHelp)}${token("tourist", s.tourists, `${"Tourists available this round"}: ${s.tourists}`)}${s.waterCountdown !== null ? `${token("water", s.waterCountdown, `${t("waterLeft")}: ${s.waterCountdown}`)}` : ""}
${tradeShips()}
${boardSvg(s, { player, colorBlind, overview, language: lang, selected, targets, hoverTile: s.phase === "expand" ? tile : null, t })}
${titled(overview ? "Focus on placed tiles" : "Show full board", icon("overview"), `data-overview aria-pressed="${overview}"`, "icon-button")}${titled(zoom ? t("fit") : t("zoom"), icon(zoom ? "eye" : "zoom"), "data-zoom", "icon-button")}
${s.upcoming.length && s.phase !== "expand" ? titled(t("next"), `${s.upcoming.map((id) => tilePreviewSvg(id, { t, colorBlind, language: lang, prefix: "upcoming-" + id })).join("")}${icon("zoom", t("next"))}`, "data-upcoming", "upcoming") : ""}${trayHtml}
${s.players.map(playerCard).join("")}
${token("coin", 10)} → ${token("point", 5)}${btn(t("help"), "data-help", "text-button")}
`; // Patch in place so cached SVG tile images and focused controls survive // preference changes and incoming state updates. morphdom(play, `
${html}
`, {