Track becomes a deck card, Departments become decks, and trains must be made up to leave, industry restrictions enforced, update display and add a new game button
This commit is contained in:
@@ -341,6 +341,35 @@ function mainlinePhase(s: GameState, events: GameEvent[]): AdvanceResult {
|
||||
|
||||
type MoveOutcome = 'moved' | 'held' | 'needsClearance' | 'expedited';
|
||||
|
||||
/**
|
||||
* §8.2 — why this train is not fit to run, or null if it is.
|
||||
*
|
||||
* "The engine in front, cars behind, and if there is a caboose, the caboose at the rear."
|
||||
*
|
||||
* DIRECTION-FREE, deliberately. The engine may be at either end of the tray — pulling or pushing —
|
||||
* and which of those counts as "in front" depends on which way the train is pointed, which the tray
|
||||
* does not reliably record for a crew that has been shunting round a siding. What a train may NOT be
|
||||
* is broken-backed: the engine buried among its own cars, with some ahead of it and some behind. The
|
||||
* caboose then has to ride at the far end from the engine, which is the rear whichever way it runs.
|
||||
*
|
||||
* This is reachable purely through switching. A train arrives made up, and only comes apart because
|
||||
* the player took cars onto the nose or picked up a cut in a run-around.
|
||||
*/
|
||||
function badlyMadeUp(tray: CrewTray): string | null {
|
||||
const n = tray.consist.length;
|
||||
if (n === 0) return null;
|
||||
const pulling = tray.engineAt === 0;
|
||||
const pushing = tray.engineAt === n;
|
||||
if (!pulling && !pushing) {
|
||||
return `not made up — the engine is buried in the train, ${tray.engineAt} car(s) ahead of it`;
|
||||
}
|
||||
const caboose = tray.consist.findIndex((c) => c.type === 'caboose');
|
||||
if (caboose === -1) return null;
|
||||
// The rear is the end away from the engine.
|
||||
const rear = pulling ? n - 1 : 0;
|
||||
return caboose === rear ? null : 'not made up — the caboose must be at the rear of the train';
|
||||
}
|
||||
|
||||
/** Puts a train onto a Mainline card with its crossing time already computed. */
|
||||
function enterMainline(
|
||||
s: GameState,
|
||||
@@ -449,6 +478,26 @@ function moveTrain(
|
||||
return 'held';
|
||||
}
|
||||
|
||||
/**
|
||||
* §8.2 — A TRAIN MUST BE MADE UP BEFORE IT MAY LEAVE.
|
||||
*
|
||||
* The engine leads, the cars follow, and a caboose rides at the rear. A train that has been
|
||||
* shunting can easily be in none of those states: taking cars on the nose puts them AHEAD of the
|
||||
* engine ("pushing them into the Facility"), and cars picked up in a run-around land wherever the
|
||||
* approach put them. Nothing checked, so a crew could shove a cut into a siding and then highball
|
||||
* onto the Mainline engine-last with the caboose in the middle.
|
||||
*
|
||||
* The remedy is in the player's hands and is the reason both exist: run around the train, or
|
||||
* spend a Move in a Small Yard, which re-makes it (`consistSorted` puts the engine back on the
|
||||
* nose). Held rather than rejected — a train that cannot leave stays where it is, which is what
|
||||
* makes an A/D track fill up and eventually bite.
|
||||
*/
|
||||
const badOrder = badlyMadeUp(tray);
|
||||
if (badOrder !== null) {
|
||||
events.push({ type: 'trainHeld', trainNumber: tray.trainNumber ?? 0, reason: badOrder });
|
||||
return 'held';
|
||||
}
|
||||
|
||||
const officeIndex = nodeIndexOfOffice(s, owner);
|
||||
const target = officeIndex + dir;
|
||||
const node = s.division.nodes[target];
|
||||
|
||||
+125
-81
@@ -292,6 +292,18 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (i.count < 1 || i.count > tray.consist.length) return 'CONSIST_EMPTY';
|
||||
const here = trayCoord(s, i.trayId);
|
||||
if (!here) return 'CANNOT_DROP_HERE';
|
||||
/**
|
||||
* A CUT COMES OFF AN OUTER END, never out of the middle.
|
||||
*
|
||||
* The tray runs `[cars ahead of the engine] ENGINE [cars behind it]`. Setting out from the
|
||||
* nose takes from the front of that, and only the cars actually ahead of the engine; setting
|
||||
* out from the tail takes from the back, and only the cars behind it. Without this, a drop
|
||||
* could lift cars from beside the engine and leave the far end of the train still attached to
|
||||
* nothing — a cut no coupler could make.
|
||||
*/
|
||||
const ahead = tray.engineAt;
|
||||
const behind = tray.consist.length - tray.engineAt;
|
||||
if (i.fromNose ? i.count > ahead : i.count > behind) return 'CONSIST_EMPTY';
|
||||
return canDropCarsAt(areaOf(s, player), here, i.count) ? null : 'CANNOT_DROP_HERE';
|
||||
}
|
||||
|
||||
@@ -331,7 +343,7 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (s.turn.option !== 'draw') return 'OPTION_NOT_CHOSEN';
|
||||
if (s.turn.drawnThisTurn) return 'OPTION_ALREADY_CHOSEN';
|
||||
if (i.slot < 0 || i.slot > 2) return 'SLOT_EMPTY';
|
||||
return s.decks.departments[i.slot] ? null : 'SLOT_EMPTY';
|
||||
return (s.decks.departments[i.slot]?.length ?? 0) > 0 ? null : 'SLOT_EMPTY';
|
||||
|
||||
case 'card.play': {
|
||||
if (!inPhase(s, 'localOps')) return 'WRONG_PHASE';
|
||||
@@ -349,17 +361,6 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
return null;
|
||||
}
|
||||
|
||||
case 'track.lay': {
|
||||
if (!inPhase(s, 'localOps')) return 'WRONG_PHASE';
|
||||
if (s.turn.option !== 'draw') return 'OPTION_NOT_CHOSEN';
|
||||
if (s.turn.laidThisTurn) return 'OPTION_ALREADY_CHOSEN';
|
||||
const key = `${i.geometry}:${i.hand}`;
|
||||
if ((areaOf(s, player).trackSupply.get(key) ?? 0) < 1) return 'NO_SUCH_CARD';
|
||||
const proto = protoTrackCard(i.geometry, i.hand, i.variant);
|
||||
if (!proto) return 'NO_PLACEMENT';
|
||||
return canPlaceAt(areaOf(s, player), i.placement, proto) ? null : 'NOT_CONNECTED';
|
||||
}
|
||||
|
||||
case 'mainline.modify': {
|
||||
if (!inPhase(s, 'localOps')) return 'WRONG_PHASE';
|
||||
if (s.turn.option !== 'draw') return 'OPTION_NOT_CHOSEN';
|
||||
@@ -594,8 +595,21 @@ function checkPlay(
|
||||
|
||||
case 'freightFacility': {
|
||||
if (!placement) return 'NO_PLACEMENT';
|
||||
// Q4 — a lockout prevents BUILDING both in one district. Each locked pair is a producer and
|
||||
// the consumer of the same commodity, so this forces traffic to flow between districts.
|
||||
/**
|
||||
* ON A STRAIGHT STUB, NEVER THE RUNNING TRACK.
|
||||
*
|
||||
* The sheet's "Placed" column reads the same for all six industries: **"Straight, Stub (not on
|
||||
* Running Track)"**. An industry has to hang off a siding, which is what makes a siding worth
|
||||
* building — the whole switching puzzle is getting a car from the main down to a spur and back.
|
||||
*
|
||||
* This was allowed, and merely warned about: an industry could sit on the Running Track and
|
||||
* the card text noted that a car left standing there would be hit by the next arrival. That is
|
||||
* a hazard, not a rule, and it let a player skip the district entirely and spot cars on the
|
||||
* main line.
|
||||
*/
|
||||
if (placement.row === area.runningRow) return 'ON_RUNNING_TRACK';
|
||||
// Q4 — a lockout prevents BUILDING both in one district: no duplicate, and never a producer
|
||||
// alongside the consumer of the same commodity.
|
||||
if (isLockedOut(area, card.kind.facility)) return 'FACILITY_LOCKED';
|
||||
const proto = protoCard(card.kind, variant);
|
||||
if (!proto) return 'NO_PLACEMENT';
|
||||
@@ -730,9 +744,12 @@ function execute(s: GameState, player: PlayerIndex, i: Intent): GameEvent[] {
|
||||
case 'switch.dropCars': {
|
||||
const tray = s.trays.get(i.trayId)!;
|
||||
const here = trayCoord(s, i.trayId)!;
|
||||
// §A.3 — cars come off in the order they are seated in the tray.
|
||||
const stock = tray.consist.slice(tray.consist.length - i.count);
|
||||
return [{ type: 'carsDropped', trayId: i.trayId, at: here, stock }];
|
||||
// §A.3 — cars come off in the order they are seated in the tray, from whichever end is being
|
||||
// set out. The nose is the end ahead of the engine.
|
||||
const stock = i.fromNose
|
||||
? tray.consist.slice(0, i.count)
|
||||
: tray.consist.slice(tray.consist.length - i.count);
|
||||
return [{ type: 'carsDropped', trayId: i.trayId, at: here, stock, ...(i.fromNose ? { fromNose: true } : {}) }];
|
||||
}
|
||||
|
||||
case 'switch.sortConsist': {
|
||||
@@ -753,8 +770,8 @@ function execute(s: GameState, player: PlayerIndex, i: Intent): GameEvent[] {
|
||||
case 'draw.end':
|
||||
return [{ type: 'phaseEnded', player, phase: 'localOps' }];
|
||||
|
||||
case 'draw.fromHomeOffice':
|
||||
return [
|
||||
case 'draw.fromHomeOffice': {
|
||||
const events: GameEvent[] = [
|
||||
{
|
||||
type: 'cardDrawn',
|
||||
player,
|
||||
@@ -762,23 +779,33 @@ function execute(s: GameState, player: PlayerIndex, i: Intent): GameEvent[] {
|
||||
cardId: s.decks.homeOffice[s.decks.homeOffice.length - 1]!,
|
||||
},
|
||||
];
|
||||
const sweep = reshuffleIfDepleted(s, 1);
|
||||
if (sweep) events.push(sweep);
|
||||
return events;
|
||||
}
|
||||
|
||||
case 'draw.fromDepartment': {
|
||||
// §6.2 — "take the TOP face-up card". Never anything buried: a player who discarded onto this
|
||||
// pile chose to put a card out of reach as much as to offer one, and letting a rival dig
|
||||
// would take that decision away.
|
||||
const pile = s.decks.departments[i.slot]!;
|
||||
const events: GameEvent[] = [
|
||||
{
|
||||
type: 'cardDrawn',
|
||||
player,
|
||||
source: 'department',
|
||||
slot: i.slot,
|
||||
cardId: s.decks.departments[i.slot]!,
|
||||
cardId: pile[pile.length - 1]!,
|
||||
},
|
||||
];
|
||||
// §6.2 — "If any of the Department decks is empty, draw a Home Office card and place it in
|
||||
// the empty spot." Without this the three face-up slots empty out permanently and the market
|
||||
// silently disappears from the game.
|
||||
// §6.2 — "If any of the Department decks is empty, draw a Home Office card and place it in the
|
||||
// empty spot." Only when taking the last card actually empties the pile; refilling on every
|
||||
// draw would grow the Departments without limit and drain the Home Office deck into them.
|
||||
const refill = s.decks.homeOffice[s.decks.homeOffice.length - 1];
|
||||
if (refill) {
|
||||
if (pile.length === 1 && refill) {
|
||||
events.push({ type: 'departmentRefilled', slot: i.slot, cardId: refill });
|
||||
const sweep = reshuffleIfDepleted(s, 1);
|
||||
if (sweep) events.push(sweep);
|
||||
}
|
||||
return events;
|
||||
}
|
||||
@@ -866,21 +893,6 @@ function execute(s: GameState, player: PlayerIndex, i: Intent): GameEvent[] {
|
||||
return [{ type: 'flyingSwitch', player, cardId: i.cardId, trayId: i.trayId, to: i.to, stock }];
|
||||
}
|
||||
|
||||
case 'track.lay': {
|
||||
const key = `${i.geometry}:${i.hand}`;
|
||||
return [
|
||||
{
|
||||
type: 'trackLaid',
|
||||
player,
|
||||
geometry: i.geometry,
|
||||
hand: i.hand,
|
||||
at: i.placement,
|
||||
variant: i.variant ?? 0,
|
||||
remaining: (areaOf(s, player).trackSupply.get(key) ?? 1) - 1,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
case 'freightAgent.stockOutbound':
|
||||
return [
|
||||
{ type: 'stockToOutbound', player, at: i.at, stock: { type: i.carType, loaded: true } },
|
||||
@@ -1025,8 +1037,16 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
case 'carsCoupled': {
|
||||
const tray = s.trays.get(e.trayId)!;
|
||||
const area = areaOf(s, tray.position.at === 'grid' ? tray.position.owner : 0);
|
||||
if (e.toNose) tray.consist.unshift(...e.stock);
|
||||
else tray.consist.push(...e.stock);
|
||||
if (e.toNose) {
|
||||
// Cars taken on the nose go AHEAD of the engine — "pushing them into the Facility" — so the
|
||||
// engine is no longer at the front and its index has to follow. It never did, so a crew that
|
||||
// shoved a cut anywhere kept a tray claiming the engine was still leading, and §8.2's
|
||||
// make-up rule had nothing truthful to check.
|
||||
tray.consist.unshift(...e.stock);
|
||||
tray.engineAt += e.stock.length;
|
||||
} else {
|
||||
tray.consist.push(...e.stock);
|
||||
}
|
||||
// ONLY the cards the crew ran over. Clearing the whole grid emptied industry tracks the crew
|
||||
// never went near.
|
||||
for (const coord of e.from) {
|
||||
@@ -1041,6 +1061,9 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
case 'consistSorted': {
|
||||
const tray = s.trays.get(e.trayId)!;
|
||||
tray.consist = e.after.map((c) => ({ ...c }));
|
||||
// A Small Yard re-makes the train, and putting the engine back on the nose is the whole reason
|
||||
// to use one: §8.2 will not let a train leave the Office with cars in front of its engine.
|
||||
tray.engineAt = 0;
|
||||
// "Spends one move in the yard" — the sort costs a Move.
|
||||
s.turn.movesRemaining = Math.max(0, s.turn.movesRemaining - 1);
|
||||
break;
|
||||
@@ -1049,7 +1072,15 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
case 'carsDropped': {
|
||||
const tray = s.trays.get(e.trayId)!;
|
||||
const area = areaOf(s, tray.position.at === 'grid' ? tray.position.owner : 0);
|
||||
tray.consist.splice(tray.consist.length - e.stock.length, e.stock.length);
|
||||
if (e.fromNose) {
|
||||
// Off the front: everything ahead of the engine shortens, so the engine moves up by that
|
||||
// much. This is how a train that took cars onto its nose gets back to being made up.
|
||||
tray.consist.splice(0, e.stock.length);
|
||||
tray.engineAt = Math.max(0, tray.engineAt - e.stock.length);
|
||||
} else {
|
||||
tray.consist.splice(tray.consist.length - e.stock.length, e.stock.length);
|
||||
}
|
||||
tray.engineAt = Math.min(tray.engineAt, tray.consist.length);
|
||||
const card = area.grid.get(coordKey(e.at));
|
||||
// On a Facility card the industry track is where cars stand (§9.3).
|
||||
if (card) carsOn(card).push(...e.stock);
|
||||
@@ -1058,13 +1089,30 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
|
||||
case 'departmentRefilled':
|
||||
s.decks.homeOffice.pop();
|
||||
s.decks.departments[e.slot] = e.cardId;
|
||||
s.decks.departments[e.slot]!.push(e.cardId);
|
||||
break;
|
||||
|
||||
case 'deckReshuffled': {
|
||||
// Everything swept comes back as ONE pile, then §4.6-4.7's opening is re-run: three cards
|
||||
// turned face up as the Departments, the rest face down as the Home Office deck. The
|
||||
// Departments start one deep again, exactly as at setup.
|
||||
s.decks.salvageYard = [];
|
||||
s.decks.departments = [[], [], []];
|
||||
const order = [...e.order];
|
||||
for (const pile of s.decks.departments) {
|
||||
const card = order.pop();
|
||||
if (card) pile.push(card);
|
||||
}
|
||||
// The END of the array is the top of the deck — `cardDrawn` pops from there.
|
||||
s.decks.homeOffice = order;
|
||||
s.rngState = e.rngState;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'cardDrawn': {
|
||||
const hand = s.decks.hands.get(e.player) ?? [];
|
||||
if (e.source === 'homeOffice') s.decks.homeOffice.pop();
|
||||
else if (e.slot !== undefined) s.decks.departments[e.slot] = null;
|
||||
else if (e.slot !== undefined) s.decks.departments[e.slot]!.pop();
|
||||
hand.push(e.cardId);
|
||||
s.decks.hands.set(e.player, hand);
|
||||
s.turn.drawnThisTurn = true;
|
||||
@@ -1135,18 +1183,6 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'trackLaid': {
|
||||
const area = areaOf(s, e.player);
|
||||
area.trackSupply.set(`${e.geometry}:${e.hand}`, e.remaining);
|
||||
s.turn.laidThisTurn = true;
|
||||
const built = protoTrackCard(e.geometry as never, e.hand as never, e.variant);
|
||||
if (built) {
|
||||
area.grid.set(coordKey(e.at), built);
|
||||
extendLimitsIfNeeded(area, e.at);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'officeUpgraded': {
|
||||
// Gap 8 — a property change, NOT a card swap. Swapping would orphan attached Secondary Track.
|
||||
const area = areaOf(s, e.player);
|
||||
@@ -1164,7 +1200,10 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
case 'cardDiscarded': {
|
||||
const hand = (s.decks.hands.get(e.player) ?? []).filter((c) => c !== e.cardId);
|
||||
s.decks.hands.set(e.player, hand);
|
||||
s.decks.departments[e.toSlot] = e.cardId;
|
||||
// ON TOP of the pile. Assigning here overwrote whatever was already face up on that
|
||||
// Department, quietly destroying a card from a closed deck — and it threw away the whole
|
||||
// point of choosing WHICH Department to discard onto.
|
||||
s.decks.departments[e.toSlot]!.push(e.cardId);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1561,35 +1600,39 @@ function spendCard(s: GameState, player: PlayerIndex, cardId: CardId): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* A track piece from the player's own supply, at the chosen rotation — which for a printed card is
|
||||
* 0° or 180°, and never a flip, so `hand` decides which diagonal the 45° leg can lie on.
|
||||
* §6.2 — "If drawing a card has depleted the Home Office deck, immediately collect all cards from
|
||||
* the Salvage Yard and three Department decks, reshuffle, and reestablish the Home Office deck and
|
||||
* Department slots."
|
||||
*
|
||||
* `taking` is how many cards the events already queued will pop off the deck, so this can be asked
|
||||
* BEFORE they are applied: a draw takes one, and refilling an emptied Department takes another.
|
||||
*
|
||||
* Returns null when the deck is not about to run out, or when there is nothing to sweep — a game
|
||||
* that has genuinely used every card ends on `DECK_EMPTY` rather than reshuffling an empty pile.
|
||||
* Cards played onto the board are NOT recovered: they are on the table, which is where they belong.
|
||||
*/
|
||||
function protoTrackCard(
|
||||
geometry: TrackGeometry,
|
||||
hand: Hand,
|
||||
variant: number | undefined,
|
||||
): TrackCard | null {
|
||||
const options = variantsFor(geometry, hand);
|
||||
const v = options[variant ?? 0];
|
||||
if (!v) return null;
|
||||
return {
|
||||
geometry: {
|
||||
kind: 'track',
|
||||
geometry,
|
||||
...(v.arc ? { arc: v.arc } : {}),
|
||||
...(v.turnout ? { turnout: v.turnout } : {}),
|
||||
...(hand !== 'none' ? { hand } : {}),
|
||||
},
|
||||
baseOperationalRail: geometry !== 'turnout',
|
||||
standing: [],
|
||||
facility: null,
|
||||
modifiers: [],
|
||||
enhancements: [],
|
||||
};
|
||||
function reshuffleIfDepleted(s: GameState, taking: number): GameEvent | null {
|
||||
if (s.decks.homeOffice.length > taking) return null;
|
||||
const collected = [...s.decks.salvageYard, ...s.decks.departments.flat()];
|
||||
if (collected.length === 0) return null;
|
||||
const rng = createRng(s.rngState);
|
||||
return { type: 'deckReshuffled', order: rng.shuffle(collected), rngState: rng.getState() };
|
||||
}
|
||||
|
||||
/**
|
||||
* Q4 — would building `kind` here conflict with something already in the district?
|
||||
*
|
||||
* TWO RULES, both from the sheet's "Lockouts" column.
|
||||
*
|
||||
* 1. **No two of the same industry in one Office Area.** The sheet states it in the Freight House
|
||||
* row, which lists Freight House among its own lockouts; it is a general rule, so it is applied
|
||||
* to every kind here rather than repeated in all six catalogue entries.
|
||||
* 2. **Not a producer and the consumer of the same commodity.** Mine Tipple makes coal and the
|
||||
* Power Plant burns it; the Refinery makes oil and the Power Plant burns that too; Packing Sheds
|
||||
* fill reefers and the Grocer's Warehouse empties them. Build one end of a chain or the other,
|
||||
* never both — which is what pushes freight to run BETWEEN districts instead of circling inside
|
||||
* one.
|
||||
*
|
||||
* The relation is symmetric, so checking either direction is enough.
|
||||
*/
|
||||
export function isLockedOut(area: OfficeArea, kind: FreightKind): boolean {
|
||||
@@ -1597,6 +1640,7 @@ export function isLockedOut(area: OfficeArea, kind: FreightKind): boolean {
|
||||
for (const card of area.grid.values()) {
|
||||
if (card.geometry.kind !== 'facility') continue;
|
||||
const present = card.geometry.facility;
|
||||
if (present === kind) return true;
|
||||
if (wanted.lockouts.includes(present)) return true;
|
||||
if (industryProfile(present).lockouts.includes(kind)) return true;
|
||||
}
|
||||
|
||||
+54
-20
@@ -42,14 +42,15 @@ export type TrackGeometry = 'straight' | 'curved' | 'sharpCurved' | 'turnout';
|
||||
export type Hand = 'left' | 'right' | 'none';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Track — a PER-PLAYER supply, not deck cards
|
||||
// Track — deck cards, drawn and played like any other
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type TrackProfile = {
|
||||
geometry: TrackGeometry;
|
||||
hand: Hand;
|
||||
name: string;
|
||||
perPlayer: number;
|
||||
/** Column B of the sheet, "Number in Deck". */
|
||||
copiesInDeck: number;
|
||||
/** Column J of the sheet, "Train can stop here". Turnouts are blank. */
|
||||
isOperationalRail: boolean;
|
||||
/** Sharp curves: "Any move across this track is doubled (two moves)". */
|
||||
@@ -57,30 +58,42 @@ export type TrackProfile = {
|
||||
};
|
||||
|
||||
/**
|
||||
* 26 pieces per player, 104 for four players. Track is NOT in the Home Office deck — this is the
|
||||
* single biggest structural change from the placeholder, and it means the draw is entirely about
|
||||
* industry, trains and enhancements.
|
||||
* TRACK IS IN THE HOME OFFICE DECK, and is drawn and played like any other card.
|
||||
*
|
||||
* Handedness is PRINTED, not chosen on placement. That supersedes Gap 11.
|
||||
* 104 cards, straight from column B of `docs/Deck cards2.xlsx`. An earlier reading made track a
|
||||
* separate per-player supply of 26 pieces, sitting outside the deck and laid one a turn. That came
|
||||
* from misreading the sheet's LAST column, headed "Track Per Player" — 8/4/4/1/1/4/4 = 26, which is
|
||||
* a note about each player's likely share of 104 across four players, not a second stack of cards.
|
||||
* The sheet's own totals settle it: "Sum other 115", "Total track 104", and a grand total of 231
|
||||
* once the 12 start cards are counted. 115 + 104 + 12 = 231.
|
||||
*
|
||||
* It matters well beyond bookkeeping. Track competes for the draw with industry, trains and
|
||||
* enhancements, so building a district is paid for in cards you did not draw instead — and the
|
||||
* hand-of-three is the real constraint on how fast a railroad grows.
|
||||
*
|
||||
* Handedness is PRINTED, not chosen on placement: it is the diagonal the 45° leg lies on.
|
||||
*/
|
||||
export const TRACK_SUPPLY: readonly TrackProfile[] = [
|
||||
{ geometry: 'straight', hand: 'none', name: 'Straight track', perPlayer: 8, isOperationalRail: true, moveCost: 1 },
|
||||
{ geometry: 'curved', hand: 'left', name: 'Curved track (left)', perPlayer: 4, isOperationalRail: true, moveCost: 1 },
|
||||
{ geometry: 'curved', hand: 'right', name: 'Curved track (right)', perPlayer: 4, isOperationalRail: true, moveCost: 1 },
|
||||
{ geometry: 'sharpCurved', hand: 'left', name: 'Sharp Curved Track (left)', perPlayer: 1, isOperationalRail: true, moveCost: 2 },
|
||||
{ geometry: 'sharpCurved', hand: 'right', name: 'Sharp Curved Track (right)', perPlayer: 1, isOperationalRail: true, moveCost: 2 },
|
||||
{ geometry: 'turnout', hand: 'left', name: 'Turnout (left)', perPlayer: 4, isOperationalRail: false, moveCost: 1 },
|
||||
{ geometry: 'turnout', hand: 'right', name: 'Turnout (right)', perPlayer: 4, isOperationalRail: false, moveCost: 1 },
|
||||
export const TRACK_CARDS: readonly TrackProfile[] = [
|
||||
{ geometry: 'straight', hand: 'none', name: 'Straight track', copiesInDeck: 32, isOperationalRail: true, moveCost: 1 },
|
||||
{ geometry: 'curved', hand: 'left', name: 'Curved track (left)', copiesInDeck: 16, isOperationalRail: true, moveCost: 1 },
|
||||
{ geometry: 'curved', hand: 'right', name: 'Curved track (right)', copiesInDeck: 16, isOperationalRail: true, moveCost: 1 },
|
||||
{ geometry: 'sharpCurved', hand: 'left', name: 'Sharp Curved Track (left)', copiesInDeck: 4, isOperationalRail: true, moveCost: 2 },
|
||||
{ geometry: 'sharpCurved', hand: 'right', name: 'Sharp Curved Track (right)', copiesInDeck: 4, isOperationalRail: true, moveCost: 2 },
|
||||
{ geometry: 'turnout', hand: 'left', name: 'Turnout (left)', copiesInDeck: 16, isOperationalRail: false, moveCost: 1 },
|
||||
{ geometry: 'turnout', hand: 'right', name: 'Turnout (right)', copiesInDeck: 16, isOperationalRail: false, moveCost: 1 },
|
||||
];
|
||||
|
||||
export const TRACK_PER_PLAYER = TRACK_SUPPLY.reduce((n, t) => n + t.perPlayer, 0); // 26
|
||||
/** 104 — the sheet's "Total track". */
|
||||
export const TRACK_IN_DECK = TRACK_CARDS.reduce((n, t) => n + t.copiesInDeck, 0);
|
||||
|
||||
/** Start cards, placed at setup and never shuffled: 4 Whistle Posts, 8 Limits. */
|
||||
export const WHISTLE_POST_SUPPLY = 4;
|
||||
export const LIMITS_SUPPLY = 8;
|
||||
|
||||
/** Legacy alias kept so existing call sites resolve; prefer TRACK_SUPPLY. */
|
||||
export const TRACK_PROFILES = TRACK_SUPPLY;
|
||||
/** Look up a track card's profile by the two things that identify it. */
|
||||
export function trackProfile(geometry: TrackGeometry, hand: Hand): TrackProfile | undefined {
|
||||
return TRACK_CARDS.find((t) => t.geometry === geometry && t.hand === hand);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Offices — Depot 4, Station 2, Terminal 1
|
||||
@@ -174,6 +187,26 @@ export type IndustryProfile = {
|
||||
* ratio while preserving the sheet's proportions exactly: the outbound/inbound balance and the
|
||||
* lockout structure are unchanged, because every kind scales by the same factor.
|
||||
*/
|
||||
/**
|
||||
* LOCKOUTS, from the sheet's "Lockouts" column verbatim:
|
||||
*
|
||||
* Freight house -> Freight house, Grocer's warehouse
|
||||
* Mine Tipple -> Power Plant
|
||||
* Refinery -> Power plant
|
||||
* Power Plant -> Mine Tipple, Refinery
|
||||
* Packing Sheds -> Grocer's Warehouse
|
||||
* Grocer's Warehouse -> Packing Sheds, Freight House
|
||||
*
|
||||
* Every pair is a PRODUCER and the CONSUMER of the same commodity: Mine Tipple makes coal and the
|
||||
* Power Plant burns it, the Refinery makes oil and the Power Plant burns that too, Packing Sheds
|
||||
* fill reefers and the Grocer's Warehouse empties them. You may build one end of a chain or the
|
||||
* other, never both — which is what forces the traffic to run BETWEEN districts rather than in
|
||||
* circles inside one.
|
||||
*
|
||||
* Freight house listing ITSELF is the sheet stating the general rule in the one row where it would
|
||||
* otherwise look like an omission: no two of the same industry in one Office Area. That rule is
|
||||
* enforced for every kind in `isLockedOut`, not repeated in each row here.
|
||||
*/
|
||||
export const INDUSTRY_PROFILES: readonly IndustryProfile[] = [
|
||||
{ kind: 'freightHouse', name: 'Freight House', carTypes: ['boxcar'], flow: 'both', baseOut: 1, baseIn: 1, baseLoaders: 1, lockouts: ['grocersWarehouse'], copies: 6 },
|
||||
{ kind: 'mineTipple', name: 'Mine Tipple', carTypes: ['hopper'], flow: 'outbound', baseOut: 1, baseIn: 0, baseLoaders: 1, lockouts: ['powerPlant'], copies: 6 },
|
||||
@@ -672,7 +705,7 @@ export function lengthProfile(length: GameLength): LengthProfile {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Deck composition — 140 cards
|
||||
// Deck composition
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -688,6 +721,7 @@ export function isOpponentOnly(category: string): boolean {
|
||||
export function deckComposition(): { category: string; count: number }[] {
|
||||
const sum = (xs: readonly { copies: number }[]): number => xs.reduce((n, x) => n + x.copies, 0);
|
||||
return [
|
||||
{ category: 'track', count: TRACK_IN_DECK },
|
||||
{ category: 'office', count: OFFICE_PROFILES.reduce((n, o) => n + o.copiesInDeck, 0) },
|
||||
{ category: 'industry', count: sum(INDUSTRY_PROFILES) },
|
||||
{ category: 'modifier', count: sum(MODIFIER_PROFILES) },
|
||||
@@ -700,9 +734,9 @@ export function deckComposition(): { category: string; count: number }[] {
|
||||
];
|
||||
}
|
||||
|
||||
export const DECK_SIZE = deckComposition().reduce((n, c) => n + c.count, 0); // 140
|
||||
export const DECK_SIZE = deckComposition().reduce((n, c) => n + c.count, 0);
|
||||
|
||||
/** The solitaire deck drops the 22 opponent-directed cards, leaving 118. */
|
||||
/** The solitaire deck drops the 22 opponent-directed cards. */
|
||||
export const SOLITAIRE_DECK_SIZE = deckComposition()
|
||||
.filter((c) => !isOpponentOnly(c.category))
|
||||
.reduce((n, c) => n + c.count, 0);
|
||||
|
||||
+11
-3
@@ -35,12 +35,21 @@ export type GameEvent =
|
||||
*/
|
||||
toNose: boolean;
|
||||
}
|
||||
| { type: 'carsDropped'; trayId: TrayId; at: GridCoord; stock: RollingStock[] }
|
||||
| { type: 'carsDropped'; trayId: TrayId; at: GridCoord; stock: RollingStock[]; fromNose?: boolean }
|
||||
| { type: 'consistSorted'; trayId: TrayId; at: GridCoord; before: RollingStock[]; after: RollingStock[] }
|
||||
| { type: 'cardDrawn'; player: PlayerIndex; source: 'homeOffice' | 'department'; slot?: number; cardId: CardId }
|
||||
/**
|
||||
* §6.2 — the Home Office deck ran out, so the Salvage Yard and all three Department decks were
|
||||
* collected, reshuffled, and dealt back out as a fresh deck plus three face-up Departments.
|
||||
*
|
||||
* The full shuffled `order` rides the event rather than being recomputed from `rngState`. A save
|
||||
* is a seed plus the intents, so events are never serialised and the size costs nothing — and an
|
||||
* event that states the outcome outright cannot drift from the reducer the way a re-derivation
|
||||
* can. `rngState` still rides along so the next roll follows on.
|
||||
*/
|
||||
| { type: 'deckReshuffled'; order: CardId[]; rngState: number }
|
||||
/** `variant` is the chosen orientation (Gap 11); it must be replayable, so it rides the event. */
|
||||
| { type: 'cardPlayed'; player: PlayerIndex; cardId: CardId; placement?: GridCoord; variant?: number }
|
||||
| { type: 'trackLaid'; player: PlayerIndex; geometry: string; hand: string; at: GridCoord; variant: number; remaining: number }
|
||||
| { type: 'mainlineModified'; player: PlayerIndex; cardId: CardId; node: number; key: string; became?: string }
|
||||
| { type: 'redFlagsSet'; player: PlayerIndex; cardId: CardId; trayId: TrayId; node: number }
|
||||
| {
|
||||
@@ -53,7 +62,6 @@ export type GameEvent =
|
||||
| { type: 'flyingSwitch'; player: PlayerIndex; cardId: CardId; trayId: TrayId; to: GridCoord; stock: RollingStock[] }
|
||||
| { type: 'officeUpgraded'; player: PlayerIndex; from: OfficeTier; to: OfficeTier }
|
||||
| { type: 'cardDiscarded'; player: PlayerIndex; cardId: CardId; toSlot: number }
|
||||
| { type: 'deckReshuffled' }
|
||||
| { type: 'departmentRefilled'; slot: number; cardId: CardId }
|
||||
// -- freight agent
|
||||
| { type: 'stockToOutbound'; player: PlayerIndex; at: GridCoord; stock: RollingStock }
|
||||
|
||||
+14
-9
@@ -17,7 +17,13 @@ export type Intent =
|
||||
| { type: 'localOps.choose'; option: LocalOpsOption }
|
||||
// -- switch (§6.1, Appendix A)
|
||||
| { type: 'switch.move'; trayId: TrayId; to: GridCoord; reverse: boolean }
|
||||
| { type: 'switch.dropCars'; trayId: TrayId; count: number }
|
||||
/**
|
||||
* Set out a cut. `fromNose` takes it off the FRONT of the train rather than the back — Appendix A's
|
||||
* worked example does exactly this: "Back up and drop off everything on the nose of your train
|
||||
* (red and blue) on Card B." Without it, cars taken onto the nose could never be set out again and
|
||||
* an engine buried in its own train had no way back to an end.
|
||||
*/
|
||||
| { type: 'switch.dropCars'; trayId: TrayId; count: number; fromNose?: boolean }
|
||||
/**
|
||||
* Small Yard enhancement — "a train that spends one move in the yard may sort itself in any
|
||||
* order, including cars in front of the engine". This is the designed answer to §A.3's
|
||||
@@ -28,16 +34,13 @@ export type Intent =
|
||||
// -- draw (§6.2)
|
||||
| { type: 'draw.fromHomeOffice' }
|
||||
| { type: 'draw.fromDepartment'; slot: number }
|
||||
/** `variant` indexes `variantsFor(geometry)` — Gap 11: orientation is chosen on placement. */
|
||||
/**
|
||||
* `variant` indexes `variantsFor(geometry, hand)` — 0° or 180°, the only two ways a printed card
|
||||
* can be laid. Track is played through here like every other card; there is no separate lay
|
||||
* intent, because there is no separate supply to lay from.
|
||||
*/
|
||||
| { type: 'card.play'; cardId: CardId; placement?: GridCoord; variant?: number }
|
||||
| { type: 'card.discard'; cardId: CardId; toSlot: number }
|
||||
/**
|
||||
* Lay a piece from your personal track supply (§12.2 / content.ts TRACK_SUPPLY).
|
||||
*
|
||||
* Laid during the "draw a card" option, one piece a turn — how track behaved when it WAS a card.
|
||||
* Confirmed; see implications.md §10 Q10.
|
||||
*/
|
||||
| { type: 'track.lay'; geometry: TrackGeometry; hand: Hand; placement: GridCoord; variant?: number }
|
||||
| { type: 'draw.end' }
|
||||
// -- freight agent (§6.3)
|
||||
| { type: 'freightAgent.stockOutbound'; at: GridCoord; carType: CarType }
|
||||
@@ -110,6 +113,8 @@ export type RejectionCode =
|
||||
| 'NO_PENDING_DECISION'
|
||||
| 'NOT_UPGRADEABLE'
|
||||
| 'FACILITY_LOCKED'
|
||||
/** An Industry goes on a straight stub, never on the Running Track (sheet: "Placed" column). */
|
||||
| 'ON_RUNNING_TRACK'
|
||||
| 'NOT_IMPLEMENTED'
|
||||
| 'WRONG_INTENT'
|
||||
| 'NOT_A_GRADE'
|
||||
|
||||
+10
-19
@@ -90,6 +90,9 @@ function localOpsCandidates(s: GameState, player: PlayerIndex): Intent[] {
|
||||
}
|
||||
for (let n = 1; n <= tray.consist.length; n++) {
|
||||
out.push({ type: 'switch.dropCars', trayId, count: n });
|
||||
// Off the nose as well as the tail — the only way to get cars back off the front of a train
|
||||
// that shoved a cut, and therefore the only way an engine buried mid-train reaches an end.
|
||||
out.push({ type: 'switch.dropCars', trayId, count: n, fromNose: true });
|
||||
}
|
||||
// Small Yard: enumerating every permutation would explode, so offer the useful ones —
|
||||
// bringing each car to the droppable end, plus a full reversal. `check` validates any order,
|
||||
@@ -136,31 +139,19 @@ function localOpsCandidates(s: GameState, player: PlayerIndex): Intent[] {
|
||||
});
|
||||
for (const cardId of s.decks.hands.get(player) ?? []) {
|
||||
out.push({ type: 'card.play', cardId });
|
||||
// Gap 11 — orientation is chosen on placement, so every rotation is a distinct candidate.
|
||||
// Six is the widest set (turnouts); `check` discards the ones whose ports do not meet.
|
||||
const targets = s.cards.get(cardId)?.kind.kind === 'enhancement' ? attachments : placements;
|
||||
const kind = s.cards.get(cardId)?.kind;
|
||||
// Enhancements ATTACH to a card already down, so their candidates are the occupied cells.
|
||||
const targets = kind?.kind === 'enhancement' ? attachments : placements;
|
||||
// Orientation is chosen on placement, and a printed card turns but never flips, so the widest
|
||||
// variant set is TWO. Anything that is not track has a single orientation and needs one entry.
|
||||
const rotations = kind?.kind === 'track' ? variantsFor(kind.geometry, kind.hand).length : 1;
|
||||
for (const placement of targets) {
|
||||
// A printed card turns but does not flip, so the widest variant set is TWO. This offered six
|
||||
// per placement per card back when a curve could be laid at all four rotations; four of every
|
||||
// six were dead weight in an option list the bot scores in full.
|
||||
for (let variant = 0; variant < 2; variant++) {
|
||||
for (let variant = 0; variant < rotations; variant++) {
|
||||
out.push({ type: 'card.play', cardId, placement, variant });
|
||||
}
|
||||
}
|
||||
for (let slot = 0; slot < 3; slot++) out.push({ type: 'card.discard', cardId, toSlot: slot });
|
||||
}
|
||||
// Lay track from the personal supply — the only way a district grows now that track is not in
|
||||
// the deck.
|
||||
for (const [key, count] of s.turn.laidThisTurn ? [] : area.trackSupply) {
|
||||
if (count < 1) continue;
|
||||
const [geometry, hand] = key.split(':') as [TrackGeometry, Hand];
|
||||
for (const placement of placements) {
|
||||
// 0° and 180°. A straight is the same card either way; `check` discards the duplicate.
|
||||
for (let variant = 0; variant < variantsFor(geometry, hand).length; variant++) {
|
||||
out.push({ type: 'track.lay', geometry, hand, placement, variant });
|
||||
}
|
||||
}
|
||||
}
|
||||
// Mainline modifiers go on a Mainline card, not a grid cell, so `node` indexes division.nodes.
|
||||
for (const cardId of s.decks.hands.get(player) ?? []) {
|
||||
if (s.cards.get(cardId)?.kind.kind !== 'mainlineModifier') continue;
|
||||
|
||||
+13
-8
@@ -18,7 +18,7 @@ import {
|
||||
OFFICE_PROFILES,
|
||||
MAINLINE_PROFILES,
|
||||
mainlineProfile,
|
||||
TRACK_SUPPLY,
|
||||
TRACK_CARDS,
|
||||
ROLLING_STOCK_SUPPLY,
|
||||
STAGES_PER_DAY,
|
||||
TIMETABLED_TRAINS,
|
||||
@@ -90,7 +90,11 @@ export function buildDeck(mode: GameConfig['mode'] = 'competitive'): Card[] {
|
||||
for (let i = 0; i < c.copies; i++) push({ kind: 'action', key: c.key });
|
||||
}
|
||||
}
|
||||
// Track is NOT in the deck any more — it is a per-player supply (content.ts TRACK_SUPPLY).
|
||||
// Track is IN the deck, 104 cards of it — the single largest category, and the reason building a
|
||||
// district costs you the industry or train you did not draw instead.
|
||||
for (const t of TRACK_CARDS) {
|
||||
for (let i = 0; i < t.copiesInDeck; i++) push({ kind: 'track', geometry: t.geometry, hand: t.hand });
|
||||
}
|
||||
|
||||
return cards;
|
||||
}
|
||||
@@ -152,7 +156,6 @@ function buildOfficeArea(owner: PlayerIndex): OfficeArea {
|
||||
adOccupancy: [],
|
||||
heldAtLimits: [],
|
||||
dispatchUsedToday: [],
|
||||
trackSupply: new Map(TRACK_SUPPLY.map((t) => [`${t.geometry}:${t.hand}`, t.perPlayer])),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -254,11 +257,13 @@ export function createGame(opts: SetupOptions): GameState {
|
||||
hands.set(p, shuffled.slice(cursor, cursor + 3));
|
||||
cursor += 3;
|
||||
}
|
||||
const departments: (CardId | null)[] = [
|
||||
shuffled[cursor++] ?? null,
|
||||
shuffled[cursor++] ?? null,
|
||||
shuffled[cursor++] ?? null,
|
||||
];
|
||||
// §4.6-4.7 — three cards turned face up beside the deck. Each is the bottom of a Department pile
|
||||
// that grows as players discard onto it.
|
||||
const departments: CardId[][] = [[], [], []];
|
||||
for (const pile of departments) {
|
||||
const card = shuffled[cursor++];
|
||||
if (card) pile.push(card);
|
||||
}
|
||||
const homeOffice = shuffled.slice(cursor);
|
||||
|
||||
const redFlags = new Map<PlayerIndex, boolean>();
|
||||
|
||||
+40
-16
@@ -9,6 +9,7 @@
|
||||
import type {
|
||||
CarType,
|
||||
Direction,
|
||||
Hand,
|
||||
MainlineKind,
|
||||
FreightKind,
|
||||
GameLength,
|
||||
@@ -127,11 +128,6 @@ export type OfficeArea = {
|
||||
heldAtLimits: TrayId[];
|
||||
/** Dispatch bonuses spent this Day, by enhancement key — each is once a Day. */
|
||||
dispatchUsedToday: string[];
|
||||
/**
|
||||
* The player's personal track supply (26 pieces), keyed `geometry:hand`. Track is NOT in the
|
||||
* Home Office deck — it is laid from here.
|
||||
*/
|
||||
trackSupply: Map<string, number>;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -192,10 +188,24 @@ export function spaceOn(card: TrackCard): number {
|
||||
|
||||
export function isOperationalRail(card: TrackCard): boolean {
|
||||
if (!card.baseOperationalRail) return false;
|
||||
if (card.facility && card.facility.menAtWork.some((slot) => slot !== null)) return false;
|
||||
if (isLockedByWork(card)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* §9.3 — "While ANY loads are in the MEN | AT | WORK track, the industry's track is locked down for
|
||||
* safety reasons. It loses its status as Operational Rail. No cars can be picked up or dropped off,
|
||||
* and **no trains may occupy or move on it**."
|
||||
*
|
||||
* That last clause is stronger than losing Operational Rail status. A turnout is not Operational
|
||||
* Rail either, and a train runs straight through one — so "cannot stop here" and "cannot pass
|
||||
* through here" are different properties, and only a locked industry has both. Kept separate from
|
||||
* `isOperationalRail` for exactly that reason.
|
||||
*/
|
||||
export function isLockedByWork(card: TrackCard): boolean {
|
||||
return !!card.facility && card.facility.menAtWork.some((slot) => slot !== null);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Trains
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -223,7 +233,16 @@ export type CrewTray = {
|
||||
* the four-car limit (§A.4) is a limit on cars, not on the locomotive hauling them.
|
||||
*/
|
||||
engineAt: number;
|
||||
/** ORDERED, left-to-right. Max 4 including any caboose (§A.4). */
|
||||
/**
|
||||
* ORDERED NOSE FIRST: index 0 is the end nearest the front of the train, the last index is the
|
||||
* tail. Max 4 including any caboose (§A.4); the engine is not one of them.
|
||||
*
|
||||
* Both diagrams in Appendix A read this way. A train drawn `[<ENG][yellow][brown][blue][red]`
|
||||
* drops "red as he starts, then brown and blue", ending with only yellow — cars come off the TAIL,
|
||||
* which is the end of the array. And a train that picks cars up on its nose gets them "in the
|
||||
* order that they were in, pushing them into the Facility" — ahead of the engine, which is why
|
||||
* `engineAt` moves when it happens.
|
||||
*/
|
||||
consist: RollingStock[];
|
||||
direction: Direction;
|
||||
/**
|
||||
@@ -298,7 +317,8 @@ export type CardKind =
|
||||
| { kind: 'office'; tier: OfficeTier }
|
||||
| { kind: 'freightFacility'; facility: FreightKind }
|
||||
| { kind: 'modifier'; modifier: ModifierKind }
|
||||
| { kind: 'track'; geometry: TrackGeometry }
|
||||
/** Handedness is printed on the card: it is the diagonal the 45° leg lies on. */
|
||||
| { kind: 'track'; geometry: TrackGeometry; hand: Hand }
|
||||
/**
|
||||
* The four categories recovered from the design. They are in the deck so the composition is
|
||||
* right; their BEHAVIOUR is not implemented yet (implications.md §10 is still open), so
|
||||
@@ -315,8 +335,18 @@ export type Card = { id: CardId; kind: CardKind };
|
||||
export type Decks = {
|
||||
/** Face down. Order is SECRET — never projected to any client. */
|
||||
homeOffice: CardId[];
|
||||
/** Three face-up market slots fed from the deck (§2.6). */
|
||||
departments: (CardId | null)[];
|
||||
/**
|
||||
* THE THREE DEPARTMENT DECKS — shared by every player, and stacks rather than single slots.
|
||||
*
|
||||
* §6.2: a discard goes "face up ON TOP of one of the three Department slots", and a draw takes
|
||||
* "the TOP face-up card". Both phrases only mean anything if a Department is a pile, and modelling
|
||||
* them as one-card slots silently DESTROYED whatever was underneath — discarding onto an occupied
|
||||
* slot overwrote it, leaking cards out of a closed deck.
|
||||
*
|
||||
* Last element is the top of the pile: the card that is face up, the only one that may be drawn,
|
||||
* and the one a discarding player is choosing to offer or to bury.
|
||||
*/
|
||||
departments: CardId[][];
|
||||
/** Face up, so players can audit discards (§2.6). */
|
||||
salvageYard: CardId[];
|
||||
/** Private to the owner. Max 3, or 4 with a Red Flag. */
|
||||
@@ -412,11 +442,6 @@ export type TurnState = {
|
||||
option: 'switch' | 'draw' | 'freightAgent' | null;
|
||||
movesRemaining: number;
|
||||
drawnThisTurn: boolean;
|
||||
/**
|
||||
* Track was a CARD before it became a per-player supply, so it was naturally limited to one play
|
||||
* a turn. The supply has 26 pieces and nothing else bounds it, so keep that limit explicitly.
|
||||
*/
|
||||
laidThisTurn: boolean;
|
||||
freightAgentUsed: boolean;
|
||||
/** Set when the actor finishes; the phase driver then moves to the next player. */
|
||||
done: boolean;
|
||||
@@ -427,7 +452,6 @@ export function freshTurn(moves: number): TurnState {
|
||||
option: null,
|
||||
movesRemaining: moves,
|
||||
drawnThisTurn: false,
|
||||
laidThisTurn: false,
|
||||
freightAgentUsed: false,
|
||||
done: false,
|
||||
};
|
||||
|
||||
+7
-1
@@ -34,7 +34,7 @@ import type {
|
||||
TrackArc,
|
||||
TurnoutOrientation,
|
||||
} from './state.ts';
|
||||
import { carsOn, coordKey, isOperationalRail, spaceOn } from './state.ts';
|
||||
import { carsOn, coordKey, isLockedByWork, isOperationalRail, spaceOn } from './state.ts';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Ports and geometry
|
||||
@@ -357,6 +357,12 @@ export function reachableDestinations(
|
||||
|
||||
if (!hasPort(card, node.entry)) continue;
|
||||
|
||||
// §9.3 — a locked industry may not be occupied OR MOVED ON. Losing Operational Rail status only
|
||||
// stops a train FINISHING here; a turnout is not Operational Rail either and trains run through
|
||||
// one all day. Without this a crew rolled straight over a locked industry, and coupled the cars
|
||||
// spotted on it on the way past — the two things the safety lockout exists to prevent.
|
||||
if (isLockedByWork(card)) continue;
|
||||
|
||||
// Mandatory coupling. Rejecting rather than truncating is deliberate: a move that would
|
||||
// overfill the tray is illegal, not a move that picks up fewer cars.
|
||||
const couples = [...node.couples, ...carsOn(card)];
|
||||
|
||||
Reference in New Issue
Block a user