Clarify board resources, add tooltips and simplify sailing choices
This commit is contained in:
parent
8a16573110
commit
36a8742f47
13 changed files with 299 additions and 45 deletions
25
docs/ARTWORK.md
Normal file
25
docs/ARTWORK.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Board artwork
|
||||
|
||||
The interactive board uses cleaned derivatives of the supplied publisher artwork. Original component images remain in `viewer/assets` for reference and tile-selection cards. Their existing rights notice still applies.
|
||||
|
||||
The built-in image-editing tool was used on 25 September 2026. Outputs were inspected, resized to 640 × 640 and encoded as WebP. The engine's component values were not changed.
|
||||
|
||||
| Original | Board derivative |
|
||||
| ---------------------------- | ---------------------------------- |
|
||||
| `viewer/assets/efate.webp` | `viewer/assets/efate-board.webp` |
|
||||
| `viewer/assets/tile-7.webp` | `viewer/assets/tile-7-board.webp` |
|
||||
| `viewer/assets/tile-9.webp` | `viewer/assets/tile-9-board.webp` |
|
||||
| `viewer/assets/tile-19.webp` | `viewer/assets/tile-19-board.webp` |
|
||||
| `viewer/assets/tile-21.webp` | `viewer/assets/tile-21-board.webp` |
|
||||
|
||||
Sea tiles use the existing `viewer/assets/ocean.webp` texture, with live resource badges and player boats rendered in SVG. They no longer display decorative printed boats or static resource values underneath the live state.
|
||||
|
||||
## Editing prompts
|
||||
|
||||
For each island tile (7, 9, 19, 21):
|
||||
|
||||
> Edit this exact supplied board-game island tile for a digital adaptation. Preserve its EXACT overhead hand-painted island silhouette, position, relative size, vegetation, sand, turquoise water, colours, tiny scenery huts, beach umbrellas and piers. Remove ONLY printed game overlays: white tourist pawn and number near top/side, all thin rectangular building-slot outlines and thin circular scoring-slot outlines, and the colored resource cubes near the bottom. Also remove tiny boats in the water. Fill small removed areas seamlessly from the adjacent water/sand/vegetation texture. Keep the same 1:1 square framing and scale, do not zoom the island or recompose. Extend matching turquoise water to fill the whole square outside the original irregular water-tile edge, without a black/white/transparent border. No new icons, text, numbers, slot markings, outlines or scenery. Restrained cleanup of publisher art, not redesign.
|
||||
|
||||
For Efate:
|
||||
|
||||
> Edit this exact square board-game island tile image for a digital adaptation. Preserve the same overhead hand-painted art, EXACT island silhouette, size, placement, colours, palms, sand and water texture. Remove ALL printed game overlays only: the white pawn with number 5 at left; the partly visible number/counter at top edge and top right; thin rectangular building boxes, the large thin circular scoring outline at bottom left, colored red/white/green resource cube symbols at lower right, and the faint thin hexagonal board-grid outlines. Fill those small areas seamlessly with adjacent original ocean/sand/vegetation texture. Keep tiny scenery huts, beach umbrellas and pier. No icons, numbers, text, geometric game outlines or new scenery. Return the same 1:1 square composition, full bleed water background. This is restrained cleanup of supplied publisher art, not a redesign.
|
||||
|
|
@ -29,7 +29,7 @@ if (existing?.public)
|
|||
const defaults = {
|
||||
public: false,
|
||||
meta: { botsPublic: true },
|
||||
label: "Vanuatu",
|
||||
label: "🏝️ Vanuatu",
|
||||
players: [2, 3, 4, 5],
|
||||
description:
|
||||
"Compete for prosperity in a growing Pacific archipelago. Plan actions, sail, trade and welcome tourists. Includes all eleven characters, the official two-player variant and Rising Waters.",
|
||||
|
|
|
|||
|
|
@ -44,6 +44,50 @@ 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]");
|
||||
// Empty action stacks do not leave labels above their icons or shift columns.
|
||||
const actionLayout = await page
|
||||
.locator(".action-dock > button")
|
||||
.evaluateAll((buttons) =>
|
||||
buttons.map((button) => {
|
||||
const icon = button
|
||||
.querySelector(".action-symbol")
|
||||
.getBoundingClientRect();
|
||||
const label = button
|
||||
.querySelector(".action-label")
|
||||
.getBoundingClientRect();
|
||||
return {
|
||||
x: label.left,
|
||||
delta: Math.abs(
|
||||
icon.top + icon.height / 2 - label.top - label.height / 2,
|
||||
),
|
||||
};
|
||||
}),
|
||||
);
|
||||
assert.ok(
|
||||
actionLayout.every(
|
||||
(b) => b.delta < 1 && Math.abs(b.x - actionLayout[0].x) < 1,
|
||||
),
|
||||
);
|
||||
assert.ok(
|
||||
await page
|
||||
.locator(".resource-badge")
|
||||
.evaluateAll((badges) =>
|
||||
badges.every((badge) =>
|
||||
[...badge.querySelectorAll("g")].every(
|
||||
(g) =>
|
||||
g.querySelector("svg").getBoundingClientRect().right <
|
||||
g.querySelector("text").getBoundingClientRect().left,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
assert.match(
|
||||
await page
|
||||
.locator(".resource-badge title")
|
||||
.allTextContents()
|
||||
.then((t) => t.join(" ")),
|
||||
/island capacity/,
|
||||
);
|
||||
// Browser language does not override the English default; an explicit choice persists.
|
||||
assert.equal(
|
||||
await page.locator("[data-back] span").textContent(),
|
||||
|
|
@ -101,6 +145,27 @@ function actionState() {
|
|||
s.players[0].treasures = [1];
|
||||
return s;
|
||||
}
|
||||
// A neighbouring destination has 1- and 3-step legal paths, but only needs one UI choice.
|
||||
const sailing = actionState();
|
||||
assert.deepEqual(
|
||||
[
|
||||
...new Set(
|
||||
E.sailOptions(sailing, 0)
|
||||
.filter((m) => m.path.at(-1) === "1,1")
|
||||
.map((m) => m.path.length),
|
||||
),
|
||||
].sort(),
|
||||
[1, 3],
|
||||
);
|
||||
await page.evaluate((s) => window.vanuatuDemo.setState(s), sailing);
|
||||
await page.locator('[data-action="sail"]').click();
|
||||
await page.locator('[data-cell="1,1"]').click();
|
||||
assert.equal(await page.locator(".turn-tray .primary[data-move]").count(), 1);
|
||||
await page.locator(".turn-tray .primary[data-move]").click();
|
||||
assert.equal(
|
||||
await page.evaluate(() => window.vanuatuDemo.state.players[0].money),
|
||||
8,
|
||||
);
|
||||
for (const width of [1440, 390]) {
|
||||
await page.setViewportSize({ width, height: width === 390 ? 844 : 1000 });
|
||||
for (const action of E.ACTIONS) {
|
||||
|
|
|
|||
|
|
@ -49,11 +49,53 @@ const paths = {
|
|||
sound:
|
||||
'<path d="M3 12h7l8-7v22l-8-7H3zM23 10q8 6 0 12" fill="none" stroke="currentColor" stroke-width="2"/>',
|
||||
};
|
||||
export function icon(name, label = "") {
|
||||
return `<svg class="icon icon-${esc(name)}" viewBox="0 0 32 32" ${label ? `role="img" aria-label="${esc(label)}"` : 'aria-hidden="true"'}>${paths[name] ?? paths.point}</svg>`;
|
||||
const meanings = {
|
||||
sail: ["Sailing / boat", "Navigation / bateau"],
|
||||
fish: ["Fish value", "Valeur du poisson"],
|
||||
sell: ["Sell fish", "Vendre du poisson"],
|
||||
explore: ["Treasure value", "Valeur du trésor"],
|
||||
build: ["Huts", "Cabanes"],
|
||||
draw: ["Sand drawings", "Dessins de sable"],
|
||||
tourist: ["Tourists", "Touristes"],
|
||||
rest: ["Rest bonus", "Bonus de repos"],
|
||||
coin: ["Vatus (money)", "Vatus (argent)"],
|
||||
point: ["Prosperity points", "Points de prospérité"],
|
||||
first: ["First player", "Premier joueur"],
|
||||
water: ["Rising Waters", "Montée des eaux"],
|
||||
dike: [
|
||||
"Dike — protects this coast from flooding",
|
||||
"Digue — protège cette côte des inondations",
|
||||
],
|
||||
kava: ["Kava — costs 1 vatu", "Kava — coûte 1 vatu"],
|
||||
copra: ["Copra — costs 2 vatus", "Coprah — coûte 2 vatus"],
|
||||
beef: ["Beef — costs 3 vatus", "Bœuf — coûte 3 vatus"],
|
||||
buy: ["Export goods", "Exporter des marchandises"],
|
||||
marker: ["Action marker", "Pion d’action"],
|
||||
chat: ["Chat", "Discussion"],
|
||||
journal: ["Journal", "Journal"],
|
||||
help: ["Rules & help", "Règles et aide"],
|
||||
fullscreen: ["Full screen", "Plein écran"],
|
||||
close: ["Close", "Fermer"],
|
||||
undo: ["Undo", "Annuler"],
|
||||
check: ["Complete", "Terminé"],
|
||||
eye: ["Overview", "Vue d’ensemble"],
|
||||
zoom: ["Zoom board", "Agrandir le plateau"],
|
||||
sound: ["Game sounds", "Sons du jeu"],
|
||||
};
|
||||
export const iconLabel = (name, language = "en") =>
|
||||
meanings[name]?.[language === "fr" ? 1 : 0] ?? name;
|
||||
export function icon(name, label = iconLabel(name)) {
|
||||
return `<svg class="icon icon-${esc(name)}" viewBox="0 0 32 32" aria-hidden="true"><title>${esc(label)}</title>${paths[name] ?? paths.point}</svg>`;
|
||||
}
|
||||
export function svgIcon(name, x, y, size = 26, color = "currentColor") {
|
||||
return `<svg x="${x}" y="${y}" width="${size}" height="${size}" viewBox="0 0 32 32" style="color:${color}" aria-hidden="true">${paths[name] ?? paths.point}</svg>`;
|
||||
export function svgIcon(
|
||||
name,
|
||||
x,
|
||||
y,
|
||||
size = 26,
|
||||
color = "currentColor",
|
||||
label = iconLabel(name),
|
||||
) {
|
||||
return `<svg x="${x}" y="${y}" width="${size}" height="${size}" viewBox="0 0 32 32" style="color:${color}" aria-hidden="true"><title>${esc(label)}</title>${paths[name] ?? paths.point}</svg>`;
|
||||
}
|
||||
export const token = (name, n) =>
|
||||
`<span class="token" role="img" aria-label="${esc(name)}: ${esc(n)}">${icon(name)}<b>${esc(n)}</b></span>`;
|
||||
export const token = (name, n, label = `${iconLabel(name)}: ${n}`) =>
|
||||
`<span class="token" role="img" aria-label="${esc(label)}" title="${esc(label)}">${icon(name, label)}<b>${esc(n)}</b></span>`;
|
||||
|
|
|
|||
BIN
viewer/assets/efate-board.webp
Normal file
BIN
viewer/assets/efate-board.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
BIN
viewer/assets/tile-19-board.webp
Normal file
BIN
viewer/assets/tile-19-board.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
viewer/assets/tile-21-board.webp
Normal file
BIN
viewer/assets/tile-21-board.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
BIN
viewer/assets/tile-7-board.webp
Normal file
BIN
viewer/assets/tile-7-board.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
BIN
viewer/assets/tile-9-board.webp
Normal file
BIN
viewer/assets/tile-9-board.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
17
viewer/board-assets.js
Normal file
17
viewer/board-assets.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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";
|
||||
import d1 from "./assets/tile-19-board.webp";
|
||||
import d2 from "./assets/tile-21-board.webp";
|
||||
|
||||
// Static printed counters stay in the reference art; the board draws live state.
|
||||
const islands = {
|
||||
efate,
|
||||
"tile-7": a1,
|
||||
"tile-9": a2,
|
||||
"tile-19": d1,
|
||||
"tile-21": d2,
|
||||
};
|
||||
export const boardArt = (tile) =>
|
||||
tile.type === "sea" ? assets.ocean : islands[tile.art];
|
||||
104
viewer/board.js
104
viewer/board.js
|
|
@ -1,6 +1,6 @@
|
|||
import { CELLS, TILES, COLORS, DIRECTIONS } from "../engine/catalog.js";
|
||||
import { assets } from "./assets.js";
|
||||
import { esc, svgIcon } from "./art.js";
|
||||
import { esc, svgIcon, iconLabel } from "./art.js";
|
||||
import { boardArt } from "./board-assets.js";
|
||||
export const center = (id) => {
|
||||
const [q, r] = id.split(",").map(Number);
|
||||
return { x: 355 + q * 162 - r * 81, y: 150 + r * 140.3 };
|
||||
|
|
@ -12,10 +12,32 @@ function hex(x, y, r = 94) {
|
|||
}).join(" ");
|
||||
}
|
||||
const symbols = ["●", "◆", "▲", "■", "✦"];
|
||||
function resourceBadge(x, y, items) {
|
||||
const widths = items.map(({ value }) => 34 + String(value).length * 11);
|
||||
const width = widths.reduce((a, b) => a + b, 0) + 8;
|
||||
let offset = x - width / 2 + 4;
|
||||
return `<g class="resource-badge"><rect x="${x - width / 2}" y="${y}" width="${width}" height="30" rx="15" fill="#fff9dfed"/>${items
|
||||
.map(({ kind, value, help }, i) => {
|
||||
const left = offset;
|
||||
offset += widths[i];
|
||||
return `<g><title>${esc(help)}</title><rect x="${left}" y="${y}" width="${widths[i]}" height="30" fill="transparent"/>${svgIcon(kind, left, y + 3, 24)}<text x="${left + 29}" y="${y + 21}" class="resource-n">${esc(value)}</text></g>`;
|
||||
})
|
||||
.join("")}</g>`;
|
||||
}
|
||||
export function boardSvg(
|
||||
s,
|
||||
{ selected, targets = [], hoverTile, player, colorBlind = false, t } = {},
|
||||
{
|
||||
selected,
|
||||
targets = [],
|
||||
hoverTile,
|
||||
player,
|
||||
colorBlind = false,
|
||||
language = "en",
|
||||
t,
|
||||
} = {},
|
||||
) {
|
||||
const fr = language === "fr";
|
||||
const label = (name) => iconLabel(name, language);
|
||||
const targetSet = new Set(targets);
|
||||
const all = CELLS.map((c) => ({ ...c, ...center(c.id) }));
|
||||
const visible = all.filter((c) => s.board[c.id] || targetSet.has(c.id));
|
||||
|
|
@ -34,10 +56,10 @@ export function boardSvg(
|
|||
const tile = s.board[c.id],
|
||||
legal = targetSet.has(c.id),
|
||||
spec = tile ? TILES[tile.id] : null;
|
||||
svg += `<g class="map-cell ${legal ? "legal" : ""} ${selected === c.id ? "selected" : ""}" data-cell="${c.id}" ${legal ? `role="button" tabindex="0" aria-label="${esc(t(tile?.type === "island" ? "island" : "sea"))} ${c.id}"` : ""}>`;
|
||||
svg += `<polygon class="cell-surface" points="${hex(c.x, c.y)}"/>`;
|
||||
svg += `<g class="map-cell ${tile ? "occupied" : ""} ${legal ? "legal" : ""} ${selected === c.id ? "selected" : ""}" data-cell="${c.id}" ${legal ? `role="button" tabindex="0" aria-label="${esc(t(tile?.type === "island" ? "island" : "sea"))} ${c.id}"` : ""}>`;
|
||||
svg += `<title>${esc(tile ? `${t(tile.type === "island" ? "island" : "sea")} · ${c.id}${tile.submerged ? ` · ${fr ? "Submergé" : "Submerged"}` : ""}` : fr ? "Emplacement de tuile" : "Tile space")}</title><polygon class="cell-surface" points="${hex(c.x, c.y)}"/>`;
|
||||
if (tile) {
|
||||
svg += `<image href="${assets[spec.art]}" x="${c.x - 111}" y="${c.y - 111}" width="222" height="222" clip-path="url(#cell-${c.q + 2}-${c.r})"/>`;
|
||||
svg += `<image href="${boardArt(spec)}" x="${c.x - 111}" y="${c.y - 111}" width="222" height="222" clip-path="url(#cell-${c.q + 2}-${c.r})"/>`;
|
||||
if (tile.submerged) {
|
||||
svg += `<polygon points="${hex(c.x, c.y)}" fill="#1c708ca6"/>${svgIcon("water", c.x - 25, c.y - 25, 50)}`;
|
||||
} else if (tile.type === "sea") {
|
||||
|
|
@ -46,31 +68,65 @@ export function boardSvg(
|
|||
...(spec.treasure ? [["explore", tile.treasure]] : []),
|
||||
];
|
||||
if (res.length)
|
||||
svg += `<rect x="${c.x - 16}" y="${c.y - 85}" width="92" height="40" rx="18" fill="#edf5ddec"/>`;
|
||||
for (const [i, [kind, n]] of res.entries()) {
|
||||
const x = c.x + 30 - (res.length * 45) / 2 + i * 45;
|
||||
svg += `<rect x="${x - 6}" y="${c.y - 80}" width="44" height="29" rx="14" fill="#fff9dfeb"/>${svgIcon(kind, x - 4, c.y - 80, 27)}<text x="${x + 26}" y="${c.y - 60}" class="resource-n">${n}</text>`;
|
||||
}
|
||||
svg += resourceBadge(
|
||||
c.x,
|
||||
c.y - 52,
|
||||
res.map(([kind, value]) => ({
|
||||
kind,
|
||||
value,
|
||||
help: value
|
||||
? `${label(kind)}: ${value} — ${fr ? "prochaine prise sur cette tuile" : "next catch on this tile"}`
|
||||
: `${label(kind)}: 0 — ${fr ? "épuisé" : "depleted"}`,
|
||||
})),
|
||||
);
|
||||
} else {
|
||||
const goods = Object.entries(tile.goods).filter(([, n]) => n > 0);
|
||||
let j = 0;
|
||||
for (const [good, n] of goods)
|
||||
for (let k = 0; k < n; k++, j++)
|
||||
svg += svgIcon(good, c.x - 45 + j * 28, c.y + 48, 29);
|
||||
svg += svgIcon(
|
||||
good,
|
||||
c.x -
|
||||
goods.reduce((sum, [, count]) => sum + count, 0) * 14 +
|
||||
j * 28,
|
||||
c.y + 48,
|
||||
29,
|
||||
"currentColor",
|
||||
`${label(good)} · ${fr ? "disponible à l’export" : "available to export"}`,
|
||||
);
|
||||
const huts = tile.huts;
|
||||
for (let i = 0; i < spec.huts; i++) {
|
||||
const x = c.x - 40 + i * 32,
|
||||
const x = c.x - spec.huts * 16 + i * 32,
|
||||
y = c.y - 29;
|
||||
const help =
|
||||
huts[i] !== undefined
|
||||
? `${label("build")} · ${s.players[huts[i]].name}`
|
||||
: fr
|
||||
? "Emplacement de cabane libre"
|
||||
: "Empty hut space";
|
||||
svg += `<g><title>${esc(help)}</title>`;
|
||||
svg +=
|
||||
huts[i] !== undefined
|
||||
? svgIcon("build", x, y, 30, COLORS[huts[i]])
|
||||
? svgIcon("build", x, y, 30, COLORS[huts[i]], help)
|
||||
: `<rect x="${x + 3}" y="${y + 5}" width="24" height="23" rx="4" fill="#ffffff77" stroke="#786344" stroke-dasharray="3 2"/>`;
|
||||
if (colorBlind && huts[i] !== undefined)
|
||||
svg += `<text x="${x + 16}" y="${y + 26}" class="color-symbol">${symbols[huts[i]]}</text>`;
|
||||
svg += "</g>";
|
||||
}
|
||||
svg += `<rect x="${c.x - 44}" y="${c.y + 10}" width="88" height="28" rx="14" fill="#fff9dfeb"/>${svgIcon("tourist", c.x - 42, c.y + 11, 24)}<text x="${c.x - 17}" y="${c.y + 30}" class="resource-n">${tile.tourists}/${spec.tourists}</text>${svgIcon("draw", c.x + 7, c.y + 13, 22)}<text x="${c.x + 32}" y="${c.y + 30}" class="resource-n">${tile.drawings}</text>`;
|
||||
svg += resourceBadge(c.x, c.y + 10, [
|
||||
{
|
||||
kind: "tourist",
|
||||
value: `${tile.tourists}/${spec.tourists}`,
|
||||
help: `${label("tourist")}: ${tile.tourists}/${spec.tourists} — ${fr ? "présents / capacité de l’île" : "present / island capacity"}`,
|
||||
},
|
||||
{
|
||||
kind: "draw",
|
||||
value: tile.drawings,
|
||||
help: `${label("draw")}: ${tile.drawings}/${spec.drawings} — ${fr ? "réalisés / emplacements" : "completed / spaces"}`,
|
||||
},
|
||||
]);
|
||||
if (tile.water)
|
||||
svg += `${svgIcon("water", c.x - 74, c.y - 20, 25)}<text x="${c.x - 59}" y="${c.y + 20}" class="resource-n">${tile.water}</text>`;
|
||||
svg += `<g><title>${esc(`${label("water")}: ${tile.water}`)}</title>${svgIcon("water", c.x - 74, c.y - 20, 25)}<text x="${c.x - 59}" y="${c.y + 20}" class="resource-n">${tile.water}</text></g>`;
|
||||
for (const edge of tile.dikes) {
|
||||
const o = center(edge);
|
||||
const dx = o.x - c.x,
|
||||
|
|
@ -78,22 +134,26 @@ export function boardSvg(
|
|||
const mx = c.x + dx * 0.48,
|
||||
my = c.y + dy * 0.48,
|
||||
l = Math.hypot(dx, dy);
|
||||
svg += `<line x1="${mx - (dy / l) * 22}" y1="${my + (dx / l) * 22}" x2="${mx + (dy / l) * 22}" y2="${my - (dx / l) * 22}" stroke="#654429" stroke-width="9" stroke-linecap="round"/><line x1="${mx - (dy / l) * 22}" y1="${my + (dx / l) * 22}" x2="${mx + (dy / l) * 22}" y2="${my - (dx / l) * 22}" stroke="#d1aa67" stroke-width="5" stroke-linecap="round"/>`;
|
||||
svg += `<g><title>${esc(label("dike"))}</title><line x1="${mx - (dy / l) * 22}" y1="${my + (dx / l) * 22}" x2="${mx + (dy / l) * 22}" y2="${my - (dx / l) * 22}" stroke="#654429" stroke-width="9" stroke-linecap="round"/><line x1="${mx - (dy / l) * 22}" y1="${my + (dx / l) * 22}" x2="${mx + (dy / l) * 22}" y2="${my - (dx / l) * 22}" stroke="#d1aa67" stroke-width="5" stroke-linecap="round"/></g>`;
|
||||
}
|
||||
}
|
||||
} else if (hoverTile && legal)
|
||||
svg += `<image class="tile-ghost" href="${assets[TILES[hoverTile].art]}" x="${c.x - 103}" y="${c.y - 103}" width="206" height="206" clip-path="url(#cell-${c.q + 2}-${c.r})"/>`;
|
||||
svg += `<image class="tile-ghost" href="${boardArt(TILES[hoverTile])}" x="${c.x - 103}" y="${c.y - 103}" width="206" height="206" clip-path="url(#cell-${c.q + 2}-${c.r})"/>`;
|
||||
if (!tile)
|
||||
svg += `<text x="${c.x}" y="${c.y + 7}" class="empty-label">${legal ? "+" : "·"}</text>`;
|
||||
svg += `<polygon class="cell-ring" points="${hex(c.x, c.y, 92)}"/></g>`;
|
||||
svg += `<polygon class="cell-ring" points="${hex(c.x, c.y, 92)}"/>`;
|
||||
const boats = s.players
|
||||
.map((p, i) => ({ p, i }))
|
||||
.filter(({ p }) => p.boat === c.id);
|
||||
for (const [i, { p, i: pi }] of boats.entries()) {
|
||||
const x = c.x + (i - (boats.length - 1) / 2) * 37,
|
||||
y = c.y + (tile?.type === "sea" ? 11 : 0);
|
||||
svg += `<g class="boat ${pi === player ? "own" : ""}" transform="translate(${x - 24} ${y - 24})" style="color:${p.color}" filter="url(#boat-shadow)">${svgIcon("sail", 0, 0, 48, p.color)}${colorBlind ? `<text x="25" y="40" class="color-symbol">${symbols[pi]}</text>` : ""}<title>${esc(p.name)}</title></g>`;
|
||||
const row = Math.floor(i / 3);
|
||||
const rowSize = Math.min(3, boats.length - row * 3);
|
||||
const x = c.x + ((i % 3) - (rowSize - 1) / 2) * 39,
|
||||
y = c.y + (boats.length > 3 ? row * 32 : 11);
|
||||
const help = `${fr ? "Bateau" : "Boat"} · ${p.name}`;
|
||||
svg += `<g class="boat ${pi === player ? "own" : ""}" transform="translate(${x - 24} ${y - 24})" style="color:${p.color}" filter="url(#boat-shadow)"><title>${esc(help)}</title>${svgIcon("sail", 0, 0, 48, p.color, help)}${colorBlind ? `<text x="25" y="40" class="color-symbol">${symbols[pi]}</text>` : ""}</g>`;
|
||||
}
|
||||
svg += "</g>";
|
||||
}
|
||||
return svg + "</svg>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,12 +189,11 @@
|
|||
}
|
||||
.vanuatu .action-dock > button {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: 33px 1fr;
|
||||
grid-template-rows: auto auto;
|
||||
justify-items: start;
|
||||
column-gap: 7px;
|
||||
row-gap: 3px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 7px;
|
||||
text-align: left;
|
||||
min-height: 54px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #d1d4c5;
|
||||
|
|
@ -204,13 +203,23 @@
|
|||
box-shadow: inset 3px 0 #a2b6a4;
|
||||
}
|
||||
.vanuatu .action-dock .action-symbol {
|
||||
grid-row: 1/3;
|
||||
align-self: center;
|
||||
display: flex;
|
||||
flex: 0 0 33px;
|
||||
align-items: center;
|
||||
}
|
||||
.vanuatu .action-dock .action-symbol .icon {
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
}
|
||||
.vanuatu .action-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 3px;
|
||||
}
|
||||
.vanuatu .action-stacks:empty {
|
||||
display: none;
|
||||
}
|
||||
.vanuatu .action-label {
|
||||
font-size: 11px;
|
||||
font-weight: 650;
|
||||
|
|
@ -310,8 +319,12 @@
|
|||
.vanuatu .cell-ring {
|
||||
fill: none;
|
||||
stroke: none;
|
||||
stroke-width: 1;
|
||||
pointer-events: none;
|
||||
}
|
||||
.vanuatu .map-cell.occupied .cell-ring {
|
||||
stroke: #e8fff980;
|
||||
}
|
||||
.vanuatu .empty-label {
|
||||
fill: #def6ed99;
|
||||
font-size: 24px;
|
||||
|
|
@ -344,6 +357,12 @@
|
|||
stroke: #fffbe3;
|
||||
stroke-width: 1px;
|
||||
}
|
||||
.vanuatu .resource-badge .resource-n {
|
||||
text-anchor: start;
|
||||
}
|
||||
.vanuatu .resource-badge svg {
|
||||
pointer-events: none;
|
||||
}
|
||||
.vanuatu .color-symbol {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
|
|
@ -354,7 +373,7 @@
|
|||
stroke-width: 2px;
|
||||
}
|
||||
.vanuatu .boat {
|
||||
pointer-events: none;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.vanuatu .boat.own {
|
||||
filter: drop-shadow(0 0 3px #fffbe3);
|
||||
|
|
@ -429,13 +448,15 @@
|
|||
.vanuatu .map-tools button {
|
||||
background: #fff8dfcf;
|
||||
}
|
||||
.vanuatu .sea-dashboard > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
.vanuatu .upcoming {
|
||||
position: absolute;
|
||||
right: 13px;
|
||||
bottom: 87px;
|
||||
display: flex;
|
||||
gap: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.vanuatu .upcoming img {
|
||||
width: 57px;
|
||||
|
|
@ -958,7 +979,9 @@ body {
|
|||
}
|
||||
.vanuatu .action-dock > button {
|
||||
padding: 5px 7px;
|
||||
grid-template-columns: 26px 1fr;
|
||||
}
|
||||
.vanuatu .action-dock .action-symbol {
|
||||
flex-basis: 26px;
|
||||
}
|
||||
.vanuatu .action-dock .action-symbol .icon {
|
||||
width: 26px;
|
||||
|
|
@ -1059,6 +1082,12 @@ body {
|
|||
padding: 4px;
|
||||
box-shadow: inset 0 3px #a2b6a4;
|
||||
}
|
||||
.vanuatu .action-content {
|
||||
align-items: center;
|
||||
}
|
||||
.vanuatu .action-dock .action-symbol {
|
||||
flex-basis: auto;
|
||||
}
|
||||
.vanuatu .action-dock .available {
|
||||
box-shadow: inset 0 3px #ae793f;
|
||||
}
|
||||
|
|
|
|||
26
viewer/ui.js
26
viewer/ui.js
|
|
@ -6,7 +6,12 @@ import {
|
|||
VALUES,
|
||||
} from "../engine/catalog.js";
|
||||
import { assets } from "./assets.js";
|
||||
import { icon, token, esc } from "./art.js";
|
||||
import {
|
||||
icon as renderIcon,
|
||||
token as renderToken,
|
||||
iconLabel,
|
||||
esc,
|
||||
} from "./art.js";
|
||||
import { boardSvg, center } from "./board.js";
|
||||
import { translator, characterHelp } from "./labels.js";
|
||||
import { mountActivity } from "./activity.js";
|
||||
|
|
@ -45,6 +50,10 @@ export function mountGame(target, options = {}) {
|
|||
sound = false,
|
||||
revision,
|
||||
focusReturn;
|
||||
const icon = (name, label) =>
|
||||
renderIcon(name, label ?? iconLabel(name, lang));
|
||||
const token = (name, n, label) =>
|
||||
renderToken(name, n, label ?? `${iconLabel(name, lang)}: ${n}`);
|
||||
let t = translator(lang);
|
||||
const events = new AbortController();
|
||||
const listener = { signal: events.signal };
|
||||
|
|
@ -59,7 +68,12 @@ export function mountGame(target, options = {}) {
|
|||
const working = () =>
|
||||
legal().filter((m) => !["treasure", "beg"].includes(m.type));
|
||||
const actMoves = () =>
|
||||
working().filter((m) => m.type === "act" && m.action === action);
|
||||
working().filter(
|
||||
(m) =>
|
||||
m.type === "act" &&
|
||||
m.action === action &&
|
||||
(action !== "sail" || m.path.at(-1) !== own()?.boat),
|
||||
);
|
||||
const actualTargets = () =>
|
||||
action === "sail"
|
||||
? unique(actMoves().map((m) => m.path.at(-1)))
|
||||
|
|
@ -170,7 +184,7 @@ export function mountGame(target, options = {}) {
|
|||
)
|
||||
.join("");
|
||||
return btn(
|
||||
`<span class="action-symbol">${icon(a)}</span><span class="action-label">${t(a)}</span><span class="action-stacks">${stacks}${s.neutral[a] ? `<span class="marker-stack neutral">${s.neutral[a]}</span>` : ""}${countDraft ? `<span class="draft-marker">+${countDraft}</span>` : ""}</span>`,
|
||||
`<span class="action-symbol">${icon(a)}</span><span class="action-content"><span class="action-label">${t(a)}</span><span class="action-stacks">${stacks}${s.neutral[a] ? `<span class="marker-stack neutral" title="${lang === "fr" ? "Pions neutres" : "Neutral markers"}">${s.neutral[a]}</span>` : ""}${countDraft ? `<span class="draft-marker" title="${lang === "fr" ? "Pions en cours de placement" : "Markers being placed"}">+${countDraft}</span>` : ""}</span></span>`,
|
||||
`data-action="${a}" ${allowed ? "" : "disabled"} aria-pressed="${action === a}"`,
|
||||
`${action === a ? "chosen" : ""} ${allowed ? "available" : ""}`,
|
||||
);
|
||||
|
|
@ -229,6 +243,8 @@ export function mountGame(target, options = {}) {
|
|||
const targets = actualTargets();
|
||||
if (targets.length)
|
||||
opts = opts.filter((m) => (m.cell ?? m.path?.at(-1)) === selected);
|
||||
// Only the destination and cost matter: longer routes have no added effect.
|
||||
if (action === "sail") opts = opts.slice(0, 1);
|
||||
const discard = moves.find(
|
||||
(m) => m.type === "discard" && m.action === action,
|
||||
);
|
||||
|
|
@ -257,8 +273,8 @@ export function mountGame(target, options = {}) {
|
|||
.filter((m) => m.type === "place" && m.tile === tile)
|
||||
.map((m) => m.cell)
|
||||
: actualTargets();
|
||||
play.innerHTML = `<header class="game-header"><div class="brand">${btn("Vanuatu", "data-boardgame", "wordmark")}<span>Alain Epron · Quined Games</span></div><div class="round-track" aria-label="${t("round")} ${s.round}/8">${Array.from({ length: 8 }, (_, i) => `<span class="${i + 1 === s.round ? "current" : i + 1 < s.round ? "past" : ""}">${i + 1}</span>`).join("")}</div><nav class="header-tools">${analysis || !options.chat ? "" : titled(t("chat"), `${icon("chat")}<span class="unread-badge" hidden></span>`, 'data-activity="chat"', "icon-button")}${titled(t("journal"), icon("journal"), 'data-activity="journal"', "icon-button")}${titled(t("help"), icon("help"), "data-help", "icon-button")}${titled(t("full"), icon("fullscreen"), "data-fullscreen", "icon-button")}</nav></header>
|
||||
<div class="table">${dock()}<section class="sea-board" style="--ocean:url('${assets.ocean}')"><div class="sea-dashboard"><div class="market-info"><span title="${t("market")}">${icon("fish")} = ${token("coin", s.market)}</span><span title="${t("tourist")}">${token("tourist", s.tourists)}</span>${s.waterCountdown !== null ? `<span title="${t("waterLeft")}">${token("water", s.waterCountdown)}</span>` : ""}</div><div class="demand-ships" aria-label="${t("demand")}">${s.demands.map((d, i) => `<div class="demand-ship" title="${t("demand")} ${i + 1} · +2 ${t("point")}"><small>${i + 1}</small>${d.goods.map((g, j) => `<span class="${d.filled[j] ? "filled" : ""}">${icon(g)}${d.filled[j] ? icon("check") : ""}</span>`).join("")}${icon("buy")}</div>`).join("")}</div></div><div class="map-scroll ${zoom ? "zoomed" : ""}">${boardSvg(s, { player, colorBlind, selected, targets, hoverTile: s.phase === "expand" ? tile : null, t })}</div><div class="map-tools">${titled(zoom ? t("fit") : t("zoom"), icon(zoom ? "eye" : "zoom"), "data-zoom", "icon-button")}</div>${s.upcoming.length && s.phase !== "expand" ? `<div class="upcoming" title="${t("next")}">${s.upcoming.map((id) => `<img src="${assets[TILES[id].art]}" alt="${t(TILES[id].type === "island" ? "island" : "sea")}">`).join("")}</div>` : ""}${trayHtml}</section></div><section class="players">${s.players.map(playerCard).join("")}</section><footer class="play-footer"><span title="${lang === "fr" ? "Conversion automatique" : "Automatic conversion"}">${token("coin", 10)} → ${token("point", 5)}</span>${btn(t("help"), "data-help", "text-button")}</footer>`;
|
||||
play.innerHTML = `<header class="game-header"><div class="brand">${btn("🏝️ Vanuatu", "data-boardgame", "wordmark")}<span>Alain Epron · Quined Games</span></div><div class="round-track" aria-label="${t("round")} ${s.round}/8">${Array.from({ length: 8 }, (_, i) => `<span title="${t("round")} ${i + 1}/8" class="${i + 1 === s.round ? "current" : i + 1 < s.round ? "past" : ""}">${i + 1}</span>`).join("")}</div><nav class="header-tools">${analysis || !options.chat ? "" : titled(t("chat"), `${icon("chat")}<span class="unread-badge" hidden></span>`, 'data-activity="chat"', "icon-button")}${titled(t("journal"), icon("journal"), 'data-activity="journal"', "icon-button")}${titled(t("help"), icon("help"), "data-help", "icon-button")}${titled(t("full"), icon("fullscreen"), "data-fullscreen", "icon-button")}</nav></header>
|
||||
<div class="table">${dock()}<section class="sea-board" style="--ocean:url('${assets.ocean}')"><div class="sea-dashboard"><div class="market-info"><span title="${t("market")}">${icon("fish", t("market"))} = ${token("coin", s.market, `${t("market")}: ${s.market} ${lang === "fr" ? "vatus par valeur de poisson" : "vatus per fish value"}`)}</span><span title="${t("tourist")}">${token("tourist", s.tourists, `${lang === "fr" ? "Touristes disponibles ce tour" : "Tourists available this round"}: ${s.tourists}`)}</span>${s.waterCountdown !== null ? `<span title="${t("waterLeft")}">${token("water", s.waterCountdown, `${t("waterLeft")}: ${s.waterCountdown}`)}</span>` : ""}</div><div class="demand-ships" aria-label="${t("demand")}">${s.demands.map((d, i) => `<div class="demand-ship" title="${t("demand")} ${i + 1} · +2 ${t("point")}"><small>${i + 1}</small>${d.goods.map((g, j) => `<span title="${esc(`${iconLabel(g, lang)} · ${d.filled[j] ? (lang === "fr" ? "déjà livré" : "already delivered") : lang === "fr" ? "à livrer" : "still needed"}`)}" class="${d.filled[j] ? "filled" : ""}">${icon(g)}${d.filled[j] ? icon("check") : ""}</span>`).join("")}${icon("buy")}</div>`).join("")}</div></div><div class="map-scroll ${zoom ? "zoomed" : ""}">${boardSvg(s, { player, colorBlind, language: lang, selected, targets, hoverTile: s.phase === "expand" ? tile : null, t })}</div><div class="map-tools">${titled(zoom ? t("fit") : t("zoom"), icon(zoom ? "eye" : "zoom"), "data-zoom", "icon-button")}</div>${s.upcoming.length && s.phase !== "expand" ? `<div class="upcoming" title="${t("next")}">${s.upcoming.map((id) => `<img src="${assets[TILES[id].art]}" alt="${t(TILES[id].type === "island" ? "island" : "sea")}">`).join("")}</div>` : ""}${trayHtml}</section></div><section class="players">${s.players.map(playerCard).join("")}</section><footer class="play-footer"><span title="${lang === "fr" ? "Conversion automatique" : "Automatic conversion"}">${token("coin", 10)} → ${token("point", 5)}</span>${btn(t("help"), "data-help", "text-button")}</footer>`;
|
||||
const newScroll = play.querySelector(".map-scroll");
|
||||
if (newScroll) {
|
||||
newScroll.scrollLeft = sx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue