diff --git a/docs/releases/phase-actions-2.3.21.json b/docs/releases/phase-actions-2.3.21.json new file mode 100644 index 0000000..2faef85 --- /dev/null +++ b/docs/releases/phase-actions-2.3.21.json @@ -0,0 +1,17 @@ +{ + "game": "powergrid", + "gameVersion": 13, + "publishedAt": "2026-11-01T20:48:52.983Z", + "viewer": { + "version": "2.3.21", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-6af8103054352c08f8b0/powergrid-viewer.umd.min.js", + "stylesheets": [ + "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-6af8103054352c08f8b0/powergrid-viewer.css" + ], + "scriptBytes": 1222956, + "sha256": "4a4a1ef686fb9ca48d0054ead0e9776a7c24022a7084ca067850067c3a3e0731", + "bundle": "split-6af8103054352c08f8b0", + "files": 42 + }, + "verified": true +} diff --git a/docs/viewer-publishing.md b/docs/viewer-publishing.md index e5e0010..7e1264c 100644 --- a/docs/viewer-publishing.md +++ b/docs/viewer-publishing.md @@ -33,5 +33,13 @@ then finish; undoing all purchases restores skip. Phase actions and Undo share previews preserve public deck counters so buying resources does not flash an empty draw pile. Existing pass-confirmation dialogs are unchanged. +Viewer 2.3.21 extends skip/finish behaviour to building and powering: skip before +any city is built or plant activated, finish afterwards, and skip again if all +those actions are undone. Skip only receives a blue cue when no legal action is +available. Button pictograms stay black on light hover backgrounds. Clickable +plants use their own border for the white hover cue, retaining the original +4-unit highlighted and 3-unit activated border widths and original blue. + 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. +normal/only-pass states, hover/focus styling against the board-option buttons, +resource/building/powering transitions, and plant borders. diff --git a/viewer/package.json b/viewer/package.json index 6ab6d8b..32171da 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -1,6 +1,6 @@ { "name": "powergrid-viewer", - "version": "2.3.20", + "version": "2.3.21", "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 index eac7754..d4887ef 100644 --- a/viewer/scripts/action-controls-smoke.mjs +++ b/viewer/scripts/action-controls-smoke.mjs @@ -70,6 +70,24 @@ try { 'rgb(255, 255, 255)' ); } + for (const control of ['color-blind', 'plan']) { + const option = page.locator(`[data-board-control="${control}"]`); + if (!(await option.count())) continue; + await option.hover(); + const iconColors = await option + .locator(':scope > g') + .first() + .evaluate((g) => + [...g.querySelectorAll('path, circle, rect')].map((e) => ({ + stroke: getComputedStyle(e).stroke, + fill: getComputedStyle(e).fill, + })) + ); + assert( + iconColors.every((style) => style.stroke === 'rgb(0, 0, 0)' && style.fill === 'none'), + `${control} pictograms stay black and unfilled` + ); + } await page.close(); console.log(`${mode}: hover matches board options; focus and market cues passed`); } @@ -97,6 +115,12 @@ try { 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.hover(); + assert.equal( + await undo.locator('image').evaluate((e) => getComputedStyle(e).filter), + 'none', + 'Undo pictogram stays black' + ); await undo.click(); await page.waitForFunction(() => document.querySelector('[data-board-control="pass"]').classList.contains('skip-action') @@ -115,6 +139,54 @@ try { console.log( 'Resources: skip → finish → undo → skip; matching enabled borders, thin disabled border, stable draw pile' ); + for (const mode of ['building', 'powering']) { + 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(); + assert(await button.evaluate((e) => e.classList.contains('skip-action'))); + assert.equal( + await button.locator('.button-outline').evaluate((e) => getComputedStyle(e).stroke), + 'rgb(0, 0, 0)' + ); + if (mode === 'powering') { + const plant = page.locator('[data-plant-number="3"]'); + const border = plant.locator(':scope > rect').first(); + assert.equal(await border.evaluate((e) => getComputedStyle(e).strokeWidth), '4px'); + assert.equal(await border.evaluate((e) => getComputedStyle(e).stroke), 'rgb(0, 0, 255)'); + await plant.hover(); + assert.equal(await border.evaluate((e) => getComputedStyle(e).stroke), 'rgb(255, 255, 255)'); + } + const echoed = page.waitForResponse((response) => response.url().includes('/move?')); + await page.evaluate((mode) => { + const game = document.querySelector('.game').__vue__; + const name = mode === 'building' ? 'Build' : 'UsePowerPlant'; + game.sendMove({ name, data: game.G.players[0].availableMoves[name][0] }); + }, mode); + await echoed; + await page.waitForFunction( + () => !document.querySelector('[data-board-control="pass"]').classList.contains('skip-action') + ); + assert.equal( + await button.locator('.button-outline').evaluate((e) => getComputedStyle(e).stroke), + 'rgb(0, 0, 255)' + ); + if (mode === 'powering') { + assert.equal( + await page + .locator('[data-plant-number="3"] > rect') + .first() + .evaluate((e) => getComputedStyle(e).strokeWidth), + '3px' + ); + } + await page.locator('[data-board-control="undo"]').click(); + await page.waitForFunction(() => + document.querySelector('[data-board-control="pass"]').classList.contains('skip-action') + ); + await page.close(); + console.log(`${mode}: skip → finish → undo → skip; consistent borders`); + } } 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 c976fba..eb647e9 100644 --- a/viewer/scripts/auction-preview.mjs +++ b/viewer/scripts/auction-preview.mjs @@ -16,8 +16,10 @@ function position(mode) { 'auction-preview' ); G.round = 2; - const yourTurn = mode === 'your-turn' || mode === 'only-pass' || mode === 'resources'; + const yourTurn = ['your-turn', 'only-pass', 'resources', 'building', 'powering'].includes(mode); if (mode === 'resources') G.phase = engine.Phase.Resources; + if (mode === 'building') G.phase = engine.Phase.Building; + if (mode === 'powering') G.phase = engine.Phase.Bureaucracy; G.playerOrder = yourTurn ? [0, 1, 2] : [2, 0, 1]; G.currentPlayers = [yourTurn ? 0 : 2]; const plant = (n) => copy(powerPlants.find((p) => p.number === n)); @@ -28,6 +30,15 @@ function position(mode) { 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; + if (mode === 'building' && i === 0) p.money = 30; + if (mode === 'powering') { + p.powerPlantsNotUsed = p.powerPlants.map((plant) => plant.number); + if (i === 0) { + p.oilCapacity = 4; + p.oilLeft = 2; + p.cities = [{ name: G.map.cities[0].name, position: 0 }]; + } + } p.availableMoves = null; }); const visible = new Set( @@ -45,11 +56,13 @@ function position(mode) { return G; } const states = new Map(); -const html = `
You have 10. With hidden money, try the auto-pass checkbox in your player card before Ada bids.
diff --git a/viewer/tests/unit/choice-revision-ui.spec.ts b/viewer/tests/unit/choice-revision-ui.spec.ts index 2025219..3728b54 100644 --- a/viewer/tests/unit/choice-revision-ui.spec.ts +++ b/viewer/tests/unit/choice-revision-ui.spec.ts @@ -66,7 +66,12 @@ describe('phase button', () => { it('pairs distinct phase icons with skip or finish and complete accessible labels', () => { const paths: string[] = []; for (const phase of [Phase.Auction, Phase.Resources, Phase.Building, Phase.Bureaucracy]) { - const context = { G: { phase }, playerBoughtResourceThisTurn: () => true }; + const context = { + G: { phase }, + playerBoughtResourceThisTurn: () => true, + playerBuiltCityThisTurn: () => true, + playerActivatedPlantThisTurn: () => true, + }; const text = computed('phaseButtonText', context); const icon = computed('phaseButtonIcon', context); const action = computed('phaseButtonAction', context); @@ -128,6 +133,55 @@ describe('phase button', () => { expect(computed('highlightPhaseButton', context)).to.equal(true); }); + it('switches building from skip to finish and back when builds are undone', () => { + const context: any = { player: 0, G: { phase: Phase.Building, log: [] } }; + context.playerBuiltCityThisTurn = () => options.methods.playerBuiltCityThisTurn.call(context); + expect(computed('phaseButtonAction', context)).to.equal('skip'); + context.G.log.push({ type: 'move', player: 0, move: { name: 'Build' } }); + expect(computed('phaseButtonAction', context)).to.equal('finish'); + context.G.log.pop(); + expect(computed('phaseButtonAction', context)).to.equal('skip'); + context.G.log.push({ type: 'move', player: 1, move: { name: 'Build' } }); + expect(computed('phaseButtonAction', context)).to.equal('skip'); + context.G.log = [ + { type: 'move', player: 0, move: { name: 'Build' } }, + { type: 'move', player: 0, move: { name: 'Pass' } }, + ]; + expect(computed('phaseButtonAction', context)).to.equal('skip'); + }); + + it('bases powering skip/finish on this player’s activated plants, including free plants', () => { + const player = { powerPlants: [{ number: 3 }, { number: 13 }], powerPlantsNotUsed: [3, 13] }; + const context: any = { player: 0, G: { phase: Phase.Bureaucracy, players: [player] } }; + context.playerActivatedPlantThisTurn = () => options.methods.playerActivatedPlantThisTurn.call(context); + expect(computed('phaseButtonAction', context)).to.equal('skip'); + player.powerPlantsNotUsed = [3]; + expect(computed('phaseButtonAction', context)).to.equal('finish'); + player.powerPlantsNotUsed = [3, 13]; + expect(computed('phaseButtonAction', context)).to.equal('skip'); + context.canChangePowering = true; + expect(computed('phaseButtonAction', context)).to.equal('edit'); + }); + + it('keeps building/powering skip black while choices exist, blue otherwise', () => { + for (const [phase, move] of [ + [Phase.Building, 'Build'], + [Phase.Bureaucracy, 'UsePowerPlant'], + ]) { + const context: any = { + canUsePhaseButton: true, + phaseButtonAction: 'skip', + player: 0, + G: { phase, players: [{ availableMoves: { [move]: [{}] } }] }, + }; + expect(computed('highlightPhaseButton', context)).to.equal(false); + context.G.players[0].availableMoves[move] = []; + expect(computed('highlightPhaseButton', context)).to.equal(true); + context.phaseButtonAction = 'finish'; + expect(computed('highlightPhaseButton', context)).to.equal(true); + } + }); + it('keeps skip styling while accepting the only-option highlight', async () => { const wrapper = mount(PassButton, { propsData: { text: 'Pass bid', action: 'skip', enabled: true, highlightButton: false },