v0.4.3 fixed load/unload bugs. empty cars must be staged prior to loading. rolling stock is now conserved.

This commit is contained in:
Jesse
2026-08-14 08:33:32 -04:00
parent 393a669418
commit d1314066bd
13 changed files with 2258 additions and 3822 deletions
+23 -4
View File
@@ -17,7 +17,7 @@
import { adTrackCount, coordKey, seatOf, turnOf } from '../engine/state.ts';
import type { GameState, GridCoord, PlayerIndex, RollingStock, TrayId } from '../engine/state.ts';
import { areaOf, canAdvanceLoad, canStartLoad, facilityCarType, laborersLeft, movesFor, portersLeft } from '../engine/apply.ts';
import { areaOf, canAdvanceLoad, canStartLoad, facilityCarType, facilityCarTypes, laborersLeft, movesFor, portersLeft } from '../engine/apply.ts';
import type { GameEvent } from '../engine/events.ts';
// ---------------------------------------------------------------------------
@@ -478,17 +478,36 @@ export function impediments(s: GameState, player: PlayerIndex = 0): Impediment[]
}
if (f.outboundBox.length > 0 && !canStartLoad(f) && laborersLeft(f) > 0) {
// Two quite different reasons, and telling a player "MEN is occupied" when the real answer is
// "there is no car to load onto" sends them to fix the wrong thing.
const blockedByBox = f.menAtWork?.[0] != null;
out.push({
where: `${name} ${key}`,
why: 'green box has a load but MEN is occupied',
severity: 'waiting',
why: blockedByBox
? 'green box has a load but MEN is occupied'
: `no empty ${want} spotted on this industry's track — a load has nowhere to go until a ` +
'crew sets one out here (§9.3)',
severity: blockedByBox ? 'waiting' : 'stuck',
});
}
if (f.allows.outbound && f.outboundBox.length === 0) {
/**
* WHAT TO DO NEXT, in the order you have to do it.
*
* A freight industry cannot be stocked at all until an empty car of its commodity is standing
* on its track (§9.3) — so "needs a Freight Agent action" was the second step told to a player
* who had not done the first, and the Freight Agent option simply would not be there. Measured
* before the rule was enforced, 78% of the stocking moves the menu offered had no car to load
* onto.
*/
const spotted = f.industryTrack.cars.some((c) => !c.loaded && facilityCarTypes(f).includes(c.type));
out.push({
where: `${name} ${key}`,
why: 'green box empty — nothing to load (needs a Freight Agent action)',
why: spotted
? 'green box empty — nothing to load (needs a Freight Agent action)'
: `green box empty, and no empty ${want} is spotted here — bring one in with a crew FIRST, ` +
'then the Freight Agent can stage a load onto it (§9.3)',
severity: 'waiting',
});
}