feat: allow revising sealed bids and powered plants

This commit is contained in:
coyotte508 2026-10-05 01:36:01 +02:00
commit 9dbb0df766
28 changed files with 439 additions and 44 deletions

View file

@ -1,4 +1,5 @@
export { availableMoves, AvailableMoves } from './src/available-moves';
export * from './src/choice-revisions';
export {
currentPlayers,
ended,

View file

@ -1,6 +1,6 @@
{
"name": "powergrid-engine",
"version": "2.0.11",
"version": "2.0.12",
"description": "An engine for Power Grid",
"main": "dist/index.js",
"types": "index.ts",

View file

@ -15,6 +15,7 @@ import prices from './prices';
import { minBy } from './utils';
export interface AvailableMoves {
[MoveName.ReopenPowering]?: number[];
[MoveName.ChoosePowerPlant]?: number[];
[MoveName.Bid]?: number[];
[MoveName.DiscardPowerPlant]?: number[];

View file

@ -0,0 +1,84 @@
import type { GameState, Player } from './gamestate';
import { Phase } from './gamestate';
import { Move, MoveName } from './move';
export type PoweringChoice = Pick<
Player,
| 'money'
| 'coalLeft'
| 'oilLeft'
| 'garbageLeft'
| 'uraniumLeft'
| 'powerPlantsNotUsed'
| 'citiesPowered'
| 'targetCitiesPowered'
| 'totalIncome'
> & { round: number };
export function rememberPowering(G: GameState, seat: number): void {
if (G.phase !== Phase.Bureaucracy || G.poweringChoices?.[seat]?.round === G.round) return;
const p = G.players[seat];
(G.poweringChoices ??= {})[seat] = {
round: G.round,
money: p.money,
coalLeft: p.coalLeft,
oilLeft: p.oilLeft,
garbageLeft: p.garbageLeft,
uraniumLeft: p.uraniumLeft,
powerPlantsNotUsed: [...p.powerPlantsNotUsed],
citiesPowered: p.citiesPowered,
targetCitiesPowered: p.targetCitiesPowered,
totalIncome: p.totalIncome,
};
}
export function canReopenPowering(G: GameState, seat: number): boolean {
return (
G.phase === Phase.Bureaucracy &&
!!G.players[seat]?.passed &&
!G.players[seat].isDropped &&
G.currentPlayers.length > 0 &&
!G.currentPlayers.includes(seat) &&
G.poweringChoices?.[seat]?.round === G.round
);
}
export function restorePowering(G: GameState, seat: number): void {
const p = G.players[seat];
const { round, ...choice } = G.poweringChoices![seat];
if (G.coalStorage !== undefined) G.coalStorage -= choice.coalLeft - p.coalLeft;
else G.coalSupply -= choice.coalLeft - p.coalLeft;
G.oilSupply -= choice.oilLeft - p.oilLeft;
G.garbageSupply -= choice.garbageLeft - p.garbageLeft;
G.uraniumSupply -= choice.uraniumLeft - p.uraniumLeft;
Object.assign(p, choice, { powerPlantsNotUsed: [...choice.powerPlantsNotUsed], passed: false });
(G.revisedPowering ??= {})[seat] = round;
G.currentPlayers = G.playerOrder.filter((id) => !G.players[id].passed && !G.players[id].isDropped);
}
export function bidRevision(G: GameState, seat: number): string | undefined {
const p = G.players[seat];
if (
!p ||
p.isDropped ||
p.skipAuction ||
!G.options.fastBid ||
G.phase !== Phase.Auction ||
!G.chosenPowerPlant ||
!G.currentPlayers.length ||
G.currentPlayers.includes(seat)
)
return undefined;
return `${G.round}:${G.log.length}:${G.chosenPowerPlant.number}`;
}
export function canReviseChoice(G: GameState, payload: unknown, seat: number): boolean {
const moves = Array.isArray(payload) ? payload : [payload];
if (moves.length !== 1 || !moves[0]) return false;
const m = moves[0] as Move;
if (m.name === MoveName.ReopenPowering) return canReopenPowering(G, seat) && m.data === G.round;
const key = bidRevision(G, seat);
return (
!!key &&
m.revision === key &&
(m.name === MoveName.Bid || (m.name === MoveName.Pass && seat !== G.auctioningPlayer))
);
}
export function alreadyCreditedPowering(G: GameState, seat: number, phase: Phase, round: number): boolean {
return phase === Phase.Bureaucracy && G.revisedPowering?.[seat] === round;
}

View file

@ -2,6 +2,7 @@ import assert from 'assert';
import { cloneDeep, isEqual, range } from 'lodash';
import seedrandom from 'seedrandom';
import { availableMoves, coalOilOverCapacity, computeRegionGraph, regionPickable } from './available-moves';
import { canReviseChoice, rememberPowering, restorePowering } from './choice-revisions';
import {
countHeldPowerPlants,
GameOptions,
@ -582,6 +583,8 @@ export function stripSecret(G: GameState, player?: number): GameState {
return {
...G,
seed: 'secret',
poweringChoices:
player !== undefined && G.poweringChoices?.[player] ? { [player]: G.poweringChoices[player] } : {},
pendingMessages: undefined,
automation: {
version: 1,
@ -618,17 +621,49 @@ export function move(
{ updateBuildingMarket = true }: { updateBuildingMarket?: boolean } = {}
): GameState {
const player = G.players[playerNumber];
const available = player.availableMoves?.[move.name];
const revision = move.revision !== undefined || move.name === MoveName.ReopenPowering;
if (revision) assert(canReviseChoice(G, move, playerNumber), 'This choice can no longer be changed.');
if (move.name === MoveName.ReopenPowering) {
restorePowering(G, playerNumber);
player.lastMove = move;
G.log.push({
type: 'move',
player: playerNumber,
move,
simple: `${player.name} changes their powered plants.`,
pretty: `${playerNameHTML(player)} changes their powered plants.`,
});
updateClocks(G, move.serverTime ?? move.time);
G.currentPlayers.forEach((p) => (G.players[p].availableMoves = availableMoves(G, G.players[p])));
G.newTurn = true;
return G;
}
const available = revision ? availableMoves(G, player)[move.name] : player.availableMoves?.[move.name];
updateGameState(G);
assert(G.currentPlayers.includes(playerNumber), 'It is not your turn!');
assert(revision || G.currentPlayers.includes(playerNumber), 'It is not your turn!');
assert(available, 'You are not allowed to run the command ' + move.name);
assert(
available.some((x) => isEqual(x, move.data)),
'Wrong argument for the command ' + move.name
);
rememberPowering(G, playerNumber);
const { revision: ignoredRevision, ...recordedMove } = move;
const replaceHiddenBid = () => {
if (!revision) return;
const index = G.hiddenLog.findIndex((entry) => entry.type === 'move' && entry.player === playerNumber);
if (index >= 0 && index < G.hiddenLog.length - 1) {
const previous = G.hiddenLog[index];
const replacement = G.hiddenLog.pop()!;
if (previous.type === 'move' && replacement.type === 'move') {
replacement.move.time = previous.move.time;
replacement.move.serverTime = previous.move.serverTime;
}
G.hiddenLog[index] = replacement;
}
};
switch (move.name) {
case MoveName.ChoosePowerPlant: {
asserts<Moves.MoveChoosePowerPlant>(move);
@ -716,11 +751,12 @@ export function move(
G.hiddenLog.push({
type: 'move',
player: playerNumber,
move,
move: recordedMove,
simple: `${player.name} bids $${move.data}.`,
pretty: `${playerNameHTML(player)} bids <span style="color: green">$${move.data}</span>.`,
});
replaceHiddenBid();
fastAuction(G, player, move.data);
} else {
G.currentBid = player.bid = move.data;
@ -861,11 +897,12 @@ export function move(
G.hiddenLog.push({
type: 'move',
player: playerNumber,
move,
move: recordedMove,
simple: `${player.name} passes.`,
pretty: `${playerNameHTML(player)} passes.`,
});
replaceHiddenBid();
fastAuction(G, player, 0);
} else {
player.passed = true;
@ -1754,7 +1791,13 @@ export function move(
player.availableMoves = null;
player.lastMove = move;
player.lastMove = revision
? (
G.hiddenLog.find(
(entry) => entry.type === 'move' && entry.player === playerNumber
) as import('./log').LogMove
)?.move ?? move
: move;
G.cardsLeft = G.powerPlantsDeck.length;
G.nextCardWeak = G.options.variant == 'recharged' && G.cardsLeft > 0 && G.powerPlantsDeck[0].number <= 15;

View file

@ -142,6 +142,8 @@ export enum Phase {
}
export interface GameState {
poweringChoices?: Record<number, import('./choice-revisions').PoweringChoice>;
revisedPowering?: Record<number, number>;
pendingMessages?: string[];
automation?: AutomationState;
map: GameMap;

View file

@ -88,11 +88,13 @@ export declare namespace Moves {
// would otherwise charge that skew to itself on every turn — inflating its timer toward
// the whole game's elapsed time. A single server clock removes the skew.
export interface MoveMeta {
revision?: string;
time?: number;
serverTime?: number;
}
export type Move = (
| { name: MoveName.ReopenPowering; data: number }
| Moves.MoveChoosePowerPlant
| Moves.MoveBid
| Moves.MoveDiscardPowerPlant
@ -117,4 +119,5 @@ export enum MoveName {
ChooseRegion = 'ChooseRegion',
ChooseColor = 'ChooseColor',
Pass = 'Pass',
ReopenPowering = 'ReopenPowering',
}

View file

@ -1,6 +1,7 @@
import assert from 'assert';
import { isEqual } from 'lodash';
import { availableMoves } from './available-moves';
import { alreadyCreditedPowering } from './choice-revisions';
import { move as play } from './engine';
import { GameState, Phase } from './gamestate';
import { Move, MoveName, Moves } from './move';
@ -183,7 +184,7 @@ export function runPremoves(initial: GameState, serverTime?: number): GameState
phase.phase === Phase.Building
? 'Your queued cities were built.'
: 'Your queued plants powered cities.';
automation(probe).increments[seat] += increments;
if (!alreadyCreditedPowering(G, seat, G.phase, G.round)) automation(probe).increments[seat] += increments;
automation(probe).liveUpdate = false;
G = probe;
} catch (error) {

View file

@ -2,6 +2,7 @@ import { expect } from 'chai';
import { cloneDeep } from 'lodash';
import 'mocha';
import * as wrapper from '../wrapper';
import { bidRevision, canReopenPowering } from './choice-revisions';
import { setup } from './engine';
import { GameState, Phase, PowerPlantType, ResourceType } from './gamestate';
import { Move, MoveName } from './move';
@ -382,6 +383,70 @@ describe('wrapper (tentative turns)', () => {
expect(platform.saved.players[B].powerPlants, 'the higher bidder wins').to.have.length(1);
});
it('replaces hidden fast bids without extra time, including changing a pass into a bid', async () => {
const platform = new Platform(3, 'revisable-bid', { fastBid: true });
const A = platform.saved.currentPlayers[0];
const choose = cheapestChoosable(platform, A);
await platform.send([choose, openingBid(choose)], A);
const keyA = bidRevision(platform.saved, A)!;
const increments = [...wrapper.timeIncrements(platform.saved)];
const changed: Move = { name: MoveName.Bid, data: Number(choose.data) + 5, revision: keyA };
expect(wrapper.canMoveOutOfTurn(platform.saved, changed, A)).to.equal(true);
expect(wrapper.canMoveOutOfTurn(platform.saved, { ...pass, revision: keyA }, A)).to.equal(false);
now += 10000;
await platform.send(changed, A);
expect(wrapper.isLiveUpdate(platform.saved)).to.equal(true);
expect(wrapper.timeIncrements(platform.saved)).to.deep.equal(increments);
expect(platform.saved.players[A].clockStartedAt).to.equal(undefined);
expect(platform.saved.hiddenLog).to.have.length(1);
const B = platform.saved.currentPlayers[0];
await platform.send(pass, B);
const keyB = bidRevision(platform.saved, B)!;
await platform.send({ name: MoveName.Bid, data: Number(choose.data) + 6, revision: keyB }, B);
expect(platform.saved.currentPlayers).to.have.length(1);
expect(wrapper.replay(platform.saved).players[B].bid).to.equal(Number(choose.data) + 6);
expect(wrapper.replay(platform.saved).players.map((p) => p.totalTimeUsed)).to.deep.equal(
platform.saved.players.map((p) => p.totalTimeUsed)
);
const C = platform.saved.currentPlayers[0];
await platform.send(pass, C);
expect(platform.saved.players[B].powerPlants).to.have.length(1);
expect(wrapper.canMoveOutOfTurn(platform.saved, changed, A)).to.equal(false);
});
it('reopens only the requester’s powering and never grants a second increment on confirmation', async () => {
const platform = new Platform(2, 'revisable-power');
const { A, B } = await playToBureaucracy(platform);
const before = cloneDeep(platform.saved);
const use: Move = { name: MoveName.UsePowerPlant, data: platform.available(A)[MoveName.UsePowerPlant]![0] };
await platform.send([use, pass], A);
const increments = [...wrapper.timeIncrements(platform.saved)];
const reopen: Move = { name: MoveName.ReopenPowering, data: platform.saved.round };
expect(canReopenPowering(platform.saved, A)).to.equal(true);
expect(wrapper.canMoveOutOfTurn(platform.saved, reopen, B)).to.equal(false);
now += 10000;
await platform.send(reopen, A);
expect(wrapper.isLiveUpdate(platform.saved)).to.equal(true);
expect(wrapper.timeIncrements(platform.saved)).to.deep.equal(increments);
expect(platform.saved.currentPlayers).to.have.members([A, B]);
expect(platform.saved.players[A].money).to.equal(before.players[A].money);
for (const field of ['coalLeft', 'oilLeft', 'garbageLeft', 'uraniumLeft', 'powerPlantsNotUsed'])
expect(platform.saved.players[A][field]).to.deep.equal(before.players[A][field]);
expect(platform.saved.players[B]).to.deep.equal(before.players[B]);
expect(wrapper.stripSecret(platform.saved, B).poweringChoices?.[A]).to.equal(undefined);
expect(wrapper.replay(platform.saved).players[A].money).to.equal(before.players[A].money);
await platform.send(pass, A);
expect(wrapper.timeIncrements(platform.saved)).to.deep.equal(increments);
await platform.send(reopen, A);
await platform.send([use, pass], A);
expect(wrapper.timeIncrements(platform.saved)).to.deep.equal(increments);
await platform.send(pass, B);
expect(canReopenPowering(platform.saved, A)).to.equal(false);
expect(wrapper.canMoveOutOfTurn(platform.saved, reopen, A)).to.equal(false);
expect(wrapper.timeIncrements(platform.saved)[B]).to.equal(increments[B] + 1);
expect(wrapper.replay(platform.saved).players[A].money).to.equal(platform.saved.players[A].money);
});
it('should drive the per-player clocks from the server clock, immune to client skew', async () => {
// The absurd client `time`s below stand in for skewed browser clocks — banking a
// stretch subtracts one player's stamp from another's, so before turns were

View file

@ -1,4 +1,5 @@
import type { GameState } from './index';
import { alreadyCreditedPowering, canReviseChoice } from './src/choice-revisions';
import * as engine from './src/engine';
import { playersSortedByScore } from './src/engine';
import { GameOptions } from './src/gamestate';
@ -57,6 +58,8 @@ export async function move(
return runPremoves(G, Date.now());
}
const initialPhase = G.phase;
const initialRound = G.round;
const revision = canReviseChoice(G, move, player);
const moves: Move[] = move == null ? [] : Array.isArray(move) ? move : [move];
if (moves.length === 0) {
@ -94,15 +97,16 @@ export async function move(
}
if (G.newTurn !== false) {
automation(G).increments[player]++;
if (revision) automation(G).liveUpdate = true;
else if (!alreadyCreditedPowering(G, player, initialPhase, initialRound)) automation(G).increments[player]++;
reconcileManualPlan(G, player, initialPhase);
G = runPremoves(G, now);
if (!revision) G = runPremoves(G, now);
}
return G;
}
export function canMoveOutOfTurn(G: GameState, move: unknown, player: number): boolean {
return isPremoveCommand(move) && canManagePremoves(G, player);
return canReviseChoice(G, move, player) || (isPremoveCommand(move) && canManagePremoves(G, player));
}
export function isLiveUpdate(G: GameState): boolean {
return G.automation?.liveUpdate === true;
@ -130,11 +134,13 @@ export { ended, scores, stripSecret } from './src/engine';
*/
export function moveAI(G: GameState, player: number): GameState {
automation(G).liveUpdate = false;
const initialPhase = G.phase;
const initialRound = G.round;
for (let i = 0; i < 500 && !engine.ended(G) && G.currentPlayers.includes(player); i++) {
G = engine.moveAI(G, player);
if (G.newTurn !== false) {
automation(G).increments[player]++;
if (!alreadyCreditedPowering(G, player, initialPhase, initialRound)) automation(G).increments[player]++;
return runPremoves(G, Date.now());
}
}

View file

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

View file

@ -4,6 +4,29 @@
<div class="statusBar">
<span class="status-message">{{ getStatusMessage() }}</span>
</div>
<div v-if="revisableBid || canChangePowering" class="choice-revision">
<template v-if="revisableBid">
<form v-if="editingBid === revisableBid" @submit.prevent="replaceBid(false)">
<label
>Your bid
<input
v-model.number="replacementBid"
type="number"
:min="revisionBids[0]"
:max="revisionBids[revisionBids.length - 1]"
step="1"
required
/></label>
<button type="submit" :disabled="!revisionBids.includes(replacementBid)">Save bid</button>
<button v-if="player !== G.auctioningPlayer" type="button" @click="replaceBid(true)">
Pass
</button>
<button type="button" @click="editingBid = null">Cancel</button>
</form>
<button v-else type="button" @click="editBid">Change bid</button>
</template>
<button v-if="canChangePowering" type="button" @click="reopenPowering">Change powered plants</button>
</div>
<RoundPlanner
v-if="!tutorialMove && !paused && hasPlanPanel"
:plan="roundPlan"
@ -921,11 +944,20 @@ import { completedPhases } from '../util/round-plan';
import Resources from './boards/Resources.vue';
import ResupplyBadge from './boards/ResupplyBadge.vue';
import { LogMove } from 'powergrid-engine/src/log';
import { isUraniumMine, Phase, playerTimeUsed, PowerPlant, PowerPlantType, ResourceType } from 'powergrid-engine/src/gamestate';
import {
isUraniumMine,
Phase,
playerTimeUsed,
PowerPlant,
PowerPlantType,
ResourceType,
} from 'powergrid-engine/src/gamestate';
import { City } from 'powergrid-engine/src/maps';
import { formatDuration } from '../util/time';
import { playerOrderForDisplay } from '../util/player-order';
import { freePlantMoves, canAutoFinishPowering, poweredCities } from '../util/powering';
import { bidRevision, canReopenPowering } from 'powergrid-engine/src/choice-revisions';
import { availableMoves } from 'powergrid-engine/src/available-moves';
import { powerIncome } from 'powergrid-engine/src/engine';
import { inactiveMapNetwork } from '../util/inactive-map';
import { desktopBoardLayout } from '../util/board-layout';
@ -1164,8 +1196,12 @@ export default class Game extends Vue {
private automaticPoweringRound = '';
get poweringPlayer() {
return this.G?.phase === Phase.Bureaucracy && this.player !== undefined && !this.paused &&
!this.tutorialMove && !this.preferences.analysis && !this.roundPlan
return this.G?.phase === Phase.Bureaucracy &&
this.player !== undefined &&
!this.paused &&
!this.tutorialMove &&
!this.preferences.analysis &&
!this.roundPlan
? this.G.players[this.player]
: null;
}
@ -1181,9 +1217,16 @@ export default class Game extends Vue {
return this.G?.phase === Phase.Bureaucracy && this.turnMoves.some((move) => move.name === MoveName.Pass);
}
get automaticPoweringKey() {
return this.poweringPlayer && this.canMove() && !this.paused && !this.tutorialMove &&
!this.preferences.analysis && !this.roundPlan && this.committedState && !this.poweringSubmitting
? `${this.G!.round}:${this.player}` : '';
return this.poweringPlayer &&
this.canMove() &&
!this.paused &&
!this.tutorialMove &&
!this.preferences.analysis &&
!this.roundPlan &&
this.committedState &&
!this.poweringSubmitting
? `${this.G!.round}:${this.player}`
: '';
}
@Watch('automaticPoweringKey')
startAutomaticPowering(key: string) {
@ -1194,7 +1237,15 @@ export default class Game extends Vue {
else if (activated) this.emitter.emit('move', [...this.turnMoves]);
}
activateFreePlants(submit = true) {
if (!this.G || this.player === undefined || this.paused || this.tutorialMove || this.preferences.analysis || this.roundPlan) return;
if (
!this.G ||
this.player === undefined ||
this.paused ||
this.tutorialMove ||
this.preferences.analysis ||
this.roundPlan
)
return;
const before = this.turnMoves.length;
for (const move of freePlantMoves(this.G, this.player)) this.sendMove(move, false);
const activated = this.turnMoves.length > before;
@ -1202,7 +1253,6 @@ export default class Game extends Vue {
return activated;
}
@Ref() powerPlantMarket!: PowerPlantMarket;
@Ref() playerOrder!: PlayerOrder;
@Ref() cityCount!: CityCount;
@ -1220,6 +1270,52 @@ export default class Game extends Vue {
// Last committed state received from the platform. Undo replays the shortened
// turn buffer from this state; when the buffer empties, the preview resets to it
// without any server call (the platform's saved state IS the turn start).
editingBid: string | null = null;
replacementBid = 0;
get revisableBid(): string | undefined {
return !this.paused && !this.interactionDisabled && !this.roundPlan && this.G && this.player !== undefined
? bidRevision(this.G, this.player)
: undefined;
}
get revisionBids(): number[] {
return this.revisableBid ? availableMoves(this.G!, this.G!.players[this.player!])[MoveName.Bid] || [] : [];
}
get canChangePowering(): boolean {
return !!(
!this.paused &&
!this.interactionDisabled &&
!this.roundPlan &&
this.G &&
this.player !== undefined &&
canReopenPowering(this.G, this.player)
);
}
editBid() {
this.editingBid = this.revisableBid || null;
this.replacementBid = Math.max(this.revisionBids[0] || 0, this.G!.players[this.player!].bid);
}
replaceBid(pass: boolean) {
if (
!this.revisableBid ||
this.editingBid !== this.revisableBid ||
(!pass && !this.revisionBids.includes(this.replacementBid))
)
return;
this.emitter.emit('move', [
{
name: pass ? MoveName.Pass : MoveName.Bid,
data: pass ? true : this.replacementBid,
revision: this.revisableBid,
time: Date.now(),
},
]);
this.editingBid = null;
}
reopenPowering() {
if (this.canChangePowering)
this.emitter.emit('move', [{ name: MoveName.ReopenPowering, data: this.G!.round, time: Date.now() }]);
}
committedState: GameState | null = null;
roundPlan: RoundPlan | null = null;
@ -2175,7 +2271,9 @@ export default class Game extends Vue {
if (this.poweringSubmitting) return false;
// Free activations are restored by Undo; only fuel choices are undoable here.
if (this.G?.phase === Phase.Bureaucracy && !this.tutorialMove && !this.preferences.analysis) {
return this.turnMoves.some((move) => move.name === MoveName.UsePowerPlant && move.data.resourcesSpent.length > 0);
return this.turnMoves.some(
(move) => move.name === MoveName.UsePowerPlant && move.data.resourcesSpent.length > 0
);
}
return this.turnMoves.length > 0;
}
@ -2770,8 +2868,10 @@ export default class Game extends Vue {
}
this.portraitViewport = this.isPortraitViewport();
const columns = !this.shouldStack() && (this.G?.players.length || 0) >= 5 &&
window.innerWidth / window.innerHeight > 1.7 ? 2 : 1;
const columns =
!this.shouldStack() && (this.G?.players.length || 0) >= 5 && window.innerWidth / window.innerHeight > 1.7
? 2
: 1;
if (columns !== this.playerBoardColumns) {
this.playerBoardColumns = columns;
this.scheduleRelayout();
@ -2787,9 +2887,16 @@ export default class Game extends Vue {
const el = this.$refs[slotRef(name)] as SVGGraphicsElement | undefined;
if (!el || typeof el.getBBox !== 'function') continue;
try {
const bb = measureBoardBox(el, !this.shouldStack() ?
name === 'cityCount' ? '.city-income-legend' : name === 'resources' ? '.resupply-strip' : undefined
: undefined);
const bb = measureBoardBox(
el,
!this.shouldStack()
? name === 'cityCount'
? '.city-income-legend'
: name === 'resources'
? '.resupply-strip'
: undefined
: undefined
);
if (bb.width > 0 && bb.height > 0) {
boxes[name] = bb;
}
@ -2811,14 +2918,16 @@ export default class Game extends Vue {
const width = this.$el.clientWidth || window.innerWidth;
const top = scene.getBoundingClientRect().top + window.scrollY;
const availableHeight = Math.max(240, window.innerHeight - top - 8);
const layout = desktopBoardLayout(boxes, STACK_WIDTH, STACK_WIDTH * availableHeight / width, {
const layout = desktopBoardLayout(boxes, STACK_WIDTH, (STACK_WIDTH * availableHeight) / width, {
pixelsPerUnit: width / STACK_WIDTH,
// Circular city markers have a 25-unit radius. Bremen's larger
// district tiles do not need this compact-controls adjustment.
cityDiameter: this.G?.map.cities.some((city) => city.connectionCost == null) ? 50 : 0,
});
this.desktopHeight = layout.height;
this.slotTransforms = Object.fromEntries(Object.entries(layout.placements).map(([name, slot]) => [name, slot.transform]));
this.slotTransforms = Object.fromEntries(
Object.entries(layout.placements).map(([name, slot]) => [name, slot.transform])
);
return;
}
@ -3012,6 +3121,38 @@ export default class Game extends Vue {
}
</script>
<style lang="scss">
.choice-revision {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
padding: 0.4rem 0.8rem;
}
.choice-revision form {
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
}
.choice-revision button,
.choice-revision input {
font: inherit;
color: inherit;
background: var(--pg-panel-bg, #f5f1e5);
border: 1px solid currentColor;
border-radius: 0.4rem;
padding: 0.35rem 0.65rem;
}
.choice-revision button {
cursor: pointer;
}
.choice-revision input {
width: 6rem;
}
.choice-revision button:disabled {
opacity: 0.45;
cursor: default;
}
ul {
margin-block-start: 0;
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Fuld pris (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Kun du kan stadig købe. Køb kraftværk {p0} for ${p1}?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Brug dit gratis spring til at bygge her for ${p0} (kun byggefeltets pris), eller betal den fulde pris på ${p1} og gem springet til senere.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Brug dit gratis spring til at bygge her for ${p0} (kun byggefeltets pris)? Byen kan ikke nås fra dit netværk på anden vis."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Brug dit gratis spring til at bygge her for ${p0} (kun byggefeltets pris)? Byen kan ikke nås fra dit netværk på anden vis.",
"Change bid": "Ændr bud",
"Change powered plants": "Ændr aktiverede kraftværker",
"Save bid": "Gem bud"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Voller Preis ({p0} $)",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Nur du kannst noch kaufen. Kraftwerk {p0} für {p1} $ kaufen?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Nutze deinen Freisprung, um hier für {p0} $ zu bauen (nur Bauplatzkosten), oder zahle den vollen Preis von {p1} $ und spare den Sprung für später auf.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Den Freisprung nutzen, um hier für {p0} $ zu bauen (nur Bauplatzkosten)? Von deinem Netz aus ist diese Stadt sonst nicht erreichbar."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Den Freisprung nutzen, um hier für {p0} $ zu bauen (nur Bauplatzkosten)? Von deinem Netz aus ist diese Stadt sonst nicht erreichbar.",
"Change bid": "Gebot ändern",
"Change powered plants": "Aktivierte Kraftwerke ändern",
"Save bid": "Gebot speichern"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Πλήρης τιμή ({p0} $)",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Μόνο εσύ μπορείς ακόμη να αγοράσεις. Αγορά του εργοστασίου {p0} για {p1} $;",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Χρησιμοποίησε το δωρεάν άλμα για να χτίσεις εδώ με {p0} $ (μόνο το κόστος θέσης), ή πλήρωσε την πλήρη τιμή των {p1} $ και κράτησε το άλμα για αργότερα.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Χρήση του δωρεάν άλματος για κατασκευή εδώ με {p0} $ (μόνο το κόστος θέσης); Η πόλη δεν συνδέεται με το δίκτυό σου με άλλον τρόπο."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Χρήση του δωρεάν άλματος για κατασκευή εδώ με {p0} $ (μόνο το κόστος θέσης); Η πόλη δεν συνδέεται με το δίκτυό σου με άλλον τρόπο.",
"Change bid": "Αλλαγή προσφοράς",
"Change powered plants": "Αλλαγή ενεργοποιημένων σταθμών",
"Save bid": "Αποθήκευση προσφοράς"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Pay Full Price (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.",
"Change bid": "Change bid",
"Change powered plants": "Change powered plants",
"Save bid": "Save bid"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "پرداخت هزینهٔ کامل (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "شما تنها بازیکنی هستید که هنوز می‌تواند خرید کند. نیروگاه {p0} را به قیمت ${p1} می‌خرید؟",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "با پرش رایگان اینجا به قیمت ${p0} بسازید (فقط هزینهٔ جایگاه)، یا هزینهٔ کامل اتصال، یعنی ${p1}، را بپردازید و پرش را برای بعد نگه دارید.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "با پرش رایگان اینجا به قیمت ${p0} بسازید (فقط هزینهٔ جایگاه)؟ این شهر بدون پرش از شبکهٔ شما قابل دسترسی نیست."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "با پرش رایگان اینجا به قیمت ${p0} بسازید (فقط هزینهٔ جایگاه)؟ این شهر بدون پرش از شبکهٔ شما قابل دسترسی نیست.",
"Change bid": "تغییر پیشنهاد",
"Change powered plants": "تغییر نیروگاه‌های فعال",
"Save bid": "ذخیرهٔ پیشنهاد"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Plein tarif ({p0} $)",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Vous êtes le seul joueur à pouvoir encore acheter. Acheter la centrale {p0} pour {p1} $ ?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Utilisez votre saut gratuit pour construire ici pour {p0} $ (coût de la case uniquement), ou payez le tarif complet de {p1} $ pour conserver votre saut.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Utiliser votre saut gratuit pour construire ici pour {p0} $ (coût de la case uniquement) ? Votre réseau ne peut pas atteindre cette ville autrement."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Utiliser votre saut gratuit pour construire ici pour {p0} $ (coût de la case uniquement) ? Votre réseau ne peut pas atteindre cette ville autrement.",
"Change bid": "Modifier l’enchère",
"Change powered plants": "Modifier les centrales activées",
"Save bid": "Enregistrer l’enchère"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "पूरी कीमत (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "केवल आप ही अभी खरीद सकते हैं। क्या संयंत्र {p0} को ${p1} में खरीदना चाहते हैं?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "मुफ़्त छलाँग से यहाँ ${p0} में निर्माण करें (केवल स्थान की लागत), या ${p1} की पूरी कीमत चुकाकर छलाँग बाद के लिए बचाएँ।",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "क्या मुफ़्त छलाँग से यहाँ ${p0} में निर्माण करना चाहते हैं (केवल स्थान की लागत)? इस शहर को आपके नेटवर्क से जोड़ने का दूसरा रास्ता नहीं है।"
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "क्या मुफ़्त छलाँग से यहाँ ${p0} में निर्माण करना चाहते हैं (केवल स्थान की लागत)? इस शहर को आपके नेटवर्क से जोड़ने का दूसरा रास्ता नहीं है।",
"Change bid": "बोली बदलें",
"Change powered plants": "सक्रिय बिजलीघर बदलें",
"Save bid": "बोली सहेजें"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Prezzo pieno (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Solo tu puoi ancora acquistare. Comprare la centrale {p0} per ${p1}?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Usa il salto gratuito per costruire qui per ${p0} (solo il costo dello spazio), oppure paga il prezzo pieno di ${p1} e conserva il salto per dopo.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Usare il salto gratuito per costruire qui per ${p0} (solo il costo dello spazio)? Non puoi raggiungere questa città dalla tua rete in altro modo."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Usare il salto gratuito per costruire qui per ${p0} (solo il costo dello spazio)? Non puoi raggiungere questa città dalla tua rete in altro modo.",
"Change bid": "Modifica offerta",
"Change powered plants": "Modifica centrali attivate",
"Save bid": "Salva offerta"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "전체 비용 지불 (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "이제 당신만 구매할 수 있습니다. ${p1}에 {p0}번 발전소를 구매하시겠습니까?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "무료 점프를 사용하면 건설 칸 비용 ${p0}만 지불합니다. 전체 연결 비용 ${p1}를 지불하고 점프를 나중을 위해 남겨 둘 수도 있습니다.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "무료 점프로 건설 칸 비용 ${p0}만 지불하고 이곳에 건설하시겠습니까? 다른 방법으로는 네트워크에서 이 도시에 도달할 수 없습니다."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "무료 점프로 건설 칸 비용 ${p0}만 지불하고 이곳에 건설하시겠습니까? 다른 방법으로는 네트워크에서 이 도시에 도달할 수 없습니다.",
"Change bid": "입찰 변경",
"Change powered plants": "가동한 발전소 변경",
"Save bid": "입찰 저장"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Volle prijs (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Alleen jij kunt nog kopen. Centrale {p0} kopen voor ${p1}?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Gebruik je gratis sprong om hier voor ${p0} te bouwen (alleen het bouwvak), of betaal de volledige prijs van ${p1} en bewaar de sprong voor later.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Je gratis sprong gebruiken om hier voor ${p0} te bouwen (alleen het bouwvak)? Anders is deze stad niet bereikbaar vanuit je netwerk."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Je gratis sprong gebruiken om hier voor ${p0} te bouwen (alleen het bouwvak)? Anders is deze stad niet bereikbaar vanuit je netwerk.",
"Change bid": "Bod wijzigen",
"Change powered plants": "Geactiveerde centrales wijzigen",
"Save bid": "Bod opslaan"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Pełna cena ({p0} $)",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Tylko ty możesz jeszcze kupić elektrownię. Kupić elektrownię {p0} za {p1} $?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Użyj darmowego skoku, aby zbudować tu za {p0} $ (tylko koszt pola), albo zapłać pełną cenę {p1} $ i zachowaj skok na później.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Użyć darmowego skoku, aby zbudować tu za {p0} $ (tylko koszt pola)? Nie możesz inaczej połączyć tego miasta ze swoją siecią."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Użyć darmowego skoku, aby zbudować tu za {p0} $ (tylko koszt pola)? Nie możesz inaczej połączyć tego miasta ze swoją siecią.",
"Change bid": "Zmień ofertę",
"Change powered plants": "Zmień uruchomione elektrownie",
"Save bid": "Zapisz ofertę"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Preço integral (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Só você ainda pode comprar. Comprar a usina {p0} por ${p1}?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Use seu salto grátis para construir aqui por ${p0} (apenas o custo do espaço), ou pague o preço integral de ${p1} e guarde o salto para depois.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Usar seu salto grátis para construir aqui por ${p0} (apenas o custo do espaço)? Não é possível alcançar esta cidade a partir da sua rede de outra forma."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Usar seu salto grátis para construir aqui por ${p0} (apenas o custo do espaço)? Não é possível alcançar esta cidade a partir da sua rede de outra forma.",
"Change bid": "Alterar lance",
"Change powered plants": "Alterar usinas ativadas",
"Save bid": "Salvar lance"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Preț întreg ({p0} $)",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Doar tu mai poți cumpăra. Cumperi centrala {p0} cu {p1} $?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Folosește saltul gratuit pentru a construi aici cu {p0} $ (doar costul spațiului) sau plătește prețul întreg de {p1} $ și păstrează saltul pentru mai târziu.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Folosești saltul gratuit pentru a construi aici cu {p0} $ (doar costul spațiului)? Orașul nu poate fi conectat altfel la rețeaua ta."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Folosești saltul gratuit pentru a construi aici cu {p0} $ (doar costul spațiului)? Orașul nu poate fi conectat altfel la rețeaua ta.",
"Change bid": "Modifică oferta",
"Change powered plants": "Modifică centralele activate",
"Save bid": "Salvează oferta"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Полная цена ({p0} $)",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Только вы ещё можете купить электростанцию. Купить электростанцию {p0} за {p1} $?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Используйте бесплатный прыжок, чтобы построить здесь за {p0} $ (только цена места), или заплатите полную цену {p1} $ и сохраните прыжок на потом.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Использовать бесплатный прыжок, чтобы построить здесь за {p0} $ (только цена места)? Иначе этот город нельзя подключить к вашей сети."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Использовать бесплатный прыжок, чтобы построить здесь за {p0} $ (только цена места)? Иначе этот город нельзя подключить к вашей сети.",
"Change bid": "Изменить ставку",
"Change powered plants": "Изменить включённые электростанции",
"Save bid": "Сохранить ставку"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "Trả đủ (${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "Chỉ bạn còn có thể mua. Mua nhà máy {p0} với giá ${p1}?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "Dùng bước nhảy miễn phí để xây tại đây với giá ${p0} (chỉ tính ô xây dựng), hoặc trả đủ ${p1} và giữ bước nhảy cho lần sau.",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Dùng bước nhảy miễn phí để xây tại đây với giá ${p0} (chỉ tính ô xây dựng)? Bạn không thể kết nối thành phố này với mạng lưới bằng cách khác."
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "Dùng bước nhảy miễn phí để xây tại đây với giá ${p0} (chỉ tính ô xây dựng)? Bạn không thể kết nối thành phố này với mạng lưới bằng cách khác.",
"Change bid": "Đổi giá đấu",
"Change powered plants": "Đổi nhà máy đã kích hoạt",
"Save bid": "Lưu giá đấu"
}

View file

@ -1995,5 +1995,8 @@
"Pay Full Price (${p0})": "支付全額(${p0})",
"You are the only player who can still buy. Buy Power Plant {p0} for ${p1}?": "只有你還能購買。要花費 ${p1} 購買 {p0} 號電廠嗎?",
"Use your Free Jump to build here for ${p0} (slot cost only), or pay the full connection price of ${p1} and save the jump for later.": "使用免費跳躍,只需支付建設格費用 ${p0};也可以支付全額 ${p1},將跳躍留到之後使用。",
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "要使用免費跳躍,花費 ${p0} 在此建設嗎(只計建設格費用)?你的電網無法以其他方式到達這座城市。"
"Use your Free Jump to build here for ${p0} (slot cost only)? This city is not reachable from your network otherwise.": "要使用免費跳躍,花費 ${p0} 在此建設嗎(只計建設格費用)?你的電網無法以其他方式到達這座城市。",
"Change bid": "更改出價",
"Change powered plants": "更改啟用的發電廠",
"Save bid": "儲存出價"
}