adding classification and division yard updates, train collisions, engine and car updates, turnout improvements.

This commit is contained in:
Jesse
2026-08-04 21:03:17 -04:00
parent 4bba991f41
commit 821d3cdffa
26 changed files with 6876 additions and 2638 deletions
+26
View File
@@ -1174,6 +1174,7 @@ export function reduce(s: GameState, e: GameEvent): void {
(c) => c.type === e.stock.type && c.loaded === e.stock.loaded,
);
if (idx >= 0) s.yards.divisionYard.splice(idx, 1);
refillDivisionYardIfEmpty(s);
f.outboundBox.push(e.stock);
s.turn.freightAgentUsed = true;
break;
@@ -1236,6 +1237,7 @@ export function reduce(s: GameState, e: GameEvent): void {
(c) => c.type === e.stock.type && c.loaded === e.stock.loaded,
);
if (idx >= 0) s.yards.divisionYard.splice(idx, 1);
refillDivisionYardIfEmpty(s);
tray.consist.push(e.stock);
break;
}
@@ -1674,6 +1676,30 @@ export function acceptsCar(tray: CrewTray, carType: CarType): boolean {
return true;
}
/**
* §2 — WHEN THE DIVISION YARD RUNS OUT, THE CLASSIFICATION YARD GOES BACK INTO SERVICE.
*
* Used Rolling Stock is set out in the Classification Yard; used engines and cabooses go straight
* back to the Division Yard. The Classification Yard empties only when the Division Yard is bare —
* every car of every kind gone — and then all of it returns at once.
*
* Confirmed from the source after an earlier guess. The first implementation returned cars at the
* DAY boundary, which is a different rule and a much more generous one: it kept the yard topped up
* continuously, where this lets it run down to nothing and refill in one go. That difference is the
* whole of the supply pressure the game is meant to have.
*
* Called wherever a car leaves the Division Yard, so the refill happens the moment it empties
* rather than at the next convenient tick.
*/
export function refillDivisionYardIfEmpty(s: GameState): { type: 'yardRefilled'; count: number } | null {
if (s.yards.divisionYard.length > 0) return null;
if (s.yards.classificationYard.length === 0) return null;
const count = s.yards.classificationYard.length;
s.yards.divisionYard.push(...s.yards.classificationYard);
s.yards.classificationYard = [];
return { type: 'yardRefilled', count };
}
/** A fresh Limits sign. The set is "2N + spares" (§12), so relocating one is not a supply question. */
function limitsCard(): TrackCard {
return {