v0.6.1 — five of six playtest bugs: one button per train, and a load that has to go somewhere
Gameplay testing on 0.4.9d returned six reports. Five are fixed; the sixth could not be reproduced and is written up in TODO.md with the two questions that would pin it down. TWO TRAINS AT ONE PLATFORM ANSWERED TO ONE BUTTON. `porter.board` and `porter.detrain` carried no tray, so there was one button per platform however many trains stood at it and the reducer filled the first empty coach on the A/D tracks. `check` and the reducer were not even asking the same question: `check` skipped a train whose card refuses passenger work and the reducer did not. Both intents now carry an optional `trayId`, one function resolves the train and the coach for check/execute/reduce alike, `legal.ts` offers one candidate per train, and the label names it. A LOAD COULD BE MADE AND BROKEN WITHOUT GOING ANYWHERE. A Freight House could unload the boxcar it had just loaded; a platform could detrain the passengers it had just boarded. Full Revenue at both ends for a movement that never happened. Jesse's rule: a load made anywhere in an Office Area may not be broken anywhere in that Office Area, ever — it has to be carried to another district. The load carries the seat that made it (`RollingStock.origin`), stripped by `pooled` at every yard push. Measured at -0.60 +/- 0.10 Revenue a game (t = -6.1) over 400 paired deals: 78 worse, 3 better, 319 unchanged — free Revenue coming off the board, not a nerf. THE GROCER'S WAREHOUSE SHIPPED AND THE REFINERY RECEIVED. Both were `flow: 'both'` on the reading that "Freight House" was a collective term for exactly those two, and therefore what §9.3 described. The engine has dealt a Freight House CARD since before v0.4.9, so §9.3 names it and the argument goes. The card set agrees: all three Refinery modifiers grant +1 outbound. Refinery outbound-only, Grocer's inbound-only, Freight House the one two-way industry — which leaves exactly the one same-district pairing the rule above refuses. NOT REPRODUCED: cars left behind when backing up over them. Five layouts tried, including cars spotted at an industry; every one couples the lot. Three are pinned in `apply.test.ts`. One way to create such cars was closed anyway — `flyingSwitch` wrote its cut past `carsOn`. Both published replays that had gone dead were re-recorded; a rules change retires a save, and `harness.test.ts` is what catches it. The same change ships as v0.4.9e on the 0.4.9 line, branched from the v0.4.9d commit — the engine files these fixes touch are identical across the two lines, so the patch applied cleanly both ways. Also carries the two "Queued 2026-08-22, from playing on StartOS" TODO items that were staged before this work started (Games in Progress readability, and getting back into a game after losing a browser). They are notes, and items 9-12 below them are numbered against them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011nbvwWMef8CuEP6t5cgkTv
This commit is contained in:
co-authored by
Claude Opus 5
parent
40f07b0710
commit
83a5450866
@@ -39,7 +39,7 @@ import type { GameEvent } from './events.ts';
|
||||
import { areaAtSeat, areaOf, trainNeedingCars } from './apply.ts';
|
||||
import { legalActions } from './legal.ts';
|
||||
import type { CrewTray, DivisionNode, GameState, PlayerIndex, RollingStock, SeatIndex, TrayId } from './state.ts';
|
||||
import { coordKey, freshTurns, playerAtSeat, playerLeftOf, subdivisions, totalRevenue, turnOf } from './state.ts';
|
||||
import { coordKey, freshTurns, playerAtSeat, playerLeftOf, pooled, subdivisions, totalRevenue, turnOf } from './state.ts';
|
||||
|
||||
export type AdvanceResult = {
|
||||
events: GameEvent[];
|
||||
@@ -959,9 +959,11 @@ function collide(
|
||||
consist: [...tray.consist],
|
||||
});
|
||||
// Gap 2c — engines and cabooses return to the Division Yard, everything else to Classification.
|
||||
// `pooled` because a car reaching a yard is back in the common supply: the load's origin stamp
|
||||
// (state.ts) belongs to the load, not to the car that happened to be carrying it.
|
||||
for (const car of tray.consist) {
|
||||
if (car.type === 'caboose') s.yards.divisionYard.push(car);
|
||||
else s.yards.classificationYard.push(car);
|
||||
if (car.type === 'caboose') s.yards.divisionYard.push(pooled(car));
|
||||
else s.yards.classificationYard.push(pooled(car));
|
||||
}
|
||||
s.trays.delete(id);
|
||||
s.freeTrays.push(id);
|
||||
@@ -1031,9 +1033,10 @@ function retireTrain(
|
||||
side: Direction,
|
||||
events: GameEvent[],
|
||||
): void {
|
||||
// `pooled` — see `trainsDestroyed` above; a load's origin stamp does not survive the yard.
|
||||
for (const car of tray.consist) {
|
||||
if (car.type === 'caboose') s.yards.divisionYard.push(car);
|
||||
else s.yards.classificationYard.push(car);
|
||||
if (car.type === 'caboose') s.yards.divisionYard.push(pooled(car));
|
||||
else s.yards.classificationYard.push(pooled(car));
|
||||
}
|
||||
s.trays.delete(id);
|
||||
s.freeTrays.push(id);
|
||||
|
||||
+137
-60
@@ -59,6 +59,7 @@ import {
|
||||
cutTowards,
|
||||
isOperationalRail,
|
||||
playerAtSeat,
|
||||
pooled,
|
||||
railFacingOf,
|
||||
seatOf,
|
||||
spaceOn,
|
||||
@@ -388,17 +389,11 @@ export function canStartLoad(f: Facility): boolean {
|
||||
}
|
||||
|
||||
/** §9.2 — boarding needs a loaded coach in a green slot and a train with an empty coach. */
|
||||
export function canBoard(s: GameState, player: PlayerIndex, at: GridCoord): boolean {
|
||||
export function canBoard(s: GameState, player: PlayerIndex, at: GridCoord, trayId?: TrayId): boolean {
|
||||
const f = facilityAt(s, player, at);
|
||||
if (!f || f.kind !== 'passenger' || portersLeft(f) < 1) return false;
|
||||
if (!f.outboundBox.some((c) => c.type === 'coach' && c.loaded)) return false;
|
||||
// §7 — a train whose card refuses passenger work, or which is not booked to stop here, is not a
|
||||
// train these passengers can board however many empty coaches it is carrying.
|
||||
return trainAtOfficeWith(
|
||||
s, player,
|
||||
(c) => c.type === 'coach' && !c.loaded,
|
||||
(t) => !refusesPassengers(t) && !refusesThisOffice(s, player, t),
|
||||
);
|
||||
return passengerWork(s, player, 'board', trayId) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,29 +408,54 @@ export function canBoard(s: GameState, player: PlayerIndex, at: GridCoord): bool
|
||||
* de-training MINTED a coach: the loaded one went to the red box and a new empty one appeared in the
|
||||
* train. Measured at 1.29 cars a game created out of nothing across the two inbound paths.
|
||||
*/
|
||||
export function canDetrain(s: GameState, player: PlayerIndex, at: GridCoord): boolean {
|
||||
export function canDetrain(s: GameState, player: PlayerIndex, at: GridCoord, trayId?: TrayId): boolean {
|
||||
const f = facilityAt(s, player, at);
|
||||
if (!f || f.kind !== 'passenger' || portersLeft(f) < 1) return false;
|
||||
if (f.inboundBox.length >= f.capacity.inbound) return false;
|
||||
if (!s.yards.divisionYard.some((c) => c.type === 'coach' && !c.loaded)) return false;
|
||||
return trainAtOfficeWith(
|
||||
s, player,
|
||||
(c) => c.type === 'coach' && c.loaded,
|
||||
(t) => !refusesPassengers(t) && !refusesThisOffice(s, player, t),
|
||||
);
|
||||
return passengerWork(s, player, 'detrain', trayId) !== null;
|
||||
}
|
||||
|
||||
function trainAtOfficeWith(
|
||||
/**
|
||||
* WHICH TRAIN, AND WHICH COACH ON IT — the one answer `check`, `execute` and the reducer all use.
|
||||
*
|
||||
* TWO PLAYTEST BUGS SHARED ONE CAUSE HERE. Reported against v0.4.9d: "operating two trains in a
|
||||
* station, the select button does not work — regardless of which you pick, it is always one train,
|
||||
* not the other". `porter.board` carried no tray at all, so `check` asked whether SOME train at the
|
||||
* Office had an empty coach and the reducer then walked `adOccupancy` and filled the first one it
|
||||
* found. The two were not even asking the same question: `check` skipped a train whose card refuses
|
||||
* passenger work and the reducer did not, so a Military train could be boarded as long as some other
|
||||
* train at the platform was eligible. The intent now names its tray (`intents.ts`) and this is the
|
||||
* one place that resolves it.
|
||||
*
|
||||
* And "passengers just boarded cannot be immediately unloaded": a coach carries the district that
|
||||
* filled it (`RollingStock.origin`), and a homegrown coach is not a coach these passengers may
|
||||
* alight from — they have to be carried to a different Office Area first.
|
||||
*
|
||||
* `trayId` absent means "any eligible train", which is what every intent recorded before this
|
||||
* existed meant, so an old save replays unchanged.
|
||||
*/
|
||||
function passengerWork(
|
||||
s: GameState,
|
||||
player: PlayerIndex,
|
||||
pred: (c: RollingStock) => boolean,
|
||||
trayOk: (t: CrewTray) => boolean = () => true,
|
||||
): boolean {
|
||||
dir: 'board' | 'detrain',
|
||||
trayId?: TrayId,
|
||||
): { trayId: TrayId; coachIndex: number } | null {
|
||||
const area = areaOf(s, player);
|
||||
return area.adOccupancy.some((id) => {
|
||||
const t = s.trays.get(id);
|
||||
return !!t && trayOk(t) && t.consist.some(pred);
|
||||
});
|
||||
const seat = seatOf(s, player);
|
||||
const wanted = (c: RollingStock): boolean =>
|
||||
c.type === 'coach' && (dir === 'board' ? !c.loaded : c.loaded && c.origin !== seat);
|
||||
for (const id of area.adOccupancy) {
|
||||
if (trayId !== undefined && id !== trayId) continue;
|
||||
const tray = s.trays.get(id);
|
||||
if (!tray) continue;
|
||||
// §7 — a train whose card refuses passenger work, or which is not booked to stop here, is not a
|
||||
// train these passengers can board however many empty coaches it is carrying.
|
||||
if (refusesPassengers(tray) || refusesThisOffice(s, player, tray)) continue;
|
||||
const coachIndex = tray.consist.findIndex(wanted);
|
||||
if (coachIndex >= 0) return { trayId: id, coachIndex };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -570,12 +590,30 @@ function passengerRefusal(
|
||||
player: PlayerIndex,
|
||||
at: GridCoord,
|
||||
dir: 'board' | 'detrain',
|
||||
trayId?: TrayId,
|
||||
): RejectionCode {
|
||||
const area = areaOf(s, player);
|
||||
const trains = area.adOccupancy.map((id) => s.trays.get(id)).filter((t): t is CrewTray => !!t);
|
||||
const trains = area.adOccupancy
|
||||
.filter((id) => trayId === undefined || id === trayId)
|
||||
.map((id) => s.trays.get(id))
|
||||
.filter((t): t is CrewTray => !!t);
|
||||
if (trains.length > 0 && trains.every((t) => refusesThisOffice(s, player, t))) return 'NOT_A_TERMINAL';
|
||||
if (trains.length > 0 && trains.every(refusesPassengers)) return 'NO_PASSENGER_WORK';
|
||||
if (trains.length === 0) return 'NO_TRAIN_AT_OFFICE';
|
||||
/**
|
||||
* EVERY LOADED COACH ABOARD BOARDED HERE — so the refusal is the district rule, not "no loaded
|
||||
* coach". Told apart because the two read as opposite situations to a player: one is an empty
|
||||
* train, the other is a train full of passengers who have not been anywhere yet.
|
||||
*/
|
||||
if (
|
||||
dir === 'detrain' &&
|
||||
trains.some((t) => t.consist.some((c) => c.type === 'coach' && c.loaded)) &&
|
||||
trains.every((t) =>
|
||||
t.consist.every((c) => !(c.type === 'coach' && c.loaded) || c.origin === seatOf(s, player)),
|
||||
)
|
||||
) {
|
||||
return 'LOADED_IN_THIS_DISTRICT';
|
||||
}
|
||||
|
||||
/**
|
||||
* A TRAIN IS STANDING THERE, so say what is actually missing.
|
||||
@@ -981,7 +1019,8 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (!f) return 'NO_SUCH_FACILITY';
|
||||
if (f.porters < 1) return 'NO_PORTERS_HERE';
|
||||
if (portersLeft(f) < 1) return 'RESOURCE_SPENT';
|
||||
return canBoard(s, player, i.at) ? null : passengerRefusal(s, player, i.at, 'board');
|
||||
if (i.trayId !== undefined && !s.trays.has(i.trayId)) return 'NO_SUCH_TRAY';
|
||||
return canBoard(s, player, i.at, i.trayId) ? null : passengerRefusal(s, player, i.at, 'board', i.trayId);
|
||||
}
|
||||
|
||||
case 'porter.detrain': {
|
||||
@@ -990,7 +1029,8 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (!f) return 'NO_SUCH_FACILITY';
|
||||
if (f.porters < 1) return 'NO_PORTERS_HERE';
|
||||
if (portersLeft(f) < 1) return 'RESOURCE_SPENT';
|
||||
return canDetrain(s, player, i.at) ? null : passengerRefusal(s, player, i.at, 'detrain');
|
||||
if (i.trayId !== undefined && !s.trays.has(i.trayId)) return 'NO_SUCH_TRAY';
|
||||
return canDetrain(s, player, i.at, i.trayId) ? null : passengerRefusal(s, player, i.at, 'detrain', i.trayId);
|
||||
}
|
||||
|
||||
case 'laborer.startLoad': {
|
||||
@@ -1026,6 +1066,19 @@ export function check(s: GameState, player: PlayerIndex, i: Intent): RejectionCo
|
||||
if (laborersLeft(f) < 1) return 'RESOURCE_SPENT';
|
||||
const car = f.industryTrack.cars[i.carIndex];
|
||||
if (!car || !car.loaded) return 'WRONG_CAR_TYPE';
|
||||
/**
|
||||
* A LOAD MAY NOT BE BROKEN IN THE DISTRICT THAT MADE IT (Jesse's ruling, v0.4.9e).
|
||||
*
|
||||
* Reported from playtesting v0.4.9d: "Freight House: boxcars loaded cannot be immediately
|
||||
* unloaded." They could — a Freight House permits both directions, so the car its own Laborers
|
||||
* had just loaded was standing on its own track, loaded, with an empty of that type in the
|
||||
* yard, and every gate below said yes. Full Revenue at both ends for a load that never moved.
|
||||
*
|
||||
* The rule is district-wide and permanent, not "not at this facility" and not "not this
|
||||
* Stage": the stamp says which Office Area made the load, and it never expires. Traffic runs
|
||||
* BETWEEN districts, which is what the lockout pairs in `content.ts` exist to force.
|
||||
*/
|
||||
if (car.origin === seatOf(s, player)) return 'LOADED_IN_THIS_DISTRICT';
|
||||
/**
|
||||
* §9.3 — "*Requirements: a load on the industry's track AND AN EMPTY CAR OF THAT TYPE IN THE
|
||||
* DIVISION YARD. The first Laborer replaces the load with an empty car of that type.*"
|
||||
@@ -1617,17 +1670,23 @@ function execute(s: GameState, player: PlayerIndex, i: Intent): GameEvent[] {
|
||||
* `passengerPerCoach` (`content.ts`). Half a passenger movement is half the work, and the rate
|
||||
* is named per COACH because a Porter handles exactly one coach per action.
|
||||
*/
|
||||
case 'porter.board':
|
||||
case 'porter.board': {
|
||||
// `check` has already established there is one; resolving it HERE, once, is what stops the
|
||||
// reducer from finding a different train than the one the rules were tested against.
|
||||
const work = passengerWork(s, player, 'board', i.trayId)!;
|
||||
return [
|
||||
{ type: 'passengersBoarded', player, at: i.at },
|
||||
{ type: 'passengersBoarded', player, at: i.at, ...work },
|
||||
...earns(s, player, houseRules(s.config).revenue.passengerPerCoach, 'boarding'),
|
||||
];
|
||||
}
|
||||
|
||||
case 'porter.detrain':
|
||||
case 'porter.detrain': {
|
||||
const work = passengerWork(s, player, 'detrain', i.trayId)!;
|
||||
return [
|
||||
{ type: 'passengersDetrained', player, at: i.at },
|
||||
{ type: 'passengersDetrained', player, at: i.at, ...work },
|
||||
...earns(s, player, houseRules(s.config).revenue.passengerPerCoach, 'detraining'),
|
||||
];
|
||||
}
|
||||
|
||||
case 'laborer.startLoad': {
|
||||
const f = facilityAt(s, player, i.at)!;
|
||||
@@ -1956,9 +2015,14 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
const card = area.grid.get(coordKey(e.to));
|
||||
if (tray && card) {
|
||||
tray.consist = tray.consist.slice(0, tray.consist.length - e.stock.length);
|
||||
const track = card.facility?.industryTrack;
|
||||
if (track) track.cars.push(...e.stock);
|
||||
else card.standing.push(...e.stock);
|
||||
// `carsOn` is the one function that knows WHERE cars stand on a given card — an industry
|
||||
// track for a freight facility, the card itself for everything else. Written out longhand
|
||||
// here it was a second copy of that rule, and the copy was wrong for a Passenger Facility:
|
||||
// it has an `industryTrack` too (an empty one, `setup.ts`), so a cut pushed into an Office
|
||||
// would have landed somewhere `carsOn` cannot see — cars on the board that no train can
|
||||
// couple and no walk is blocked by. `check` refuses a non-freight target, so this never
|
||||
// fired; a trap that needs another rule to stay unsprung is still a trap.
|
||||
carsOn(card).push(...e.stock);
|
||||
}
|
||||
turnOf(s, e.player).movesRemaining -= 1;
|
||||
spendCard(s, e.player, e.cardId);
|
||||
@@ -2049,7 +2113,8 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
const f = facilityAt(s, e.player, e.at)!;
|
||||
const idx = f.inboundBox.findIndex((c) => c.type === e.stock.type && c.loaded === e.stock.loaded);
|
||||
if (idx >= 0) f.inboundBox.splice(idx, 1);
|
||||
s.yards.classificationYard.push(e.stock);
|
||||
// `pooled` — a car back in a yard is back in the common supply, carrying nothing (state.ts).
|
||||
s.yards.classificationYard.push(pooled(e.stock));
|
||||
turnOf(s, e.player).freightAgentUsed = true;
|
||||
break;
|
||||
}
|
||||
@@ -2064,7 +2129,7 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
const idx = box.findIndex((c) => c.type === e.stock.type);
|
||||
if (idx >= 0) box.splice(idx, 1);
|
||||
}
|
||||
s.yards.classificationYard.push(e.stock);
|
||||
s.yards.classificationYard.push(pooled(e.stock));
|
||||
turnOf(s, e.player).freightAgentUsed = true;
|
||||
break;
|
||||
}
|
||||
@@ -2132,19 +2197,28 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* THE TRAIN AND THE COACH THE PLAYER PICKED, not "the first one on the A/D tracks".
|
||||
*
|
||||
* This used to walk `adOccupancy` and fill the first empty coach it met, which is why two trains
|
||||
* standing at one station both answered to whichever chip was clicked (v0.4.9d playtest), and
|
||||
* why it could fill a coach on a train whose card refuses passenger work — `check` skipped such
|
||||
* a train and the reducer did not. `e.trayId`/`e.coachIndex` are exactly what `passengerWork`
|
||||
* resolved for `check`, carried on the event rather than looked up again here.
|
||||
*/
|
||||
case 'passengersBoarded': {
|
||||
const f = facilityAt(s, e.player, e.at)!;
|
||||
const area = areaOf(s, e.player);
|
||||
const idx = f.outboundBox.findIndex((c) => c.type === 'coach' && c.loaded);
|
||||
const loaded = f.outboundBox.splice(idx, 1)[0]!;
|
||||
for (const id of area.adOccupancy) {
|
||||
const tray = s.trays.get(id);
|
||||
const ci = tray?.consist.findIndex((c) => c.type === 'coach' && !c.loaded) ?? -1;
|
||||
if (tray && ci >= 0) {
|
||||
s.yards.classificationYard.push(tray.consist[ci]!);
|
||||
tray.consist[ci] = loaded;
|
||||
break;
|
||||
}
|
||||
const tray = s.trays.get(e.trayId);
|
||||
if (tray && tray.consist[e.coachIndex]) {
|
||||
s.yards.classificationYard.push(pooled(tray.consist[e.coachIndex]!));
|
||||
/**
|
||||
* Stamped with the district that filled it — the chip turned upside down in the tray. These
|
||||
* passengers may not alight anywhere in this Office Area; the train has to carry them to a
|
||||
* different one. See `RollingStock.origin` in state.ts.
|
||||
*/
|
||||
tray.consist[e.coachIndex] = { ...loaded, origin: seatOf(s, e.player) };
|
||||
}
|
||||
f.usedThisStage.porters += 1;
|
||||
break;
|
||||
@@ -2152,21 +2226,18 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
|
||||
case 'passengersDetrained': {
|
||||
const f = facilityAt(s, e.player, e.at)!;
|
||||
const area = areaOf(s, e.player);
|
||||
for (const id of area.adOccupancy) {
|
||||
const tray = s.trays.get(id);
|
||||
const ci = tray?.consist.findIndex((c) => c.type === 'coach' && c.loaded) ?? -1;
|
||||
if (tray && ci >= 0) {
|
||||
// The empty coach comes OUT OF THE DIVISION YARD, as §9.2 says. It used to be conjured,
|
||||
// which minted a coach on every de-training. Throws now, for the reason in `unloadBegan`.
|
||||
const yi = s.yards.divisionYard.findIndex((c) => c.type === 'coach' && !c.loaded);
|
||||
if (yi < 0) throw new Error('passengersDetrained: no empty coach in the Division Yard');
|
||||
const empty = s.yards.divisionYard.splice(yi, 1)[0]!;
|
||||
refillDivisionYardIfEmpty(s);
|
||||
f.inboundBox.push(tray.consist[ci]!);
|
||||
tray.consist[ci] = empty;
|
||||
break;
|
||||
}
|
||||
const tray = s.trays.get(e.trayId);
|
||||
if (tray && tray.consist[e.coachIndex]) {
|
||||
// The empty coach comes OUT OF THE DIVISION YARD, as §9.2 says. It used to be conjured,
|
||||
// which minted a coach on every de-training. Throws now, for the reason in `unloadBegan`.
|
||||
const yi = s.yards.divisionYard.findIndex((c) => c.type === 'coach' && !c.loaded);
|
||||
if (yi < 0) throw new Error('passengersDetrained: no empty coach in the Division Yard');
|
||||
const empty = s.yards.divisionYard.splice(yi, 1)[0]!;
|
||||
refillDivisionYardIfEmpty(s);
|
||||
// The arriving coach goes into the red box carrying nothing: the journey it was stamped for
|
||||
// is over, and the box feeds straight back to a yard through the Freight Agent.
|
||||
f.inboundBox.push(pooled(tray.consist[e.coachIndex]!));
|
||||
tray.consist[e.coachIndex] = empty;
|
||||
}
|
||||
f.usedThisStage.porters += 1;
|
||||
break;
|
||||
@@ -2202,8 +2273,14 @@ export function reduce(s: GameState, e: GameEvent): void {
|
||||
workTrack(f)[workTrack(f).length - 1] = null;
|
||||
const ci = f.industryTrack.cars.findIndex((c) => !c.loaded && c.type === e.carType);
|
||||
if (ci >= 0) {
|
||||
s.yards.classificationYard.push(f.industryTrack.cars[ci]!);
|
||||
f.industryTrack.cars[ci] = { type: e.carType, loaded: true };
|
||||
s.yards.classificationYard.push(pooled(f.industryTrack.cars[ci]!));
|
||||
/**
|
||||
* THE LOAD IS STAMPED WITH THE DISTRICT THAT MADE IT — the chip turned upside down in the
|
||||
* tray. `laborer.beginUnload` refuses a car stamped with the district it is standing in, so
|
||||
* this load now has to leave the Office Area on a train before anyone can break it. See
|
||||
* `RollingStock.origin` in state.ts for the rule and why it is a seat.
|
||||
*/
|
||||
f.industryTrack.cars[ci] = { type: e.carType, loaded: true, origin: seatOf(s, e.player) };
|
||||
}
|
||||
f.usedThisStage.laborers += 1;
|
||||
break;
|
||||
|
||||
+32
-23
@@ -231,42 +231,51 @@ 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 },
|
||||
/**
|
||||
* BOTH DIRECTIONS, per the card reference — this was `outbound` and it contradicted the rules.
|
||||
* OUTBOUND ONLY. A Refinery ships oil out and receives nothing; reported from playtesting and
|
||||
* confirmed by Jesse (v0.4.9e): "only ships out tanks, does not receive anything".
|
||||
*
|
||||
* `card-reference.md`: "Oil Refinery | Tank car | Both | 3 | 2 | 2 | 4", and in prose — "'Freight
|
||||
* House' is not a card. It is the collective term for a freight facility that loads *and* unloads
|
||||
* — the Grocer's Warehouse and the Oil Refinery." §9.3's "Passenger Facilities and Freight Houses
|
||||
* permit cars to move each direction" therefore names exactly these two, and the engine had both
|
||||
* of them one-way.
|
||||
* It was briefly `flow: 'both'`, on the reading that "'Freight House' is not a card — it is the
|
||||
* collective term for a freight facility that loads *and* unloads, the Grocer's Warehouse and the
|
||||
* Oil Refinery", which made §9.3's "Passenger Facilities and Freight Houses permit cars to move
|
||||
* each direction" name exactly those two. That premise is dead: `glossary.md` and
|
||||
* `rules-v0.2.md` corrected the Freight House to a card of its own, dealt like any other industry,
|
||||
* so §9.3 names the Freight House and nothing else, and card-reference.md's "Both" column loses
|
||||
* the only argument it had.
|
||||
*
|
||||
* The consequence was silent: `usableGrant` drops a Modifier's grant on a direction its host
|
||||
* cannot use, so every +1 inbound beside a Refinery went nowhere.
|
||||
*
|
||||
* The base numbers stay at the engine's own scale (1 per direction it allows) rather than the card
|
||||
* reference's 2/2 — every industry here is scaled down the same way, Mine Tipple included, and
|
||||
* raising one of them alone would be a balance change rather than a correction. Flagged in TODO.
|
||||
* The card set says the same thing on its own. All three Refinery modifiers — Pipelines, Oil
|
||||
* Depot, Viscosity Breakers — grant `+1 outbound`; a two-way Refinery would be the one industry in
|
||||
* the game with no way to raise the direction it is supposed to use half its capacity on.
|
||||
* `StationMaster-Home-Deck-v0.4.5.md` prints it "Outbound, 1 out / 0 in".
|
||||
*/
|
||||
{ kind: 'refinery', name: 'Refinery', carTypes: ['tank'], flow: 'both', baseOut: 1, baseIn: 1, baseLoaders: 1, lockouts: ['powerPlant'], copies: 3 },
|
||||
{ kind: 'refinery', name: 'Refinery', carTypes: ['tank'], flow: 'outbound', baseOut: 1, baseIn: 0, baseLoaders: 1, lockouts: ['powerPlant'], copies: 3 },
|
||||
{ kind: 'powerPlant', name: 'Power Plant', carTypes: ['hopper', 'tank'], flow: 'inbound', baseOut: 0, baseIn: 1, baseLoaders: 1, lockouts: ['mineTipple', 'refinery'], copies: 6 },
|
||||
{ kind: 'packingSheds', name: 'Packing Sheds', carTypes: ['reefer'], flow: 'outbound', baseOut: 1, baseIn: 0, baseLoaders: 1, lockouts: ['grocersWarehouse'], copies: 3 },
|
||||
/**
|
||||
* BOTH DIRECTIONS — see the Refinery above; "Grocer's Warehouse | Boxcar | Both | 2 | 2 | 2 | 3".
|
||||
* INBOUND ONLY — the mirror of the Refinery above, and the same correction. Reported from
|
||||
* playtesting and confirmed by Jesse (v0.4.9e): "Grocer's Warehouse should be receive only, does
|
||||
* not ship anything out". `StationMaster-Home-Deck-v0.4.5.md` prints it "Inbound, 0 out / 1 in".
|
||||
*
|
||||
* Reported from play: "grocer's warehouse didn't get extra outbound slot for truck dock." It could
|
||||
* not: the Truck Dock printed +1 outbound at the time and this was `flow: 'inbound'`, so the grant
|
||||
* was dropped on a direction the facility did not have. The same trap still swallows an Ice House
|
||||
* set beside a Grocer's that has been left one-way.
|
||||
*
|
||||
* `TODO.md` had previously recorded this as "checked, and there is no bug" on the reasoning that a
|
||||
* Grocer's is inbound-only. That premise was the bug.
|
||||
* THE ICE HOUSE IS THEREFORE A DEAD CARD BESIDE A GROCER'S, and that is the design, not an
|
||||
* oversight: `usableGrant` drops a Modifier's grant on a direction its host cannot use, and the
|
||||
* Home Deck sheet says so outright — "a bonus beside a facility that cannot use its direction is
|
||||
* not usable", naming the Truck Dock's inbound bonus beside the outbound-only Packing Sheds as the
|
||||
* other example. The Truck Dock (+1 inbound) and Local Small Groceries (+1 Laborer) are the two
|
||||
* that do work here.
|
||||
*/
|
||||
{ kind: 'grocersWarehouse', name: "Grocer's Warehouse", carTypes: ['boxcar', 'reefer'], flow: 'both', baseOut: 1, baseIn: 1, baseLoaders: 1, lockouts: ['packingSheds', 'freightHouse'], copies: 3 },
|
||||
{ kind: 'grocersWarehouse', name: "Grocer's Warehouse", carTypes: ['boxcar', 'reefer'], flow: 'inbound', baseOut: 0, baseIn: 1, baseLoaders: 1, lockouts: ['packingSheds', 'freightHouse'], copies: 3 },
|
||||
];
|
||||
|
||||
/** Legacy alias; the engine still reads FREIGHT_PROFILES in places. */
|
||||
export const FREIGHT_PROFILES = INDUSTRY_PROFILES;
|
||||
|
||||
/** §9.3 — the collective term for an industry that both loads and unloads. */
|
||||
/**
|
||||
* §9.3 — "Passenger Facilities and Freight Houses permit cars to move each direction".
|
||||
*
|
||||
* ONE CARD ANSWERS TO THIS NOW: the Freight House itself. It was briefly three, while the Refinery
|
||||
* and the Grocer's Warehouse were also `both` on a reading of the term the glossary has since
|
||||
* corrected — a Freight House is a card, not a collective noun. Kept as a predicate on `flow`
|
||||
* rather than a comparison against the kind, because it is the DIRECTION §9.3 is talking about.
|
||||
*/
|
||||
export function isFreightHouse(p: IndustryProfile): boolean {
|
||||
return p.flow === 'both';
|
||||
}
|
||||
|
||||
+10
-2
@@ -163,8 +163,16 @@ export type GameEvent =
|
||||
| { type: 'clearanceRequested'; trainId: TrayId; occupiedBy: TrayId }
|
||||
| { type: 'clearanceGiven'; trainId: TrayId; allow: boolean }
|
||||
// -- load / unload
|
||||
| { type: 'passengersBoarded'; player: PlayerIndex; at: GridCoord }
|
||||
| { type: 'passengersDetrained'; player: PlayerIndex; at: GridCoord }
|
||||
/**
|
||||
* `trayId` and `coachIndex` name the TRAIN and the COACH the Porter worked, rather than leaving the
|
||||
* reducer to find them again — the same lesson as `unloadBegan`'s `carIndex` below. Re-deriving
|
||||
* "the first empty coach on the first train at the Office" is how two trains standing at one
|
||||
* station both answered to one roster chip (v0.4.9d playtest), and how a coach the player had not
|
||||
* chosen got filled. Required, not optional: an event is a fact, and a fact that has to be looked
|
||||
* up against live state cannot render standalone in a replay.
|
||||
*/
|
||||
| { type: 'passengersBoarded'; player: PlayerIndex; at: GridCoord; trayId: TrayId; coachIndex: number }
|
||||
| { type: 'passengersDetrained'; player: PlayerIndex; at: GridCoord; trayId: TrayId; coachIndex: number }
|
||||
| { type: 'loadStarted'; player: PlayerIndex; at: GridCoord; carType: CarType }
|
||||
| { type: 'loadAdvanced'; player: PlayerIndex; at: GridCoord; fromBox: number; toBox: number }
|
||||
| { type: 'unloadCompleted'; player: PlayerIndex; at: GridCoord; carType: CarType }
|
||||
|
||||
+23
-2
@@ -101,8 +101,18 @@ export type Intent =
|
||||
| { type: 'maneuver.flyingSwitch'; cardId: CardId; trayId: TrayId; count: number; to: GridCoord }
|
||||
| { type: 'redFlag.play' }
|
||||
// -- Load/Unload Phase (§9)
|
||||
| { type: 'porter.board'; at: GridCoord }
|
||||
| { type: 'porter.detrain'; at: GridCoord }
|
||||
/**
|
||||
* `trayId` names the train the Porter works — reported from playtesting v0.4.9d as "operating two
|
||||
* trains in a station, the select button does not work: regardless of which you pick, it is always
|
||||
* one train, not the other". It was: neither intent carried a train, so the reducer took the first
|
||||
* one on the A/D tracks and the roster chip the player had clicked changed nothing but the drawing.
|
||||
*
|
||||
* OPTIONAL, like `switch.move`'s `via` and for the same reason: intents are the canonical record
|
||||
* `undo` and every save replay against, and absent means what it has always meant — the first
|
||||
* eligible train at the Office.
|
||||
*/
|
||||
| { type: 'porter.board'; at: GridCoord; trayId?: TrayId }
|
||||
| { type: 'porter.detrain'; at: GridCoord; trayId?: TrayId }
|
||||
/** §9.3 — the first Laborer step: Green Loading Slot -> MEN. */
|
||||
| { type: 'laborer.startLoad'; at: GridCoord }
|
||||
| { type: 'laborer.advanceLoad'; at: GridCoord; box: number }
|
||||
@@ -199,6 +209,17 @@ export type RejectionCode =
|
||||
* the Laborers can move it out of the box.
|
||||
*/
|
||||
| 'NO_EMPTY_CAR_SPOTTED'
|
||||
/**
|
||||
* §9 (Jesse's ruling, v0.4.9e) — freight or passengers loaded anywhere in an Office Area may not
|
||||
* be unloaded anywhere in that same Office Area. The load has to be carried out of the district by
|
||||
* a train first; a Freight House may not break the load it just made, and passengers may not
|
||||
* detrain at the platform they boarded from.
|
||||
*
|
||||
* Distinct from the other refusals because the car IS loaded, the Laborer IS free and the boxes
|
||||
* ARE clear: the only thing wrong with it is where it came from, and a player looking at a loaded
|
||||
* boxcar standing on their own industry track deserves to be told that rather than "wrong car".
|
||||
*/
|
||||
| 'LOADED_IN_THIS_DISTRICT'
|
||||
| 'NO_PORTERS_HERE'
|
||||
| 'NO_PASSENGERS_WAITING'
|
||||
| 'NO_EMPTY_COACH'
|
||||
|
||||
+14
-2
@@ -288,9 +288,21 @@ function loadUnloadCandidates(s: GameState, player: PlayerIndex): Intent[] {
|
||||
const out: Intent[] = [];
|
||||
const area = areaOf(s, player);
|
||||
|
||||
/**
|
||||
* ONE OPTION PER TRAIN STANDING AT THE OFFICE, not one per square.
|
||||
*
|
||||
* Reported from playtesting v0.4.9d: "operating two trains in a station, the select button does
|
||||
* not work — regardless of which you pick, it is always one train, not the other". There was only
|
||||
* ever ONE `board passengers` button, because the intent carried no train; the roster chip chose
|
||||
* what the board drew and nothing else. Now each eligible train is its own candidate, and `check`
|
||||
* filters the ones whose card, consist or passengers rule them out.
|
||||
*/
|
||||
const traysHere = area.adOccupancy.filter((id) => s.trays.has(id));
|
||||
for (const coord of facilityCoords(s, player)) {
|
||||
out.push({ type: 'porter.board', at: coord });
|
||||
out.push({ type: 'porter.detrain', at: coord });
|
||||
for (const trayId of traysHere) {
|
||||
out.push({ type: 'porter.board', at: coord, trayId });
|
||||
out.push({ type: 'porter.detrain', at: coord, trayId });
|
||||
}
|
||||
const f = area.grid.get(`${coord.row},${coord.col}`)?.facility;
|
||||
if (f) {
|
||||
out.push({ type: 'laborer.startLoad', at: coord });
|
||||
|
||||
+41
-1
@@ -55,7 +55,47 @@ export function coordKey(c: GridCoord): string {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** §2.2 — a coloured car is loaded, a white car is empty. */
|
||||
export type RollingStock = { type: CarType; loaded: boolean };
|
||||
export type RollingStock = {
|
||||
type: CarType;
|
||||
loaded: boolean;
|
||||
/**
|
||||
* WHICH OFFICE AREA MADE THIS LOAD — the physical game's chip turned upside down in the tray.
|
||||
*
|
||||
* Reported from playtesting v0.4.9d as two bugs with one cause: a boxcar loaded at a Freight
|
||||
* House could be unloaded at that same Freight House on the next Laborer action, and passengers
|
||||
* who had just boarded could be detrained again before the train turned a wheel. Both paid full
|
||||
* Revenue at each end for a load that never went anywhere.
|
||||
*
|
||||
* Jesse's rule (v0.4.9e): freight or passengers loaded anywhere in an Office Area may not be
|
||||
* unloaded ANYWHERE in that same Office Area — not at another facility, not in a later Stage.
|
||||
* They have to be carried by a train to a different Office Area. So the stamp is the SEAT, which
|
||||
* is what an Office Area belongs to (Employee Rotation moves players between chairs; the district
|
||||
* stays with the chair), and it never expires.
|
||||
*
|
||||
* A SEAT, NOT A PLAYER, and undefined rather than -1 for "no origin": the Division Yard opens with
|
||||
* loaded cars and loaded coaches that were made up off-Division (`ROLLING_STOCK_SUPPLY`), and
|
||||
* those are exactly the inbound traffic a solitaire district lives on. A sentinel inside
|
||||
* `SeatIndex`'s own value range is not a sentinel — see `card.play`'s `node` in intents.ts.
|
||||
*
|
||||
* Stripped by `pooled` whenever a car goes back to a yard: the stamp belongs to the LOAD, and a
|
||||
* car returning to the common supply is carrying nothing.
|
||||
*/
|
||||
origin?: SeatIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* A car returning to the common pool — the Division or Classification Yard — with its load's origin
|
||||
* stamp taken off.
|
||||
*
|
||||
* Every yard push goes through this. A loaded car CAN reach a yard still loaded (a train retires at
|
||||
* a Division Point with freight aboard, `advance.ts`), and without this it would carry a stamp from
|
||||
* a district it left several Days ago into whatever train is made up from it next.
|
||||
*/
|
||||
export function pooled(car: RollingStock): RollingStock {
|
||||
if (car.origin === undefined) return car;
|
||||
const { origin: _origin, ...rest } = car;
|
||||
return rest;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Track and Office Area
|
||||
|
||||
+12
-3
@@ -17,7 +17,7 @@
|
||||
|
||||
import { MAX_CONSIST } from '../engine/content.ts';
|
||||
import { adTrackCount, coordKey, seatOf, turnOf } from '../engine/state.ts';
|
||||
import type { GameState, GridCoord, PlayerIndex, RollingStock, TrayId } from '../engine/state.ts';
|
||||
import type { GameState, GridCoord, PlayerIndex, RollingStock, SeatIndex, TrayId } from '../engine/state.ts';
|
||||
import { areaOf, canAdvanceLoad, canStartLoad, facilityCarType, facilityCarTypes, laborersLeft, movesFor, portersLeft } from '../engine/apply.ts';
|
||||
import type { GameEvent } from '../engine/events.ts';
|
||||
|
||||
@@ -34,11 +34,20 @@ export function clockTime(stage: number): string {
|
||||
return CLOCK[stage - 1] ?? `Stage ${stage}`;
|
||||
}
|
||||
|
||||
export function carLabel(c: RollingStock): string {
|
||||
/**
|
||||
* `homeSeat` is the district the page is being drawn for. Give it, and a load THIS district made
|
||||
* says so — the printed game's answer is to turn the chip upside down in the tray, and this is the
|
||||
* screen's. A load may not be broken in the Office Area that made it (state.ts `RollingStock.origin`),
|
||||
* so "loaded here" is the difference between a boxcar worth switching and one that has to leave the
|
||||
* district first. Omit it and the label is what it always was, which is what the replay viewers and
|
||||
* the history lines want: they describe a board, not a seat's view of one.
|
||||
*/
|
||||
export function carLabel(c: RollingStock, homeSeat?: SeatIndex): string {
|
||||
// A caboose carries the crew, not freight, so "loaded caboose" is nonsense on the page even
|
||||
// though the supply marks every caboose loaded. Name it plainly.
|
||||
if (c.type === 'caboose') return 'caboose';
|
||||
return `${c.loaded ? 'loaded' : 'empty'} ${c.type}`;
|
||||
const label = `${c.loaded ? 'loaded' : 'empty'} ${c.type}`;
|
||||
return homeSeat !== undefined && c.origin === homeSeat ? `${label} (loaded here)` : label;
|
||||
}
|
||||
|
||||
export function carsLabel(cars: RollingStock[]): string {
|
||||
|
||||
+22
-6
@@ -560,6 +560,7 @@ const FACILITY_NAMES: Record<string, string> = {
|
||||
function facilityView(
|
||||
card: { geometry: { kind: string; facility?: string }; facility: unknown; modifiers?: string[] },
|
||||
officeName: string,
|
||||
viewerSeat: SeatIndex,
|
||||
): FacilityView | null {
|
||||
const f = (card as { facility: import('../engine/state.ts').Facility | null }).facility;
|
||||
// Passenger facilities were excluded entirely, so the Office's green and red slots never
|
||||
@@ -581,7 +582,9 @@ function facilityView(
|
||||
maw: (f.menAtWork ?? []).map((l) => (l ? `${l.type} ${l.dir === 'out' ? '→' : '←'}` : null)),
|
||||
red: f.inboundBox.map(carLabel),
|
||||
redCap: f.capacity.inbound,
|
||||
track: f.industryTrack.cars.map(carLabel),
|
||||
// Marked when this district made the load: the spotted car is exactly where a player is looking
|
||||
// when they ask why the Laborer will not unload it.
|
||||
track: f.industryTrack.cars.map((c) => carLabel(c, viewerSeat)),
|
||||
laborers: `${laborersLeft(f)}/${f.laborers}`,
|
||||
porters: `${portersLeft(f)}/${f.porters}`,
|
||||
canFinish: canFinishHere(f),
|
||||
@@ -672,7 +675,9 @@ function trainsOnCard(s: GameState, viewerSeat: SeatIndex, key: string): CellVie
|
||||
out.push({
|
||||
trayId: id,
|
||||
label: t.trainNumber === null ? 'crew' : `T${t.trainIsExtra ? 'X' : ''}${t.trainNumber}`,
|
||||
cars: t.consist.map(carLabel),
|
||||
// A coach filled at THIS Office reads "loaded coach (loaded here)" — those passengers may not
|
||||
// alight in the district that boarded them, and the tray is where a player looks for that.
|
||||
cars: t.consist.map((c) => carLabel(c, viewerSeat)),
|
||||
engineAt: Math.max(0, Math.min(t.consist.length, t.engineAt)),
|
||||
facing: railFacingOf(t),
|
||||
what: t.trainNumber === null ? 'A local crew — no timetable, no card, no special rules.' : trainRules(t),
|
||||
@@ -728,6 +733,11 @@ function sampleDetail(s: GameState, kind: string, list: Intent[]): string {
|
||||
return shown.join('; ') + (more > 0 ? ` … and ${more} more distinct` : '');
|
||||
}
|
||||
|
||||
/** " onto Train 8", or nothing at all when the intent names no train (an old save, or one train). */
|
||||
function onto(s: GameState, trayId: string | undefined, joiner: string): string {
|
||||
return trayId === undefined ? '' : `${joiner}${trainName(s, trayId)}`;
|
||||
}
|
||||
|
||||
/** One readable line for a single intent. */
|
||||
export function describeIntent(s: GameState, i: Intent): string {
|
||||
// X,Y — east/west then north/south, not the internal row/col storage order.
|
||||
@@ -907,10 +917,16 @@ export function describeIntent(s: GameState, i: Intent): string {
|
||||
return `advance load in box ${i.box} at ${at(i.at)}`;
|
||||
case 'laborer.beginUnload':
|
||||
return `begin unloading car ${i.carIndex} at ${at(i.at)}`;
|
||||
/**
|
||||
* NAME THE TRAIN. The action list drops duplicate labels within a crew, and with two trains
|
||||
* standing at one station "board passengers at (0,0)" describes both — which is half of why the
|
||||
* v0.4.9d playtest found that picking a train changed nothing. The intent now carries the tray;
|
||||
* the label has to say so or the second button is thrown away before the menu sees it.
|
||||
*/
|
||||
case 'porter.board':
|
||||
return `board passengers at ${at(i.at)}`;
|
||||
return `board passengers at ${at(i.at)}${onto(s, i.trayId, ' onto ')}`;
|
||||
case 'porter.detrain':
|
||||
return `detrain passengers at ${at(i.at)}`;
|
||||
return `detrain passengers at ${at(i.at)}${onto(s, i.trayId, ' from ')}`;
|
||||
case 'newTrain.startExtra': {
|
||||
const runs = i.trainNumber % 2 === 0 ? 'east' : 'west';
|
||||
if (i.atSeat === null) {
|
||||
@@ -1059,7 +1075,7 @@ export function snapshot(
|
||||
else if (g.kind === 'spaceUse') label = prettyKey(g.key);
|
||||
else label = geometryLabel(g.geometry);
|
||||
|
||||
const fv = facilityView(card as never, officeProfile(area.tier).name);
|
||||
const fv = facilityView(card as never, officeProfile(area.tier).name, viewerSeat);
|
||||
if (fv) facilities.push(fv);
|
||||
|
||||
cells.push({
|
||||
@@ -1074,7 +1090,7 @@ export function snapshot(
|
||||
enhancementsWhat: card.enhancements.map((k) => enhancementText(k) ?? prettyKey(k)),
|
||||
trains: trainsOnCard(s, viewerSeat, key),
|
||||
adTracks: card.geometry.kind === 'office' ? officeProfile(area.tier).adTracks : null,
|
||||
cars: carsOn(card).map(carLabel),
|
||||
cars: carsOn(card).map((c) => carLabel(c, viewerSeat)),
|
||||
standingWest: card.standingWest,
|
||||
facility: fv,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user