Release viewer 2.3.21: phase-aware skip controls and consistent icon hover
This commit is contained in:
parent
06bb0aebf6
commit
776aad8d22
10 changed files with 281 additions and 88 deletions
17
docs/releases/phase-actions-2.3.21.json
Normal file
17
docs/releases/phase-actions-2.3.21.json
Normal file
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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 = `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Power Grid · Auction auto-pass preview</title><link rel="stylesheet" href="/bundle.css"><style>body{margin:0;background:#e8ebdf;font-family:system-ui}.preview{display:flex;gap:12px;align-items:center;flex-wrap:wrap;background:#173b32;color:#fff;padding:10px 16px;font-size:13px}.preview button,.preview select{font:inherit;padding:7px}.preview a{color:white}.hint{font-size:13px;padding:8px 16px;margin:0;background:#edf1e8;color:#253b2c}#error{color:#9e1515}#error:empty{display:none}</style></head><body><header class="preview"><strong>Local preview</strong><select id="mode" aria-label="Auction scenario"><option value="your-turn">Your turn · start an auction</option><option value="only-pass">Your turn · only passing is possible</option><option value="resources">Your turn · buy resources</option><option value="public">Public money · open auction</option><option value="hidden">Hidden money · open auction</option><option value="public-sealed">Public money · sealed auction</option><option value="hidden-sealed">Hidden money · sealed auction</option></select><button id="opponent">Ada bids 10</button><button id="reset">Reset</button><a href="/mobile">Mobile preview</a></header><p class="hint">You have 10. With hidden money, try the auto-pass checkbox in your player card before Ada bids.</p><p id="error" role="alert"></p><div id="app"></div><script src="/vue.js"></script><script src="/bundle.js"></script><script>
|
||||
const html = `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Power Grid · Auction auto-pass preview</title><link rel="stylesheet" href="/bundle.css"><style>body{margin:0;background:#e8ebdf;font-family:system-ui}.preview{display:flex;gap:12px;align-items:center;flex-wrap:wrap;background:#173b32;color:#fff;padding:10px 16px;font-size:13px}.preview button,.preview select{font:inherit;padding:7px}.preview a{color:white}.hint{font-size:13px;padding:8px 16px;margin:0;background:#edf1e8;color:#253b2c}#error{color:#9e1515}#error:empty{display:none}</style></head><body><header class="preview"><strong>Local preview</strong><select id="mode" aria-label="Auction scenario"><option value="your-turn">Your turn · start an auction</option><option value="only-pass">Your turn · only passing is possible</option><option value="resources">Your turn · buy resources</option><option value="building">Your turn · build cities</option><option value="powering">Your turn · activate plants</option><option value="public">Public money · open auction</option><option value="hidden">Hidden money · open auction</option><option value="public-sealed">Public money · sealed auction</option><option value="hidden-sealed">Hidden money · sealed auction</option></select><button id="opponent">Ada bids 10</button><button id="reset">Reset</button><a href="/mobile">Mobile preview</a></header><p class="hint">You have 10. With hidden money, try the auto-pass checkbox in your player card before Ada bids.</p><p id="error" role="alert"></p><div id="app"></div><script src="/vue.js"></script><script src="/bundle.js"></script><script>
|
||||
const query=new URLSearchParams(location.search),mode=query.get('mode')||'public';
|
||||
const host=window.host=powergrid.launch('#app');
|
||||
document.querySelector('#mode').value=mode;
|
||||
if(mode==='only-pass')document.querySelector('.hint').textContent='You have 1. No plant is affordable, so passing is the only legal action.';
|
||||
if(mode==='building')document.querySelector('.hint').textContent='Build a city to change skip to confirm. Undo all builds to restore skip.';
|
||||
if(mode==='powering')document.querySelector('.hint').textContent='Activate your oil plant to change skip to confirm. Hover its border to see the white highlight.';
|
||||
document.querySelector('#mode').onchange=e=>location.search='?mode='+e.target.value;
|
||||
async function send(path,body){const response=await fetch(path+'?mode='+mode,{method:body?'POST':'GET',headers:{'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined});const data=await response.json();document.querySelector('#error').textContent=data.error||'';if(data.error)return;host.emit('settings',data.settings);host.emit('state',data.state);const button=document.querySelector('#opponent');button.textContent=data.next;button.disabled=!data.opponent;}
|
||||
host.on('fetchState',()=>send('/state'));host.on('move',move=>send('/move',{move}));host.on('update:setting',setting=>send('/setting',setting));
|
||||
|
|
|
|||
|
|
@ -1357,6 +1357,8 @@ export default class Game extends Vue {
|
|||
if (this.changingBid) return this.revisionBids.length === 0;
|
||||
const moves = this.G?.players[this.player!]?.availableMoves;
|
||||
if (this.G?.phase === Phase.Resources) return !moves?.[MoveName.BuyResource]?.length;
|
||||
if (this.G?.phase === Phase.Building) return !moves?.[MoveName.Build]?.length;
|
||||
if (this.G?.phase === Phase.Bureaucracy) return !moves?.[MoveName.UsePowerPlant]?.length;
|
||||
return !moves?.[MoveName.Bid]?.length && !moves?.[MoveName.ChoosePowerPlant]?.length;
|
||||
}
|
||||
get phaseButtonText(): string {
|
||||
|
|
@ -1381,6 +1383,8 @@ export default class Game extends Vue {
|
|||
if ((this.revisableBid && !this.changingBid) || this.canChangePowering) return 'edit';
|
||||
if (this.changingBid) return 'skip';
|
||||
if (this.G?.phase === Phase.Resources) return this.playerBoughtResourceThisTurn() ? 'finish' : 'skip';
|
||||
if (this.G?.phase === Phase.Building) return this.playerBuiltCityThisTurn() ? 'finish' : 'skip';
|
||||
if (this.G?.phase === Phase.Bureaucracy) return this.playerActivatedPlantThisTurn() ? 'finish' : 'skip';
|
||||
if (this.tutorialMove || this.roundPlan) return 'finish';
|
||||
return this.G?.phase === Phase.Auction ? 'skip' : 'finish';
|
||||
}
|
||||
|
|
@ -2767,6 +2771,25 @@ export default class Game extends Vue {
|
|||
return false;
|
||||
}
|
||||
|
||||
playerActivatedPlantThisTurn(): boolean {
|
||||
const player = this.player === undefined ? undefined : this.G?.players[this.player];
|
||||
// Powering can be simultaneous: use this player's activation state rather
|
||||
// than the log tail, which may include other players' actions.
|
||||
return !!player?.powerPlants.some((plant) => !player.powerPlantsNotUsed.includes(plant.number));
|
||||
}
|
||||
|
||||
// Check this building turn, not the player's total city count from older rounds.
|
||||
playerBuiltCityThisTurn(): boolean {
|
||||
const log = this.G!.log;
|
||||
for (let i = log.length - 1; i >= 0; i--) {
|
||||
const entry = log[i];
|
||||
if (entry.type !== 'move' || entry.player !== this.player) return false;
|
||||
if (entry.move.name === MoveName.Pass) return false;
|
||||
if (entry.move.name === MoveName.Build) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
toggleColorBlind() {
|
||||
this.preferences.colorBlind = !this.preferences.colorBlind;
|
||||
this.emitter.emit('update:preference', { name: 'colorBlind', value: this.preferences.colorBlind });
|
||||
|
|
@ -3497,27 +3520,13 @@ text {
|
|||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
rect {
|
||||
// Only the outer surface reacts. Nested shapes, text and SVG images
|
||||
// are pictograms, not separate button backgrounds.
|
||||
> rect,
|
||||
> circle {
|
||||
fill: silver;
|
||||
stroke: white;
|
||||
}
|
||||
|
||||
circle {
|
||||
fill: silver;
|
||||
stroke: white;
|
||||
}
|
||||
|
||||
line {
|
||||
stroke: white;
|
||||
}
|
||||
|
||||
image {
|
||||
filter: invert(1);
|
||||
}
|
||||
|
||||
text {
|
||||
fill: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,13 @@
|
|||
:powerPlant="powerPlant"
|
||||
:canClick="canUse(powerPlant)"
|
||||
:activationState="activationState(powerPlant)"
|
||||
:highlightColor="
|
||||
canUse(powerPlant)
|
||||
? player.availableMoves && player.availableMoves.DiscardPowerPlant
|
||||
? '#c62828'
|
||||
: 'blue'
|
||||
: undefined
|
||||
"
|
||||
:data-plant-number="powerPlant.number"
|
||||
@click="powerPlantClick(powerPlant)"
|
||||
/>
|
||||
|
|
@ -119,23 +126,6 @@
|
|||
</g>
|
||||
</template>
|
||||
|
||||
<template>
|
||||
<template v-for="(powerPlant, i) in player.powerPlants">
|
||||
<rect
|
||||
v-if="canUse(powerPlant)"
|
||||
:key="i + '_' + i + '_helper'"
|
||||
:x="cardX(i)"
|
||||
:y="30"
|
||||
width="60"
|
||||
height="40"
|
||||
fill="none"
|
||||
:stroke="player.availableMoves && player.availableMoves.DiscardPowerPlant ? '#c62828' : 'blue'"
|
||||
stroke-width="4px"
|
||||
rx="2px"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<g v-if="canClickResources">
|
||||
<rect
|
||||
v-if="canClickResource('coal')"
|
||||
|
|
@ -214,7 +204,7 @@
|
|||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { playerSymbol } from "../player-colors";
|
||||
import { playerSymbol } from '../player-colors';
|
||||
import { colorText } from '../player-colors';
|
||||
import { MoveName, Player } from 'powergrid-engine';
|
||||
import { Phase, playerTimeUsed, PowerPlant, PowerPlantType, ResourceType } from 'powergrid-engine/src/gamestate';
|
||||
|
|
@ -230,8 +220,8 @@ import { Coal, Oil, Garbage, Uranium, Card } from './pieces';
|
|||
Oil,
|
||||
Garbage,
|
||||
Uranium,
|
||||
Card
|
||||
}
|
||||
Card,
|
||||
},
|
||||
})
|
||||
export default class PlayerBoard extends Vue {
|
||||
colorText = colorText;
|
||||
|
|
@ -306,7 +296,8 @@ export default class PlayerBoard extends Vue {
|
|||
name += '• ';
|
||||
}
|
||||
|
||||
if (this.preferences.colorBlind && this.owner !== undefined) name += `${playerSymbol(this.owner, this.preferences)} · `;
|
||||
if (this.preferences.colorBlind && this.owner !== undefined)
|
||||
name += `${playerSymbol(this.owner, this.preferences)} · `;
|
||||
name += this.player.name;
|
||||
|
||||
if (this.ended) {
|
||||
|
|
@ -340,8 +331,13 @@ export default class PlayerBoard extends Vue {
|
|||
activationState(plant: PowerPlant) {
|
||||
if (!this.isPlayer || this.phase !== Phase.Bureaucracy || this.isMine(plant)) return undefined;
|
||||
if (!this.player.powerPlantsNotUsed.includes(plant.number)) return 'used';
|
||||
const fuel = [this.player.coalLeft, this.player.oilLeft, this.player.garbageLeft,
|
||||
this.player.uraniumLeft, this.player.coalLeft + this.player.oilLeft];
|
||||
const fuel = [
|
||||
this.player.coalLeft,
|
||||
this.player.oilLeft,
|
||||
this.player.garbageLeft,
|
||||
this.player.uraniumLeft,
|
||||
this.player.coalLeft + this.player.oilLeft,
|
||||
];
|
||||
fuel[PowerPlantType.GarbageOilHybrid] = this.player.garbageLeft + this.player.oilLeft;
|
||||
if (plant.cost > 0 && fuel[plant.type] < plant.cost) return 'unavailable';
|
||||
return this.canUse(plant) ? 'ready' : 'idle';
|
||||
|
|
@ -351,8 +347,10 @@ export default class PlayerBoard extends Vue {
|
|||
if (!this.isCurrentPlayer) return false;
|
||||
const moves = this.player.availableMoves;
|
||||
if (moves?.DiscardPowerPlant) return moves.DiscardPowerPlant.includes(powerPlant.number);
|
||||
return this.player.resourcesUsed.length === 0 &&
|
||||
!!moves?.UsePowerPlant?.some((move) => move.powerPlant === powerPlant.number);
|
||||
return (
|
||||
this.player.resourcesUsed.length === 0 &&
|
||||
!!moves?.UsePowerPlant?.some((move) => move.powerPlant === powerPlant.number)
|
||||
);
|
||||
}
|
||||
|
||||
// The fuel a hybrid plant can burn besides oil: coal for the standard hybrid,
|
||||
|
|
@ -367,16 +365,10 @@ export default class PlayerBoard extends Vue {
|
|||
const other = this.hybridFuel(powerPlant);
|
||||
if (this.phase == Phase.Bureaucracy && other) {
|
||||
const otherLeft = other == ResourceType.Coal ? this.player.coalLeft : this.player.garbageLeft;
|
||||
if (
|
||||
otherLeft == 0 ||
|
||||
this.player.oilLeft == 0 ||
|
||||
otherLeft + this.player.oilLeft == powerPlant.cost
|
||||
) {
|
||||
if (otherLeft == 0 || this.player.oilLeft == 0 || otherLeft + this.player.oilLeft == powerPlant.cost) {
|
||||
this.player.resourcesUsed = Array(Math.min(powerPlant.cost, otherLeft))
|
||||
.fill(other)
|
||||
.concat(
|
||||
Array(powerPlant.cost - Math.min(powerPlant.cost, otherLeft)).fill(ResourceType.Oil)
|
||||
);
|
||||
.concat(Array(powerPlant.cost - Math.min(powerPlant.cost, otherLeft)).fill(ResourceType.Oil));
|
||||
this.$emit('powerPlantClick', powerPlant);
|
||||
} else {
|
||||
this.powerPlantClicked = powerPlant;
|
||||
|
|
@ -390,7 +382,7 @@ export default class PlayerBoard extends Vue {
|
|||
get canClickResources() {
|
||||
return (
|
||||
(this.player.availableMoves && this.player.availableMoves['DiscardResources']) ||
|
||||
this.player.resourcesUsed.some(r => r == null)
|
||||
this.player.resourcesUsed.some((r) => r == null)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -403,7 +395,7 @@ export default class PlayerBoard extends Vue {
|
|||
if (resourceType == ResourceType.Garbage && !this.player.garbageOilHybridCapacity) return false;
|
||||
return discards.includes(resourceType);
|
||||
}
|
||||
if (!this.player.resourcesUsed.some(r => r == null)) return false;
|
||||
if (!this.player.resourcesUsed.some((r) => r == null)) return false;
|
||||
// Without the clicked plant (not expected), fall back to the coal/oil hybrid.
|
||||
const other = this.powerPlantClicked ? this.hybridFuel(this.powerPlantClicked) : ResourceType.Coal;
|
||||
return resourceType == ResourceType.Oil || resourceType == other;
|
||||
|
|
@ -412,8 +404,8 @@ export default class PlayerBoard extends Vue {
|
|||
clickResource(resourceType) {
|
||||
if (this.player.availableMoves && this.player.availableMoves['DiscardResources']) {
|
||||
this.$emit('discardResource', resourceType);
|
||||
} else if (this.player.resourcesUsed.some(r => r == null)) {
|
||||
const index = this.player.resourcesUsed.findIndex(r => r == null)!;
|
||||
} else if (this.player.resourcesUsed.some((r) => r == null)) {
|
||||
const index = this.player.resourcesUsed.findIndex((r) => r == null)!;
|
||||
this.player.resourcesUsed[index] = resourceType;
|
||||
|
||||
if (resourceType == 'coal') {
|
||||
|
|
@ -424,7 +416,7 @@ export default class PlayerBoard extends Vue {
|
|||
this.player.garbageLeft--;
|
||||
}
|
||||
|
||||
if (!this.player.resourcesUsed.some(r => r == null)) {
|
||||
if (!this.player.resourcesUsed.some((r) => r == null)) {
|
||||
this.$emit('powerPlantClick', this.powerPlantClicked);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ export default class BoardOption extends Vue {
|
|||
</script>
|
||||
<style scoped>
|
||||
.board-option {
|
||||
color: #253221;
|
||||
color: black;
|
||||
}
|
||||
.board-option:hover {
|
||||
color: black;
|
||||
}
|
||||
.option-background {
|
||||
fill: gainsboro;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<g
|
||||
v-else
|
||||
:id="elId"
|
||||
:class="[{ canClick: canClick }, activationState && 'plant-' + activationState]"
|
||||
:class="['power-plant-card', { canClick: canClick }, activationState && 'plant-' + activationState]"
|
||||
:data-activation="activationState"
|
||||
:transform="`translate(${currentX}, ${currentY})`"
|
||||
@click="canClick && $emit('click')"
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
width="60"
|
||||
height="40"
|
||||
:fill="getColor()"
|
||||
:stroke="hasDiscount ? 'palegreen' : 'black'"
|
||||
stroke-width="2"
|
||||
:stroke="highlightColor || (hasDiscount ? 'palegreen' : 'black')"
|
||||
:stroke-width="highlightColor ? 4 : 2"
|
||||
rx="4"
|
||||
/>
|
||||
<g v-if="hasDiscount">
|
||||
|
|
@ -99,7 +99,7 @@ import Piece from './Piece.vue';
|
|||
@Component({
|
||||
created(this: Card) {
|
||||
this.pieceType = PieceType.Card;
|
||||
}
|
||||
},
|
||||
})
|
||||
export default class Card extends Mixins(Piece) {
|
||||
@Prop()
|
||||
|
|
@ -111,6 +111,9 @@ export default class Card extends Mixins(Piece) {
|
|||
@Prop()
|
||||
canClick?: boolean;
|
||||
|
||||
@Prop()
|
||||
highlightColor?: string;
|
||||
|
||||
@Prop({ default: false })
|
||||
hasDiscount?: boolean;
|
||||
|
||||
|
|
@ -118,36 +121,58 @@ export default class Card extends Mixins(Piece) {
|
|||
activationState?: 'used' | 'unavailable' | 'ready' | 'idle';
|
||||
|
||||
get activationLabel() {
|
||||
return this.activationState === 'used' ? 'Activated' :
|
||||
this.activationState === 'unavailable' ? 'Not enough fuel' :
|
||||
this.activationState === 'ready' ? 'Ready to activate' : 'Not activated';
|
||||
return this.activationState === 'used'
|
||||
? 'Activated'
|
||||
: this.activationState === 'unavailable'
|
||||
? 'Not enough fuel'
|
||||
: this.activationState === 'ready'
|
||||
? 'Ready to activate'
|
||||
: 'Not activated';
|
||||
}
|
||||
|
||||
getColor() {
|
||||
switch (this.powerPlant?.type) {
|
||||
case PowerPlantType.Coal: return '#8b4513';
|
||||
case PowerPlantType.Oil: return '#445';
|
||||
case PowerPlantType.Garbage: return 'goldenrod';
|
||||
case PowerPlantType.Uranium: return 'red';
|
||||
case PowerPlantType.Hybrid: return 'url(#hybrid)';
|
||||
case PowerPlantType.Wind: return 'limegreen';
|
||||
case PowerPlantType.Nuclear: return 'dodgerblue';
|
||||
case PowerPlantType.Step3: return 'dodgerblue';
|
||||
case PowerPlantType.GarbageOilHybrid: return 'url(#garbageOilHybrid)';
|
||||
case PowerPlantType.Coal:
|
||||
return '#8b4513';
|
||||
case PowerPlantType.Oil:
|
||||
return '#445';
|
||||
case PowerPlantType.Garbage:
|
||||
return 'goldenrod';
|
||||
case PowerPlantType.Uranium:
|
||||
return 'red';
|
||||
case PowerPlantType.Hybrid:
|
||||
return 'url(#hybrid)';
|
||||
case PowerPlantType.Wind:
|
||||
return 'limegreen';
|
||||
case PowerPlantType.Nuclear:
|
||||
return 'dodgerblue';
|
||||
case PowerPlantType.Step3:
|
||||
return 'dodgerblue';
|
||||
case PowerPlantType.GarbageOilHybrid:
|
||||
return 'url(#garbageOilHybrid)';
|
||||
}
|
||||
}
|
||||
|
||||
getResourcePath() {
|
||||
switch (this.powerPlant?.type) {
|
||||
case PowerPlantType.Coal: return 'M0,3 L7.5,0 L15,3 L15,12 L7.5,15 L0,12Z';
|
||||
case PowerPlantType.Oil: return 'M3,2 A6,3 0 0,1 12,2 L12,12 A6,3 0 0,1 3,12Z';
|
||||
case PowerPlantType.Garbage: return 'M0,3 A7.5,3 0 0,1 15,3 L15,12 A7.5,3 0 0,1 0,12Z';
|
||||
case PowerPlantType.Uranium: return 'M1,2 l4,-2 l6,0 l4,2 l0,11 l-4,2 l-6,0 l-4,-2Z';
|
||||
case PowerPlantType.Hybrid: return 'M0,3 L7.5,0 L15,3 L15,12 L7.5,15 L0,12Z M9,1 A6,3 0 0,1 18,1 L18,10 A6,3 0 0,1 10,10Z';
|
||||
case PowerPlantType.Wind: return '';
|
||||
case PowerPlantType.Nuclear: return '';
|
||||
case PowerPlantType.Step3: return '';
|
||||
case PowerPlantType.GarbageOilHybrid: return 'M0,3 A7.5,3 0 0,1 15,3 L15,12 A7.5,3 0 0,1 0,12Z M9,1 A6,3 0 0,1 18,1 L18,10 A6,3 0 0,1 10,10Z';
|
||||
case PowerPlantType.Coal:
|
||||
return 'M0,3 L7.5,0 L15,3 L15,12 L7.5,15 L0,12Z';
|
||||
case PowerPlantType.Oil:
|
||||
return 'M3,2 A6,3 0 0,1 12,2 L12,12 A6,3 0 0,1 3,12Z';
|
||||
case PowerPlantType.Garbage:
|
||||
return 'M0,3 A7.5,3 0 0,1 15,3 L15,12 A7.5,3 0 0,1 0,12Z';
|
||||
case PowerPlantType.Uranium:
|
||||
return 'M1,2 l4,-2 l6,0 l4,2 l0,11 l-4,2 l-6,0 l-4,-2Z';
|
||||
case PowerPlantType.Hybrid:
|
||||
return 'M0,3 L7.5,0 L15,3 L15,12 L7.5,15 L0,12Z M9,1 A6,3 0 0,1 18,1 L18,10 A6,3 0 0,1 10,10Z';
|
||||
case PowerPlantType.Wind:
|
||||
return '';
|
||||
case PowerPlantType.Nuclear:
|
||||
return '';
|
||||
case PowerPlantType.Step3:
|
||||
return '';
|
||||
case PowerPlantType.GarbageOilHybrid:
|
||||
return 'M0,3 A7.5,3 0 0,1 15,3 L15,12 A7.5,3 0 0,1 0,12Z M9,1 A6,3 0 0,1 18,1 L18,10 A6,3 0 0,1 10,10Z';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +185,7 @@ export default class Card extends Mixins(Piece) {
|
|||
.canClick {
|
||||
cursor: pointer;
|
||||
}
|
||||
[data-market-plant].canClick:hover > rect:first-of-type {
|
||||
.power-plant-card.canClick:hover > rect:first-of-type {
|
||||
stroke: white;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue