diff --git a/test/browser.mjs b/test/browser.mjs index 5bfa2c2..fbdfdeb 100644 --- a/test/browser.mjs +++ b/test/browser.mjs @@ -174,15 +174,19 @@ for (const width of [390, 1440]) { requestAnimationFrame(() => requestAnimationFrame(resolve)), ), ); + // Resizing reframes the camera too; measure only settled geometry. + await page.evaluate(() => window.vanuatuDemo.ui.whenIdle()); const before = await page .locator(".archipelago") .evaluate((svg) => svg.getBoundingClientRect().width); await page.locator("[data-zoom-in]").click(); + await page.evaluate(() => window.vanuatuDemo.ui.whenIdle()); const after = await page .locator(".archipelago") .evaluate((svg) => svg.getBoundingClientRect().width); assert.ok(Math.abs(after / before - 1.25) < 0.02); await page.locator("[data-zoom-out]").click(); + await page.evaluate(() => window.vanuatuDemo.ui.whenIdle()); } // Empty action stacks do not leave labels above their icons or shift columns. const actionLayout = await page @@ -265,10 +269,12 @@ assert.equal( await page.locator("[data-character-choice]").first().click(); assert.equal(await page.locator("dialog[open]").count(), 1); await page.locator("dialog [data-move]").click(); +await page.locator("dialog[open]").waitFor({ state: "hidden" }); assert.equal(await page.locator("dialog[open]").count(), 0); for (let n = 0; n < 2; n++) { await page.locator("[data-character-choice]").first().click(); await page.locator("dialog [data-move]").click(); + await page.locator("dialog[open]").waitFor({ state: "hidden" }); } // Unavailable planning actions explain prerequisites without placing a marker. const blockedFish = page.locator('[data-action="fish"]'); @@ -322,6 +328,139 @@ function actionState() { s.players[0].treasures = [1]; return s; } +// Export rates are icon-only visually, but every hover/accessibility target +// explains both the cost and reward. Keep expectations independent of the renderer. +const exportGoods = [ + ["kava", "Kava", "Kava", 1, 1], + ["copra", "Copra", "Coprah", 2, 3], + ["beef", "Beef", "Bœuf", 3, 5], +]; +// Ignore icon artwork/SVG titles and hidden mobile arrows when checking copy. +function visibleHelperText(el) { + const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT); + let text = "", + node; + while ((node = walker.nextNode())) { + if (node.parentElement.closest("svg")) continue; + const range = document.createRange(); + range.selectNodeContents(node); + const box = range.getBoundingClientRect(); + if (box.width && box.height) text += node.textContent; + } + return text.replace(/\s+/g, ""); +} +async function assertExportHelp(language = "en", colorBlind = false) { + const french = language === "fr"; + const labels = Object.fromEntries( + exportGoods.map(([good, en, fr, cost, reward]) => [ + good, + { + available: `${french ? fr + " :" : en + ":"} −${cost} vatus → +${reward} ${french ? "prospérité" : "prosperity"}`, + delivered: `${french ? fr + " : déjà livré" : en + ": already delivered"}`, + empty: `${french ? fr + " : vide" : en + ": empty"}`, + }, + ]), + ); + const reference = page.locator(".trade-info > .export-reference"); + assert.equal(await reference.count(), 1); + assert.equal(await reference.getAttribute("role"), "group"); + assert.equal( + await reference.getAttribute("aria-label"), + french ? "Exporter des marchandises" : "Export goods", + ); + assert.equal(await reference.locator(".export-rate").count(), 3); + assert.equal(await page.locator(".trade-info > .demand-ships").count(), 1); + assert.equal(await page.locator(".demand-ships").getAttribute("title"), null); + for (const [index, [good, , , cost, reward]] of exportGoods.entries()) { + const rate = reference.locator(".export-rate").nth(index); + assert.equal(await rate.getAttribute("role"), "img"); + assert.equal(await rate.getAttribute("title"), labels[good].available); + assert.equal(await rate.getAttribute("aria-label"), labels[good].available); + assert.equal( + await rate + .and( + page.getByRole("img", { name: labels[good].available, exact: true }), + ) + .count(), + 1, + ); + for (const kind of [good, "coin", "point"]) + assert.equal(await rate.locator(`.icon-${kind}`).count(), 1); + const visibleText = await rate.evaluate(visibleHelperText); + const arrow = page.viewportSize().width >= 360 ? "→" : ""; + assert.equal( + visibleText, + `${cost === 1 ? "" : cost}${arrow}${reward === 1 ? "" : reward}`, + ); + assert.equal(await rate.locator("b").count(), index === 0 ? 0 : 2); + } + assert.deepEqual( + await reference.locator(".resource-symbol").allTextContents(), + colorBlind ? ["K", "C", "B"] : [], + ); + const completion = reference.locator(".export-completion"); + assert.equal(await completion.count(), 1); + assert.equal(await completion.evaluate(visibleHelperText), "→2"); + assert.equal( + await completion.getAttribute("title"), + french + ? "Compléter un navire ajoute 2 au gain de la marchandise." + : "Completing a ship adds 2 to the good's reward.", + ); + for (const kind of ["buy", "check", "point"]) + assert.equal(await completion.locator(`.icon-${kind}`).count(), 1); + assert.equal( + await completion.locator(".completed-ship").getAttribute("aria-label"), + french ? "Terminer" : "Complete", + ); + const targets = page.locator( + '.export-rate, .export-completion, .demand-ships span[data-good], .map-cell[data-cell="0,0"] .goods-slot', + ); + for (const target of await targets.all()) { + const info = await target.evaluate((el) => ({ + good: el.dataset.good, + status: el.classList.contains("empty") + ? "empty" + : el.classList.contains("filled") + ? "delivered" + : "available", + role: el.getAttribute("role"), + label: el.getAttribute("aria-label"), + title: + el.getAttribute("title") ?? + el.querySelector(":scope > title")?.textContent, + })); + if (info.good) { + assert.equal(info.role, "img"); + assert.equal(info.title, labels[info.good][info.status]); + assert.equal(info.label, info.title); + assert.equal( + await target + .and(page.getByRole("img", { name: info.title, exact: true })) + .count(), + 1, + ); + } + await target.scrollIntoViewIfNeeded(); + assert.ok( + await target.evaluate((el) => + [el, ...el.querySelectorAll("svg, b")].every((part) => { + const r = part.getBoundingClientRect(); + const hit = document.elementFromPoint( + r.x + r.width / 2, + r.y + r.height / 2, + ); + return ( + hit?.closest( + ".export-rate, .export-completion, span[data-good], .goods-slot", + ) === el + ); + }), + ), + `${info.title}: the good, coin and reward must hit their tooltip owner, not the map underneath`, + ); + } +} // A neighbouring destination has 1- and 3-step legal paths, but only needs one UI choice. const sailing = actionState(); assert.deepEqual( @@ -419,10 +558,14 @@ for (const width of [1440, 390]) { await touristAction.click(); assert.equal(await page.locator(".action-dock .supply-empty").count(), 0); assert.ok((await page.locator(".cell-highlight.legal").count()) > 0); + await page.evaluate(() => + window.vanuatuDemo.ui.setPreferences({ language: "en", colorBlind: false }), + ); for (const [index, good] of E.GOODS.entries()) { const s = actionState(); s.demands = [{ id: 1, goods: [...E.GOODS], filled: [false, false, false] }]; await page.evaluate((s) => window.vanuatuDemo.setState(s), s); + await assertExportHelp(); await page.locator('[data-action="buy"]').click(); assert.equal( await page @@ -451,7 +594,39 @@ for (const width of [1440, 390]) { assert.equal(exported.players[0].money, 9 - E.PRICES[good]); assert.equal(exported.players[0].score, E.VALUES[good]); assert.equal(exported.board["0,0"].goods[good], 0); + await page.waitForFunction( + () => !document.querySelector("[data-trade-transition]"), + ); + await page.evaluate(() => window.vanuatuDemo.ui.whenIdle()); + assert.equal( + await page.locator(`.demand-ships .filled[data-good="${good}"]`).count(), + 1, + ); + assert.equal( + await page.locator(`.goods-slot.empty[data-good="${good}"]`).count(), + 1, + ); + await assertExportHelp(); } + // Live localization/color-blind updates preserve all three sources of help, + // including the delivered demand and empty island space from the last export. + await page.locator(".header-tools [data-help]").click(); + await page.locator("[data-language]").selectOption("fr"); + if ( + (await page.locator("[data-color-blind]").getAttribute("aria-pressed")) !== + "true" + ) + await page.locator("[data-color-blind]").click(); + await page.waitForFunction(() => + document.querySelector(".export-rate")?.title.includes("prospérité"), + ); + await assertExportHelp("fr", true); + await page.locator(".header-tools [data-help]").click(); + await page.locator("[data-language]").selectOption("en"); + await page.locator("[data-color-blind]").click(); + await page.waitForFunction(() => + document.querySelector(".export-rate")?.title.includes("prosperity"), + ); // Choosing a full island explains why it cannot take another hut. const crowded = actionState(); crowded.players[0].character = null; diff --git a/test/map-zoom-browser.mjs b/test/map-zoom-browser.mjs index 5701c7a..3d4b809 100644 --- a/test/map-zoom-browser.mjs +++ b/test/map-zoom-browser.mjs @@ -43,6 +43,10 @@ async function zoomOutFully(page) { assert.ok(steps++ < 20, "Zoom out reaches its full-board limit"); await out.click(); } + // The zoom limit is set before the final camera animation has settled. + await page.waitForFunction( + () => !document.querySelector("[data-map-transition]"), + ); const clipped = await page.locator(".map-scroll").evaluate((map) => { const frame = map.getBoundingClientRect(); const css = getComputedStyle(map); diff --git a/test/mobile-layout-browser.mjs b/test/mobile-layout-browser.mjs index 6b6dc18..098a248 100644 --- a/test/mobile-layout-browser.mjs +++ b/test/mobile-layout-browser.mjs @@ -74,6 +74,9 @@ try { // Even five players' stacks plus a draft marker fit in the same band. await page.locator('[data-action="rest"]').click(); assert.equal(await page.locator(".draft-marker").textContent(), "+1"); + await page.locator(".trade-info").scrollIntoViewIfNeeded(); + // Measure settled geometry, not the marker-drop animation's temporary scale. + await page.evaluate(() => window.vanuatuDemo.ui.whenIdle()); const layout = await page.evaluate(() => { const dock = document.querySelector(".action-dock"); const strip = document.querySelector(".players"); @@ -88,7 +91,72 @@ try { b.bottom <= a.bottom + 1 ); }; + const board = document.querySelector(".sea-board"); + const trade = board.querySelector(".trade-info"); + const reference = trade.querySelector(".export-reference"); + const rates = [...reference.querySelectorAll(".export-rate")]; + const items = [ + ...reference.querySelectorAll(".export-rate, .export-completion"), + ]; + const overlaps = (a, b) => { + a = a.getBoundingClientRect(); + b = b.getBoundingClientRect(); + return ( + a.left < b.right - 1 && + a.right > b.left + 1 && + a.top < b.bottom - 1 && + a.bottom > b.top + 1 + ); + }; return { + exportReference: { + count: rates.length, + completion: reference.querySelectorAll(".export-completion").length, + arrowsVisible: rates.map( + (rate) => + rate.querySelector(".export-arrow").getBoundingClientRect() + .width > 0, + ), + contained: contained(board, trade) && contained(trade, reference), + itemsFit: items.every( + (rate) => + contained(reference, rate) && + [...rate.querySelectorAll("svg, b")].every((part) => + contained(rate, part), + ), + ), + noScroll: reference.scrollWidth <= reference.clientWidth + 1, + singleRow: items.every( + (rate) => + Math.abs( + rate.getBoundingClientRect().top - + rates[0].getBoundingClientRect().top, + ) < 1, + ), + noCollisions: + [ + ...board.querySelectorAll( + ".market-info, .map-tools, .upcoming, .turn-tray", + ), + ].every((overlay) => !overlaps(trade, overlay)) && + !overlaps(reference, trade.querySelector(".demand-ships")), + hitTargets: [ + ...trade.querySelectorAll( + ".export-rate, .export-completion, span[data-good]", + ), + ].every((el) => + [el, ...el.querySelectorAll("svg, b")].every((part) => { + const r = part.getBoundingClientRect(); + return ( + document + .elementFromPoint(r.x + r.width / 2, r.y + r.height / 2) + ?.closest( + ".export-rate, .export-completion, span[data-good]", + ) === el + ); + }), + ), + }, dockWidth: dock.clientWidth, dockScroll: dock.scrollWidth, dockHeight: dock.clientHeight, @@ -118,6 +186,21 @@ try { names: cards.map((c) => c.querySelector(".profile").title), }; }); + assert.deepEqual( + layout.exportReference, + { + count: 3, + completion: 1, + arrowsVisible: Array(3).fill(width >= 360), + contained: true, + itemsFit: true, + noScroll: true, + singleRow: true, + noCollisions: true, + hitTargets: true, + }, + `${width}px/${count} players: French/color-blind export helper fits without clipping or covering other overlays; tooltips receive pointer hits`, + ); assert.equal(layout.actions, 9); assert.equal( layout.dockScroll, @@ -141,8 +224,10 @@ try { layout.cardsFit, "individual stock values and scores are not clipped", ); + // At 320px supplies need a second row, alongside the character and + // treasure-conversion rows; larger screens retain the tighter bound. assert.ok( - layout.height <= 140, + layout.height <= (width === 320 ? 152 : 140), "loaded player cards stay shorter than the previous 191px strip", ); for (const values of layout.supplies) diff --git a/test/three-viewer-browser.mjs b/test/three-viewer-browser.mjs index e9010e4..a0902ff 100644 --- a/test/three-viewer-browser.mjs +++ b/test/three-viewer-browser.mjs @@ -52,13 +52,77 @@ try { await page.goto(base + "/qa/hosted.html?saved"); assert.equal((await state()).preferences.mapView, "3d"); await page.locator(".map-3d canvas").waitFor(); + const reference = page.locator(".trade-info > .export-reference"); + assert.deepEqual( + await reference + .locator(".export-rate") + .evaluateAll((rates) => + rates.map((rate) => [ + rate.getAttribute("role"), + rate.title, + rate.getAttribute("aria-label"), + ]), + ), + [ + "Kava : −1 vatus → +1 prospérité", + "Coprah : −2 vatus → +3 prospérité", + "Bœuf : −3 vatus → +5 prospérité", + ].map((label) => ["img", label, label]), + ); + assert.equal(await reference.locator(".export-completion").count(), 1); + assert.equal( + await reference.locator(".export-completion b").textContent(), + "2", + ); + const referenceBefore = await reference.evaluate((el) => { + window.exportReferenceBefore = el; + return el.outerHTML; + }); + async function assertReferencePersists() { + assert.equal(await reference.count(), 1); + assert.equal( + await reference.evaluate((el) => el.outerHTML), + referenceBefore, + ); + assert.ok( + await reference.evaluate((el) => el === window.exportReferenceBefore), + ); + assert.equal( + await page.locator(".trade-info > .demand-ships").count(), + 1, + ); + await reference.scrollIntoViewIfNeeded(); + assert.ok( + await reference.evaluate((el) => + [...el.querySelectorAll(".export-rate, .export-completion")].every( + (rate) => + [rate, ...rate.querySelectorAll("svg, b")].every((part) => { + const r = part.getBoundingClientRect(); + return ( + document + .elementFromPoint(r.x + r.width / 2, r.y + r.height / 2) + ?.closest(".export-rate, .export-completion") === rate + ); + }), + ), + ), + "The reference stays hoverable above the 3D map during and after the final export", + ); + } + await assertReferencePersists(); await page.locator("[data-export]").click(); await page.locator("[data-trade-transition]").waitFor(); + await assertReferencePersists(); await page.waitForFunction( () => !document.querySelector("[data-trade-transition]"), ); assert.equal((await state()).round, 2); assert.equal(await page.locator(".goods-slot.empty").count(), 0); + assert.equal( + await page.locator('.demand-ship[data-ship="101"]').count(), + 0, + ); + await assertReferencePersists(); await page.emulateMedia({ reducedMotion: "reduce" }); await page.waitForFunction( () => document.querySelector(".vanuatu").dataset.animations === "false", diff --git a/test/tutorial-browser.mjs b/test/tutorial-browser.mjs index 6bdc9c8..2da21f0 100644 --- a/test/tutorial-browser.mjs +++ b/test/tutorial-browser.mjs @@ -289,12 +289,18 @@ try { .innerText(), "0", ); - assert.ok( - !( - await page - .locator('[data-cell="0,0"] .island-goods title') - .allTextContents() - ).some((text) => text.includes("Copra")), + // Exporting clears the cube, but its named empty slot remains on the island. + assert.equal( + await page + .locator('[data-cell="0,0"] .goods-slot.stocked[data-good="copra"]') + .count(), + 0, + ); + assert.equal( + await page + .locator('[data-cell="0,0"] .goods-slot.empty[data-good="copra"]') + .getAttribute("aria-label"), + "Copra: empty", ); await page.close(); console.log( diff --git a/viewer/board.js b/viewer/board.js index 4215ea0..f3a288e 100644 --- a/viewer/board.js +++ b/viewer/board.js @@ -1,4 +1,5 @@ import { goodsSlots } from "./goods-slots.js"; +import { exportGoodHelp } from "./export-reference.js"; import { playerSymbolGlyph } from "@boardgamers/protocol/player-symbols"; import { boardCells, tileState, TILES, COLORS } from "../engine/catalog.js"; import { esc, svgIcon, iconLabel } from "./art.js"; @@ -149,8 +150,8 @@ export function boardSvg( for (const [j, { good, filled }] of slots.entries()) { const x = c.x - slots.length * 14 + j * 28, y = c.y + 34; - const help = `${label(good)} · ${filled ? "available to export" : "Empty goods space"}`; - svg += `${esc(help)}`; + const help = exportGoodHelp(good, filled ? "available" : "empty"); + svg += `${esc(help)}`; svg += svgIcon(good, x, y, 29, "currentColor", help, colorBlind); svg += ""; } diff --git a/viewer/export-reference.js b/viewer/export-reference.js new file mode 100644 index 0000000..bd405d0 --- /dev/null +++ b/viewer/export-reference.js @@ -0,0 +1,26 @@ +import { PRICES, VALUES } from "../engine/catalog.js"; +import { esc, icon, token } from "./art.js"; + +const names = { kava: "Kava", copra: "Copra", beef: "Beef" }; + +export function exportGoodHelp(good, state = "available") { + if (state === "delivered") return `${names[good]}: already delivered`; + if (state === "empty") return `${names[good]}: empty`; + return `${names[good]}: −${PRICES[good]} vatus → +${VALUES[good]} prosperity`; +} + +export function exportReference(colorBlind = false) { + const completionHelp = "Completing a ship adds 2 to the good's reward."; + const amount = (kind, value, help) => + value === 1 ? icon(kind, help) : token(kind, value, help); + return `
${Object.keys( + PRICES, + ) + .map((good) => { + const help = exportGoodHelp(good); + return `${icon(good, help, false, colorBlind)}${amount("coin", PRICES[good], help)}${amount("point", VALUES[good], help)}`; + }) + .join( + "", + )}${icon("buy", completionHelp)}${icon("check", completionHelp)}${token("point", 2)}
`; +} diff --git a/viewer/localization/da.json b/viewer/localization/da.json index 0d47427..b1a5c73 100644 --- a/viewer/localization/da.json +++ b/viewer/localization/da.json @@ -950,6 +950,10 @@ "Undo my move": "Fortryd mit træk", "Auto-retrieve when forced": "Automatisk tvungen tilbagetagning", "Goods replenished": "Varer genopfyldt", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatu → +{p2} velstand", + "{p0}: already delivered": "{p0}: allerede leveret", + "{p0}: empty": "{p0}: tom", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Første skib, der mangler varen (1 → 3). Fyldt skib: +2 velstand.", "Empty goods space": "Tom vareplads", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Ved begyndelsen af hver runde udskiftes fyldte skibe. En ø uden varer får sit oprindelige udvalg igen. Hvis blot én terning er tilbage, genopfyldes intet." } diff --git a/viewer/localization/de.json b/viewer/localization/de.json index 8c6696f..21413fe 100644 --- a/viewer/localization/de.json +++ b/viewer/localization/de.json @@ -950,6 +950,10 @@ "Undo my move": "Zug zurücknehmen", "Auto-retrieve when forced": "Pflichtrücknahme automatisch", "Goods replenished": "Waren aufgefüllt", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} Vatu → +{p2} Wohlstand", + "{p0}: already delivered": "{p0}: bereits geliefert", + "{p0}: empty": "{p0}: leer", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Erstes Schiff, das die Ware benötigt (1 → 3). Volles Schiff: +2 Wohlstand.", "Empty goods space": "Leerer Warenplatz", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Zu Beginn jeder Runde werden volle Schiffe ersetzt. Eine Insel ohne Waren erhält ihren ursprünglichen Warenbestand zurück. Solange auch nur ein Würfel übrig ist, wird nichts aufgefüllt." } diff --git a/viewer/localization/el.json b/viewer/localization/el.json index 49d06cf..879d334 100644 --- a/viewer/localization/el.json +++ b/viewer/localization/el.json @@ -950,6 +950,10 @@ "Undo my move": "Αναίρεση κίνησης", "Auto-retrieve when forced": "Αυτόματη υποχρεωτική ανάκτηση", "Goods replenished": "Αναπλήρωση αγαθών", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} βάτου → +{p2} ευημερία", + "{p0}: already delivered": "{p0}: έχει ήδη παραδοθεί", + "{p0}: empty": "{p0}: κενή θέση", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Πρώτο πλοίο που χρειάζεται το αγαθό (1 → 3). Γεμάτο πλοίο: +2 ευημερία.", "Empty goods space": "Κενή θέση αγαθού", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Στην αρχή κάθε γύρου, τα γεμάτα πλοία αντικαθίστανται. Ένα νησί χωρίς κανένα αγαθό λαμβάνει ξανά την αρχική του συλλογή. Αν απομένει έστω ένας κύβος, δεν αναπληρώνεται τίποτα." } diff --git a/viewer/localization/en.json b/viewer/localization/en.json index 499f86a..4020f52 100644 --- a/viewer/localization/en.json +++ b/viewer/localization/en.json @@ -950,6 +950,10 @@ "Undo my move": "Undo my move", "Auto-retrieve when forced": "Auto-retrieve when forced", "Goods replenished": "Goods replenished", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatus → +{p2} prosperity", + "{p0}: already delivered": "{p0}: already delivered", + "{p0}: empty": "{p0}: empty", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "First ship needing the good (1 → 3). Complete ship: +2 prosperity.", "Empty goods space": "Empty goods space", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished." } diff --git a/viewer/localization/fa.json b/viewer/localization/fa.json index e291e21..1a0c18f 100644 --- a/viewer/localization/fa.json +++ b/viewer/localization/fa.json @@ -950,6 +950,10 @@ "Undo my move": "بازگرداندن حرکت", "Auto-retrieve when forced": "بازگشت خودکار در حالت اجباری", "Goods replenished": "کالاها دوباره تأمین شدند", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} واتو → +{p2} شکوفایی", + "{p0}: already delivered": "{p0}: قبلاً تحویل شده", + "{p0}: empty": "{p0}: خالی", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "اولین کشتی نیازمند این کالا (1 → 3). کشتی تکمیل‌شده: +2 شکوفایی.", "Empty goods space": "جای خالی کالا", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "در آغاز هر دور، کشتی‌های تکمیل‌شده جایگزین می‌شوند. جزیره‌ای که هیچ کالایی در آن نمانده، دوباره مجموعهٔ اولیهٔ کالاهایش را دریافت می‌کند. اگر حتی یک مکعب باقی مانده باشد، هیچ کالایی اضافه نمی‌شود." } diff --git a/viewer/localization/fr.json b/viewer/localization/fr.json index 3a20fec..b2d74b6 100644 --- a/viewer/localization/fr.json +++ b/viewer/localization/fr.json @@ -950,6 +950,10 @@ "Undo my move": "Annuler mon coup", "Auto-retrieve when forced": "Retrait auto si forcé", "Goods replenished": "Marchandises réapprovisionnées", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0} : −{p1} vatus → +{p2} prospérité", + "{p0}: already delivered": "{p0} : déjà livré", + "{p0}: empty": "{p0} : vide", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Premier navire demandant cette marchandise (1 → 3). Navire complet : +2 prospérité.", "Empty goods space": "Emplacement de marchandise vide", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Au début de chaque manche, les navires complets sont remplacés. Une île sans aucune marchandise retrouve son assortiment initial. S’il reste ne serait-ce qu’un cube, rien n’est réapprovisionné." } diff --git a/viewer/localization/hi.json b/viewer/localization/hi.json index 7cf612d..0ea1c19 100644 --- a/viewer/localization/hi.json +++ b/viewer/localization/hi.json @@ -950,6 +950,10 @@ "Undo my move": "अपनी चाल वापस लें", "Auto-retrieve when forced": "अनिवार्य वापसी अपने-आप", "Goods replenished": "माल फिर भरा गया", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} वातु → +{p2} समृद्धि", + "{p0}: already delivered": "{p0}: पहले ही पहुँचाया गया", + "{p0}: empty": "{p0}: खाली", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "पहला जहाज़ जिसे इस माल की ज़रूरत है (1 → 3)। जहाज़ पूरा भरने पर: +2 समृद्धि।", "Empty goods space": "माल की खाली जगह", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "हर दौर की शुरुआत में भरे हुए जहाज़ बदल दिए जाते हैं। जिस द्वीप पर कोई माल नहीं बचा है, वहाँ शुरुआती माल फिर रख दिया जाता है। अगर एक भी घन बचा हो, तो कोई माल नहीं भरा जाता।" } diff --git a/viewer/localization/it.json b/viewer/localization/it.json index 9b0ada3..6fa1161 100644 --- a/viewer/localization/it.json +++ b/viewer/localization/it.json @@ -950,6 +950,10 @@ "Undo my move": "Annulla la mossa", "Auto-retrieve when forced": "Ritiro automatico se obbligato", "Goods replenished": "Merci rifornite", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatu → +{p2} prosperità", + "{p0}: already delivered": "{p0}: consegna effettuata", + "{p0}: empty": "{p0}: spazio vuoto", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Prima nave che richiede la merce (1 → 3). Nave completa: +2 prosperità.", "Empty goods space": "Spazio merce vuoto", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "All’inizio di ogni round, le navi complete vengono sostituite. Un’isola senza più merci riceve nuovamente il suo assortimento iniziale. Se rimane anche un solo cubetto, non viene rifornito nulla." } diff --git a/viewer/localization/ko.json b/viewer/localization/ko.json index 5235d87..5a2d9ce 100644 --- a/viewer/localization/ko.json +++ b/viewer/localization/ko.json @@ -950,6 +950,10 @@ "Undo my move": "내 수 되돌리기", "Auto-retrieve when forced": "강제 회수 자동화", "Goods replenished": "상품 보충", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1}바투 → 번영 +{p2}", + "{p0}: already delivered": "{p0}: 이미 배달됨", + "{p0}: empty": "{p0}: 비어 있음", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "해당 상품이 필요한 첫 번째 배(1 → 3). 배를 모두 채우면: 번영 +2.", "Empty goods space": "빈 상품 자리", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "매 라운드 시작 시 가득 찬 배를 교체합니다. 상품이 하나도 남지 않은 섬은 처음의 상품 구성을 다시 받습니다. 큐브가 하나라도 남아 있으면 보충하지 않습니다." } diff --git a/viewer/localization/nl.json b/viewer/localization/nl.json index c0167ec..cf301e1 100644 --- a/viewer/localization/nl.json +++ b/viewer/localization/nl.json @@ -950,6 +950,10 @@ "Undo my move": "Zet ongedaan maken", "Auto-retrieve when forced": "Verplicht terugnemen automatisch", "Goods replenished": "Goederen aangevuld", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatu → +{p2} welvaart", + "{p0}: already delivered": "{p0}: al geleverd", + "{p0}: empty": "{p0}: leeg", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Eerste schip dat dit goed nodig heeft (1 → 3). Vol schip: +2 welvaart.", "Empty goods space": "Lege goederenplek", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Aan het begin van elke ronde worden volle schepen vervangen. Een eiland zonder goederen krijgt zijn oorspronkelijke assortiment terug. Als er ook maar één blokje over is, wordt niets aangevuld." } diff --git a/viewer/localization/pl.json b/viewer/localization/pl.json index 509a69b..ace97dd 100644 --- a/viewer/localization/pl.json +++ b/viewer/localization/pl.json @@ -950,6 +950,10 @@ "Undo my move": "Cofnij ruch", "Auto-retrieve when forced": "Automatyczne wymuszone wycofanie", "Goods replenished": "Uzupełniono towary", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatu → +{p2} dobrobytu", + "{p0}: already delivered": "{p0}: już dostarczono", + "{p0}: empty": "{p0}: puste miejsce", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Pierwszy statek potrzebujący tego towaru (1 → 3). Pełny statek: +2 dobrobytu.", "Empty goods space": "Puste miejsce na towar", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Na początku każdej rundy pełne statki są zastępowane nowymi. Wyspa, na której nie ma już żadnych towarów, odzyskuje swój początkowy zestaw. Jeśli pozostała choć jedna kostka, niczego się nie uzupełnia." } diff --git a/viewer/localization/pt-BR.json b/viewer/localization/pt-BR.json index a412135..2fc30b6 100644 --- a/viewer/localization/pt-BR.json +++ b/viewer/localization/pt-BR.json @@ -950,6 +950,10 @@ "Undo my move": "Desfazer jogada", "Auto-retrieve when forced": "Recolher automaticamente se obrigatório", "Goods replenished": "Mercadorias reabastecidas", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatus → +{p2} prosperidade", + "{p0}: already delivered": "{p0}: já entregue", + "{p0}: empty": "{p0}: espaço vazio", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Primeiro navio que precisa da mercadoria (1 → 3). Navio completo: +2 prosperidade.", "Empty goods space": "Espaço vazio de mercadoria", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "No início de cada rodada, os navios completos são substituídos. Uma ilha sem nenhuma mercadoria recebe novamente seu conjunto original. Se restar um único cubo, nada é reabastecido." } diff --git a/viewer/localization/ro.json b/viewer/localization/ro.json index ec34936..3c5be51 100644 --- a/viewer/localization/ro.json +++ b/viewer/localization/ro.json @@ -950,6 +950,10 @@ "Undo my move": "Anulează mutarea", "Auto-retrieve when forced": "Retragere forțată automată", "Goods replenished": "Mărfuri reaprovizionate", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatu → +{p2} prosperitate", + "{p0}: already delivered": "{p0}: livrare efectuată", + "{p0}: empty": "{p0}: loc gol", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Prima navă care are nevoie de marfă (1 → 3). Navă plină: +2 prosperitate.", "Empty goods space": "Loc gol pentru marfă", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "La începutul fiecărei runde, navele complete sunt înlocuite. O insulă fără nicio marfă primește din nou sortimentul inițial. Dacă a rămas chiar și un singur cub, nu se reaprovizionează nimic." } diff --git a/viewer/localization/ru.json b/viewer/localization/ru.json index e564d33..0ac3f59 100644 --- a/viewer/localization/ru.json +++ b/viewer/localization/ru.json @@ -950,6 +950,10 @@ "Undo my move": "Отменить ход", "Auto-retrieve when forced": "Автовозврат без выбора", "Goods replenished": "Товары пополнены", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} вату → +{p2} процветания", + "{p0}: already delivered": "{p0}: уже доставлено", + "{p0}: empty": "{p0}: пусто", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Первый корабль, которому нужен товар (1 → 3). Полный корабль: +2 процветания.", "Empty goods space": "Пустое место для товара", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "В начале каждого раунда заполненные корабли заменяются. Остров, на котором не осталось товаров, снова получает исходный набор. Если остался хотя бы один кубик, товары не пополняются." } diff --git a/viewer/localization/vi.json b/viewer/localization/vi.json index 28768b4..5f95d97 100644 --- a/viewer/localization/vi.json +++ b/viewer/localization/vi.json @@ -950,6 +950,10 @@ "Undo my move": "Hoàn tác nước đi", "Auto-retrieve when forced": "Tự thu hồi khi bắt buộc", "Goods replenished": "Đã bổ sung hàng hóa", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}: −{p1} vatu → +{p2} thịnh vượng", + "{p0}: already delivered": "{p0}: đã giao", + "{p0}: empty": "{p0}: trống", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "Tàu đầu tiên cần mặt hàng này (1 → 3). Tàu đầy hàng: +2 thịnh vượng.", "Empty goods space": "Ô hàng hóa trống", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "Ở đầu mỗi vòng, các tàu đã đầy được thay thế. Một đảo không còn hàng hóa nào sẽ được bổ sung lại đúng loại và số lượng ban đầu. Nếu vẫn còn dù chỉ một khối, sẽ không bổ sung gì." } diff --git a/viewer/localization/zh-CN.json b/viewer/localization/zh-CN.json index 2ced05d..938f6b9 100644 --- a/viewer/localization/zh-CN.json +++ b/viewer/localization/zh-CN.json @@ -950,6 +950,10 @@ "Undo my move": "撤销我的行动", "Auto-retrieve when forced": "强制收回时自动执行", "Goods replenished": "货物已补充", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}:−{p1} 瓦图 → +{p2} 繁荣", + "{p0}: already delivered": "{p0}:已交付", + "{p0}: empty": "{p0}:空位", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "第一艘需要该货物的船(1 → 3)。装满船:+2 繁荣。", "Empty goods space": "空货物格", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "每轮开始时,已装满的船会被替换。完全没有货物的岛屿会重新补上原本的货物组合。只要还剩一颗方块,就不会补充任何货物。" } diff --git a/viewer/localization/zh-TW.json b/viewer/localization/zh-TW.json index 26e3a8a..624aaf4 100644 --- a/viewer/localization/zh-TW.json +++ b/viewer/localization/zh-TW.json @@ -950,6 +950,10 @@ "Undo my move": "撤回我的行動", "Auto-retrieve when forced": "強制收回時自動執行", "Goods replenished": "貨物已補充", + "{p0}: −{p1} vatus → +{p2} prosperity": "{p0}:−{p1} 瓦圖 → +{p2} 繁榮", + "{p0}: already delivered": "{p0}:已交付", + "{p0}: empty": "{p0}:空位", + "First ship needing the good (1 → 3). Complete ship: +2 prosperity.": "第一艘需要該貨物的船(1 → 3)。裝滿船:+2 繁榮。", "Empty goods space": "空貨物格", "At the start of each round, completed ships are replaced. An island with no goods left receives its original assortment again. If even one cube remains, none are replenished.": "每輪開始時,已裝滿的船會被替換。完全沒有貨物的島嶼會重新補上原本的貨物組合。只要還剩一顆方塊,就不會補充任何貨物。" } diff --git a/viewer/style.css b/viewer/style.css index d1152a6..e0d6a28 100644 --- a/viewer/style.css +++ b/viewer/style.css @@ -407,7 +407,7 @@ scrollbar-width: thin; min-height: 490px; height: min(69vh, 740px); - padding: 65px 10px 83px; + padding: 80px 10px 83px; } .vanuatu .map-canvas { display: grid; @@ -507,7 +507,7 @@ right: 18px; z-index: 2; display: flex; - align-items: center; + align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none; @@ -528,13 +528,65 @@ align-items: center; gap: 3px; } +.vanuatu .trade-info { + display: flex; + flex-direction: column; + align-items: flex-end; + gap: 5px; +} +.vanuatu .export-reference { + display: flex; + background: #f6f4dfdb; + border: 1px solid #fff9; + border-radius: 7px; + font-size: 11px; + white-space: nowrap; +} +.vanuatu .export-rate, +.vanuatu .export-completion { + display: flex; + align-items: center; + gap: 3px; + padding: 3px 6px; +} +.vanuatu .export-reference > span + span { + border-left: 1px solid #b7975c44; +} +.vanuatu .export-reference .token { + gap: 2px; +} +.vanuatu .export-reference .icon { + width: 18px; + height: 18px; +} +.vanuatu .completed-ship { + position: relative; + display: flex; +} +.vanuatu .completed-ship .icon-check { + position: absolute; + right: -3px; + bottom: -2px; + width: 12px; + height: 12px; + color: #356658; + background: #f6f4df; + border-radius: 50%; +} +.vanuatu .export-reference > span > *, +.vanuatu .demand-ship > span > *, +.vanuatu .demand-ship > .icon { + pointer-events: none; +} +@media (max-width: 359px) { + .vanuatu .export-arrow { + display: none; + } +} .vanuatu .demand-ships { display: flex; gap: 7px; } -.vanuatu .demand-ships * { - pointer-events: none; -} .vanuatu .demand-ship { background: #faf1cfdf; border: 1px solid #b7975c66; @@ -1426,7 +1478,7 @@ body:has(.vanuatu) { .vanuatu .map-scroll { height: 57vh; min-height: 430px; - padding: 80px 0 104px; + padding: 108px 0 104px; } .vanuatu .sea-dashboard { top: 8px; @@ -1444,6 +1496,24 @@ body:has(.vanuatu) { width: 19px; height: 19px; } + .vanuatu .trade-info { + align-items: center; + } + .vanuatu .export-reference { + font-size: 10px; + } + .vanuatu .export-rate, + .vanuatu .export-completion { + gap: 1px; + padding: 3px; + } + .vanuatu .export-reference .token { + gap: 1px; + } + .vanuatu .export-reference .icon:not(.icon-check) { + width: 16px; + height: 16px; + } .vanuatu .demand-ships { gap: 4px; } diff --git a/viewer/three/board.js b/viewer/three/board.js index fc09c37..16f2a0e 100644 --- a/viewer/three/board.js +++ b/viewer/three/board.js @@ -1472,7 +1472,7 @@ export function mountBoard3D(target, { onSelect } = {}) { const occupied = [...pieces.values()]; const frame = host.getBoundingClientRect(); for (const overlay of target.parentElement.querySelectorAll( - ".market-info, .demand-ships, .map-tools, .upcoming", + ".market-info, .trade-info, .map-tools, .upcoming", )) { const r = overlay.getBoundingClientRect(); if (r.width && r.height) diff --git a/viewer/ui.js b/viewer/ui.js index 2565ced..433d25a 100644 --- a/viewer/ui.js +++ b/viewer/ui.js @@ -1,4 +1,5 @@ import { createTradeTransition } from "./trade-transition.js"; +import { exportGoodHelp, exportReference } from "./export-reference.js"; import { mountBoard3D } from "./three/board.js"; import { playerSymbolGlyph } from "@boardgamers/protocol/player-symbols"; import { @@ -122,7 +123,7 @@ export function mountGame(target, options = {}) { } catch {} root.dataset.mapView = mapView; const patch = createRenderer( - ".map-3d, .game-header, .action-dock, .market-info, .demand-ships, .map-scroll, .map-tools, .upcoming, .turn-tray, .player-card, .play-footer", + ".map-3d, .game-header, .action-dock, .market-info, .demand-ships, .export-reference, .map-scroll, .map-tools, .upcoming, .turn-tray, .player-card, .play-footer", (from, to) => { // These attributes belong to the layout/zoom controllers, not the state. const attr = from.matches(".sea-board, .map-canvas, .archipelago") @@ -489,12 +490,21 @@ export function mountGame(target, options = {}) { return `
${selectedAction ? `${icon(action)} ${t(action)}` : t("actions")}
${discard ? `

${blockingHtml(s, player, action, lang, undefined, colorBlind)}

` : !selectedAction && moves.some((m) => m.type === "discard") ? `

${esc(translateText(RETRIEVE_CHOICE, lang))}

` : ""}${hasBonus && hasNormal ? `` : ""}${pickText}
${opts.map((m) => moveButton(m, true)).join("")}${discard ? moveButton(discard) : ""}
${governor ? btn(`${icon("marker")} ↔`, `data-governor title="${t("governor")}"`) : ""}${selectedAction ? titled(t("cancel"), icon("close"), "data-cancel", "icon-button") : ""}
`; } function tradeShips() { - const help = `Foreign trade\n${colorBlind ? "K: kava · C: copra · B: beef." : "Green: kava · White: copra · Red: beef."}\nEach export fills the first ship (1 → 3) still needing that good. ✓ = already delivered.\nCompleting a ship adds 2 prosperity points.`; - return `
${tradeTransition + const help = + "First ship needing the good (1 → 3). Complete ship: +2 prosperity."; + return `
${tradeTransition .demands(s.demands) .map( (d, i) => - `
${i + 1}${d.goods.map((g, j) => `${icon(g)}${d.filled[j] ? icon("check") : ""}`).join("")}${icon("buy")}
`, + `
${i + 1}${d.goods + .map((g, j) => { + const goodHelp = exportGoodHelp( + g, + d.filled[j] ? "delivered" : "available", + ); + return `${icon(g, goodHelp)}${d.filled[j] ? icon("check", goodHelp) : ""}`; + }) + .join("")}${icon("buy", help)}
`, ) .join("")}
`; } @@ -640,7 +650,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()}
${renderBoard(targets)}
${btn("2D", `data-map-view="2d" aria-pressed="${mapView === "2d"}"`)}${btn("3D", `data-map-view="3d" aria-pressed="${mapView === "3d"}" ${threeUnavailable ? "disabled" : ""}`)}${titled(translateText("Overview", lang), icon("overview"), "data-three-home", "icon-button")}${titled("Zoom out", icon("zoomOut"), "data-three-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-three-in", "icon-button")}${titled("Zoom out", icon("zoomOut"), "data-zoom-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-zoom-in", "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")}
`; +
${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()}${exportReference(colorBlind)}
${renderBoard(targets)}
${btn("2D", `data-map-view="2d" aria-pressed="${mapView === "2d"}"`)}${btn("3D", `data-map-view="3d" aria-pressed="${mapView === "3d"}" ${threeUnavailable ? "disabled" : ""}`)}${titled(translateText("Overview", lang), icon("overview"), "data-three-home", "icon-button")}${titled("Zoom out", icon("zoomOut"), "data-three-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-three-in", "icon-button")}${titled("Zoom out", icon("zoomOut"), "data-zoom-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-zoom-in", "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. patch(play, `
${html}
`, true);