Release engine 2.0.26: redact sealed auction last moves
This commit is contained in:
parent
30dcc16f44
commit
e954346757
4 changed files with 131 additions and 1 deletions
28
docs/releases/sealed-bid-privacy-2.0.26.json
Normal file
28
docs/releases/sealed-bid-privacy-2.0.26.json
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"game": "powergrid",
|
||||||
|
"gameVersion": 13,
|
||||||
|
"publishedAt": "2026-11-10T18:22:54.716Z",
|
||||||
|
"engine": {
|
||||||
|
"version": "2.0.26",
|
||||||
|
"package": {
|
||||||
|
"name": "powergrid-engine",
|
||||||
|
"version": "2.0.26",
|
||||||
|
"url": "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/engine/205bbfe810742768/powergrid-engine-2.0.26.tgz"
|
||||||
|
},
|
||||||
|
"entryPoint": "dist/wrapper.js",
|
||||||
|
"sha256": "205bbfe8107427684381b1c22a1189e49843f937ad31b33b71afbc7f6fad5651",
|
||||||
|
"bytes": 378982
|
||||||
|
},
|
||||||
|
"changes": [
|
||||||
|
"Hide opponents lastMove throughout pending sealed auctions, including bids, passes and revisions; preserve own moves and public resolved-auction history."
|
||||||
|
],
|
||||||
|
"verification": {
|
||||||
|
"engineTests": 425,
|
||||||
|
"viewerUnitTests": 95,
|
||||||
|
"engineBuild": true,
|
||||||
|
"publicTarballHash": true,
|
||||||
|
"liveSpectatorEndpoint": "https://boardgamers.space/api/gameplay/Adrenal-gadget-8637",
|
||||||
|
"pendingAuctionLastMovesAllNull": true
|
||||||
|
},
|
||||||
|
"verified": true
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "powergrid-engine",
|
"name": "powergrid-engine",
|
||||||
"version": "2.0.25",
|
"version": "2.0.26",
|
||||||
"description": "An engine for Power Grid",
|
"description": "An engine for Power Grid",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "index.ts",
|
"types": "index.ts",
|
||||||
|
|
|
||||||
|
|
@ -771,6 +771,10 @@ export function stripSecret(G: GameState, player?: number): GameState {
|
||||||
availableMoves: pl.availableMoves ? {} : null,
|
availableMoves: pl.availableMoves ? {} : null,
|
||||||
money: ended(G) || G.options.showMoney || G.analysisMoney === 'hypothetical' ? pl.money : -1,
|
money: ended(G) || G.options.showMoney || G.analysisMoney === 'hypothetical' ? pl.money : -1,
|
||||||
bid: G.options.fastBid ? 0 : pl.bid,
|
bid: G.options.fastBid ? 0 : pl.bid,
|
||||||
|
// A sealed response must not leak via its duplicate in lastMove.
|
||||||
|
// Hide every opponent's last move throughout the pending auction,
|
||||||
|
// including passes and revisions, rather than revealing its kind.
|
||||||
|
lastMove: G.options.fastBid && G.phase === Phase.Auction && G.chosenPowerPlant ? null : pl.lastMove,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
98
engine/src/sealed-bid-privacy.spec.ts
Normal file
98
engine/src/sealed-bid-privacy.spec.ts
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
import { expect } from 'chai';
|
||||||
|
import 'mocha';
|
||||||
|
import * as wrapper from '../wrapper';
|
||||||
|
import { bidRevision } from './choice-revisions';
|
||||||
|
import { setup, stripSecret } from './engine';
|
||||||
|
import { GameState } from './gamestate';
|
||||||
|
import { MoveName } from './move';
|
||||||
|
|
||||||
|
const json = (value: unknown) => JSON.parse(JSON.stringify(value));
|
||||||
|
|
||||||
|
describe('sealed auction lastMove privacy', () => {
|
||||||
|
async function opening(fastBid = true) {
|
||||||
|
let state = setup(3, { fastBid, showMoney: false }, 'sealed-privacy');
|
||||||
|
const bidder = state.currentPlayers[0];
|
||||||
|
const plant = state.players[bidder].availableMoves!.ChoosePowerPlant![0];
|
||||||
|
state = await wrapper.move(
|
||||||
|
state,
|
||||||
|
[
|
||||||
|
{ name: MoveName.ChoosePowerPlant, data: plant },
|
||||||
|
{ name: MoveName.Bid, data: plant + 3 },
|
||||||
|
],
|
||||||
|
bidder
|
||||||
|
);
|
||||||
|
return { state, bidder, plant };
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertPrivate(state: GameState) {
|
||||||
|
const before = json(state);
|
||||||
|
for (const viewer of [undefined, -1, 0, 1, 2]) {
|
||||||
|
const stripped = json(stripSecret(state, viewer));
|
||||||
|
expect(stripped.hiddenLog).to.deep.equal([]);
|
||||||
|
expect(stripped.log.filter((e) => e.type === 'move' && e.move.name === MoveName.Bid)).to.deep.equal([]);
|
||||||
|
state.players.forEach((player, index) => {
|
||||||
|
if (index === viewer) {
|
||||||
|
expect(stripped.players[index].lastMove).to.deep.equal(json(player.lastMove));
|
||||||
|
expect(stripped.players[index].bid).to.equal(player.bid);
|
||||||
|
} else {
|
||||||
|
expect(stripped.players[index].lastMove).to.equal(null);
|
||||||
|
expect(stripped.players[index].bid).to.equal(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (viewer !== undefined && viewer >= 0) {
|
||||||
|
expect(json(wrapper.logSlice(state, { player: viewer })).state).to.deep.equal(stripped);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect(json(state), 'redaction must not mutate authoritative state').to.deep.equal(before);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('hides pending bids and passes from opponents and spectators, including revisions', async () => {
|
||||||
|
let { state, bidder, plant } = await opening();
|
||||||
|
assertPrivate(state);
|
||||||
|
const second = state.currentPlayers[0];
|
||||||
|
state = await wrapper.move(state, { name: MoveName.Pass, data: true }, second);
|
||||||
|
expect(state.players[second].lastMove!.name).to.equal(MoveName.Pass);
|
||||||
|
assertPrivate(state);
|
||||||
|
state = await wrapper.move(
|
||||||
|
state,
|
||||||
|
{
|
||||||
|
name: MoveName.Bid,
|
||||||
|
data: plant + 5,
|
||||||
|
revision: bidRevision(state, second)!,
|
||||||
|
},
|
||||||
|
second
|
||||||
|
);
|
||||||
|
assertPrivate(state);
|
||||||
|
state = await wrapper.move(
|
||||||
|
state,
|
||||||
|
{
|
||||||
|
name: MoveName.Bid,
|
||||||
|
data: plant + 7,
|
||||||
|
revision: bidRevision(state, bidder)!,
|
||||||
|
},
|
||||||
|
bidder
|
||||||
|
);
|
||||||
|
assertPrivate(state);
|
||||||
|
state = await wrapper.move(
|
||||||
|
state,
|
||||||
|
{
|
||||||
|
name: MoveName.Pass,
|
||||||
|
data: true,
|
||||||
|
revision: bidRevision(state, second)!,
|
||||||
|
},
|
||||||
|
second
|
||||||
|
);
|
||||||
|
assertPrivate(state);
|
||||||
|
|
||||||
|
state = await wrapper.move(state, { name: MoveName.Pass, data: true }, state.currentPlayers[0]);
|
||||||
|
const publicState = stripSecret(state);
|
||||||
|
expect(publicState.hiddenLog).to.deep.equal([]);
|
||||||
|
expect(publicState.log.some((e) => e.type === 'move' && e.move.name === MoveName.Bid)).to.equal(true);
|
||||||
|
expect(publicState.players.map((p) => p.lastMove)).to.deep.equal(state.players.map((p) => p.lastMove));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preserves public last moves in ordinary open auctions', async () => {
|
||||||
|
const { state, bidder } = await opening(false);
|
||||||
|
expect(stripSecret(state).players[bidder].lastMove).to.deep.equal(state.players[bidder].lastMove);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue