powergrid/engine
MikeIsom 96f3dedd5e
Shuffled Decks on every map, deck rules on the rules window, skipping Step 2 fix (#169)
* Count only wind plants as ecological, behind one switch

Benelux's extra market slot and Québec's protected plants now share one
isEcological() helper. Fusion is not ecological unless FUSION_IS_ECOLOGICAL
is flipped. New Benelux and Québec games store the ruling as
options.fusionEcological, so flipping it later only affects new games.

Québec's deck setup used to protect fusion plant 50 while its bureaucracy
and Benelux did not. Games without the stored flag rebuild their Québec
deck the old way via reconstructionOptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add a power plant deck option with Deck 1, Deck 2 and Random

New games choose a deck with options.powerPlantDeck: standard, deck1 (The
New Power Plants / Set 1, without 52-60), deck2 (Set 2) or random, which
resolves from the seed and stores the result. Only a non-standard deck is
stored.

Deck 1 deals from 01-08 with 11 on top in the Original edition and from
the 01-16 plug cards in Recharged. Deck 1 and Deck 2 are offered on maps
whose setup doesn't name standard-deck plant numbers; the rest fall back
to the standard deck until their per-deck changes land. Germany's uranium
phase-out triggers on 38 (Deck 1) or 37 (Deck 2).

The legacy alternatePowerPlants flag keeps its Europe/North America-only
behaviour and storage, so existing games set up identically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Offer Deck 1 and Deck 2 on every map

Map rules that name plant numbers now look them up per deck in
deckChanges.ts: removed plants, market openers, top-of-deck plants and
Spain & Portugal's Step 2 plants, from the decks' 2024 map-changes sheets.
Map setup and the deck analysis share that table. Original-edition games
use the same numbers, except France with Deck 1, which follows The New
Power Plants rulebook (remove 11).

Australia, India, South Africa, Spain & Portugal and UK & Ireland now use
the shared default setup instead of their own copies. India has a version
of each deck. Italy's uranium phase-out uses Germany's plant per deck.
Northern Europe's regional cards replace the deck's plants by number, and
a regional plant the deck lacks is shuffled into the draw pile. Middle
East closes garbage purchases in Step 1, for Deck 2's garbage/oil hybrids.

Standard-deck setups are unchanged for old and new games. Also stops the
ecological replay test from comparing the transient pendingMessages queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add shuffled power plant decks: all decks, or one per number

powerPlantDeck now also takes 'shuffled' (every plant of the standard deck,
Deck 1 and Deck 2 together) and 'shuffledUnique' (one random copy of each
number, without Deck 1's 52-60). Extra copies are numbered n.1 (Deck 1) and
n.2 (Deck 2), so the market ranks duplicates Deck 2 > Deck 1 > Original and
moves keep identifying plants by number. Cards show the printed number, and
logs read "Power Plant 46 (Deck 2)"; the journal and the deck analysis
parse that label back to the copy.

Bids start at the printed number, the Original discard rule and plug
cards compare it, and each deck's own nuclear plant ends Germany's and
Italy's uranium resupply. The shuffled decks are only offered on maps
whose rules don't name plant numbers; Random still picks a single deck.

Standard-deck setups are unchanged for old and new games.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Offer the shuffled decks on maps with deck-specific rules

The shuffled decks follow all three decks' map rules at once, for the
copies dealt: Deck 1's and Deck 2's plant numbers become n.1 and n.2.
This opens them on Australia, Brazil, Bremen, China, France, India,
Manhattan, Middle East, Recharged Russia, South Africa and Spain &
Portugal.

Exceptions, where the decks' rules clash:
- Northern Europe and Quebec keep the single decks only.
- Original Russia keeps the single decks only (availableDecks now takes
  the variant).
- Original "top of the deck" plants use the standard deck's list.

Spain & Portugal stores the dealt held-back copies in heldPowerPlants
and puts them on top at Step 2. India's shuffled decks keep India's
garbage plants. Map setups deal the sampled deck and split plug cards
with isPlugPlant.

The analysis sampler now copes with shuffled decks: undealt top plants,
protected-plant overflow and plug-count estimates are capped. The
Middle East public replay resets the plant discount before refiltering
its opening market.

Single-deck setups are byte-identical to before for every map,
variant, deck, player count and seed checked.

* Offer the shuffled decks on Northern Europe, Quebec and Original Russia

Where the three decks' rules clash, the shuffled decks now follow each
rule's purpose:

- Northern Europe: each regional plant in play is always dealt. It takes
  the place of one dealt copy of its number, and every other copy leaves
  the game; a regional number that wasn't dealt is shuffled in. This
  also applies once the regions are drafted, which now also updates
  cardsLeft.
- Quebec: one plug card on top of the deck, then the two smallest dealt
  ecological plants not in the market. The Recharged market is drawn
  from the plug cards; the Original market is the eight smallest plants,
  with the standard deck's 13 (if dealt) or else the smallest plug card
  left on top. Ecological plants are never removed.
- Original Russia: the six smallest dealt plants open the market, the
  standard deck's 13 goes on top if dealt, and the 7th and 8th smallest
  plants are shuffled into the top five.

The analysis sampler mirrors all three. Maps can give a `shuffled` deck
note, which the viewer shows for the shuffled decks.

Single-deck setups are unchanged for every map, variant, deck, player
count and seed checked.

* Generate the rules tab's deck build from the deck tables

The rules dialog's "Deck build" section is now built from the same tables
the decks are dealt from (deckChanges.ts and each deck's card list), so
it names the right plants for Deck 1, Deck 2 and the shuffled decks
instead of always the Original deck's. Shuffled games list each rule's
plants as Original deck / Deck 1 / Deck 2, with a sentence explaining
that only the dealt plants count. Player-count lists show the game's
own player count.

Each sentence is a template with plant numbers as {pN} values, rendered
in its own span, so the catalogues translate it whole. The 54 new
templates are translated into all 16 languages; the 20 old deck-build
sentences are removed. The maps' hand-written deckBuild notes are gone.

Tests read the plant numbers back out of the generated text and compare
them with real setups for every map, edition, single deck and player
count, and check that every sentence translates in every language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Describe Central Europe's nuclear and Wien rules

Central Europe had no map rules text, though the engine limits nuclear
plants to players with a city in Czechia, Slovakia or Hungary and gives
a Wien network $1 off garbage (never below $1). The rules dialog now
says so, in all 17 languages, using each catalogue's own name for Wien.

The dialog reads a map's rules from the current map definition rather
than the copy saved in the game, so games already under way see rules
text added later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Outline buildable Bremen districts around the diamond

The blue build hint and the gold region-draft ring were fixed 18-unit
circles, which on Bremen's diamond tiles crossed the entry cost and slot
numbers. Bremen's tiles now get a diamond outline just outside their own
region border instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Begin Step 2 first when the Step 3 card comes early

The rulebooks: if the Step 3 card is drawn before Step 2 has begun,
carry out everything that begins Step 2, then prepare Step 3, back to
back. The engine only did this on UK & Ireland, and without Step 2's
own setup, so on Spain & Portugal the held-back plants never came back.

Step 2's setup (the smallest plant leaves, Spain & Portugal puts its
held-back plants on top, a new plant is drawn) is now one function.
Normal Step 2 uses it unchanged, and an early Step 3 card runs it first:
straight away outside the auction, or at the end of the auction phase
with Step 3's own setup, which then shuffles the draw pile again.
Middle East, China and Manhattan keep their own rules.

New games store step2BeforeStep3; games created earlier replay with
their old sequence.

The rules summary now lists what happens when Step 2 and Step 3 start,
and the early-Step-3 order, in all 17 languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove a stale Manhattan line brought back by the master merge

Merging the fork's older master into combined-deck-rules restored
`const lastPlug = lastPlugPlant(powerPlantDeck)` in Manhattan's setup.
lastPlugPlant isn't imported there and the value is unused, so the
engine build failed and CI went red on the branch and on master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:45:47 -08:00
..
.vscode ✨ (all) Add Germany map, update map structure 2021-10-27 22:49:46 -03:00
src Shuffled Decks on every map, deck rules on the rules window, skipping Step 2 fix (#169) 2026-11-11 13:45:47 -08:00
.eslintignore 💚 (engine) add dist folder to eslint ignore 2021-10-29 18:30:11 -03:00
.eslintrc.js China: correct seven city names and the Changchun-Jilin cost (#59) (#117) 2026-08-14 09:26:23 -07:00
.gitignore Initial 2021-10-13 00:09:21 -03:00
.pnpm-debug.log Initial 2021-10-13 00:09:21 -03:00
.travis.yml Initial 2021-10-13 00:09:21 -03:00
index.ts feat: allow revising sealed bids and powered plants 2026-10-05 01:36:01 +02:00
LICENSE Initial 2021-10-13 00:09:21 -03:00
package-lock.json 🚨 (engine) Fix lint 2022-02-04 09:38:54 -03:00
package.json 🔖 powergrid-engine 2.0.28 2026-11-11 19:13:03 +00:00
pnpm-lock.yaml Revert "add devcontainer and specify pnpm version" 2025-08-09 20:52:36 +00:00
README.md Running pretter, fixing names 2021-10-22 19:29:36 -03:00
tsconfig.json ✅ (engine) add full game tests 2021-11-21 15:04:44 -03:00
wrapper.ts Fix interactive analysis cash and manual-seat policy 2026-11-10 08:25:37 +00:00

powergrid-engine

Typescript engine for Power Grid.

Setup

Requirements

Recent version of node / pnpm.

Dependencies

In the project's folder:

pnpm

Build

To compile Typescript into javascript:

pnpm build

Test

pnpm test