diff --git a/README.md b/README.md index 82b3452..e413f89 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The repository is public; the game is listed on BGS as a beta. Supplied artwork Node 24+, pnpm. `pnpm install`, `pnpm build`, `pnpm dev` (port 5246). `pnpm test` runs rules tests; install the browser once with `pnpm exec playwright install chromium`; `pnpm test:browser` checks the viewer. -BGS supplies the shared `colorBlind` and `sound` preferences. Color-blind mode adds player symbols and K/C/B resource labels; game sounds give a quiet confirmation after successful moves. The toggles in Rules & help update the same BGS account settings. Standalone practice stores its own preferences locally. +BGS supplies the shared `colorBlind` and `sound` preferences. Color-blind mode adds player symbols and K/C/B resource labels; game sounds give a quiet confirmation after successful moves. The toggles in Rules & help update the same BGS account settings. Standalone practice stores its own preferences locally. The 2D/3D switch saves the `mapView` preference through BGS; 3D is the default, with a 2D fallback when WebGL is unavailable. Motion follows the browser’s reduced-motion setting. Marker retrieval is manual by default, including the last unusable action stack. Each player can opt into automatic retrieval when retrieving one stack is the only available move in Rules & help; this setting is saved separately for each game. Automatic retrieval never skips optional treasure exchanges or chooses between multiple stacks. Guided lessons always use manual retrieval. diff --git a/engine/index.js b/engine/index.js index 48d2e42..d3730f8 100644 --- a/engine/index.js +++ b/engine/index.js @@ -810,13 +810,17 @@ function endRound(s) { s._demandDiscards.push(d); s.demands = s.demands.filter((d) => !d.filled.every(Boolean)); while (s.demands.length < 3) s.demands.push(revealDemand(s)); - for (const t of Object.values(s.board)) + const refills = []; + for (const [cell, t] of Object.entries(s.board)) if ( t.type === "island" && !t.submerged && sum(Object.values(t.goods)) === 0 - ) + ) { t.goods = { ...TILES[t.id].goods }; + if (sum(Object.values(t.goods))) + refills.push({ cell, goods: { ...t.goods } }); + } if (s.players.length === 2) { const previous = new Set([ ...s.characters, @@ -838,7 +842,12 @@ function endRound(s) { s.planningPass = 0; s.neutral = emptyMarkers(); s.neutralPlaced = 0; - say(s, "round", { round: s.round, first: s.first, tourists: s.tourists }); + say(s, "round", { + round: s.round, + first: s.first, + tourists: s.tourists, + refills, + }); } function finish(s) { for (const [p, a] of s.players.entries()) { diff --git a/package.json b/package.json index 2fa172a..5980512 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@boardgamers/vanuatu", - "version": "0.1.10", + "version": "0.2.0", "private": true, "type": "module", "main": "dist/engine.js", @@ -11,7 +11,7 @@ "build": "node scripts/build.mjs", "test": "node --test test/*.test.js", "dev": "node scripts/dev.mjs", - "test:browser": "node test/browser.mjs && node test/undo-browser.mjs && node test/journal-browser.mjs && node test/map-zoom-browser.mjs && node test/map-drag-browser.mjs && node test/redraw-browser.mjs && node test/mobile-layout-browser.mjs && node test/prose-browser.mjs && node test/effects-browser.mjs", + "test:browser": "node test/browser.mjs && node test/undo-browser.mjs && node test/journal-browser.mjs && node test/map-zoom-browser.mjs && node test/map-drag-browser.mjs && node test/redraw-browser.mjs && node test/mobile-layout-browser.mjs && node test/prose-browser.mjs && node test/effects-browser.mjs && node test/three-viewer-browser.mjs", "check": "pnpm test:locales && pnpm build && pnpm test && pnpm test:browser && pnpm test:tutorial:browser", "test:locales": "node scripts/check-locales.mjs viewer/localization && node --test scripts/localization.test.mjs", "test:tutorial:browser": "node test/tutorial-browser.mjs && node test/tutorial-walkthrough-browser.mjs && node test/tutorial-errors-browser.mjs" @@ -19,7 +19,8 @@ "dependencies": { "@boardgamers/protocol": "0.10.0", "@noble/hashes": "2.0.1", - "morphdom": "2.7.8" + "morphdom": "2.7.8", + "three": "0.186.1" }, "devDependencies": { "esbuild": "0.25.12", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 57060b7..b28052c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: morphdom: specifier: 2.7.8 version: 2.7.8 + three: + specifier: 0.186.1 + version: 0.186.1 devDependencies: esbuild: specifier: 0.25.12 @@ -221,6 +224,9 @@ packages: engines: {node: '>=14'} hasBin: true + three@0.186.1: + resolution: {integrity: sha512-blFeqb49wRCSGUGj7gtpfnSGHy2lwDk94RhUmS1c/hTby70kvChbWpkJ4Pm1390LqzzvTmzgXKHPEafJwCb8jA==} + zod@4.6.5: resolution: {integrity: sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==} @@ -354,4 +360,6 @@ snapshots: prettier@3.6.2: {} + three@0.186.1: {} + zod@4.6.5: {} diff --git a/scripts/publish-beta.mjs b/scripts/publish-beta.mjs index cac025b..805789f 100644 --- a/scripts/publish-beta.mjs +++ b/scripts/publish-beta.mjs @@ -1,3 +1,7 @@ +import { + mapViewPreference, + releasePreferences, +} from "./release-preferences.mjs"; import { uploadViewerFiles } from "./viewer-files.mjs"; import { chapterMetadata } from "../viewer/tutorials.js"; import { readFile, mkdir, writeFile } from "node:fs/promises"; @@ -68,12 +72,7 @@ const defaults = { default: false, }, { name: "sound", label: "Game sounds", type: "checkbox", default: true }, - { - name: "animations", - label: "Animations", - type: "checkbox", - default: true, - }, + mapViewPreference, { name: "language", label: "Language", @@ -123,17 +122,9 @@ const files = await uploadViewerFiles( const viewer = { url: files.url }, style = { url: files.stylesheets[0] }; const patch = { - preferences: [ - ...(existing?.preferences ?? defaults.preferences).filter( - (preference) => preference.name !== "animations", - ), - existing?.preferences?.find( - (preference) => preference.name === "animations", - ) ?? - defaults.preferences.find( - (preference) => preference.name === "animations", - ), - ], + preferences: releasePreferences( + existing?.preferences ?? defaults.preferences, + ), settings: [ ...(existing?.settings ?? []).filter( (setting) => setting.name !== "autoRetrieve", @@ -207,6 +198,10 @@ if (existing) { } else assert.ok(!meta.unlisted); assert.equal(published.engine.package.version, pkg.version); assert.equal(published.viewer.chat, true); +assert.deepEqual( + published.preferences, + releasePreferences(existing?.preferences ?? defaults.preferences), +); await writeFile( ".local/release/published.json", JSON.stringify(published, null, 2), diff --git a/scripts/release-preferences.mjs b/scripts/release-preferences.mjs new file mode 100644 index 0000000..f3b8415 --- /dev/null +++ b/scripts/release-preferences.mjs @@ -0,0 +1,24 @@ +export const mapViewPreference = { + name: "mapView", + label: "2D / 3D", + type: "select", + default: "3d", + items: [ + { name: "2d", label: "2D" }, + { name: "3d", label: "3D" }, + ], +}; + +export function releasePreferences(existing) { + const preferences = existing.filter( + ({ name }) => name !== "animations" && name !== "mapView", + ); + if (!preferences.some(({ name }) => name === "sound")) + preferences.push({ + name: "sound", + label: "Game sounds", + type: "checkbox", + default: true, + }); + return [...preferences, mapViewPreference]; +} diff --git a/test/browser.mjs b/test/browser.mjs index c5e18d8..5bfa2c2 100644 --- a/test/browser.mjs +++ b/test/browser.mjs @@ -42,6 +42,7 @@ const page = await browser.newPage({ locale: "fr-FR", }); page.on("pageerror", (e) => errors.push(e.message)); +await page.addInitScript(() => localStorage.setItem("vanuatu-map-view", "2d")); await page.goto(base + "/?new&hotseat"); await page.waitForSelector("[data-character-choice]"); // Decorative motion must never move a tile's clickable/focusable SVG bounds. @@ -94,6 +95,9 @@ for (const locale of [ "utf8", ), ); + await page.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await page.goto(`${base}/?new&hotseat&locale=${locale}`); await page.waitForFunction( (expected) => @@ -116,6 +120,7 @@ for (const locale of [ ); } } +await page.addInitScript(() => localStorage.setItem("vanuatu-map-view", "2d")); await page.goto(base + "/?new&hotseat"); await page.waitForSelector("[data-character-choice]"); // Action descriptions remain available even before an action can be selected. @@ -763,6 +768,7 @@ await page.locator("[data-scores]").click(); assert.equal(await page.locator(".final-scores>div").count(), 3); await page.locator("[data-close]").click(); // Hosted protocol: replay, names, analysis chat visibility, hover anchors and board thumbnail. +await page.addInitScript(() => localStorage.setItem("vanuatu-map-view", "2d")); await page.goto(base + "/"); await page.evaluate(() => { document.body.innerHTML = '
'; diff --git a/test/effects-browser.mjs b/test/effects-browser.mjs index 0526b28..897c7a6 100644 --- a/test/effects-browser.mjs +++ b/test/effects-browser.mjs @@ -93,6 +93,7 @@ try { } }; }); + await p.addInitScript(() => localStorage.setItem("vanuatu-map-view", "2d")); await p.goto(`http://127.0.0.1:${server.address().port}/`); if (width === 1440) { const samples = await p.evaluate(async () => { @@ -293,13 +294,8 @@ try { 0, "Reduced motion suppresses overlays", ); - await p.emulateMedia({ reducedMotion: "no-preference" }); await p.evaluate(() => - host.emit("preferences", { - locale: "fr", - sound: false, - animations: false, - }), + host.emit("preferences", { locale: "fr", sound: false, mapView: "2d" }), ); await emit(s); const mutedAt = await p.evaluate(() => window.played); @@ -311,11 +307,9 @@ try { "Muted incoming moves are silent", ); await p.locator("[data-help]").first().click(); - assert.equal( - await p.locator('[data-pref="animations"]').isChecked(), - false, - ); - await p.locator('[data-pref="animations"]').check(); + assert.equal(await p.locator('[data-pref="animations"]').count(), 0); + assert.equal(await p.locator("[data-map-preference]").inputValue(), "2d"); + await p.emulateMedia({ reducedMotion: "no-preference" }); await p.locator("dialog [data-close]").click(); await emit(s); await emit(sailed); diff --git a/test/journal-browser.mjs b/test/journal-browser.mjs index c1b4c20..44dac12 100644 --- a/test/journal-browser.mjs +++ b/test/journal-browser.mjs @@ -108,6 +108,9 @@ try { }); const errors = []; page.on("pageerror", (e) => errors.push(e.message)); + await page.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await page.goto(`http://127.0.0.1:${server.address().port}`); await page.evaluate((state) => { window.fixture = state; diff --git a/test/map-drag-browser.mjs b/test/map-drag-browser.mjs index 33287f0..694d2a9 100644 --- a/test/map-drag-browser.mjs +++ b/test/map-drag-browser.mjs @@ -38,6 +38,9 @@ try { }); const errors = []; page.on("pageerror", (e) => errors.push(e.message)); + await page.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await page.goto(base + "/?new&hotseat"); await page.waitForFunction(() => window.vanuatuDemo); const state = E.init(3, [], {}, "mouse-pan"); @@ -156,15 +159,13 @@ try { await page.evaluate((type) => { if (type === "blur") window.dispatchEvent(new Event("blur")); else - document - .querySelector(".map-scroll") - .dispatchEvent( - new PointerEvent(type, { - bubbles: true, - pointerId: window.lastPointer, - pointerType: "mouse", - }), - ); + document.querySelector(".map-scroll").dispatchEvent( + new PointerEvent(type, { + bubbles: true, + pointerId: window.lastPointer, + pointerType: "mouse", + }), + ); }, cancel); await page.mouse.up(); assert.equal(await map.getAttribute("data-pan"), "ready"); diff --git a/test/map-zoom-browser.mjs b/test/map-zoom-browser.mjs index 23f8260..5701c7a 100644 --- a/test/map-zoom-browser.mjs +++ b/test/map-zoom-browser.mjs @@ -98,6 +98,9 @@ try { const page = await browser.newPage({ viewport: { width, height } }); page.on("pageerror", (error) => errors.push(error.message)); for (const state of [E.init(3, [], {}, "map-fit"), partial, expanded]) { + await page.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await page.goto(base + "/?hotseat"); await page.evaluate( (s) => localStorage.setItem("vanuatu-practice-v1", JSON.stringify(s)), @@ -230,6 +233,9 @@ try { viewport: { width: 390, height: 844 }, }); resizedPage.on("pageerror", (error) => errors.push(error.message)); + await resizedPage.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await resizedPage.goto(base + "/?hotseat"); await resizedPage.evaluate( (s) => localStorage.setItem("vanuatu-practice-v1", JSON.stringify(s)), @@ -264,6 +270,9 @@ try { hasTouch: true, }); page.on("pageerror", (error) => errors.push(error.message)); + await page.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await page.goto(base + "/?new&hotseat&locale=fr"); await page.waitForSelector(".map-scroll[data-zoom]"); assert.equal( diff --git a/test/mobile-layout-browser.mjs b/test/mobile-layout-browser.mjs index e4bddf1..6b6dc18 100644 --- a/test/mobile-layout-browser.mjs +++ b/test/mobile-layout-browser.mjs @@ -43,6 +43,9 @@ try { }); page.on("pageerror", (error) => errors.push(error.message)); for (const count of [2, 3, 5]) { + await page.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await page.goto(`${base}/?new&hotseat&players=${count}&locale=fr`); await page.waitForFunction(() => window.vanuatuDemo); await page.evaluate(() => { diff --git a/test/navigation.test.js b/test/navigation.test.js new file mode 100644 index 0000000..217bef0 --- /dev/null +++ b/test/navigation.test.js @@ -0,0 +1,145 @@ +import assert from "node:assert/strict"; +import { + seaRoute, + routePosition, + giveWay, + passingSide, + arrivalFraction, + stepYield, +} from "../viewer/three/navigation.js"; +import * as engine from "../engine/index.js"; +const opening = engine.init(3, [], {}, "navigation"); +const expanded = structuredClone(opening); +for (const cell of ["2,0", "2,1", "2,2", "1,2", "0,2", "-1,1", "-1,0"]) + expanded.board[cell] = engine.tileState("c1"); +const scenes = { opening, expanded }; +const tilt = Math.PI / 9; +function position(id) { + const [q, r] = id.split(",").map(Number), + x = q * 162 - r * 81, + z = r * 140.3; + return { + x: (x * Math.cos(tilt) - z * Math.sin(tilt)) / 60, + z: (x * Math.sin(tilt) + z * Math.cos(tilt)) / 60, + }; +} +let checks = 0; +for (const state of Object.values(scenes)) { + const seas = Object.keys(state.board).filter( + (id) => state.board[id].type === "sea", + ); + for (const from of seas) + for (const to of seas) { + if (from === to) continue; + for (let count = 1; count <= 3; count++) { + const a = position(from), + b = position(to), + start = { x: a.x, z: a.z - 0.15 }, + end = { x: b.x + (count - 1) * 0.47, z: b.z - 0.15 }; + const path = seaRoute(state.board, from, to, start, end, position); + assert.ok( + path.length >= 2, + "Every sea destination has an animation even when crowded", + ); + assert.deepEqual(routePosition(path, 0), start); + assert.deepEqual(routePosition(path, 1), end); + for (let i = 0; i <= 100; i++) { + const p = routePosition(path, i / 100); + assert.ok(Number.isFinite(p.x) && Number.isFinite(p.z)); + } + checks++; + } + } +} +const path = [ + { x: 0, z: 0 }, + { x: 5, z: 0 }, + ], + near = { x: 2.5, z: 0.2 }; +const boat = { minX: -0.28, maxX: 0.46, minZ: -0.52, maxZ: 0.3 }; +const fish = { minX: -0.43, maxX: 0.43, minZ: -0.26, maxZ: 0.26 }; +const side = passingSide(path, near, 0); +const offset = giveWay( + near, + { x: 2.5, z: 0 }, + { x: 1, z: 0 }, + side, + boat, + fish, +); +assert.ok( + near.z + offset.z + fish.minZ > boat.maxZ, + "An intersecting fish moves far enough aside", +); +assert.deepEqual( + giveWay(near, { x: 5, z: 0 }, { x: 1, z: 0 }, side, boat, fish), + { x: 0, z: 0 }, + "It returns after the boat passes", +); +for (const direction of [ + { x: 1, z: 0 }, + { x: 0, z: 1 }, + { x: 1, z: 1 }, + { x: -1, z: 1 }, +]) { + for (const sign of [-1, 1]) { + for (const point of [ + { x: 0, z: -10 }, + { x: 0, z: 10 }, + { x: -10, z: 0 }, + { x: 10, z: 0 }, + { x: 2.7, z: 0 }, + ]) { + assert.deepEqual( + giveWay(point, { x: 0, z: 0 }, direction, sign, boat, fish), + { x: 0, z: 0 }, + "Remote and neighbouring-tile resources stay still, even on the opposite side of the route", + ); + } + } +} +assert.equal( + arrivalFraction(6), + 0, + "No destination rearrangement at departure", +); +assert.equal( + arrivalFraction(1.1), + 0, + "Wait until the boat is actually approaching its berth", +); +assert.ok( + arrivalFraction(0.6) > 0 && arrivalFraction(0.6) < 1, + "Rearrange progressively on approach", +); +assert.equal(arrivalFraction(0), 1, "Berths settle completely on arrival"); +console.log( + `${checks} routes checked; local contact only, remote pieces stay still, destination waits for arrival.`, +); + +const pose = { x: 0, z: 0, yaw: 0, vx: 0, vz: 0, vyaw: 0 }; +let previous = 0; +for (let i = 0; i < 40; i++) { + stepYield(pose, { x: 0.5, z: 0, yaw: 0.2 }, 1 / 60); + assert.ok( + pose.x >= previous && pose.x <= 0.5, + "Yielding approaches its target without reversing or overshooting", + ); + previous = pose.x; +} +assert.ok(pose.yaw > 0.19, "The piece pivots while giving way"); +for (let i = 0; i < 60; i++) { + stepYield(pose, { x: 0, z: 0, yaw: 0 }, 1 / 60); + assert.ok( + pose.x >= 0 && pose.x <= previous, + "Returning home never overshoots or oscillates", + ); + previous = pose.x; +} +assert.ok( + Math.hypot(pose.x, pose.z, pose.yaw) < 0.0001, + "Position and orientation settle completely", +); +console.log( + "Yielding: gradual pivot, damped slide, no oscillation and complete restoration passed.", +); diff --git a/test/persian-browser.mjs b/test/persian-browser.mjs index 2cb087e..ad05c27 100644 --- a/test/persian-browser.mjs +++ b/test/persian-browser.mjs @@ -36,6 +36,9 @@ try { p.setDefaultTimeout(5000); const errors = []; p.on("pageerror", (e) => errors.push(e.message)); + await p.addInitScript(() => + localStorage.setItem("vanuatu-map-view", "2d"), + ); await p.goto(`http://127.0.0.1:${server.address().port}/`); await p.evaluate(async (id) => { window.progress = null; @@ -139,6 +142,7 @@ try { const p = await browser.newPage({ viewport: { width, height: 1000 } }); const errors = []; p.on("pageerror", (error) => errors.push(error.message)); + await p.addInitScript(() => localStorage.setItem("vanuatu-map-view", "2d")); await p.goto(`http://127.0.0.1:${server.address().port}/`); const state = init(3, [], {}, "persian-switch"); state.players[0].name = "Draw"; diff --git a/test/presentation-transitions.test.js b/test/presentation-transitions.test.js new file mode 100644 index 0000000..957eb4a --- /dev/null +++ b/test/presentation-transitions.test.js @@ -0,0 +1,157 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import * as engine from "../engine/index.js"; +import { tradeFrames } from "../viewer/trade-transition.js"; +import { eventCells, journalRows } from "../viewer/journal.js"; +import { goodsSlots } from "../viewer/goods-slots.js"; + +function lastExport() { + const s = engine.init(3, [], {}, "smooth-transitions"); + s.phase = "actions"; + s.actor = s.first = 0; + s.players.forEach((p) => { + p.character = null; + p.markers = Object.fromEntries(engine.ACTIONS.map((a) => [a, 0])); + }); + s.players[0].markers.buy = 1; + s.players[0].money = 3; + s.players[0].boat = "1,0"; + s.board["0,0"].goods = { kava: 0, copra: 0, beef: 1 }; + s.demands[0] = { + id: 101, + goods: ["kava", "copra", "beef"], + filled: [true, true, false], + }; + return s; +} +function exportLast(s) { + return engine.move( + s, + engine + .availableMoves(s) + .find( + (m) => + m.type === "act" && + m.action === "buy" && + m.good === "beef" && + !m.bonus, + ), + 0, + ); +} + +test("last export keeps the completed ship available for presentation after the next round starts", () => { + const before = lastExport(), + unchanged = structuredClone(before), + after = exportLast(before); + assert.equal(after.round, 2); + const events = after.events.slice(before.events.length), + frames = tradeFrames(before, after, events); + assert.deepEqual(frames.departing, [101]); + assert.deepEqual(frames.initial[0].filled, [true, true, false]); + assert.deepEqual(frames.delivered[0].filled, [true, true, true]); + assert.ok(!after.demands.some((d) => d.id === 101)); + assert.deepEqual( + before, + unchanged, + "presentation never mutates the engine state", + ); + assert.equal( + tradeFrames(before, after, []), + null, + "loading or replaying does not animate", + ); +}); +test("a Buyer delivering twice fills distinct slots in order", () => { + const before = { + demands: [{ id: 1, goods: ["kava", "kava"], filled: [false, false] }], + }, + after = structuredClone(before); + const frame = tradeFrames(before, after, [ + { + good: "kava", + details: { shipments: [{ ship: 1 }, { ship: 1, complete: true }] }, + }, + ]); + assert.deepEqual(frame.delivered[0].filled, [true, true]); + assert.deepEqual(frame.completed, [1]); +}); +test("only fully empty islands refill, and each refill is logged with exact goods", () => { + const s = lastExport(); + s.board["2,1"] = engine.tileState("a1"); + s.board["2,1"].goods = { kava: 1, copra: 0, beef: 0 }; + const after = exportLast(s), + round = after.events.findLast((e) => e.type === "round"); + assert.deepEqual(round.refills, [ + { cell: "0,0", goods: engine.TILES.efate.goods }, + ]); + assert.deepEqual(after.board["2,1"].goods, s.board["2,1"].goods); + const rows = journalRows(engine.stripSecret(after, 0)).filter( + (r) => r.event?.type === "restock", + ); + assert.deepEqual( + rows.map((r) => [r.event.cell, r.event.goods]), + [["0,0", engine.TILES.efate.goods]], + ); +}); +test("older complete journals reconstruct refill locations without guessing from current stock", () => { + const s = engine.init(3, [], {}, "legacy-refill"); + s.events = [ + { type: "start", round: 1, p: 0 }, + ...["kava", "copra", "beef"].map((good) => ({ + type: "action", + action: "buy", + cell: "0,0", + p: 0, + round: 1, + good, + })), + { type: "round", round: 2, first: 0 }, + ]; + const before = structuredClone(s); + const rows = journalRows(s).filter((r) => r.event?.type === "restock"); + assert.deepEqual( + rows.map((r) => r.event.cell), + ["0,0"], + ); + assert.deepEqual(rows[0].event.goods, engine.TILES.efate.goods); + assert.deepEqual(s, before); + const incomplete = { ...s, events: s.events.slice(1) }; + assert.equal( + journalRows(incomplete).filter((r) => r.event?.type === "restock").length, + 0, + ); +}); +test("journal highlights the actual route and affected tile, never malformed coordinates", () => { + assert.deepEqual( + eventCells({ path: ["1,0", "2,0"], details: { from: "0,0", cell: "2,0" } }), + ["0,0", "1,0", "2,0"], + ); + assert.deepEqual(eventCells({ type: "restock", cell: "-1,0" }), ["-1,0"]); + assert.deepEqual(eventCells({ cell: "