diff --git a/docs/releases/action-controls-2.3.20.json b/docs/releases/action-controls-2.3.20.json new file mode 100644 index 0000000..a00218f --- /dev/null +++ b/docs/releases/action-controls-2.3.20.json @@ -0,0 +1,17 @@ +{ + "game": "powergrid", + "gameVersion": 13, + "publishedAt": "2026-11-01T20:28:11.887Z", + "viewer": { + "version": "2.3.20", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-b941db4298f1f241f1f1/powergrid-viewer.umd.min.js", + "stylesheets": [ + "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-b941db4298f1f241f1f1/powergrid-viewer.css" + ], + "scriptBytes": 1222070, + "sha256": "a780e6ed833a202ad26f3697b5e9ca7527d105a1bb439aa20315febc5d5aa7a5", + "bundle": "split-b941db4298f1f241f1f1", + "files": 42 + }, + "verified": true +} diff --git a/docs/viewer-publishing.md b/docs/viewer-publishing.md index dce699d..e5e0010 100644 --- a/docs/viewer-publishing.md +++ b/docs/viewer-publishing.md @@ -22,4 +22,16 @@ Remove those two entries from the BGS game-version preferences, preserving all other entries. Local undo now always removes one unconfirmed action, and board sizing is always automatic; old saved values for these preferences are ignored. The phase control pairs a phase pictogram with a skip, finish or edit pictogram. -Only the action inset highlights on hover/focus; the whole control is clickable. +From viewer 2.3.20, the paired pictograms use one shared grey surface with the +same silver/white-border hover as the color-blind and simulation controls. The +separator darkens on hover to preserve contrast. Passing has a normal black +border unless it is the only legal option, when it gets a blue cue. Unaffordable +plants are muted while choosing; the market outline is hidden when there are no +legal plant choices. The resource action shows skip until a purchase is made, +then finish; undoing all purchases restores skip. Phase actions and Undo share +2-unit borders while enabled and 1-unit borders while disabled. Local tentative +previews preserve public deck counters so buying resources does not flash an empty +draw pile. Existing pass-confirmation dialogs are unchanged. + +After packaging, run `node viewer/scripts/action-controls-smoke.mjs` to check +normal/only-pass states and hover/focus styling against the board-option buttons. diff --git a/viewer/package.json b/viewer/package.json index 4f0d64b..6ab6d8b 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -1,6 +1,6 @@ { "name": "powergrid-viewer", - "version": "2.3.19", + "version": "2.3.20", "repository": { "type": "git", "url": "git+https://github.com/boardgamers/powergrid.git", diff --git a/viewer/scripts/action-controls-smoke.mjs b/viewer/scripts/action-controls-smoke.mjs new file mode 100644 index 0000000..eac7754 --- /dev/null +++ b/viewer/scripts/action-controls-smoke.mjs @@ -0,0 +1,121 @@ +// Run after packaging: node viewer/scripts/action-controls-smoke.mjs +import assert from 'node:assert/strict'; +import { chromium } from 'playwright'; +import { auctionPreviewServer } from './auction-preview.mjs'; + +const server = auctionPreviewServer(); +await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)); +const browser = await chromium.launch({ executablePath: process.env.CHROMIUM_EXECUTABLE }); +try { + for (const mode of ['your-turn', 'only-pass']) { + const page = await browser.newPage(); + await page.goto(`http://127.0.0.1:${server.address().port}/?mode=${mode}`); + const button = page.locator('[data-board-control="pass"]'); + await button.waitFor(); + const appearance = () => + button.evaluate((element) => { + const style = (selector) => { + const css = getComputedStyle(element.querySelector(selector)); + return { fill: css.fill, stroke: css.stroke, width: css.strokeWidth }; + }; + return { + phase: style('.phase-background'), + divider: style('.button-divider'), + phaseIcon: style('[data-phase-icon]'), + actionIcon: style('[data-action-icon]'), + outline: style('.button-outline'), + }; + }); + const reference = page.locator('[data-board-control="color-blind"]'); + const referenceStyle = () => + reference.locator('.option-background').evaluate((e) => { + const css = getComputedStyle(e); + return { fill: css.fill, stroke: css.stroke, width: css.strokeWidth }; + }); + const referenceRest = await referenceStyle(); + await reference.hover(); + const referenceHover = await referenceStyle(); + await page.mouse.move(0, 0); + const before = await appearance(); + assert.equal(before.phase.fill, referenceRest.fill); + assert.equal(before.outline.stroke, mode === 'only-pass' ? 'rgb(0, 0, 255)' : 'rgb(0, 0, 0)'); + assert.equal(await page.locator('[data-market-highlight]').count(), mode === 'only-pass' ? 0 : 1); + const checkHover = async (focused = false) => { + const after = await appearance(); + assert.equal(after.outline.stroke, 'rgb(255, 255, 255)'); + assert.equal(after.outline.fill, 'none'); + assert.equal(after.phase.fill, focused ? referenceRest.fill : referenceHover.fill); + assert.equal(after.outline.width, focused ? '3px' : referenceHover.width); + assert.equal(after.divider.stroke, focused ? before.divider.stroke : 'rgb(89, 102, 108)'); + for (const key of ['phaseIcon', 'actionIcon']) { + assert.deepEqual(after[key], before[key], `${key} stays unchanged`); + } + }; + for (const side of ['[data-phase-icon]', '[data-action-icon]']) { + await button.locator(side).hover(); + await checkHover(); + } + await page.mouse.move(0, 0); + assert.deepEqual(await appearance(), before); + await button.focus(); + await checkHover(true); + if (mode === 'your-turn') { + const plant = page.locator('[data-market-plant="8"]'); + await plant.hover(); + assert.equal( + await plant + .locator(':scope > rect') + .first() + .evaluate((e) => getComputedStyle(e).stroke), + 'rgb(255, 255, 255)' + ); + } + await page.close(); + console.log(`${mode}: hover matches board options; focus and market cues passed`); + } + const page = await browser.newPage(); + await page.goto(`http://127.0.0.1:${server.address().port}/?mode=resources`); + const phaseButton = page.locator('[data-board-control="pass"]'); + await phaseButton.waitFor(); + assert(await phaseButton.evaluate((e) => e.classList.contains('skip-action'))); + await page.evaluate(() => { + const deck = document.querySelector('[data-board-slot="powerPlantDeck"]'); + window.deckSnapshots = [deck.innerHTML]; + window.deckObserver = new MutationObserver(() => window.deckSnapshots.push(deck.innerHTML)); + window.deckObserver.observe(deck, { childList: true, attributes: true, characterData: true, subtree: true }); + }); + const echo = page.waitForResponse((response) => response.url().includes('/move?')); + await page.evaluate(() => { + const game = document.querySelector('.game').__vue__; + game.buyResource(game.G.players[0].availableMoves.BuyResource[0]); + }); + await echo; + await page.waitForFunction( + () => !document.querySelector('[data-board-control="pass"]').classList.contains('skip-action') + ); + const undo = page.locator('[data-board-control="undo"]'); + const width = (locator) => locator.evaluate((e) => getComputedStyle(e).strokeWidth); + assert.equal(await width(phaseButton.locator('.button-outline')), '2px'); + assert.equal(await width(undo.locator('.undo-background')), '2px'); + await undo.click(); + await page.waitForFunction(() => + document.querySelector('[data-board-control="pass"]').classList.contains('skip-action') + ); + assert.equal(await width(phaseButton.locator('.button-outline')), '2px'); + assert.equal(await width(undo.locator('.undo-background')), '1px', 'disabled undo is thinner'); + const snapshots = await page.evaluate(() => { + window.deckObserver.disconnect(); + return window.deckSnapshots; + }); + assert( + snapshots.every((snapshot) => snapshot === snapshots[0]), + 'draw pile stays unchanged during buy/echo/undo' + ); + await page.close(); + console.log( + 'Resources: skip → finish → undo → skip; matching enabled borders, thin disabled border, stable draw pile' + ); +} finally { + await browser.close(); + await new Promise((resolve) => server.close(resolve)); +} diff --git a/viewer/scripts/auction-preview.mjs b/viewer/scripts/auction-preview.mjs index 70c237b..c976fba 100644 --- a/viewer/scripts/auction-preview.mjs +++ b/viewer/scripts/auction-preview.mjs @@ -16,15 +16,18 @@ function position(mode) { 'auction-preview' ); G.round = 2; - G.playerOrder = [2, 0, 1]; - G.currentPlayers = [2]; + const yourTurn = mode === 'your-turn' || mode === 'only-pass' || mode === 'resources'; + if (mode === 'resources') G.phase = engine.Phase.Resources; + G.playerOrder = yourTurn ? [0, 1, 2] : [2, 0, 1]; + G.currentPlayers = [yourTurn ? 0 : 2]; const plant = (n) => copy(powerPlants.find((p) => p.number === n)); G.actualMarket = (fastBid ? [17, 19, 20, 21] : [8, 10, 13, 15]).map(plant); G.futureMarket = [22, 23, 24, 25].map(plant); G.players.forEach((p, i) => { p.name = ['You', 'Leo', 'Ada'][i]; - p.money = [10, 40, 50][i]; + p.money = [mode === 'only-pass' ? 1 : 10, 40, 50][i]; p.powerPlants = [plant([3, 4, 5][i])]; + if (mode === 'resources' && i === 0) p.oilCapacity = 4; p.availableMoves = null; }); const visible = new Set( @@ -32,16 +35,21 @@ function position(mode) { ); G.powerPlantsDeck = G.powerPlantsDeck.filter((p) => !visible.has(p.number)); G.cardsLeft = G.powerPlantsDeck.length; - G.players[2].availableMoves = engine.availableMoves(G, G.players[2]); - G.log.push({ type: 'event', event: 'Waiting for Ada to start an auction.' }); + const activePlayer = G.players[G.currentPlayers[0]]; + activePlayer.availableMoves = engine.availableMoves(G, activePlayer); + G.log.push({ + type: 'event', + event: yourTurn ? 'Your turn to start an auction.' : 'Waiting for Ada to start an auction.', + }); G.newTurn = true; return G; } const states = new Map(); -const html = `Power Grid · Auction auto-pass preview
Local previewMobile preview

You have 10. With hidden money, try the auto-pass checkbox in your player card before Ada bids.

+ + diff --git a/viewer/src/components/buttons/BoardOption.vue b/viewer/src/components/buttons/BoardOption.vue index f4f8e76..c1e68cb 100644 --- a/viewer/src/components/buttons/BoardOption.vue +++ b/viewer/src/components/buttons/BoardOption.vue @@ -11,7 +11,7 @@ @keydown.enter.prevent="$emit('click')" @keydown.space.prevent="$emit('click')" > - +