Show plug cards on the draw pile for every deck (#168)
* Show plug cards on the draw pile for every deck
The draw pile darkens when its top card is a plug card, and the engine
decided that by comparing the plant number with 15. That was right for the
standard deck only. Deck 1 has plug cards up to 16, and the shuffled decks
mix in copies such as 16.1 and 15.2, so in those games a plug card on top
was shown as an ordinary one.
Ask the deck instead, with the isPlugPlant() rule the decks already use.
For the standard deck (and India, and Deck 2) it is the same test as
before, so those games cannot change.
Measured over seeded 3p/5p Recharged games on Italy, USA and Germany:
before, 41/3112 states wrong on Deck 1, 40/3278 on shuffled, 31/3420 on
shuffled-unique, 0/3338 on standard; after, 0 on all four. The new test
fails on the old code ("deck1: 16 on top: expected false to equal true").
Found while answering Frankie_Stein's report on Italy_Rechrg_1103 (a
standard-deck game, so this is not the cause of that report).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fix the engine lint error that has kept CI red since 2.0.26
`pnpm lint` fails on master since e954346: prefer-const flags `bidder` and
`plant` in sealed-bid-privacy.spec.ts, destructured with `let` alongside
`state`, which is reassigned. Split the destructuring; the test is unchanged
and still passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d381197fdc
commit
bbe533ee8d
3 changed files with 47 additions and 3 deletions
|
|
@ -535,4 +535,34 @@ describe('shuffled power plant decks', () => {
|
|||
expect(replay.players.map((p) => p.money)).to.deep.equal(G.players.map((p) => p.money));
|
||||
});
|
||||
}
|
||||
|
||||
it("marks the draw pile by the deck's own plug cards, not by plant 15", () => {
|
||||
// Deck 1 has plug cards up to 16, and the shuffled decks mix in copies such as
|
||||
// 16.1 and 15.2. Comparing the number with 15 showed those as ordinary cards.
|
||||
const fresh = (deck: PowerPlantDeck) =>
|
||||
setup(5, { map: 'Germany', variant: 'recharged', powerPlantDeck: deck }, 'plug-flag');
|
||||
for (const deck of ['standard', 'deck1', 'shuffled', 'shuffledUnique'] as PowerPlantDeck[]) {
|
||||
const dealt = visible(fresh(deck)).filter((pp) => pp.number != 99);
|
||||
const plugAbove15 = dealt.find((pp) => pp.number > 15 && isPlugPlant(pp, deck));
|
||||
const ordinary = dealt.find((pp) => !isPlugPlant(pp, deck))!;
|
||||
if (deck == 'standard') expect(plugAbove15, deck).to.equal(undefined);
|
||||
else expect(plugAbove15, `${deck} deals a plug card above 15`).to.not.equal(undefined);
|
||||
|
||||
for (const top of [plugAbove15, ordinary]) {
|
||||
if (!top) continue;
|
||||
const G = fresh(deck);
|
||||
// Swap the chosen plant onto the top of the draw pile, wherever it was dealt.
|
||||
for (const row of [G.actualMarket, G.futureMarket, G.powerPlantsDeck]) {
|
||||
const at = row.findIndex((pp) => pp.number == top.number);
|
||||
if (at >= 0) [row[at], G.powerPlantsDeck[0]] = [G.powerPlantsDeck[0], row[at]];
|
||||
}
|
||||
const player = G.currentPlayers[0];
|
||||
G.players[player].availableMoves = availableMoves(G, G.players[player]);
|
||||
const chosen = G.actualMarket[0].number;
|
||||
const after = move(G, { name: MoveName.ChoosePowerPlant, data: chosen } as Move, player);
|
||||
expect(after.powerPlantsDeck[0].number, deck).to.equal(top.number);
|
||||
expect(after.nextCardWeak, `${deck}: ${top.number} on top`).to.equal(isPlugPlant(top, deck));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -597,7 +597,7 @@ export function setup(
|
|||
if (G.map.name == 'Middle East') {
|
||||
removePlantsForMiddleEastStep1(G);
|
||||
G.cardsLeft = G.powerPlantsDeck.length;
|
||||
G.nextCardWeak = variant === 'recharged' && G.cardsLeft > 0 && G.powerPlantsDeck[0].number <= 15;
|
||||
G.nextCardWeak = nextCardIsPlug(G);
|
||||
}
|
||||
|
||||
// chooseRegions: start in the region draft instead of the auction. The map
|
||||
|
|
@ -746,6 +746,18 @@ function advanceColorDraft(G: GameState) {
|
|||
}
|
||||
}
|
||||
|
||||
// The draw pile shows whether its top card has a plug on the back (Recharged only).
|
||||
// Which plants are plug cards depends on the deck: Deck 1 has plugs up to 16, and the
|
||||
// shuffled decks mix copies from every deck (16.1, 15.2, ...), so ask the deck rather
|
||||
// than comparing the number with 15.
|
||||
function nextCardIsPlug(G: GameState): boolean {
|
||||
return (
|
||||
G.options.variant == 'recharged' &&
|
||||
G.powerPlantsDeck.length > 0 &&
|
||||
isPlugPlant(G.powerPlantsDeck[0], gameDeck(G.options))
|
||||
);
|
||||
}
|
||||
|
||||
export function stripSecret(G: GameState, player?: number): GameState {
|
||||
return {
|
||||
...G,
|
||||
|
|
@ -2028,7 +2040,7 @@ export function move(
|
|||
: move;
|
||||
|
||||
G.cardsLeft = G.powerPlantsDeck.length;
|
||||
G.nextCardWeak = G.options.variant == 'recharged' && G.cardsLeft > 0 && G.powerPlantsDeck[0].number <= 15;
|
||||
G.nextCardWeak = nextCardIsPlug(G);
|
||||
|
||||
updateClocks(G, move.poweringClock?.at ?? move.serverTime ?? move.time);
|
||||
if (move.poweringClock) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ describe('sealed auction lastMove privacy', () => {
|
|||
}
|
||||
|
||||
it('hides pending bids and passes from opponents and spectators, including revisions', async () => {
|
||||
let { state, bidder, plant } = await opening();
|
||||
const opened = await opening();
|
||||
const { bidder, plant } = opened;
|
||||
let { state } = opened;
|
||||
assertPrivate(state);
|
||||
const second = state.currentPlayers[0];
|
||||
state = await wrapper.move(state, { name: MoveName.Pass, data: true }, second);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue