v0.4.9g — a caboose is not a load, a Day that says it ended, and a train you may throw away
The v0.7.1 bugfix set ported to the playtest line: Gitea#8, #10, #9 and #2. Reasoning, and what differs from main, in CHANGELOG.md. - Gitea#8: X22 Pee-Dee refused every caboose, including the one it was made up with. A caboose carries the crew, not freight, so it is never a load. - Gitea#10: a dialog when the Day rolls over, carrying the standings, the Days left and your Revenue against the target with the pace. Suppressed on the first frame, on Undo stepping back across a rollover, and on the Day the game ends. - Gitea#9, superseding Gitea#6 from v0.4.9f: a Timetabled train may be discarded, an Extra may not. This line takes the plain rule — main has it as a New Game setting. - Gitea#2: the shortage stays, by Jesse's ruling. A blocked platform now gives its reason instead of simply having no button. Three things are written for this line rather than ported: the Timetabled discard has no setting and no URL parameter, the Day-end dialog reads f.objective (this line's per-player target) where main reads its combined victory dials, and Frame gained the viewer index the dialog needs to mark your row. 636 tests pass; no published replay was retired. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FLnYR4XtXQNamYJXGYT8oC
This commit is contained in:
co-authored by
Claude Opus 5
parent
e255076b5c
commit
9735468d25
+88
-1
@@ -10,8 +10,10 @@ import assert from 'node:assert/strict';
|
||||
|
||||
import { pump } from '../src/engine/advance.ts';
|
||||
import type { GameEvent } from '../src/engine/events.ts';
|
||||
import { areaOf } from '../src/engine/apply.ts';
|
||||
import { createGame } from '../src/engine/setup.ts';
|
||||
import type { GameConfig } from '../src/engine/state.ts';
|
||||
import { coordKey } from '../src/engine/state.ts';
|
||||
import type { GameConfig, GameState } from '../src/engine/state.ts';
|
||||
import { developerBot, playGame } from '../src/sim/bot.ts';
|
||||
import { impediments, isVisible, narrate, phaseLabel } from '../src/sim/narrate.ts';
|
||||
import { compress, rehydrateCells, record, renderHtml } from '../src/sim/replay.ts';
|
||||
@@ -133,6 +135,91 @@ describe('impediments', () => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Gitea#2 — "four porters, two passengers on the platform, and I never get the chance to work them."
|
||||
*
|
||||
* The engine was faithful at every step; what was missing was any way to SEE why. A Porter action
|
||||
* that cannot be taken is simply absent from the menu, and this panel — the one that answers "why is
|
||||
* nothing moving?" — opened with `f.kind !== 'freight'`, so a platform had never had anything to say
|
||||
* for itself at all.
|
||||
*/
|
||||
describe('a blocked platform says why (Gitea#2)', () => {
|
||||
/** Raise the Whistle Post to a working Terminal: the tier's printed numbers, applied directly. */
|
||||
function platform(s: GameState) {
|
||||
const area = areaOf(s, 0);
|
||||
area.tier = 'terminal';
|
||||
const card = area.grid.get(coordKey(area.officeCoord))!;
|
||||
const f = card.facility!;
|
||||
f.allows = { outbound: true, inbound: true };
|
||||
f.porters = 3;
|
||||
f.capacity = { outbound: 3, inbound: 3 };
|
||||
return { area, f };
|
||||
}
|
||||
|
||||
/** A tray standing on an A/D track at the Office, carrying whatever it is given. */
|
||||
function atOffice(s: GameState, consist: { type: 'coach'; loaded: boolean; origin?: number }[]): void {
|
||||
const area = areaOf(s, 0);
|
||||
const id = s.freeTrays.pop()!;
|
||||
s.trays.set(id, {
|
||||
id, trainNumber: null, trainIsExtra: false, engineAt: 0, consist,
|
||||
direction: 'east', position: { at: 'grid', seat: 0, coord: area.officeCoord }, movesUsed: 0,
|
||||
});
|
||||
area.adOccupancy.push(id);
|
||||
}
|
||||
|
||||
it('reports passengers standing on a platform with no train to take them', () => {
|
||||
// The whole of the bug's second half: before this, `impediments` returned an EMPTY list here.
|
||||
const s = createGame({ id: 'g', seed: 5, config, playerNames: ['p'] });
|
||||
const { f } = platform(s);
|
||||
f.outboundBox = [{ type: 'coach', loaded: true }];
|
||||
const found = impediments(s, 0);
|
||||
const platformRow = found.find((b) => /platform/.test(b.why));
|
||||
assert.ok(platformRow, `nothing reported for the platform:\n${JSON.stringify(found, null, 2)}`);
|
||||
assert.match(platformRow.why, /passengers waiting, no train at the platform/);
|
||||
assert.equal(platformRow.severity, 'waiting');
|
||||
});
|
||||
|
||||
it('names the Office by its tier rather than the word "facility"', () => {
|
||||
// A Passenger Facility rides on the `office` card, so the freight branch's `geometry.facility`
|
||||
// is not there to read and every passenger row read `facility 0,0` next to `mineTipple 1,-3`.
|
||||
const s = createGame({ id: 'g', seed: 5, config, playerNames: ['p'] });
|
||||
const { f } = platform(s);
|
||||
f.outboundBox = [{ type: 'coach', loaded: true }];
|
||||
const row = impediments(s, 0).find((b) => /platform/.test(b.why))!;
|
||||
assert.match(row.where, /^terminal /, `the Office is unnamed: ${row.where}`);
|
||||
});
|
||||
|
||||
it('explains the coach shortage that made the game look broken', () => {
|
||||
// The reported state: a train in with passengers to set down, red slots free, four porters —
|
||||
// and §9.2 needs a white coach out of the Division Yard to swap in. There was none, with eight
|
||||
// more sitting in the Classification Yard that §2.2 returns only when the Division Yard is BARE.
|
||||
const s = createGame({ id: 'g', seed: 5, config, playerNames: ['p'] });
|
||||
const { f } = platform(s);
|
||||
atOffice(s, [{ type: 'coach', loaded: true, origin: 1 }]);
|
||||
s.yards.divisionYard = s.yards.divisionYard.filter((c) => !(c.type === 'coach' && !c.loaded));
|
||||
s.yards.classificationYard = [
|
||||
{ type: 'coach', loaded: false },
|
||||
{ type: 'coach', loaded: false },
|
||||
];
|
||||
const row = impediments(s, 0).find((b) => /§9\.2/.test(b.why));
|
||||
assert.ok(row, `the coach shortage was not explained:\n${JSON.stringify(impediments(s, 0), null, 2)}`);
|
||||
assert.equal(row.severity, 'stuck', 'a train that cannot be emptied is stuck, not merely waiting');
|
||||
assert.match(row.why, /2 coaches are in the Classification Yard/, `where the coaches are is not said: ${row.why}`);
|
||||
assert.match(row.why, /Classification returns only when the Division Yard is bare/);
|
||||
assert.ok(f.inboundBox.length === 0, 'the red slots were free — the shortage is the only cause');
|
||||
});
|
||||
|
||||
it('says nothing about a platform that is working fine', () => {
|
||||
// Passengers waiting AND a train with an empty coach to take them: no impediment.
|
||||
const s = createGame({ id: 'g', seed: 5, config, playerNames: ['p'] });
|
||||
const { f } = platform(s);
|
||||
f.outboundBox = [{ type: 'coach', loaded: true }];
|
||||
atOffice(s, [{ type: 'coach', loaded: false }]);
|
||||
const found = impediments(s, 0).filter((b) => /platform|§9\.2|Porters/.test(b.why));
|
||||
assert.deepEqual(found, [], `a working platform reported an impediment:\n${JSON.stringify(found, null, 2)}`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('replay recording', () => {
|
||||
const rec = record(1234, 'standard');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user