v0.6.2 — an Extra starts where you put it, a train card is never discarded
Three more from the v0.4.9e gameplay-testing round, filed as Gitea issues, plus two bugs found underneath them. Gitea#2 is diagnosed but NOT fixed: it needs a ruling, and the reasoning is in TODO.md under Play Balance. GITEA#4 — AN EXTRA STARTS WHERE THE PLAYER PUTS IT. Only one Division Point was ever offered, chosen by number parity. The number no longer decides an Extra's direction — the start does, which supersedes the recorded ruling that "the number decides, like everything else on the timetable". The two cannot both hold: an odd, westbound Extra placed at the WEST end would leave the Division on its first move having crossed nothing, and be paid for the run. Either end now runs the train away from itself; at an Interchange or a Control Point the player picks the direction. The Interchange start is a YARD, off the running line, which is what makes the Superintendent clause work: placing it can never force a collision, a guaranteed one holds it there for another Stage, and a potential one is the Superintendent's to rule on — exactly evaluateClearance's `blocked` and `ask`, so nothing new decides collisions. Where an Extra may start is now a house rule (divisionPointsOnly / ownOffice / anyOffice, defaulting to what the engine already did). The legacy `atSeat` intent field still replays as it always meant. FOUND UNDERNEATH IT: an Extra started away from a Division Point ran empty. isBeingMadeUp tested position alone, so the Control Point start has been shipping since it was added with a train that could never be given a consist. Found by playing it, not by the tests, which had only asserted where the tray landed. FOUND UNDERNEATH IT: collide left the wrecks on the card. Destroyed trains kept their Transit entries, and evaluateClearance counts every transit as an occupant, so one rear-end collision permanently poisoned that Mainline card for every later train. THE MAINLINE CARDS WERE ROLLED, NOT DEALT — drawn from the nine types with replacement, so a Division could hold two Interchanges and Plains carried the weight of a card printed once. "An Extra may start at the Interchange if one is on the board" only reads as a rule if the board holds at most one. Now dealt from the printed deck without replacement, verified over 1600 deals. This re-deals every seed: the published replays were re-recorded, and the saved games in docs/ are retired too — two of those were already dead before this release and nobody had noticed. GITEA#6 — A TRAIN CARD IS NEVER DISCARDED, Timetabled and Extra alike. The forced play needed no mechanism: nothing discardable plus a hand over the limit leaves exactly one legal way to end the turn, and playing a train is unconditionally legal, so the corner cannot trap anyone. The bot needed no rule either. 400/400 games finished, revenue unmoved, trains scheduled 1.2 -> 1.3. The player is told on the card and on the button. GITEA#7 — COACH COUNTS. 1/2 Crack Limited 3 -> 2, 5/6 The Sparrow 2 -> 3. A change to the cards, so Trains3.pdf and the transcription keep the original numbers with a footnote while content.ts and the Home Deck reference carry what the game plays. CONTENT.TS COMMENT PASS — no data changed, only comments. Four were factually wrong, including an office table naming counts doubled long ago and a pointer to a DEALT_DECK_SIZE that has never existed. Every Enhancement row cited its implementation by line number and every citation had rotted; they name functions now. Card counts came out of the comments, since they move with play balance; source-sheet figures and dated measurements stayed. TODO.md gains an item for a card reference generated from content.ts, in six sections, so the documentation cannot disagree with the game. 715 tests pass, tsc clean, site builds.
This commit is contained in:
@@ -456,6 +456,9 @@ function enterMainline(
|
||||
);
|
||||
node.transits.push({ tray: id, stagesRemaining: stages, stagesTotal: stages, direction: tray.direction });
|
||||
tray.position = { at: 'mainline', index };
|
||||
// It is running now, so it is no longer being assembled (state.ts). A train at a Division Point
|
||||
// needs no equivalent: leaving one changes its position, which is what that case reads.
|
||||
delete tray.beingMadeUp;
|
||||
|
||||
/**
|
||||
* OUT OF THE DISTRICT, AND THE SPUR PORT GOES WITH IT.
|
||||
@@ -653,6 +656,43 @@ function moveTrain(s: GameState, id: TrayId, tray: CrewTray, events: GameEvent[]
|
||||
const node = s.division.nodes[index];
|
||||
if (!node || node.kind !== 'mainline') return 'held';
|
||||
|
||||
/**
|
||||
* §7/§8.1 — AN EXTRA HIGHBALLING OUT OF THE INTERCHANGE'S YARD.
|
||||
*
|
||||
* Standing in `holding` rather than crossing in `transits` (state.ts), which is the position an
|
||||
* Extra started at an Interchange begins in. It leaves exactly the way a train at a Division
|
||||
* Point does — clearance first, then onto the running line — except that the card it enters is
|
||||
* the one it is already standing beside rather than the next one along.
|
||||
*
|
||||
* That reuse is the whole point of modelling the yard separately: Jesse's rule is "a guaranteed
|
||||
* collision holds it at the Interchange for another Stage and it tries again; a potential one is
|
||||
* the Superintendent's to hold", and those are precisely `evaluateClearance`'s `blocked` and
|
||||
* `ask`. Nothing new decides collisions here.
|
||||
*/
|
||||
if (node.holding?.includes(id)) {
|
||||
const clearance = evaluateClearance(s, id, tray, index, events);
|
||||
if (clearance === 'blocked') {
|
||||
events.push({
|
||||
type: 'trainHeld',
|
||||
trainNumber: tray.trainNumber ?? 0,
|
||||
reason: 'held in the Interchange — the Subdivision ahead is occupied',
|
||||
});
|
||||
return 'held';
|
||||
}
|
||||
if (clearance === 'ask') return 'needsClearance';
|
||||
|
||||
node.holding = node.holding.filter((t) => t !== id);
|
||||
enterMainline(s, node, id, tray, index);
|
||||
events.push({
|
||||
type: 'trainHighballed',
|
||||
trainNumber: tray.trainNumber ?? 0,
|
||||
from: 'the Interchange',
|
||||
to: 'the Mainline',
|
||||
why: 'it was made up in the yard and the Subdivision was clear, so its run begins',
|
||||
});
|
||||
return 'moved';
|
||||
}
|
||||
|
||||
const transit = node.transits.find((t) => t.tray === id);
|
||||
if (!transit) return 'held';
|
||||
|
||||
@@ -967,6 +1007,25 @@ function collide(
|
||||
}
|
||||
s.trays.delete(id);
|
||||
s.freeTrays.push(id);
|
||||
/**
|
||||
* TAKE THE WRECK OFF THE CARD.
|
||||
*
|
||||
* Nothing did. `s.trays.delete` removed the train and left its `Transit` sitting on the Mainline
|
||||
* card it died on, and `evaluateClearance` counts every transit as an occupant — so a rear-end
|
||||
* collision (the caller at "ran into the train ahead") permanently poisoned that card: every
|
||||
* later train was either held against a ghost or put to the Superintendent about one. The only
|
||||
* other place a transit is removed is a train rolling off the far end, which a destroyed train
|
||||
* never does.
|
||||
*
|
||||
* Found while adding the Interchange start, which clears onto the running line through that
|
||||
* same occupant list.
|
||||
*/
|
||||
for (const n of s.division.nodes) {
|
||||
if (n.kind !== 'mainline') continue;
|
||||
n.transits = n.transits.filter((t) => t.tray !== id);
|
||||
if (n.holding) n.holding = n.holding.filter((t) => t !== id);
|
||||
if (n.redFlagged) n.redFlagged = n.redFlagged.filter((t) => t !== id);
|
||||
}
|
||||
}
|
||||
|
||||
if (lost.length > 0) {
|
||||
|
||||
+175
-33
@@ -33,9 +33,9 @@ import {
|
||||
officeProfile,
|
||||
trainProfile,
|
||||
} from './content.ts';
|
||||
import type { CarType, FreightKind, Hand, MainlineKind, ModifierKind, ModifierProfile, TrackGeometry, TrainRules } from './content.ts';
|
||||
import type { CarType, Direction, FreightKind, Hand, MainlineKind, ModifierKind, ModifierProfile, TrackGeometry, TrainRules } from './content.ts';
|
||||
import type { GameEvent } from './events.ts';
|
||||
import type { Intent, RejectionCode } from './intents.ts';
|
||||
import type { ExtraStart, Intent, RejectionCode } from './intents.ts';
|
||||
import type {
|
||||
CardId,
|
||||
CrewTray,
|
||||
@@ -416,6 +416,83 @@ export function canDetrain(s: GameState, player: PlayerIndex, at: GridCoord, tra
|
||||
return passengerWork(s, player, 'detrain', trayId) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Timetabled or Extra train card (§6.2, Gitea#6) — the one place that decides what "a train card"
|
||||
* means, so the rule, the UI's reason text and any test all ask the same question.
|
||||
*/
|
||||
export function isTrainCard(s: GameState, cardId: CardId): boolean {
|
||||
const kind = s.cards.get(cardId)?.kind.kind;
|
||||
return kind === 'timetabledTrain' || kind === 'extraTrain';
|
||||
}
|
||||
|
||||
/**
|
||||
* WHERE AN EXTRA STARTS AND WHICH WAY IT RUNS — the one answer `check`, `execute` and the reducer
|
||||
* all use, so a placement can never be checked against one square and made on another.
|
||||
*
|
||||
* §7 lets the player who played the card choose the start, and Jesse's ruling makes the start
|
||||
* decide the direction rather than the number (`runDirection`'s comment carries the supersession):
|
||||
*
|
||||
* - a DIVISION POINT runs the train away from itself — the west end runs east, the east end west.
|
||||
* `direction` on the intent is ignored rather than refused, because there is only one answer;
|
||||
* - an INTERCHANGE or a CONTROL POINT sits in the middle of the railroad, where both ways are real
|
||||
* runs, so the intent must say which.
|
||||
*
|
||||
* Which of those are on offer is the `extraStart` house rule. The two that belong to nobody — the
|
||||
* Division Points and the Interchange — are always available; an Office is a seat's own ground and
|
||||
* is gated, to `ownOffice` (the player who played the card) or `anyOffice`.
|
||||
*
|
||||
* Returns a refusal code rather than throwing, so `check` can hand it straight back.
|
||||
*/
|
||||
export function resolveExtraStart(
|
||||
s: GameState,
|
||||
player: PlayerIndex,
|
||||
i: { trainNumber: number; atSeat?: SeatIndex | null; start?: ExtraStart; direction?: Direction },
|
||||
): { at: ExtraStart; direction: Direction } | RejectionCode {
|
||||
/**
|
||||
* A save written before the choice existed. `atSeat` null meant the Division Point the NUMBER
|
||||
* sent the train to, a seat meant that Office, and both ran in the number's direction — so that
|
||||
* is what these replay as, whatever the rules say today.
|
||||
*/
|
||||
if (!i.start) {
|
||||
const direction = runDirection(i.trainNumber);
|
||||
if (i.atSeat === null || i.atSeat === undefined) {
|
||||
return { at: { kind: 'divisionPoint', side: startingDivisionPoint(i.trainNumber) }, direction };
|
||||
}
|
||||
return { at: { kind: 'office', seat: i.atSeat }, direction };
|
||||
}
|
||||
|
||||
const start = i.start;
|
||||
if (start.kind === 'divisionPoint') {
|
||||
if (!s.division.nodes.some((n) => n.kind === 'divisionPoint' && n.side === start.side)) {
|
||||
return 'NO_SUCH_DIVISION_POINT';
|
||||
}
|
||||
// Away from the end it is standing at. Nothing else is a run.
|
||||
return { at: start, direction: start.side === 'west' ? 'east' : 'west' };
|
||||
}
|
||||
|
||||
if (i.direction === undefined) return 'NO_DIRECTION_CHOSEN';
|
||||
|
||||
if (start.kind === 'mainline') {
|
||||
const node = s.division.nodes[start.node];
|
||||
if (!node || node.kind !== 'mainline') return 'NO_SUCH_CARD';
|
||||
// The Interchange is the one Mainline card an Extra may be made up on — it is the one with a
|
||||
// yard. `sortsCars` is what the card prints and the only thing that distinguishes it.
|
||||
if (!mainlineProfile(node.card).sortsCars) return 'NOT_AN_INTERCHANGE';
|
||||
return { at: start, direction: i.direction };
|
||||
}
|
||||
|
||||
const rule = houseRules(s.config).extraStart;
|
||||
if (rule === 'divisionPointsOnly') return 'OFFICE_STARTS_NOT_ALLOWED';
|
||||
if (rule === 'ownOffice' && start.seat !== seatOf(s, player)) return 'NOT_YOUR_OFFICE';
|
||||
const area = s.officeAreas.get(start.seat);
|
||||
if (!area) return 'NO_SUCH_FACILITY';
|
||||
// A Control Point is any Office above a Whistle Post (§8). A Whistle Post is not one, which is
|
||||
// the whole reason upgrading buys a place for an Extra to start — and no setting of the house
|
||||
// rule lets one in.
|
||||
if (!officeProfile(area.tier).isControlPoint) return 'NOT_A_CONTROL_POINT';
|
||||
return { at: start, direction: i.direction };
|
||||
}
|
||||
|
||||
/**
|
||||
* WHICH TRAIN, AND WHICH COACH ON IT — the one answer `check`, `execute` and the reducer all use.
|
||||
*
|
||||
@@ -803,11 +880,31 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
return checkPlay(s, player, i.cardId, i.placement, i.variant, i.node);
|
||||
}
|
||||
|
||||
/**
|
||||
* §6.2, AS RULED BY JESSE (Gitea#6): A TRAIN CARD MAY NOT BE DISCARDED. EVER.
|
||||
*
|
||||
* It may be held for as many Stages and Days as the player likes — the hand limit is the only
|
||||
* pressure on it — but it never goes onto a Department pile. The consequence is the point of the
|
||||
* rule and needs no machinery of its own: a player holding four train cards has nothing
|
||||
* discardable, and `draw.end` already refuses while the hand is over the limit, so the only way
|
||||
* to conclude the turn is to PLAY one. Playing a train card is unconditionally legal (see
|
||||
* `card.play`'s `timetabledTrain` case, which refuses only a board placement), so that corner
|
||||
* can never lock a player in.
|
||||
*
|
||||
* Extras count. They are trains — Jesse's ruling in the same breath — even though an Extra runs
|
||||
* once and ends in the Salvage Yard while a Timetabled card joins the timetable for the rest of
|
||||
* the game.
|
||||
*
|
||||
* `legal.ts` enumerates candidates and filters them through here, so the discard option simply
|
||||
* stops being offered for these cards; the bot needs no separate rule and already reaches for
|
||||
* `card.play` before it reaches for a discard.
|
||||
*/
|
||||
case 'card.discard': {
|
||||
if (!inPhase(s, 'localOps')) return 'WRONG_PHASE';
|
||||
const hand = s.decks.hands.get(player) ?? [];
|
||||
if (!hand.includes(i.cardId)) return 'CARD_NOT_IN_HAND';
|
||||
if (i.toSlot < 0 || i.toSlot > 2) return 'SLOT_EMPTY';
|
||||
if (isTrainCard(s, i.cardId)) return 'TRAINS_ARE_NEVER_DISCARDED';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -826,8 +923,9 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (rule.gradeOnly && mainlineProfile(node.card).speed.kind !== 'grade') return 'NOT_A_GRADE';
|
||||
if (rule.requiresOnCard && !on.includes(rule.requiresOnCard)) return 'NOT_CONNECTED';
|
||||
// "Not while a train is on it" — realigning under a moving train is exactly the situation the
|
||||
// restriction exists to prevent.
|
||||
if (node.transits.length > 0) return 'TRAIN_ON_CARD';
|
||||
// restriction exists to prevent. A train standing in the Interchange's yard counts: it is on
|
||||
// the card, and it is about to pull out onto the very rail being relaid.
|
||||
if (node.transits.length > 0 || (node.holding?.length ?? 0) > 0) return 'TRAIN_ON_CARD';
|
||||
if (rule.key === 'realignment' && !REALIGNMENTS.some((r) => r.from === node.card)) {
|
||||
return 'NO_PLACEMENT';
|
||||
}
|
||||
@@ -954,12 +1052,16 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (!inPhase(s, 'newTrain')) return 'WRONG_PHASE';
|
||||
if (!s.pendingExtras.includes(i.trainNumber)) return 'NO_EXTRA_PENDING';
|
||||
if (s.freeTrays.length === 0) return 'NO_FREE_TRAY';
|
||||
if (i.atSeat === null) return null;
|
||||
// A Control Point is any Office above a Whistle Post (§8). A Whistle Post is not one, which is
|
||||
// the whole reason upgrading buys a place for an Extra to start.
|
||||
const area = s.officeAreas.get(i.atSeat);
|
||||
if (!area) return 'NO_SUCH_FACILITY';
|
||||
if (!officeProfile(area.tier).isControlPoint) return 'NOT_A_CONTROL_POINT';
|
||||
const where = resolveExtraStart(s, player, i);
|
||||
if (typeof where === 'string') return where;
|
||||
if (where.at.kind === 'divisionPoint') return null;
|
||||
if (where.at.kind === 'mainline') {
|
||||
// Nothing to refuse. The train is made up in the Interchange's yard, off the running line,
|
||||
// so however busy the card is this cannot be the collision §7 says it must not force. What
|
||||
// it may not do is get OUT — that is §8.1's question, asked at the Mainline Phase.
|
||||
return null;
|
||||
}
|
||||
const area = s.officeAreas.get(where.at.seat)!;
|
||||
// It still has to fit: an Extra starting here takes an A/D track like any other arrival.
|
||||
return area.adOccupancy.length >= officeProfile(area.tier).adTracks ? 'NO_FREE_AD_TRACK' : null;
|
||||
}
|
||||
@@ -1637,8 +1739,13 @@ function execute(s: GameState, player: PlayerIndex, i: Intent): GameEvent[] {
|
||||
return [{ type: 'facilityUnjammed', player, at: i.at, from: i.from, stock }];
|
||||
}
|
||||
|
||||
case 'newTrain.startExtra':
|
||||
return [{ type: 'extraStarted', player, trainNumber: i.trainNumber, atSeat: i.atSeat }];
|
||||
case 'newTrain.startExtra': {
|
||||
// `check` has already accepted this, so the resolve cannot fail here.
|
||||
const where = resolveExtraStart(s, player, i) as { at: ExtraStart; direction: Direction };
|
||||
return [
|
||||
{ type: 'extraStarted', player, trainNumber: i.trainNumber, at: where.at, direction: where.direction },
|
||||
];
|
||||
}
|
||||
|
||||
case 'newTrain.placeCar':
|
||||
return [
|
||||
@@ -2171,29 +2278,57 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* THE THREE PLACES AN EXTRA MAY BE MADE UP (§7, Jesse's ruling) — and all three leave it
|
||||
* STANDING somewhere it must later highball out of, never already running.
|
||||
*/
|
||||
case 'extraStarted': {
|
||||
const trayId = s.freeTrays.pop()!;
|
||||
s.pendingExtras = s.pendingExtras.filter((n) => n !== e.trainNumber);
|
||||
const direction = runDirection(e.trainNumber);
|
||||
if (e.atSeat === null) {
|
||||
const side = startingDivisionPoint(e.trainNumber);
|
||||
s.trays.set(trayId, {
|
||||
id: trayId, trainNumber: e.trainNumber, trainIsExtra: true, engineAt: 0, consist: [],
|
||||
direction, position: { at: 'divisionPoint', side }, movesUsed: 0,
|
||||
});
|
||||
const { direction } = e;
|
||||
const base = {
|
||||
id: trayId, trainNumber: e.trainNumber, trainIsExtra: true, engineAt: 0,
|
||||
consist: [] as RollingStock[], direction, movesUsed: 0,
|
||||
};
|
||||
// Which way the tray physically points, for the cards it will pick up. A Division Point start
|
||||
// does not set it: those trays have never carried a facing and `enterMainline` does not read
|
||||
// one, so writing it here would be inventing state the DP path has always done without.
|
||||
const facing = { facing: direction === 'west' ? ('w' as const) : ('e' as const),
|
||||
railFacing: direction === 'west' ? ('w' as const) : ('e' as const) };
|
||||
|
||||
if (e.at.kind === 'divisionPoint') {
|
||||
const side = e.at.side;
|
||||
s.trays.set(trayId, { ...base, position: { at: 'divisionPoint', side } });
|
||||
const dp = s.division.nodes.find((n) => n.kind === 'divisionPoint' && n.side === side);
|
||||
if (dp?.kind === 'divisionPoint') dp.holding.push(trayId);
|
||||
} else {
|
||||
// Starting at a Control Point: it stands on the Office card and takes an A/D track, exactly
|
||||
// as though it had arrived there.
|
||||
const area = areaAtSeat(s, e.atSeat);
|
||||
s.trays.set(trayId, {
|
||||
id: trayId, trainNumber: e.trainNumber, trainIsExtra: true, engineAt: 0, consist: [],
|
||||
direction, facing: direction === 'west' ? 'w' : 'e', railFacing: direction === 'west' ? 'w' : 'e',
|
||||
position: { at: 'grid', seat: e.atSeat, coord: area.officeCoord }, movesUsed: 0,
|
||||
});
|
||||
area.adOccupancy.push(trayId);
|
||||
break;
|
||||
}
|
||||
|
||||
if (e.at.kind === 'mainline') {
|
||||
/**
|
||||
* IN THE INTERCHANGE'S YARD, NOT ON THE MAINLINE — the distinction §7 turns on.
|
||||
*
|
||||
* `holding` rather than `transits`, so the card can be nose to tail with traffic and this
|
||||
* placement still forces no collision. It joins the running line at a later Mainline Phase
|
||||
* through `evaluateClearance`, which is what gives the Superintendent the hold Jesse asked
|
||||
* for: an automatic one against a facing train, a ruling against a following one.
|
||||
*/
|
||||
const node = s.division.nodes[e.at.node];
|
||||
s.trays.set(trayId, {
|
||||
...base, ...facing, beingMadeUp: true, position: { at: 'mainline', index: e.at.node },
|
||||
});
|
||||
if (node?.kind === 'mainline') (node.holding ??= []).push(trayId);
|
||||
break;
|
||||
}
|
||||
|
||||
// Starting at a Control Point: it stands on the Office card and takes an A/D track, exactly
|
||||
// as though it had arrived there.
|
||||
const area = areaAtSeat(s, e.at.seat);
|
||||
s.trays.set(trayId, {
|
||||
...base, ...facing, beingMadeUp: true,
|
||||
position: { at: 'grid', seat: e.at.seat, coord: area.officeCoord },
|
||||
});
|
||||
area.adOccupancy.push(trayId);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2765,9 +2900,16 @@ export function acceptsCar(tray: CrewTray, carType: CarType): boolean {
|
||||
/**
|
||||
* §7 — IS THIS TRAY THE ONE BEING MADE UP?
|
||||
*
|
||||
* A train is made up where it is built, standing at a Division Point, and only until its consist
|
||||
* matches its card. Everything else with a Crew Tray — a train working your district, a train
|
||||
* halfway across the Division — is running, not being assembled.
|
||||
* A train is made up where it is built and only until its consist matches its card. Everything else
|
||||
* with a Crew Tray — a train working your district, a train halfway across the Division — is
|
||||
* running, not being assembled.
|
||||
*
|
||||
* WHERE that is used to be the whole test: "standing at a Division Point". True while a Division
|
||||
* Point was the only place to build one, and wrong once an Extra could be started at a Control Point
|
||||
* or in an Interchange's yard (§7) — those trains were never offered a car and ran empty. The extra
|
||||
* clause is `beingMadeUp` (state.ts), a flag set on exactly those trays and cleared when they start
|
||||
* running, rather than a second positional rule: a train STANDING at an Office is usually one that
|
||||
* arrived, and must not be fillable from the yard.
|
||||
*
|
||||
* SHARED with the New Train Phase, which uses it to decide whether to stop and ask. It has to be:
|
||||
* `check` accepted any tray with room in its consist, so during a New Train Phase the Division Yard
|
||||
@@ -2777,7 +2919,7 @@ export function acceptsCar(tray: CrewTray, carType: CarType): boolean {
|
||||
*/
|
||||
export function isBeingMadeUp(tray: CrewTray): boolean {
|
||||
if (tray.trainNumber === null) return false;
|
||||
if (tray.position.at !== 'divisionPoint') return false;
|
||||
if (tray.position.at !== 'divisionPoint' && !tray.beingMadeUp) return false;
|
||||
const profile = trainProfile(tray.trainNumber, tray.trainIsExtra);
|
||||
if (!profile) return false;
|
||||
return tray.consist.length < consistSize(profile.consist);
|
||||
|
||||
+173
-74
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* TRANSCRIBED FROM THE RECOVERED DESIGN FILES (2026-07-30):
|
||||
* docs/Deck cards2.xlsx — the complete card list and counts
|
||||
* docs/Trains3.pdf — all 22 train cards
|
||||
* docs/Mainline Cards.pdf — the ten Mainline card types
|
||||
* docs/Trains3.pdf — the train cards
|
||||
* docs/Mainline Cards.pdf — the Mainline card types, and the two Division Points
|
||||
* docs/tracks.png — card art
|
||||
*
|
||||
* This replaced an invented 52-card placeholder. See docs/rules/implications.md for what changed
|
||||
@@ -60,13 +60,17 @@ export type TrackProfile = {
|
||||
/**
|
||||
* TRACK IS IN THE HOME OFFICE DECK, and is drawn and played like any other card.
|
||||
*
|
||||
* 96 dealt of the sheet's 104 (column B of `docs/Deck cards2.xlsx`) — the 8 sharp curves are dealt
|
||||
* zero, see below. 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.
|
||||
* Every row's dealt count is in `copiesInDeck` below; the sharp curves are dealt zero, see below.
|
||||
* How many that comes to is `TRACK_IN_DECK`, computed rather than written down — it moves with
|
||||
* balance work, so a number in this comment would be wrong before long.
|
||||
*
|
||||
* An earlier reading made track a separate per-player supply, 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 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. Those are figures
|
||||
* from `docs/Deck cards2.xlsx`, a fixed document, and stay here as the audit trail for the
|
||||
* transcription — they are not claims about what the game deals today.
|
||||
*
|
||||
* 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
|
||||
@@ -89,10 +93,10 @@ export const TRACK_CARDS: readonly TrackProfile[] = [
|
||||
* SHARP CURVES ARE DEALT ZERO COPIES — Jesse's call, and the same treatment as Poling.
|
||||
*
|
||||
* The only thing that made them different from an ordinary curve was `moveCost: 2`, and nothing
|
||||
* ever charged it: every switching move costs exactly 1, hard-coded. So the 8 cards in the deck
|
||||
* were geometric duplicates of the curves, taking 8 draws from a deck the rebalance already thinks
|
||||
* is too diluted. They come out rather than having the Move cost built, because a per-card movement
|
||||
* cost is a change to the Move model and the rebalance can wait.
|
||||
* ever charged it: every switching move costs exactly 1, hard-coded. So they were geometric
|
||||
* duplicates of the curves, taking draws from a deck the rebalance already thinks is too diluted.
|
||||
* They come out rather than having the Move cost built, because a per-card movement cost is a
|
||||
* change to the Move model and the rebalance can wait.
|
||||
*
|
||||
* The rows stay in the catalogue at zero, exactly as Poling does, so the design is still visible
|
||||
* and the geometry still works if they are ever dealt again.
|
||||
@@ -103,10 +107,10 @@ export const TRACK_CARDS: readonly TrackProfile[] = [
|
||||
{ geometry: 'turnout', hand: 'left', name: 'Turnout (left)', copiesInDeck: 16, isOperationalRail: false, moveCost: 1 },
|
||||
];
|
||||
|
||||
/** 96 — the sheet's "Total track" of 104, less the 8 sharp curves now dealt at zero. */
|
||||
/** Summed from `copiesInDeck` above, never written down — it moves whenever the deck is retuned. */
|
||||
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. */
|
||||
/** Start cards, placed at setup and never shuffled. */
|
||||
export const WHISTLE_POST_SUPPLY = 4;
|
||||
export const LIMITS_SUPPLY = 8;
|
||||
|
||||
@@ -116,7 +120,7 @@ export function trackProfile(geometry: TrackGeometry, hand: Hand): TrackProfile
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Offices — Depot 4, Station 2, Terminal 1
|
||||
// Offices — the upgrade ladder: Whistle Post, Depot, Station, Terminal
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type OfficeProfile = {
|
||||
@@ -139,13 +143,12 @@ export type OfficeProfile = {
|
||||
* passenger modifier cards (Waiting Area, Restaurant, Hotel).
|
||||
*/
|
||||
/**
|
||||
* Office cards. `copiesInDeck` was **doubled** (Depot 4→8, Station 2→4, Terminal 1→2) — Q12.
|
||||
* Office cards. Every tier's `copiesInDeck` was **doubled** against the recovered design — Q12.
|
||||
*
|
||||
* Players always start at a Whistle Post, which has ONE A/D track, so a second arrival is an
|
||||
* automatic collision (§8.3, Gap 2a). Measured at the original density, 25 of 100 games never drew
|
||||
* a Depot and never escaped: they averaged **−6.0** revenue against **−0.4** for games that
|
||||
* upgraded at least once, and 25 of 26 collisions happened at Whistle Post. Escaping needed one of
|
||||
* 4 Depot cards in 111, roughly a 59% chance across a game's draws.
|
||||
* upgraded at least once, and 25 of 26 collisions happened at Whistle Post.
|
||||
*
|
||||
* Upgrades are strictly sequential (Gap 3b, no skipping), so Station and Terminal are rarer than
|
||||
* their raw counts imply — Terminal needs all three cards in order. Station and Terminal were
|
||||
@@ -153,9 +156,10 @@ export type OfficeProfile = {
|
||||
*
|
||||
* PROVISIONAL — re-evaluate. This was chosen to remove a 25% chance of an unwinnable opening deal,
|
||||
* not from the recovered design, and it is a blunt instrument: it lifts the whole office ladder and
|
||||
* dilutes every other category slightly (deck 133 → 140). Revisit once the victory target is
|
||||
* settled and freight is carrying its intended share; the right answer may instead be fewer
|
||||
* Terminals, a cheaper first upgrade, or more A/D capacity at Whistle Post.
|
||||
* dilutes every other category slightly. Revisit once the victory target is settled and freight is
|
||||
* carrying its intended share; the right answer may instead be fewer Terminals, a cheaper first
|
||||
* upgrade, or more A/D capacity at Whistle Post. The counts themselves are in the rows below, which
|
||||
* is the only place they should be read from.
|
||||
*/
|
||||
export const OFFICE_PROFILES: readonly OfficeProfile[] = [
|
||||
{ tier: 'whistlePost', name: 'Whistle Post', isControlPoint: false, isPassengerFacility: false, adTracks: 1, porters: 0, passengerOut: 0, passengerIn: 0, copiesInDeck: 0 },
|
||||
@@ -199,13 +203,14 @@ export type IndustryProfile = {
|
||||
|
||||
/**
|
||||
* Industry density (Gap 12). The recovered sheet lists 9 industries in a 115-card deck; the
|
||||
* prototype ran 10 in 52. At 9-in-115 a game saw 1.6 Freight Facilities, freight was 10% of gross
|
||||
* revenue, and `carsCoupled` fired 4 times per 100 games — the freight loop, which is the point of
|
||||
* the game, effectively never ran.
|
||||
* prototype ran 10 in 52. At the sheet's density a game saw 1.6 Freight Facilities, freight was 10%
|
||||
* of gross revenue, and `carsCoupled` fired 4 times per 100 games — the freight loop, which is the
|
||||
* point of the game, effectively never ran.
|
||||
*
|
||||
* Each industry's `copies` is TRIPLED, giving 27 in 133. That restores roughly the prototype's
|
||||
* Each industry's `copies` is TRIPLED against the sheet, which restores roughly the prototype's
|
||||
* 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.
|
||||
* lockout structure are unchanged, because every kind scales by the same factor. The multiplier is
|
||||
* the decision; the resulting totals are in the rows below and move with every retune.
|
||||
*/
|
||||
/**
|
||||
* LOCKOUTS, from the sheet's "Lockouts" column verbatim:
|
||||
@@ -287,7 +292,7 @@ export function industryProfile(kind: FreightKind): IndustryProfile {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Modifiers — 17 industry + 6 passenger, each tied to specific hosts
|
||||
// Modifiers — passenger and industry, each tied to specific hosts
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type ModifierKind =
|
||||
@@ -356,7 +361,7 @@ export function modifierProfile(kind: ModifierKind): ModifierProfile {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Trains — 22 cards, named, with speed class and individual rules
|
||||
// Trains — named, with a speed class and individual printed rules
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type TrainSpeed = 'fast' | 'slow';
|
||||
@@ -420,11 +425,18 @@ function pair(odd: number, name: string, speed: TrainSpeed, consist: ConsistSpec
|
||||
}
|
||||
|
||||
export const TIMETABLED_TRAINS: readonly TrainProfile[] = [
|
||||
...pair(1, 'Crack Limited', 'fast', { freight: 0, coach: 3, caboose: 0 },
|
||||
/**
|
||||
* COACH COUNTS ON 1/2 AND 5/6 WERE SWAPPED BY JESSE (Gitea#7, v0.4.9e playtest): the Crack Limited
|
||||
* drops from three coaches to two, and The Sparrow rises from two to three. A change to the card
|
||||
* faces themselves, not a transcription fix — `Trains3.pdf` and the tables that transcribe it
|
||||
* still print the old numbers, so `docs/rules/card-reference.md` is the place that now carries
|
||||
* what the cards say.
|
||||
*/
|
||||
...pair(1, 'Crack Limited', 'fast', { freight: 0, coach: 2, caboose: 0 },
|
||||
{ terminalsOnly: true, noSwitching: true, expedite: true, note: 'Stop at Terminals only.' }),
|
||||
...pair(3, 'Express', 'fast', { freight: 2, coach: 0, caboose: 0 },
|
||||
{ oneFreightPerLocation: true, expedite: true, note: 'May drop or pick up one freight car at every location.' }),
|
||||
...pair(5, 'The Sparrow', 'fast', { freight: 0, coach: 2, caboose: 0 },
|
||||
...pair(5, 'The Sparrow', 'fast', { freight: 0, coach: 3, caboose: 0 },
|
||||
{ noSwitching: true, expedite: true }),
|
||||
...pair(7, 'Local', 'slow', { freight: 1, coach: 1, caboose: 0 },
|
||||
{ coachStaysOnStationTrack: true, note: 'Maximum one freight, one coach.' }),
|
||||
@@ -452,11 +464,18 @@ export const EXTRA_TRAINS: readonly TrainProfile[] = [
|
||||
export const ALL_TRAINS: readonly TrainProfile[] = [...TIMETABLED_TRAINS, ...EXTRA_TRAINS];
|
||||
|
||||
/**
|
||||
* §2.3 — ODD RUNS WEST, EVEN RUNS EAST. The number is the direction, for an Extra as much as for a
|
||||
* timetabled train, and the Division Point it starts at is therefore the one it runs away from.
|
||||
* §2.3 — ODD RUNS WEST, EVEN RUNS EAST. The number is the direction for a TIMETABLED train.
|
||||
*
|
||||
* Extras print `direction: 'playerChoice'`, which the engine read as "always eastbound from the West
|
||||
* Division Point". Jesse's ruling: the number decides, like everything else on the timetable.
|
||||
* NOT for an Extra any more. Extras print `direction: 'playerChoice'` and now mean it (Jesse's
|
||||
* ruling, superseding "the number decides, like everything else on the timetable"): the player who
|
||||
* played the card picks where it starts, and the start decides the direction — a Crew Tray placed
|
||||
* at the Western Division Point runs east and one at the Eastern runs west, because the alternative
|
||||
* is a train that leaves the Division on its first move having crossed nothing. Where the start is
|
||||
* NOT an end of the Division — an Interchange, or a Control Point — both ways are real runs and the
|
||||
* player says which. `resolveExtraStart` in apply.ts is where that happens.
|
||||
*
|
||||
* Still read for an Extra in one place: replaying a save written before the choice existed, where
|
||||
* `newTrain.startExtra` carries only the legacy `atSeat` field.
|
||||
*/
|
||||
export function runDirection(trainNumber: number): Direction {
|
||||
return trainNumber % 2 === 0 ? 'east' : 'west';
|
||||
@@ -527,6 +546,29 @@ export const MAINLINE_PROFILES: readonly MainlineProfile[] = [
|
||||
{ kind: 'interchange', name: 'Interchange', speed: { kind: 'uniform', value: 60 }, trainsMayPass: false, sortsCars: true, entryPoints: ['start', 'sortCars'] },
|
||||
];
|
||||
|
||||
/**
|
||||
* THE MAINLINE DECK AS PRINTED, dealt WITHOUT replacement.
|
||||
*
|
||||
* `MAINLINE_PROFILES` above is a list of card TYPES, one entry each. It is not the deck, and setup
|
||||
* used it as one: `buildDivision` drew uniformly from those types with replacement, which made two
|
||||
* Interchanges (or two Trestles, or two Tunnels) an ordinary outcome and gave Plains the same weight
|
||||
* as everything else although the deck prints two of it. `Mainline Cards.pdf` is the
|
||||
* inventory, transcribed in `docs/StationMaster-Mainline-Deck-v0.4.5.md`, which had already flagged
|
||||
* the mismatch as needing correction.
|
||||
*
|
||||
* It matters more than card flavour now that an Extra may start at an Interchange (§7): "if an
|
||||
* Interchange is on the board" has to mean a card there is at most one of, not a type the deal can
|
||||
* hand out twice.
|
||||
*
|
||||
* The two Division Point cards in that inventory are not here — they are the fixed ends of the
|
||||
* Division, laid by `buildDivision` itself rather than drawn. Plains appears twice because the deck
|
||||
* prints it twice; every other type once. The list below is the deck, so it is not counted here.
|
||||
*/
|
||||
export const MAINLINE_DECK: readonly MainlineKind[] = [
|
||||
'plains', 'plains', 'curves', 'hilly', 'heavyGrade',
|
||||
'doubleTrack', 'uncontrolledSiding', 'tunnel', 'trestle', 'interchange',
|
||||
];
|
||||
|
||||
/**
|
||||
* How many Stages a train needs to cross a Mainline card.
|
||||
*
|
||||
@@ -693,9 +735,9 @@ export type SimpleCard = {
|
||||
* The opponent-directed card this exists SOLELY to answer.
|
||||
*
|
||||
* A defence with nothing to defend against is a dead draw, exactly as the attack itself would be.
|
||||
* The 22 Space-use and Action cards are held out of every deck until they are implemented (Q6),
|
||||
* and these go with them — named here rather than in a list somewhere else so the pairing is
|
||||
* visible on the card, and so they come back together when their attacker does.
|
||||
* The Space-use and Action cards are held out of every deck until they are implemented (Q6), and
|
||||
* these go with them — named here rather than in a list somewhere else so the pairing is visible
|
||||
* on the card, and so they come back together when their attacker does.
|
||||
*/
|
||||
answers?: string;
|
||||
};
|
||||
@@ -741,39 +783,48 @@ export type EnhancementRule = {
|
||||
* opponent-directed card that a solitaire deck does not contain (Q6).
|
||||
* - `unbuilt` — nothing reads it at all. The effect is recorded here and not yet written.
|
||||
*
|
||||
* Seven of the ten are live. Each row below cites the file that reads it, because the first
|
||||
* attempt at this table got FIVE of the ten wrong: it was filled in by grepping for four helper
|
||||
* function names and reading "no match" as "no implementation", when Interlocking, Yard Office,
|
||||
* Small Yard and ABS Signals are all read directly by key — and all four are covered by tests in
|
||||
* `enhancements.test.ts` that were passing the whole time. The result was a tooltip telling players
|
||||
* that four working cards did nothing, which is worse than the bare label it replaced.
|
||||
* Most are live. Each row below cites the file that reads it — the row is the answer, and no
|
||||
* tally is kept here, because a tally is one more thing to forget when a card is implemented.
|
||||
*
|
||||
* The first attempt at this table got FIVE of the ten wrong: it was filled in by grepping for four
|
||||
* helper function names and reading "no match" as "no implementation", when Interlocking, Yard
|
||||
* Office, Small Yard and ABS Signals are all read directly by key — and all four are covered by
|
||||
* tests in `enhancements.test.ts` that were passing the whole time. The result was a tooltip
|
||||
* telling players that four working cards did nothing, which is worse than the bare label it
|
||||
* replaced.
|
||||
*
|
||||
* KEEP THIS HONEST, AND CHECK THE CITATION. Implementing one of these means changing its value in
|
||||
* the same commit; otherwise the card goes on apologising for something it now does. It is data
|
||||
* rather than something derived because "is this key read anywhere" is not a question the type
|
||||
* system can answer — but a claim here without a file reference beside it is a claim nobody checked.
|
||||
* system can answer — but a claim here without a reference beside it is a claim nobody checked.
|
||||
*
|
||||
* CITE THE FUNCTION, NEVER THE LINE NUMBER. Every one of these rows once carried a `file.ts:NNN`
|
||||
* and every one of them had rotted — `apply.ts:405` for Small Yard was pointing four hundred lines
|
||||
* short by the time anyone looked. A line number is a citation that decays silently on the next
|
||||
* edit anywhere above it, which is the opposite of what this note is for.
|
||||
*/
|
||||
effect: 'live' | 'dormantSolo' | 'unbuilt';
|
||||
};
|
||||
|
||||
export const ENHANCEMENT_RULES: readonly EnhancementRule[] = [
|
||||
// Holds an arrival at the Limits instead of colliding when the Office is full — advance.ts:770.
|
||||
// Holds an arrival at the Limits instead of colliding when the Office is full — `arriveAtOffice`.
|
||||
{ key: 'interlocking', placement: 'runningTrackStraight', effect: 'live' },
|
||||
// Wired at apply.ts:1738, but it answers Derail, an Action card the solitaire deck omits (Q6).
|
||||
// Wired in `isProtectedFromDerail`, but it answers Derail, an Action card the solo deck omits (Q6).
|
||||
{ key: 'facingPointLocks', placement: 'onCard', requiresInDistrict: 'interlocking', effect: 'dormantSolo' },
|
||||
// Diverts a coachless arrival away from the Train Order Office — advance.ts:750.
|
||||
// Diverts a coachless arrival away from the Train Order Office — `arriveAtOffice`.
|
||||
{ key: 'yardOffice', placement: 'secondaryTrackStraight', effect: 'live' },
|
||||
// Lets a consist be re-ordered for one Move — apply.ts:405.
|
||||
// Lets a consist be re-ordered for one Move — `check`'s `switch.sortConsist` case.
|
||||
{ key: 'smallYard', placement: 'secondaryTrackStraight', effect: 'live' },
|
||||
// Wired at apply.ts:1743, but it removes a Watertower, a Space-use card the solo deck omits.
|
||||
// Wired in `watertowersRemovable`, but it removes a Watertower, a Space-use card the solo deck omits.
|
||||
{ key: 'waterColumn', placement: 'runningTrackStraight', effect: 'dormantSolo' },
|
||||
// The only one with NO code path at all: nothing anywhere reads `overpass`.
|
||||
{ key: 'overpass', placement: 'onCard', effect: 'unbuilt' },
|
||||
{ key: 'telegraph', placement: 'runningTrackStraight', dispatchBonus: 4, effect: 'live' },
|
||||
{ key: 'telephone', placement: 'onCard', requiresOnSameCard: 'telegraph', dispatchBonus: 8, effect: 'live' },
|
||||
{ key: 'radio', placement: 'onCard', requiresOnSameCard: 'telephone', dispatchBonus: 12, effect: 'live' },
|
||||
// Stored on the Mainline node rather than in `enhancements[]` — apply.ts:1461, read at
|
||||
// advance.ts:599 (no rear-ending) and advance.ts:721 (the follower holds instead of being ruled on).
|
||||
// Stored on the Mainline node rather than in `enhancements[]` — written by `reduce`'s
|
||||
// `enhancementPlaced`, read in `moveTrain` (no rear-ending) and `evaluateClearance` (the follower
|
||||
// holds instead of being ruled on).
|
||||
{ key: 'absSignals', placement: 'mainlineCard', effect: 'live' },
|
||||
];
|
||||
|
||||
@@ -864,11 +915,15 @@ export type StockSupply = { type: CarType; loaded: number; empty: number };
|
||||
/**
|
||||
* NOT in the recovered files — still the provisional figure.
|
||||
*
|
||||
* Scaled up alongside the Gap 12 industry increase. Worst-case demand (every copy of every
|
||||
* industry in play at full capacity) is boxcar 15, hopper 12, tank 9, reefer 6; the supply must
|
||||
* cover that, since a Division Yard that runs dry starves the freight loop the increase exists to
|
||||
* feed. Lockouts and district size mean the worst case cannot actually occur, so this carries
|
||||
* deliberate headroom.
|
||||
* Scaled up alongside the Gap 12 industry increase. The rule it was set by, rather than the numbers
|
||||
* it produced: worst-case demand for a car type is every copy of every industry that uses it, in
|
||||
* play at full capacity, and the supply must cover that — a Division Yard that runs dry starves the
|
||||
* freight loop the increase exists to feed. Lockouts and district size mean the worst case cannot
|
||||
* actually occur, so this carries deliberate headroom. RE-DERIVE IT FROM `INDUSTRY_PROFILES`
|
||||
* whenever industry copies move; a figure written here would not survive the next retune.
|
||||
*
|
||||
* Coaches are the type this rule does NOT cover, because no industry asks for one — their demand
|
||||
* comes from passenger work, and Gitea#2 is the open report that the supply is short (see TODO.md).
|
||||
*/
|
||||
export const ROLLING_STOCK_SUPPLY: readonly StockSupply[] = [
|
||||
{ type: 'coach', loaded: 8, empty: 8 },
|
||||
@@ -902,11 +957,11 @@ export const STAGES_PER_SHIFT = 3;
|
||||
export const HAND_LIMIT = 3;
|
||||
|
||||
/**
|
||||
* The split opening deal: 3 track cards and 3 others, from two separately shuffled piles
|
||||
* (`setup.ts`). One of the three `StartingHand` options below, not the only one any more.
|
||||
* The split opening deal — track cards and others, from two separately shuffled piles (`setup.ts`).
|
||||
* One of the three `StartingHand` options below, not the only one any more.
|
||||
*
|
||||
* Six against a limit of three on purpose — the first turn is spent choosing which district you can
|
||||
* afford to build.
|
||||
* Deliberately over the hand limit: the first turn is spent choosing which district you can afford
|
||||
* to build. The two constants below are the deal.
|
||||
*/
|
||||
export const OPENING_TRACK = 3;
|
||||
export const OPENING_OTHER = 3;
|
||||
@@ -940,10 +995,16 @@ export const OPENING_DEALS: Readonly<Record<StartingHand, { any: number; track:
|
||||
/**
|
||||
* WHAT THE THREE WORKING ECONOMIES PAY.
|
||||
*
|
||||
* Balance is the open problem in this game — the developer bot averages 7.0 Revenue against a target
|
||||
* of 20, of which most came from traffic nobody had to work — and the way to settle it is to play it
|
||||
* at several settings rather than to keep re-deriving it. So the three rates are dials, set when the
|
||||
* game is dealt and fixed for its duration.
|
||||
* Balance is the open problem in this game, and the way to settle it is to play it at several
|
||||
* settings rather than to keep re-deriving it. So the three rates are dials, set when the game is
|
||||
* dealt and fixed for its duration.
|
||||
*
|
||||
* DO NOT WRITE A CURRENT BALANCE FIGURE HERE. This said "the developer bot averages 7.0 Revenue
|
||||
* against a target of 20" long after that stopped being true: 7.0 was measured while
|
||||
* `trainPerTransit` still defaulted to 1, and the paragraph below explains that this very setting
|
||||
* was then defaulted to 0 for being worth ~5.4 of it. Re-measured 2026-08-22 over 400 games at the
|
||||
* current defaults, the developer bot means about ZERO. Run `node src/sim/harness.ts 400 standard`
|
||||
* for today's number rather than trusting one written here.
|
||||
*
|
||||
* `passengerPerCoach` and `freightPerLoad` each pay on BOTH halves of their cycle: a coach pays when
|
||||
* it is boarded and again when it is detrained, a load pays when it is made up outbound and again
|
||||
@@ -960,10 +1021,30 @@ export type RevenueRules = {
|
||||
trainPerTransit: number;
|
||||
};
|
||||
|
||||
export type HouseRules = { startingHand: StartingHand; revenue: RevenueRules };
|
||||
/**
|
||||
* WHERE AN EXTRA MAY BE STARTED — a setting, because the table disagrees about it.
|
||||
*
|
||||
* §7 gives an Extra "either Division Point", and Jesse's ruling adds the Interchange to that base
|
||||
* set: both are places on the shared Division that belong to nobody, so neither favours a seat.
|
||||
* Starting one inside a player's own district is the part that does, which is what this dials.
|
||||
*
|
||||
* - `divisionPointsOnly` — the Division Points and the Interchange. No Office start at all.
|
||||
* - `ownOffice` — those, plus a Control Point in the district of the player who played the card.
|
||||
* - `anyOffice` — those, plus a Control Point in ANY player's district.
|
||||
*
|
||||
* A Whistle Post never qualifies however this is set: an Office has to be a Control Point to start
|
||||
* an Extra, which is part of what upgrading buys (§11).
|
||||
*/
|
||||
export type ExtraStartRule = 'divisionPointsOnly' | 'ownOffice' | 'anyOffice';
|
||||
|
||||
export type HouseRules = { startingHand: StartingHand; revenue: RevenueRules; extraStart: ExtraStartRule };
|
||||
|
||||
/** What a caller may name — any subset, down to none — resolved by `houseRules()`. */
|
||||
export type HouseRuleOverrides = { startingHand?: StartingHand; revenue?: Partial<RevenueRules> };
|
||||
export type HouseRuleOverrides = {
|
||||
startingHand?: StartingHand;
|
||||
revenue?: Partial<RevenueRules>;
|
||||
extraStart?: ExtraStartRule;
|
||||
};
|
||||
|
||||
/** The dialog's range. Zero is a real setting: it switches an economy off so the others can be read. */
|
||||
export const REVENUE_MIN = 0;
|
||||
@@ -972,6 +1053,10 @@ export const REVENUE_MAX = 5;
|
||||
export const DEFAULT_HOUSE_RULES: HouseRules = {
|
||||
startingHand: 'threeRandom',
|
||||
revenue: { passengerPerCoach: 1, freightPerLoad: 1, trainPerTransit: 0 },
|
||||
// `anyOffice` is what the engine did before the setting existed, so a game dealt without naming
|
||||
// it plays the way it always has. Jesse's call, so the 0.4.9 playtest line does not change under
|
||||
// its testers in the middle of a bugfix release.
|
||||
extraStart: 'anyOffice',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -986,6 +1071,8 @@ export const DEFAULT_HOUSE_RULES: HouseRules = {
|
||||
export const LEGACY_HOUSE_RULES: HouseRules = {
|
||||
startingHand: 'threeTrackThreeOther',
|
||||
revenue: { passengerPerCoach: 1, freightPerLoad: 1, trainPerTransit: 1 },
|
||||
// An Extra could always be started at a Control Point in these games, in any district.
|
||||
extraStart: 'anyOffice',
|
||||
};
|
||||
|
||||
/** A whole, valid rule set from a config that may carry none, some, or out-of-range values. */
|
||||
@@ -1004,6 +1091,7 @@ export function houseRules(config: { houseRules?: HouseRuleOverrides }): HouseRu
|
||||
freightPerLoad: clamp(rev.freightPerLoad, d.revenue.freightPerLoad),
|
||||
trainPerTransit: clamp(rev.trainPerTransit, d.revenue.trainPerTransit),
|
||||
},
|
||||
extraStart: given.extraStart ?? d.extraStart,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1013,6 +1101,12 @@ export const STARTING_HAND_LABELS: readonly { value: StartingHand; label: string
|
||||
{ value: 'sixRandom', label: 'Six random cards' },
|
||||
{ value: 'threeTrackThreeOther', label: 'Three random track and three random non-track cards' },
|
||||
];
|
||||
/** What the dialog calls each `ExtraStartRule`, in the order it offers them. */
|
||||
export const EXTRA_START_LABELS: readonly { value: ExtraStartRule; label: string }[] = [
|
||||
{ value: 'divisionPointsOnly', label: 'Division Points and the Interchange only' },
|
||||
{ value: 'ownOffice', label: 'Also the playing player\u2019s own Control Point' },
|
||||
{ value: 'anyOffice', label: 'Also any player\u2019s Control Point' },
|
||||
];
|
||||
export const MAX_CONSIST = 4;
|
||||
export const MOVES_PER_LOCAL_OPS = 6;
|
||||
export const MOVES_PER_LOCAL_OPS_NIGHT = 5;
|
||||
@@ -1065,7 +1159,8 @@ export function lengthProfile(length: GameLength): LengthProfile {
|
||||
|
||||
/**
|
||||
* Cards that can only be played AT another player (Q6). In a solitaire game they have no legal
|
||||
* target, so they are removed from the deck rather than sitting in hand as 19% dead draws.
|
||||
* target, so they are removed from the deck rather than sitting in hand as dead draws — which, when
|
||||
* this was written, was very nearly a fifth of the deck.
|
||||
*/
|
||||
export const OPPONENT_ONLY_CATEGORIES: readonly string[] = ['spaceUse', 'action'];
|
||||
|
||||
@@ -1073,8 +1168,10 @@ export function isOpponentOnly(category: string): boolean {
|
||||
return OPPONENT_ONLY_CATEGORIES.includes(category);
|
||||
}
|
||||
|
||||
/** How many cards `DEFENCE_ONLY_CARDS` accounts for — 7: two Facing Point Locks of each kind, two
|
||||
* Water Columns and one Overpass. */
|
||||
/**
|
||||
* How many cards `DEFENCE_ONLY_CARDS` accounts for. Summed from the rows rather than written down:
|
||||
* which cards qualify is `SimpleCard.answers`, and the total moves whenever one is added.
|
||||
*/
|
||||
export const DEFENCE_ONLY_COPIES =
|
||||
ENHANCEMENT_CARDS.filter((c) => c.answers).reduce((n, c) => n + c.copies, 0) +
|
||||
MAINLINE_MODIFIER_CARDS.filter((c) => c.answers).reduce((n, c) => n + c.copies, 0);
|
||||
@@ -1097,17 +1194,19 @@ export function deckComposition(): { category: string; count: number }[] {
|
||||
|
||||
/**
|
||||
* The whole CATALOGUE, including cards not currently dealt. Not the size of any deck in play — see
|
||||
* `DEALT_DECK_SIZE`, which is what `buildDeck` actually returns.
|
||||
* `SOLITAIRE_DECK_SIZE` below, which is what `buildDeck` actually deals. (This pointed at a
|
||||
* `DEALT_DECK_SIZE` that has never existed.)
|
||||
*/
|
||||
export const DECK_SIZE = deckComposition().reduce((n, c) => n + c.count, 0);
|
||||
|
||||
/**
|
||||
* The deck actually dealt, in every mode: the catalogue less the 22 opponent-directed cards.
|
||||
* The deck actually dealt, in every mode: the catalogue less the opponent-directed cards, less the
|
||||
* defensive cards that exist only to answer them.
|
||||
*
|
||||
* Named for solitaire because Q6 dropped them there first, and kept under that name because the
|
||||
* number is the same either way. They are out of the competitive deck too until they are
|
||||
* implemented — `checkPlay` answers both categories NOT_IMPLEMENTED, so dealing them would make ~9%
|
||||
* of draws reject. See `buildDeck`.
|
||||
* implemented — `checkPlay` answers both categories NOT_IMPLEMENTED, so dealing them would make a
|
||||
* meaningful share of draws reject outright. See `buildDeck`.
|
||||
*/
|
||||
export const SOLITAIRE_DECK_SIZE =
|
||||
deckComposition()
|
||||
|
||||
+14
-3
@@ -19,8 +19,8 @@
|
||||
* reconstruct the whole board to draw one frame.
|
||||
*/
|
||||
|
||||
import type { CarType, OfficeTier } from './content.ts';
|
||||
import type { LocalOpsOption } from './intents.ts';
|
||||
import type { CarType, Direction, OfficeTier } from './content.ts';
|
||||
import type { ExtraStart, LocalOpsOption } from './intents.ts';
|
||||
import type { CardId, GridCoord, PlayerIndex, RollingStock, SeatIndex, TrayId } from './state.ts';
|
||||
|
||||
export type GameEvent =
|
||||
@@ -156,7 +156,18 @@ export type GameEvent =
|
||||
*/
|
||||
| { type: 'trainCompleted'; trainNumber: number; isExtra: boolean; side: 'east' | 'west'; consist: RollingStock[] }
|
||||
/** An Extra took a Crew Tray and started its run — at a Division Point, or at a Control Point. */
|
||||
| { type: 'extraStarted'; player: PlayerIndex; trainNumber: number; atSeat: SeatIndex | null }
|
||||
/**
|
||||
* Carries the RESOLVED start and direction (`resolveExtraStart`), not the raw intent fields, so
|
||||
* the reducer never re-answers a question `check` already answered — the same shape as
|
||||
* `passengersBoarded` carrying its tray and coach index.
|
||||
*/
|
||||
| {
|
||||
type: 'extraStarted';
|
||||
player: PlayerIndex;
|
||||
trainNumber: number;
|
||||
at: ExtraStart;
|
||||
direction: Direction;
|
||||
}
|
||||
| { type: 'carPlacedOnTrain'; player: PlayerIndex; trayId: TrayId; stock: RollingStock }
|
||||
| { type: 'carPassed'; player: PlayerIndex; trayId: TrayId }
|
||||
| { type: 'dispatchBonusUsed'; key: string; bonus: number; trainNumber: number; againstTrain: number }
|
||||
|
||||
+51
-6
@@ -13,6 +13,17 @@ import type { CardId, GridCoord, PlayerIndex, SeatIndex, TrayId } from './state.
|
||||
|
||||
export type LocalOpsOption = 'switch' | 'draw' | 'freightAgent';
|
||||
|
||||
/**
|
||||
* Where an Extra is placed when it is started (§7).
|
||||
*
|
||||
* `mainline` names a node index in `division.nodes` and is only ever an Interchange; `office` names
|
||||
* a SEAT, which is what an Office Area belongs to, and only ever a Control Point.
|
||||
*/
|
||||
export type ExtraStart =
|
||||
| { kind: 'divisionPoint'; side: Direction }
|
||||
| { kind: 'mainline'; node: number }
|
||||
| { kind: 'office'; seat: SeatIndex };
|
||||
|
||||
export type Intent =
|
||||
| { type: 'localOps.choose'; option: LocalOpsOption }
|
||||
// -- switch (§6.1, Appendix A)
|
||||
@@ -74,12 +85,31 @@ export type Intent =
|
||||
| { type: 'newTrain.placeCar'; trayId: TrayId; carType: CarType; loaded: boolean }
|
||||
| { type: 'newTrain.passCar'; trayId: TrayId }
|
||||
/**
|
||||
* §7 — "the player who played the card may place the Crew Tray in either division point for
|
||||
* immediate departure", extended by Jesse: an Extra starts at the Division Point its NUMBER sends
|
||||
* it to (odd runs west, even east, exactly as a timetabled train), or at any Control Point — any
|
||||
* Office above a Whistle Post — at the player's choice. `atSeat` null means the Division Point.
|
||||
* §7 — "the player who played the card may place the Crew Tray at EITHER Division Point for
|
||||
* immediate departure", plus Jesse's ruling on where else and which way.
|
||||
*
|
||||
* The number does not decide an Extra's direction — the START does. Either Division Point may be
|
||||
* chosen and the train runs away from it (west end runs east, east end runs west, since the other
|
||||
* reading is a train that leaves the Division having crossed nothing). At an Interchange or a
|
||||
* Control Point, which are in the middle of the railroad, both ways are real runs and `direction`
|
||||
* says which; it is required there and ignored at a Division Point.
|
||||
*
|
||||
* WHICH STARTS ARE OFFERED is the `extraStart` house rule (content.ts) — Division Points and the
|
||||
* Interchange always, Offices by setting.
|
||||
*
|
||||
* `atSeat` IS LEGACY AND WRITE-ONCE. Saves written before this choice existed carry only that
|
||||
* field: `null` meant "the Division Point this train's number sends it to" and a seat meant that
|
||||
* Office, both running in the number's direction. `start` absent is exactly what those saves said,
|
||||
* so they replay unchanged; everything written from now on carries `start` and `atSeat` is
|
||||
* omitted. `resolveExtraStart` (apply.ts) is the single place that reads either.
|
||||
*/
|
||||
| { type: 'newTrain.startExtra'; trainNumber: number; atSeat: SeatIndex | null }
|
||||
| {
|
||||
type: 'newTrain.startExtra';
|
||||
trainNumber: number;
|
||||
atSeat?: SeatIndex | null;
|
||||
start?: ExtraStart;
|
||||
direction?: Direction;
|
||||
}
|
||||
/** Q9 — run a second, identical section behind a train that is due out this Stage. */
|
||||
| { type: 'newTrain.secondSection'; trainNumber: number }
|
||||
// -- Mainline Phase (§8.1) — the Superintendent's clearance ruling
|
||||
@@ -229,7 +259,22 @@ export type RejectionCode =
|
||||
| 'NOT_A_CONTROL_POINT'
|
||||
| 'NO_EXTRA_PENDING'
|
||||
| 'NO_FREE_TRAY'
|
||||
| 'NO_FREE_AD_TRACK';
|
||||
| 'NO_FREE_AD_TRACK'
|
||||
// -- §7, where an Extra may be started (`resolveExtraStart`)
|
||||
| 'NO_SUCH_DIVISION_POINT'
|
||||
/** Only the Interchange has a yard an Extra can be made up in. */
|
||||
| 'NOT_AN_INTERCHANGE'
|
||||
/** In the middle of the railroad both ways are real runs, so the intent has to say which. */
|
||||
| 'NO_DIRECTION_CHOSEN'
|
||||
/** The `extraStart` house rule is `divisionPointsOnly`. */
|
||||
| 'OFFICE_STARTS_NOT_ALLOWED'
|
||||
/** The `extraStart` house rule is `ownOffice` and this is somebody else's district. */
|
||||
| 'NOT_YOUR_OFFICE'
|
||||
/**
|
||||
* §6.2, Jesse's ruling (Gitea#6) — a train card is never discarded. Hold it as long as you like;
|
||||
* the only way it leaves your hand is onto the timetable.
|
||||
*/
|
||||
| 'TRAINS_ARE_NEVER_DISCARDED';
|
||||
|
||||
export type Rejection = { code: RejectionCode; message: string };
|
||||
|
||||
|
||||
+20
-6
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import type { CarType, Hand, TrackGeometry } from './content.ts';
|
||||
import { enhancementRule } from './content.ts';
|
||||
import { enhancementRule, mainlineProfile } from './content.ts';
|
||||
import { check, areaOf, destinationsFor } from './apply.ts';
|
||||
import type { Intent } from './intents.ts';
|
||||
import type { GameState, GridCoord, PlayerIndex } from './state.ts';
|
||||
@@ -271,14 +271,28 @@ function newTrainCandidates(s: GameState): Intent[] {
|
||||
out.push({ type: 'newTrain.secondSection', trainNumber: due });
|
||||
}
|
||||
/**
|
||||
* Where a pending Extra starts: its own Division Point, decided by its number, or any Control
|
||||
* Point. `check` refuses a Whistle Post and a full Office, so every seat is offered and the rules
|
||||
* do the filtering — one implementation of "is this a Control Point", not two.
|
||||
* WHERE A PENDING EXTRA MAY START (§7, Jesse's ruling) — every candidate offered, with `check`
|
||||
* doing the filtering, so "is this a Control Point" and "does the house rule allow it" have one
|
||||
* implementation each rather than two.
|
||||
*
|
||||
* BOTH Division Points, not the one the number dictates: an Extra's direction comes from where it
|
||||
* is placed. In the middle of the railroad — an Interchange, a Control Point — both ways are real
|
||||
* runs, so those are offered twice, once per direction.
|
||||
*/
|
||||
for (const trainNumber of s.pendingExtras) {
|
||||
out.push({ type: 'newTrain.startExtra', trainNumber, atSeat: null });
|
||||
for (const side of ['west', 'east'] as const) {
|
||||
out.push({ type: 'newTrain.startExtra', trainNumber, start: { kind: 'divisionPoint', side } });
|
||||
}
|
||||
for (const [node, n] of s.division.nodes.entries()) {
|
||||
if (n.kind !== 'mainline' || !mainlineProfile(n.card).sortsCars) continue;
|
||||
for (const direction of ['west', 'east'] as const) {
|
||||
out.push({ type: 'newTrain.startExtra', trainNumber, start: { kind: 'mainline', node }, direction });
|
||||
}
|
||||
}
|
||||
for (const seat of s.officeAreas.keys()) {
|
||||
out.push({ type: 'newTrain.startExtra', trainNumber, atSeat: seat });
|
||||
for (const direction of ['west', 'east'] as const) {
|
||||
out.push({ type: 'newTrain.startExtra', trainNumber, start: { kind: 'office', seat }, direction });
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
||||
+19
-3
@@ -17,7 +17,7 @@ import {
|
||||
MODIFIER_PROFILES,
|
||||
OFFICE_PROFILES,
|
||||
OPENING_DEALS,
|
||||
MAINLINE_PROFILES,
|
||||
MAINLINE_DECK,
|
||||
houseRules,
|
||||
mainlineProfile,
|
||||
TRACK_CARDS,
|
||||
@@ -224,11 +224,27 @@ function buildPassengerFacility(tier: Parameters<typeof officeProfile>[0]): NonN
|
||||
* placed between each player"), which is what gives the Division its terrain and therefore its
|
||||
* crossing times.
|
||||
*/
|
||||
/**
|
||||
* THE MAINLINE CARDS ARE DEALT FROM A DECK, NOT ROLLED.
|
||||
*
|
||||
* `MAINLINE_PROFILES` is a list of card TYPES and this drew from it uniformly WITH replacement, so
|
||||
* a Division could be handed two Interchanges or two Tunnels, and Plains — printed twice in the
|
||||
* deck — carried the same weight as cards printed once. `MAINLINE_DECK` is the printed inventory
|
||||
* (`docs/StationMaster-Mainline-Deck-v0.4.5.md`, which flagged this as needing correction), and the
|
||||
* deal is now a deal: take cards out of it and do not put them back.
|
||||
*
|
||||
* The Extra-start rules are what forced the issue. "An Extra may start at the Interchange if one is
|
||||
* on the board" only reads as a rule if the board can hold at most one.
|
||||
*
|
||||
* A Division needs `players + 1` cards, so four players draw five from ten and the deck is never
|
||||
* close to exhausted; the throw is there because a silent short Division would be very hard to see.
|
||||
*/
|
||||
function buildDivision(players: number, rng: Rng): DivisionNode[] {
|
||||
const nodes: DivisionNode[] = [];
|
||||
const kinds = MAINLINE_PROFILES.map((m) => m.kind);
|
||||
const deck = [...MAINLINE_DECK];
|
||||
const mainline = (): DivisionNode => {
|
||||
const card = kinds[rng.nextInt(kinds.length)]!;
|
||||
if (deck.length === 0) throw new Error('the Mainline deck ran out — too many players for it');
|
||||
const card = deck.splice(rng.nextInt(deck.length), 1)[0]!;
|
||||
const node: DivisionNode = { kind: 'mainline', card, transits: [] };
|
||||
if (mainlineProfile(card).speed.kind === 'grade') {
|
||||
/**
|
||||
|
||||
@@ -354,6 +354,23 @@ export type CrewTray = {
|
||||
/** null while a local crew is switching without a train card. */
|
||||
trainNumber: number | null;
|
||||
trainIsExtra: boolean;
|
||||
/**
|
||||
* STILL BEING ASSEMBLED, somewhere that is not a Division Point.
|
||||
*
|
||||
* `isBeingMadeUp` used to read the position alone — "standing at a Division Point" — which was
|
||||
* true of every train being built when the only place to build one WAS a Division Point. An Extra
|
||||
* may now be started at a Control Point or in an Interchange's yard (§7), and those trains could
|
||||
* not be given a consist at all: they ran empty, and so did every Control Point Extra since that
|
||||
* option was added. Jesse's report says it plainly — an Extra started at the Interchange "would be
|
||||
* loaded with cars".
|
||||
*
|
||||
* Set when such an Extra is placed and cleared the moment it starts running (`enterMainline`), so
|
||||
* it names a train that is being made up rather than one that merely happens to be standing
|
||||
* somewhere. That distinction is load-bearing: a train that ARRIVED at an Office must never be
|
||||
* fillable from the Division Yard, which is the "cars appearing on a train nobody was making up"
|
||||
* bug `isBeingMadeUp` was tightened to kill, and an arriving train never carries this.
|
||||
*/
|
||||
beingMadeUp?: boolean;
|
||||
/**
|
||||
* WHERE THE ENGINE SITS IN THE TRAY, as an index into `consist`.
|
||||
*
|
||||
@@ -470,6 +487,20 @@ export type DivisionNode =
|
||||
kind: 'mainline';
|
||||
card: MainlineKind;
|
||||
transits: Transit[];
|
||||
/**
|
||||
* TRAINS STANDING IN THE INTERCHANGE'S YARD — not out on the running line.
|
||||
*
|
||||
* Only an Interchange ever has these. An Extra started there (§7, Jesse's ruling) is made up
|
||||
* in the yard beside the Mainline, which is why placing it can never be a collision however
|
||||
* busy the card is: it is not on the road yet. It highballs onto this same card at a later
|
||||
* Mainline Phase, through the ordinary §8.1 clearance check — held automatically against a
|
||||
* facing train, put to the Superintendent against a following one — and becomes a `Transit`
|
||||
* at that moment, exactly like a train leaving a Division Point.
|
||||
*
|
||||
* A tray listed here has `position.at === 'mainline'` with this node's index and NO entry in
|
||||
* `transits`. That pair is what distinguishes standing from crossing.
|
||||
*/
|
||||
holding?: TrayId[];
|
||||
absSignals?: boolean;
|
||||
/** Brakeman / Airbrakes / Helpers / Realignment laid on this card. */
|
||||
modifiers?: string[];
|
||||
|
||||
+17
-2
@@ -196,15 +196,30 @@ export function divisionSvg(nodes: DivisionView[], roster?: DivisionRoster | nul
|
||||
continue;
|
||||
}
|
||||
const dp = n.kind === 'dp';
|
||||
/**
|
||||
* A train in the Interchange's yard is drawn on the card but counted against nothing.
|
||||
*
|
||||
* It is not on the running line — that is the whole distinction §7 rests on — so it cannot take
|
||||
* the card's capacity. It still has to be SEEN: an Extra made up here would otherwise be a train
|
||||
* the player just placed that appears nowhere on the map.
|
||||
*/
|
||||
const inYard = n.yard ?? [];
|
||||
const onRoad = n.trains.flat();
|
||||
const free = n.capacity === null ? '' : `${Math.max(0, n.capacity - onRoad.length)} of ${n.capacity} free`;
|
||||
push({
|
||||
kind: dp ? 'dp' : 'ml',
|
||||
label: n.label,
|
||||
sub: n.capacity === null ? 'no limit — trains queue' : `${Math.max(0, n.capacity - n.trains.flat().length)} of ${n.capacity} free`,
|
||||
trains: n.trains.flat(),
|
||||
sub: n.capacity === null
|
||||
? 'no limit — trains queue'
|
||||
: [free, inYard.length > 0 ? `${inYard.length} in the yard` : ''].filter(Boolean).join(' · '),
|
||||
trains: [...onRoad, ...inYard],
|
||||
cap: n.capacity,
|
||||
tip: dp
|
||||
? 'A Division Point — the end of the line. Trains both enter and leave the Division here (odd numbers run west, even run east), and queue without limit'
|
||||
: `${n.label} — Mainline${n.gradeUp ? `, climbs ${n.gradeUp === 'east' ? 'east' : 'west'}` : ''}${n.modifiers.length ? ` · ${n.modifiers.join(' · ')}` : ''}` +
|
||||
(inYard.length > 0
|
||||
? `\n\n${inYard.length} train${inYard.length === 1 ? '' : 's'} standing in the yard, not on the running line — waiting to highball onto this card`
|
||||
: '') +
|
||||
// What the card actually DOES. The name alone left Hilly and Uncontrolled Siding as
|
||||
// words with no gameplay attached — reported exactly that way.
|
||||
(n.what ? `\n\n${n.what}` : ''),
|
||||
|
||||
+22
-5
@@ -269,14 +269,31 @@ export function narrate(e: GameEvent, ctx: NarrateContext = {}): Narration {
|
||||
tone: 'bad',
|
||||
text: `SECOND SECTION ordered on Train ${e.trainNumber} — an identical train will run right behind it, which forces the Superintendent to rule on a following train (§8.1)`,
|
||||
};
|
||||
case 'extraStarted':
|
||||
/**
|
||||
* WHERE THE PLAYER PUT IT, not where its number would have sent it.
|
||||
*
|
||||
* An Extra's direction comes from its start now (§7, Jesse's ruling), so the line that used to
|
||||
* explain the number's parity would be explaining a rule that no longer applies to this train.
|
||||
*/
|
||||
case 'extraStarted': {
|
||||
const where =
|
||||
e.at.kind === 'divisionPoint'
|
||||
? `the ${e.at.side === 'west' ? 'Western' : 'Eastern'} Division Point`
|
||||
: e.at.kind === 'mainline'
|
||||
? "the Interchange's yard"
|
||||
: `the Control Point in seat ${e.at.seat}`;
|
||||
const why =
|
||||
e.at.kind === 'divisionPoint'
|
||||
? 'the end it runs away from — an Extra may start at either, and the end chooses the run'
|
||||
: e.at.kind === 'mainline'
|
||||
? 'made up off the running line, so it highballs onto the Mainline once the Subdivision ' +
|
||||
'is clear and may be held in the yard until it is'
|
||||
: 'an Extra may begin at any Office above a Whistle Post, and the player chooses the run';
|
||||
return {
|
||||
tone: 'good',
|
||||
text:
|
||||
e.atSeat === null
|
||||
? `EXTRA X${e.trainNumber} started at the ${e.trainNumber % 2 === 0 ? 'Western' : 'Eastern'} Division Point, running ${e.trainNumber % 2 === 0 ? 'east' : 'west'} — odd numbers run west and even run east (§2.3), so its number chose the end`
|
||||
: `EXTRA X${e.trainNumber} started at the Control Point in seat ${e.atSeat}, running ${e.trainNumber % 2 === 0 ? 'east' : 'west'} — an Extra may begin at any Office above a Whistle Post instead of at a Division Point`,
|
||||
text: `EXTRA X${e.trainNumber} started at ${where}, running ${e.direction} — ${why}`,
|
||||
};
|
||||
}
|
||||
case 'trainMadeUp':
|
||||
return {
|
||||
tone: 'good',
|
||||
|
||||
+44
-6
@@ -18,7 +18,9 @@ import {
|
||||
laborersLeft,
|
||||
movesFor,
|
||||
ownCutFor,
|
||||
isTrainCard,
|
||||
portersLeft,
|
||||
resolveExtraStart,
|
||||
selectDestination,
|
||||
} from '../engine/apply.ts';
|
||||
import {
|
||||
@@ -323,6 +325,14 @@ export type DivisionView = {
|
||||
/** Office nodes only: whose district this is. */
|
||||
/** Which SEAT's district this is — a position on the Division, not a player. */
|
||||
seat?: number;
|
||||
/**
|
||||
* Interchange only: trains standing in its yard, not out on the running line (state.ts).
|
||||
*
|
||||
* Separate from `trains` for the same reason `switching` is separate from an Office's A/D list —
|
||||
* they are not occupying the thing whose capacity is being counted. An Extra made up here has to
|
||||
* be VISIBLE, though, or the player who placed it has a train that exists nowhere on the map.
|
||||
*/
|
||||
yard?: TrainChip[];
|
||||
/**
|
||||
* Office nodes only: crews working BELOW the Running Track.
|
||||
*
|
||||
@@ -469,6 +479,15 @@ export type Frame = {
|
||||
hand: string[];
|
||||
/** What each hand card does, in the same order — names alone are not a playable hand. */
|
||||
handWhat: string[];
|
||||
/**
|
||||
* Whether each hand card may be DISCARDED, in the same order.
|
||||
*
|
||||
* §6.2 as ruled by Jesse (Gitea#6): a train card never can be. The player has to be told which
|
||||
* cards those are, not merely find that a button is missing — that silence is the whole of the
|
||||
* Gitea#2 complaint, where a blocked platform left the board with nothing to click and no reason.
|
||||
* Named for the rule rather than for trains, since it answers the question the panel is asking.
|
||||
*/
|
||||
handDiscardable: boolean[];
|
||||
deck: number;
|
||||
/** The face-up card on top of each Department pile — the only one that may be drawn. */
|
||||
departments: string[];
|
||||
@@ -927,14 +946,29 @@ export function describeIntent(s: GameState, i: Intent): string {
|
||||
return `board passengers at ${at(i.at)}${onto(s, i.trayId, ' onto ')}`;
|
||||
case 'porter.detrain':
|
||||
return `detrain passengers at ${at(i.at)}${onto(s, i.trayId, ' from ')}`;
|
||||
/**
|
||||
* NAME THE PLACE AND THE DIRECTION, because the player is choosing both.
|
||||
*
|
||||
* This used to explain why the Extra had no choice — "it runs west, so that is the end it
|
||||
* starts from". It has one now (§7, Jesse's ruling), and every candidate is on screen at once,
|
||||
* so each label has to be distinguishable from its three or four siblings at a glance.
|
||||
*/
|
||||
case 'newTrain.startExtra': {
|
||||
const runs = i.trainNumber % 2 === 0 ? 'east' : 'west';
|
||||
if (i.atSeat === null) {
|
||||
const end = i.trainNumber % 2 === 0 ? 'Western' : 'Eastern';
|
||||
return `start Extra X${i.trainNumber} at the ${end} Division Point — it runs ${runs}, so that is the end it starts from`;
|
||||
const where = resolveExtraStart(s, s.clock.currentActor ?? 0, i);
|
||||
if (typeof where === 'string') return `start Extra X${i.trainNumber}`;
|
||||
const { direction } = where;
|
||||
if (where.at.kind === 'divisionPoint') {
|
||||
const end = where.at.side === 'west' ? 'Western' : 'Eastern';
|
||||
return `start Extra X${i.trainNumber} at the ${end} Division Point — it runs ${direction} from there`;
|
||||
}
|
||||
const tier = officeProfile(areaAtSeat(s, i.atSeat).tier).name;
|
||||
return `start Extra X${i.trainNumber} at the ${tier} in seat ${i.atSeat} — a Control Point, so it may begin its ${runs}bound run there instead`;
|
||||
if (where.at.kind === 'mainline') {
|
||||
return (
|
||||
`start Extra X${i.trainNumber} ${direction}bound in the Interchange — it is made up in the ` +
|
||||
'yard and highballs onto the Mainline once the Subdivision is clear'
|
||||
);
|
||||
}
|
||||
const tier = officeProfile(areaAtSeat(s, where.at.seat).tier).name;
|
||||
return `start Extra X${i.trainNumber} ${direction}bound at the ${tier} in seat ${where.at.seat} — a Control Point, so it may begin its run there`;
|
||||
}
|
||||
|
||||
case 'newTrain.placeCar':
|
||||
@@ -1159,6 +1193,9 @@ export function snapshot(
|
||||
};
|
||||
})],
|
||||
capacity: MAINLINE_PROFILES.find((m) => m.kind === n.card)?.trainsMayPass ? 2 : 1,
|
||||
// Drawn at the start of the card: the yard is beside the rail, and this is the end the
|
||||
// train will pull out of. It counts against nothing — see `yard` on DivisionView.
|
||||
yard: (n.holding ?? []).map((id) => ({ ...trainChip(s, id), region: 0 })),
|
||||
modifiers: [
|
||||
...(n.modifiers ?? []).map(prettyKey),
|
||||
...(n.absSignals ? ['ABS Signals'] : []),
|
||||
@@ -1247,6 +1284,7 @@ export function snapshot(
|
||||
*/
|
||||
hand: [...(s.decks.hands.get(viewer) ?? [])].reverse().map((id) => cardName(s, id)),
|
||||
handWhat: [...(s.decks.hands.get(viewer) ?? [])].reverse().map((id) => cardDescription(s, id)),
|
||||
handDiscardable: [...(s.decks.hands.get(viewer) ?? [])].reverse().map((id) => !isTrainCard(s, id)),
|
||||
deck: s.decks.homeOffice.length,
|
||||
departments: s.decks.departments.map((pile) => {
|
||||
const top = pile[pile.length - 1];
|
||||
|
||||
+34
-3
@@ -17,11 +17,12 @@ import {
|
||||
DEFAULT_MAX_COLLISIONS_PER_DAY,
|
||||
DEFAULT_MAX_COLLISIONS_TOTAL,
|
||||
MOVES_PER_LOCAL_OPS,
|
||||
EXTRA_START_LABELS,
|
||||
STARTING_HAND_LABELS,
|
||||
collectiveRevenueFloor,
|
||||
houseRules,
|
||||
} from '../engine/content.ts';
|
||||
import type { HouseRuleOverrides, HouseRules, RevenueRules, StartingHand } from '../engine/content.ts';
|
||||
import type { ExtraStartRule, HouseRuleOverrides, HouseRules, RevenueRules, StartingHand } from '../engine/content.ts';
|
||||
import type { NewGameOptions } from './game.ts';
|
||||
import type { LocalSession, Session } from './session.ts';
|
||||
import { createLocalSession, createRemoteSession } from './session.ts';
|
||||
@@ -274,6 +275,8 @@ function gameOptionsFromUrl(params: URLSearchParams): NewGameOptions {
|
||||
const rules: HouseRuleOverrides = {};
|
||||
const hand = params.get('hand');
|
||||
if (STARTING_HAND_LABELS.some((o) => o.value === hand)) rules.startingHand = hand as StartingHand;
|
||||
const extra = params.get('extra');
|
||||
if (EXTRA_START_LABELS.some((o) => o.value === extra)) rules.extraStart = extra as ExtraStartRule;
|
||||
|
||||
const revenue: Partial<RevenueRules> = {};
|
||||
for (const [param, key] of Object.entries(RULE_PARAMS)) {
|
||||
@@ -300,6 +303,9 @@ function rulesToUrl(rules: HouseRules, options: NewGameOptions, seed: string): s
|
||||
const params = new URLSearchParams();
|
||||
if (seed !== '') params.set('seed', seed);
|
||||
params.set('hand', rules.startingHand);
|
||||
// The dialog answers reach `start()` through the URL and nowhere else, so a setting missing from
|
||||
// here is a setting the dialog silently discards.
|
||||
params.set('extra', rules.extraStart);
|
||||
for (const [param, key] of Object.entries(RULE_PARAMS)) params.set(param, String(rules.revenue[key]));
|
||||
for (const [param, key] of Object.entries(VICTORY_PARAMS)) {
|
||||
const value = options[key];
|
||||
@@ -1221,9 +1227,29 @@ function renderActions(
|
||||
) {
|
||||
// The hand being counted is the ACTOR's — they are the one who cannot end the turn.
|
||||
const hand = f.handCount;
|
||||
/**
|
||||
* WHEN NOTHING IN HAND MAY BE DISCARDED, SAY SO AND SAY WHAT TO DO INSTEAD.
|
||||
*
|
||||
* §6.2 as ruled by Jesse (Gitea#6): a train card is never discarded, so a player holding four
|
||||
* trains has exactly one way forward — play one onto the timetable. The rule creates that corner
|
||||
* deliberately and needs no machinery, but it must not be a corner the player has to infer from
|
||||
* a discard button that has quietly stopped appearing.
|
||||
*/
|
||||
const stuck = f.handDiscardable.length > 0 && f.handDiscardable.every((d) => !d);
|
||||
const tip = stuck
|
||||
? '§6.2 — you may not end a turn holding more than three cards, and a TRAIN CARD IS NEVER ' +
|
||||
'DISCARDED. Every card you hold is a train, so the only way on is to play one onto the ' +
|
||||
'timetable. A train may be held for as many Stages and Days as you like; it just cannot be ' +
|
||||
'thrown away.'
|
||||
: '§6.2 — you may not end a turn holding more than three cards (four with a Red Flag). Play ' +
|
||||
'one onto the board, or discard one face-up to a Department slot. A train card is never ' +
|
||||
'discardable and can only be played.';
|
||||
html +=
|
||||
`<div class="grp"><button class="act blocked" disabled data-tip="§6.2 — you may not end a turn holding more than three cards (four with a Red Flag). Play one onto the board, or discard one face-up to a Department slot.">` +
|
||||
`End Local Operations — play or discard down to three first (holding ${hand})</button></div>`;
|
||||
`<div class="grp"><button class="act blocked" disabled data-tip="${tip.replace(/"/g, '"')}">` +
|
||||
(stuck
|
||||
? `End Local Operations — play a train card first, they cannot be discarded (holding ${hand})`
|
||||
: `End Local Operations — play or discard down to three first (holding ${hand})`) +
|
||||
`</button></div>`;
|
||||
}
|
||||
|
||||
el.innerHTML = html;
|
||||
@@ -1403,6 +1429,9 @@ if (newBtn && dlg) {
|
||||
for (const input of dlg.querySelectorAll<HTMLInputElement>('input[name="ng-hand"]')) {
|
||||
input.checked = input.value === current.startingHand;
|
||||
}
|
||||
for (const input of dlg.querySelectorAll<HTMLInputElement>('input[name="ng-extra"]')) {
|
||||
input.checked = input.value === current.extraStart;
|
||||
}
|
||||
field<HTMLInputElement>('ng-passenger').value = String(current.revenue.passengerPerCoach);
|
||||
field<HTMLInputElement>('ng-freight').value = String(current.revenue.freightPerLoad);
|
||||
field<HTMLInputElement>('ng-transit').value = String(current.revenue.trainPerTransit);
|
||||
@@ -1431,9 +1460,11 @@ if (newBtn && dlg) {
|
||||
// both mean "surprise me", which is what leaving the box alone plainly asks for.
|
||||
const seed = asked === '' || !Number.isFinite(Number(asked)) ? '' : String(Math.trunc(Number(asked)));
|
||||
const picked = dlg.querySelector<HTMLInputElement>('input[name="ng-hand"]:checked')?.value;
|
||||
const extra = dlg.querySelector<HTMLInputElement>('input[name="ng-extra"]:checked')?.value;
|
||||
const rules = houseRules({
|
||||
houseRules: {
|
||||
...(STARTING_HAND_LABELS.some((o) => o.value === picked) ? { startingHand: picked as StartingHand } : {}),
|
||||
...(EXTRA_START_LABELS.some((o) => o.value === extra) ? { extraStart: extra as ExtraStartRule } : {}),
|
||||
revenue: {
|
||||
passengerPerCoach: Number(field<HTMLInputElement>('ng-passenger').value),
|
||||
freightPerLoad: Number(field<HTMLInputElement>('ng-freight').value),
|
||||
|
||||
+11
-1
@@ -31,8 +31,18 @@ export function cardRow(name: string, why: string, playable: boolean | null): st
|
||||
}
|
||||
|
||||
export function handHtml(f: Frame, canPlay: (boolean | null)[] = []): string {
|
||||
// §6.2 (Gitea#6) — say so on the card itself. A player who cannot discard a train needs to read
|
||||
// that on the train, not deduce it from a button that is not there.
|
||||
const held = 'You may hold this for as many Stages and Days as you like — but a train card is ' +
|
||||
'never discarded (§6.2). The only way it leaves your hand is onto the timetable.';
|
||||
return f.hand.length
|
||||
? f.hand.map((h, i) => cardRow(h, f.handWhat[i] ?? '', canPlay[i] ?? null)).join('')
|
||||
? f.hand
|
||||
.map((h, i) => {
|
||||
const what = f.handWhat[i] ?? '';
|
||||
const keep = f.handDiscardable[i] === false;
|
||||
return cardRow(h, keep ? [what, held].filter(Boolean).join(' · ') : what, canPlay[i] ?? null);
|
||||
})
|
||||
.join('')
|
||||
: '<span class="dim">empty</span>';
|
||||
}
|
||||
|
||||
|
||||
@@ -493,6 +493,15 @@ ul.blocked li{padding:2px 0}
|
||||
<label class="ng-radio"><input type="radio" name="ng-hand" value="threeTrackThreeOther">
|
||||
<span><b>Three random track and three random non-track cards</b><br><span class="dim">Dealt from two piles, so the district you can build is dealt rather than waited for.</span></span></label>
|
||||
|
||||
<h3>Where an Extra may start</h3>
|
||||
<p class="ng-note">The player who plays an Extra Train card chooses where its Crew Tray goes, and the place decides which way it runs — a Division Point sends it away from itself; in the middle of the railroad the player picks east or west. The Division Points and the Interchange belong to nobody and are always available. Starting one inside a district is the part that favours a seat, so it is set here. An Office must be a Control Point whatever this says: a Whistle Post never qualifies.</p>
|
||||
<label class="ng-radio"><input type="radio" name="ng-extra" value="divisionPointsOnly">
|
||||
<span><b>Division Points and the Interchange only</b><br><span class="dim">The strictest reading of §7. Every Extra begins on shared ground.</span></span></label>
|
||||
<label class="ng-radio"><input type="radio" name="ng-extra" value="ownOffice">
|
||||
<span><b>Also the playing player’s own Control Point</b><br><span class="dim">You may start one at home, but not in somebody else’s district.</span></span></label>
|
||||
<label class="ng-radio"><input type="radio" name="ng-extra" value="anyOffice" checked>
|
||||
<span><b>Also any player’s Control Point</b><br><span class="dim">The most permissive, and what the game did before this setting existed.</span></span></label>
|
||||
|
||||
<h3>Revenue</h3>
|
||||
<p class="ng-note">What each piece of work pays, 0 to 5. A coach pays when it is boarded and again when it is detrained; a load pays when it is made up and again when it is broken. Zero switches an economy off so the others can be read.</p>
|
||||
<label class="ng-num"><span>Passenger revenue per coach</span>
|
||||
|
||||
Reference in New Issue
Block a user