Release viewer 2.3.19 with phase/action pictograms and simpler preferences

This commit is contained in:
coyotte508 2026-11-01 18:52:11 +01:00
commit fcf31f459e
10 changed files with 195 additions and 44 deletions

View file

@ -0,0 +1,46 @@
{
"game": "powergrid",
"gameVersion": 13,
"publishedAt": "2026-11-01T17:51:55.790Z",
"viewer": {
"version": "2.3.19",
"url": "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-7591ffbc527393825d36/powergrid-viewer.umd.min.js",
"stylesheets": [
"https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-7591ffbc527393825d36/powergrid-viewer.css"
],
"scriptBytes": 1220594,
"sha256": "7ea36483c8ab18d00f6c2403d3bc0a942c63a5bd13bd3dc5364bd1b00d8b7db4",
"bundle": "split-7591ffbc527393825d36",
"files": 42
},
"removedPreferences": ["undoWholeTurn", "fitToScreen"],
"preferences": [
{
"label": "Enable sound when players move",
"type": "checkbox",
"name": "sound",
"items": null,
"default": false
},
{
"name": "showUnselectedRegions",
"label": "Show unselected regions",
"type": "checkbox",
"default": true
},
{
"label": "Adjust player order",
"type": "checkbox",
"name": "adjustPlayerOrder",
"items": null,
"default": false
},
{
"name": "colorBlind",
"label": "Color-blind mode",
"type": "checkbox",
"default": false
}
],
"verified": true
}

View file

