v0.7.1 — a caboose is not a load, a Day that says it ended, and a train you may throw away
Four issues off the Gitea tracker, all of them things a player saw at the board. Reasoning for every item, and what was verified how: CHANGELOG.md. - Gitea#8: X22 Pee-Dee refused every caboose, including the one it was made up with, so setting it out stranded the train. All six cabooses are minted loaded because §2.2's "coloured is loaded, white is empty" doubles as a piece count in the supply table; one read of the flag took that literally. A caboose carries the crew, not freight, so it is never a load. - Gitea#10: a Day turns over inside the phases that run themselves, so it passes between one click and the next — and both transient signals fade before a player reading the board notices. A modal stops and waits, carrying the standings, the Days left and the combined target. Suppressed on the first frame, on Undo stepping back across a rollover, and on the Day the game ends. - Gitea#9, which SUPERSEDES Gitea#6 from three days ago: a Timetabled train may be tossed face-up to a Department slot, where a rival may pick it up — the second half of the ruling needed no code, since that is where every discard already goes. An Extra still may not. A New Game setting on this line (discardTimetabled, on by default), the plain rule on the 0.4.9 line. - Gitea#2 is not an engine bug: the rules are implemented exactly, and running the coach pool dry is Jesse's ruling to keep — "part of the strategy". What was wrong is that the game said nothing. A blocked platform now gives its reason, from the engine's own predicate, including how many coaches are stranded in Classification and what brings them back. The same four ship as v0.4.9g on the playtest line. Closes #2 Closes #8 Closes #9 Closes #10 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
603d38602c
commit
441447648d
+88
-1
@@ -11,8 +11,10 @@ import assert from 'node:assert/strict';
|
||||
import { pump } from '../src/engine/advance.ts';
|
||||
import { DEFAULT_MAX_COLLISIONS_PER_DAY, DEFAULT_MAX_COLLISIONS_TOTAL, collectiveRevenueFloor } from '../src/engine/content.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';
|
||||
@@ -138,6 +140,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