@ -16,3 +16,10 @@ preferences with `{ "name": "showUnselectedRegions", "label": "Show unselected r
Preserve the other preferences. BGS only persists declared preference names, so
this metadata change must accompany the viewer release. Old saved `disableHelp`
values are ignored by the viewer; move indicators are always enabled.
Viewer 2.3.19 also removes the `undoWholeTurn` and `fitToScreen` preferences.
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.

View file

@ -1,6 +1,6 @@
{
"name": "powergrid-viewer",
"version": "2.3.18",
"version": "2.3.19",
"repository": {
"type": "git",
"url": "git+https://github.com/boardgamers/powergrid.git",

View file

@ -1,5 +1,5 @@
<template>
<div :class="['game', { fitToScreen: preferences.fitToScreen && !stacked, stacked: stacked }]">
<div :class="['game', { stacked: stacked }]">
<div class="planner-header" :class="{ planning: hasPlanPanel }">
<div class="statusBar">
<span class="status-message" :title="getStatusMessage()">{{ getStatusMessage() }}</span>
@ -473,6 +473,7 @@
:highlightButton="canUsePhaseButton"
:text="phaseButtonText"
:icon="phaseButtonIcon"
:action="phaseButtonAction"
@click="usePhaseButton"
/>
<!-- BGS's "Undo my move" (games against bots) takes this button's
@ -918,14 +919,7 @@ import {
} from '../util/turn-buffer';
import { UIData, Preferences } from '../types/ui-data';
import { Card, House, Coal, Oil, Garbage, Uranium } from './pieces';
import {
Button,
PassButton,
UndoButton,
BoardOption,
SoundButton,
RulesButton,
} from './buttons';
import { Button, PassButton, UndoButton, BoardOption, SoundButton, RulesButton } from './buttons';
import PlayerBoard from './PlayerBoard.vue';
import Calculator from './Calculator.vue';
import PowerPlantMarket from './boards/PowerPlantMarket.vue';
@ -1224,7 +1218,11 @@ export default class Game extends Vue {
private automaticPoweringRound = '';
get buildingPowerCapacity() {
if (this.G?.phase !== Phase.Building || this.player === undefined || !this.G.currentPlayers.includes(this.player))
if (
this.G?.phase !== Phase.Building ||
this.player === undefined ||
!this.G.currentPlayers.includes(this.player)
)
return undefined;
return this.G.players[this.player]?.powerPlants.reduce((total, plant) => total + plant.citiesPowered, 0);
}
@ -1358,21 +1356,36 @@ export default class Game extends Vue {
if (this.canChangePowering) return 'Edit powering';
if (this.tutorialMove || this.roundPlan) return 'Done';
switch (this.G?.phase) {
case Phase.Auction: return this.G?.chosenPowerPlant ? 'Pass bid' : 'Skip auction';
case Phase.Resources: return 'Finish buying';
case Phase.Building: return 'Finish building';
case Phase.Bureaucracy: return 'Finish powering';
default: return 'Done';
case Phase.Auction:
return this.G?.chosenPowerPlant ? 'Pass bid' : 'Skip auction';
case Phase.Resources:
return 'Finish buying';
case Phase.Building:
return 'Finish building';
case Phase.Bureaucracy:
return 'Finish powering';
default:
return 'Done';
}
}
get phaseButtonAction(): string {
if ((this.revisableBid && !this.changingBid) || this.canChangePowering) return 'edit';
if (this.changingBid) return 'skip';
if (this.tutorialMove || this.roundPlan) return 'finish';
return this.G?.phase === Phase.Auction ? 'skip' : 'finish';
}
get phaseButtonIcon(): string {
if (this.revisableBid && !this.changingBid || this.canChangePowering) return 'edit';
switch (this.G?.phase) {
case Phase.Auction: return 'auction';
case Phase.Resources: return 'resources';
case Phase.Building: return 'building';
case Phase.Bureaucracy: return 'powering';
default: return 'done';
case Phase.Auction:
return 'auction';
case Phase.Resources:
return 'resources';
case Phase.Building:
return 'building';
case Phase.Bureaucracy:
return 'powering';
default:
return 'done';
}
}
usePhaseButton() {
@ -1794,13 +1807,8 @@ export default class Game extends Vue {
return;
}
// Honor the preference locally — the engine has no Undo move anymore: pop the
// last move from the turn buffer, or scrap the whole tentative turn.
if (this.preferences.undoWholeTurn) {
this.turnMoves = [];
} else {
this.turnMoves.pop();
}
// Undo one unconfirmed action at a time, regardless of legacy saved preferences.
this.turnMoves.pop();
if (this.turnMoves.length > 0) {
// Preview the shortened turn locally and re-send it so the server echoes
@ -3335,7 +3343,7 @@ ul {
// Once measured, the layout fits the viewport where possible and grows when
// needed to preserve readable cities and cards. A second CSS cap would shrink
// the whole board again, silently undoing those pixel-size floors.
.fitToScreen #scene:not(.laid-out) {
.game:not(.stacked) #scene:not(.laid-out) {
max-height: calc(100vh - 40px);
}

View file

@ -10,10 +10,13 @@
@keydown.enter.prevent="enabled && $emit('click')"
@keydown.space.prevent="enabled && $emit('click')"
>
<rect width="80" height="26" fill="gainsboro" stroke="black" rx="2" />
<rect class="phase-background" width="80" height="26" fill="#e9edef" stroke="black" rx="3" />
<path class="action-background" d="M49 1H77Q79 1 79 3V23Q79 25 77 25H49Z" fill="#d1dce0" />
<path d="M49 3V23" stroke="#adbdc4" aria-hidden="true" />
<path
:d="iconPath"
transform="translate(30, 4)"
data-phase-icon
transform="translate(17, 4.5)"
fill="none"
stroke="black"
stroke-width="1.5"
@ -21,6 +24,17 @@
stroke-linejoin="round"
aria-hidden="true"
/>
<path
:d="actionPath"
data-action-icon
transform="translate(56, 5.5) scale(0.9)"
fill="none"
stroke="black"
stroke-width="1.6"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
/>
<title>{{ text }}</title>
</g>
</template>
@ -33,6 +47,16 @@ export default class PassButton extends Vue {
@Prop() highlightButton!: boolean;
@Prop() text!: string;
@Prop({ default: 'done' }) icon!: string;
@Prop({ default: 'finish' }) action!: string;
get actionPath(): string {
const paths: Record<string, string> = {
skip: 'M16 8A7 7 0 1 1 2 8A7 7 0 1 1 16 8Z M4 3L14 13',
finish: 'M1 9L6 14L16 2',
edit: 'M2 11L12 1L16 5L6 15L1 16Z M10 3L14 7',
};
return paths[this.action] || paths.finish;
}
get iconPath(): string {
const paths: Record<string, string> = {
@ -47,3 +71,19 @@ export default class PassButton extends Vue {
}
}
</script>
<style scoped>
/* The whole control is clickable, but only the action inset reacts. Keep the
phase context unchanged instead of inheriting the board's generic hover. */
.button.enabled:hover .phase-background {
fill: #e9edef;
stroke: black;
}
.button.enabled.highlightButton:hover .phase-background {
stroke: blue;
}
.button.enabled:hover .action-background,
.button.enabled:focus-visible .action-background {
fill: white;
}
</style>

View file

@ -47,8 +47,7 @@ function launch(selector: string) {
colorBlind: false,
showUnselectedRegions: true,
adjustPlayerOrder: false,
undoWholeTurn: true,
fitToScreen: true,
geographicBackground: 'terrain',
}),
avatars: [],

View file

@ -38,8 +38,6 @@ export const mountTutorial: TutorialMount = async (target, { chapter, onProgress
colorBlind: false,
disableHelp: false,
adjustPlayerOrder: false,
undoWholeTurn: true,
fitToScreen: true,
}),
interactionDisabled: false,
tutorialMove: (move) => {

View file

@ -21,8 +21,6 @@ export type Preferences = {
disableHelp?: boolean;
showUnselectedRegions?: boolean;
adjustPlayerOrder: boolean;
undoWholeTurn: boolean;
fitToScreen: boolean;
};
export interface Piece {

View file

@ -63,18 +63,51 @@ describe('pending auction UI', () => {
});
describe('phase button', () => {
it('distinguishes resources, building and powering with icons and accessible labels without visible text', () => {
it('pairs distinct phase icons with skip or finish and complete accessible labels', () => {
const paths: string[] = [];
for (const phase of [Phase.Resources, Phase.Building, Phase.Bureaucracy]) {
for (const phase of [Phase.Auction, Phase.Resources, Phase.Building, Phase.Bureaucracy]) {
const context = { G: { phase } };
const text = computed('phaseButtonText', context);
const icon = computed('phaseButtonIcon', context);
const wrapper = mount(PassButton, { propsData: { text, icon, enabled: true } });
const action = computed('phaseButtonAction', context);
expect(action).to.equal(phase === Phase.Auction ? 'skip' : 'finish');
const wrapper = mount(PassButton, { propsData: { text, icon, action, enabled: true } });
expect(wrapper.attributes('aria-label')).to.equal(text);
expect(wrapper.find('text').exists()).to.equal(false);
paths.push(wrapper.find('path').attributes('d') as string);
expect(wrapper.find('title').text()).to.equal(text);
expect(wrapper.find('[data-action-icon]').attributes('d')).to.equal((wrapper.vm as any).actionPath);
paths.push(wrapper.find('[data-phase-icon]').attributes('d') as string);
wrapper.destroy();
}
expect(new Set(paths).size).to.equal(3);
expect(new Set(paths).size).to.equal(4);
});
it('keeps the phase visible when editing and uses skip when passing a revised bid', () => {
for (const context of [
{ G: { phase: Phase.Auction }, revisableBid: 'bid' },
{ G: { phase: Phase.Bureaucracy }, canChangePowering: true },
]) {
expect(computed('phaseButtonAction', context)).to.equal('edit');
expect(computed('phaseButtonIcon', context)).to.equal(
context.G.phase === Phase.Auction ? 'auction' : 'powering'
);
}
expect(computed('phaseButtonAction', { changingBid: true, revisableBid: 'bid' })).to.equal('skip');
});
it('makes either pictogram part of the same enabled action, including keyboard activation', async () => {
const wrapper = mount(PassButton, {
propsData: { text: 'Pass bid', icon: 'auction', action: 'skip', enabled: true },
});
await wrapper.find('[data-phase-icon]').trigger('click');
await wrapper.find('[data-action-icon]').trigger('click');
await wrapper.trigger('keydown.enter');
await wrapper.trigger('keydown.space');
expect(wrapper.emitted('click')!.length).to.equal(4);
await wrapper.setProps({ enabled: false });
await wrapper.find('[data-action-icon]').trigger('click');
await wrapper.trigger('keydown.enter');
expect(wrapper.emitted('click')!.length).to.equal(4);
wrapper.destroy();
});
});

View file

@ -18,6 +18,28 @@ const move = (player: number, name: MoveName, data: unknown, time: number): LogI
});
const withLog = (log: LogItem[]) => ({ log } as GameState);
describe('local undo', () => {
it('removes one action even with an old whole-turn preference saved', () => {
const sent: any[] = [];
const restored: any[] = [];
const context: any = {
preferences: { undoWholeTurn: true },
turnMoves: [{ name: 'first' }, { name: 'second' }],
committedState: { start: true },
replayTurnBuffer: () => ({ preview: true }),
emitter: { emit: (...args: any[]) => sent.push(args) },
replaceState: (state: any) => restored.push(state),
activateFreePlants: () => undefined,
};
options.methods.undo.call(context);
expect(context.turnMoves).to.deep.equal([{ name: 'first' }]);
expect(sent).to.deep.equal([['move', [{ name: 'first' }]]]);
options.methods.undo.call(context);
expect(context.turnMoves).to.deep.equal([]);
expect(restored[1]).to.equal(context.committedState);
});
});
describe('Undo my move', () => {
const start: LogItem[] = [{ type: 'event', event: 'Game Start!' }];
const mine = move(0, MoveName.ChoosePowerPlant, 3, 1);