v0.7.2 — a leg that is part of the row, the deck the sheet prints, regions not miles per hour, and a Division you read left to right

Gitea#17 — a 45° leg is an end of the west-to-east row, so backing into a cut
through a curve's south leg no longer couples it back to front. The same
assumption left a crew's own cut standing when it pulled out through a leg,
which is the "cars left behind" report we had failed to reproduce.

Gitea#14 — every count is docs/Deck cards5.xlsx. Track halved, and the Q12
office doubling and Gap 12 industry tripling both come out with it: they were
measured against a deck with twice the track, and keeping them at the sheet's
track count wipes out the reefer chain entirely. 84 rows now match card for
card; the ten Safety, Event and Inspection cards it adds are not built and are
held out. Cards the sheet no longer lists are dealt zero copies rather than
deleted, so their rules stay implemented.

Gitea#15 — RAR reversed it: a rail may stop dead against its neighbour and the
placement is legal. What must hold is that no train crosses the gap, which was
already true and is now pinned against the reported board.

Gitea#3 — the printed speeds are scenery. A card costs one Stage per printed
region and where a train STARTS is what varies; Fast/Slow is read on Hilly
alone. Entering a one-region card behind another is a collision now, which is
what ABS exists to prevent, and ABS no longer holds trains silently.

Gitea#18 — the Division draws as one row, west to east, with no office-area
detail. East is finally always to the right.

Closes #3
Closes #14
Closes #15
Closes #17
Closes #18
This commit is contained in:
Jesse.Markowitz
2026-08-26 15:20:56 -04:00
parent 441447648d
commit 2ab25e320c
23 changed files with 4619 additions and 3264 deletions
+136 -16
View File
@@ -947,17 +947,29 @@ describe('the page explains itself', () => {
// A played card becomes a cell with a name on it — "turnout", "Freight House", "waiting area" —
// and the explanation that was visible while it sat in hand disappears exactly when it starts
// mattering. Play a long way in so every card kind reaches the grid.
const game = newGame(111);
for (let i = 0; i < 400; i++) {
if (currentActor(game) === null) break;
const { options } = actionGroups(game);
if (options.length === 0) break;
const pick = options.find((o) => o.type === 'card.play' && o.placement) ?? options[0]!;
if (!submit(game, pick)) break;
/**
* THE SEED IS SEARCHED FOR, not written down. This took seed 111 flat and asserted its board
* ended up with more than four cards on it. Gitea#3 changed how fast trains cross, which changes
* how a game unfolds, and 111 stopped building enough of a district — so the test failed on its
* own precondition rather than on anything about tooltips.
*
* It needs A well-built board, not one particular one, so it takes the first seed that gives it.
*/
let game = newGame(111);
for (let seed = 111; seed < 211; seed++) {
game = newGame(seed);
for (let i = 0; i < 400; i++) {
if (currentActor(game) === null) break;
const { options } = actionGroups(game);
if (options.length === 0) break;
const pick = options.find((o) => o.type === 'card.play' && o.placement) ?? options[0]!;
if (!submit(game, pick)) break;
}
if (view(game).cells.length > 4) break;
}
const cells = view(game).cells;
assert.ok(cells.length > 4, 'not enough of the board was built to be a real check');
assert.ok(cells.length > 4, 'no seed under 211 built enough of a board to be a real check');
for (const c of cells) {
assert.ok(c.what.length > 0, `(${c.row},${c.col}) ${c.label} has no explanation`);
// camelCase on the board is the failure that keeps recurring — labels AND descriptions.
@@ -1586,7 +1598,40 @@ describe('the static build', () => {
(target['onclick'] as (() => void) | null)?.();
return true;
};
assert.ok(clickVerb(hand, 'play'), 'no card in hand offers a play verb');
/**
* TRY EVERY PLAY BUTTON, NOT JUST THE FIRST — a card offering "play" does not necessarily play
* ONTO THE BOARD.
*
* This clicked the first play verb it found and then asserted the board had lit up. A train card
* plays to the timetable and a Department discard to the piles, so neither lights a square, and
* whether the first playable card in this deal happens to be a track or facility card is luck.
* Gitea#14's deck counts re-dealt seed 555, the first play verb landed on Train 2, and the test
* failed claiming the page highlighted nothing — when the page was right and the card simply had
* no square to point at.
*
* So it clicks each play button in turn until the board lights, which is the property the test
* is named for. It still fails loudly if NO card in hand can light a square.
*
* EACH BUTTON IS CLICKED EXACTLY ONCE. Picking a card is a toggle, so clicking one to check it
* and then clicking it again inside the loop would UNPICK it — which is how the first draft of
* this managed to fail on a deal whose very first play card was a good one.
*/
const playButtons = (el: Record<string, unknown>): Record<string, unknown>[] => {
const fn = el['querySelectorAll'] as (s: string) => Record<string, unknown>[];
return fn
.call(el, 'button.cardact')
.filter((n) => (n['dataset'] as Record<string, string>)['verb'] === 'play');
};
assert.ok(playButtons(hand).length > 0, 'no card in hand offers a play verb');
let litTheBoard = false;
for (const target of playButtons(hand)) {
(target['onclick'] as (() => void) | null)?.();
const drawn = String(grid['innerHTML']);
if ((grid['highlighted'] as () => unknown[])().length > 0 || /data-ghost="/.test(drawn)) {
litTheBoard = true;
break;
}
}
// Without the board stylesheet every shape is drawn black on a near-black background: the page
// looks empty even though the markup is perfect.
@@ -1599,7 +1644,10 @@ describe('the static build', () => {
assert.match(html, /data-cell="/, 'the board drew no addressable cards');
const lit = (grid['highlighted'] as () => unknown[])();
const ghosts = /data-ghost="/.test(html);
assert.ok(lit.length > 0 || ghosts, 'picking a card highlighted nothing on the board');
assert.ok(
litTheBoard || lit.length > 0 || ghosts,
'no card in hand, picked in turn, ever highlighted a square on the board',
);
/**
* POINTING AT THE SQUARE A BUTTON MEANS — wired on the emitted bundle, not asserted off the menu.
@@ -2762,18 +2810,44 @@ describe('the Division map shows the whole route', () => {
}
});
it('seats 1 to 4 players without overlapping or spilling off the canvas', () => {
// A row, two facing rows, a horseshoe and a square. The layout is geometry with no visual
// feedback loop, so this is the only thing standing between a change and an unreadable board.
it('draws 1 to 4 players as ONE row, west to east, without overlapping or spilling', () => {
/**
* Gitea#18. This used to check "a row, two facing rows, a horseshoe and a square" — the route
* was laid out around a table, on the reasoning that players sit around one. It cost three
* reports, and the one that decided it was that **east stopped being to the right**: a player's
* east could be drawn south, west or north depending which lane their district landed in, on a
* map whose whole job is saying which way a train is going.
*
* So the property is now stronger and much simpler to state — every cell on one row, ordered
* west to east — which is exactly what makes "east is right" true and is the thing that would
* silently regress if anyone reintroduced lanes. The overlap and canvas checks are kept: the
* layout is geometry with no visual feedback loop.
*/
for (const players of [1, 2, 3, 4]) {
const svg = divisionFor(players);
const vb = /viewBox="0 0 (\d+) (\d+)"/.exec(svg);
assert.ok(vb, `${players}p produced no viewBox`);
const W = Number(vb![1]);
const H = Number(vb![2]);
const rects = [...svg.matchAll(/class="bs-dcell[^"]*"[^>]*><rect x="([\d.]+)" y="([\d.]+)" width="([\d.]+)" height="([\d.]+)"/g)]
.map((m) => ({ x: +m[1]!, y: +m[2]!, w: +m[3]!, h: +m[4]! }));
assert.ok(rects.length >= 5, `${players}p drew only ${rects.length} cells`);
const rects = [...svg.matchAll(/class="bs-dcell bs-d(\w+)[^"]*"[^>]*><rect x="([\d.]+)" y="([\d.]+)" width="([\d.]+)" height="([\d.]+)"/g)]
.map((m) => ({ kind: m[1]!, x: +m[2]!, y: +m[3]!, w: +m[4]!, h: +m[5]! }));
// WDP · (ML · Office) × players · ML · EDP — including the Mainline card before the East
// Division Point, which the issue's own sketch left out.
assert.equal(rects.length, 2 * players + 3, `${players}p drew ${rects.length} cells`);
assert.equal(rects[0]!.kind, 'dp', `${players}p does not start at a Division Point`);
assert.equal(rects[rects.length - 1]!.kind, 'dp', `${players}p does not end at a Division Point`);
assert.equal(rects[rects.length - 2]!.kind, 'ml', `${players}p has no Mainline card before the East DP`);
// ONE ROW: every cell at the same y, and x strictly increasing.
const ys = new Set(rects.map((r) => r.y));
assert.equal(ys.size, 1, `${players}p drew ${ys.size} rows — the Division must be one`);
for (let i = 1; i < rects.length; i++) {
assert.ok(
rects[i]!.x > rects[i - 1]!.x,
`${players}p: cell ${i} is not east of the one before it — east is no longer to the right`,
);
}
for (let i = 0; i < rects.length; i++) {
const a = rects[i]!;
assert.ok(
@@ -2789,6 +2863,52 @@ describe('the Division map shows the whole route', () => {
}
});
it('draws no office-area detail on the Division map, but keeps the trains', () => {
// Gitea#18: "Division map should not show any office area detail (no limits, no running track,
// etc.)" — an Office used to expand into its whole Running Track, Limits to Limits, so this map
// carried every straight, turnout and Limits sign of every district and grew sideways as
// districts were built. One cell per district now.
//
// The trains stay: "trains within the office area should definitely be represented on the
// division map", split into the A/D register and the crews switching below it.
const s = createEngineGame({
id: 'div-collapse', seed: 7,
config: {
mode: 'solitaire', days: 5, minCombinedRevenue: 0, maxCollisionsPerDay: 0, maxCollisionsTotal: 0, pvpCardsAllowed: false,
optionalRules: { reducedVisibility: false, employeeRotation: false, emergencyToolbox: false },
},
playerNames: ['Solitaire'],
});
const area = areaOf(s, 0);
area.tier = 'terminal';
const place = (id: string, n: number, coord: { row: number; col: number }, ad: boolean): void => {
s.trays.set(id, {
id, trainNumber: n, trainIsExtra: false, engineAt: 0,
consist: [{ type: 'boxcar', loaded: true }],
direction: 'east', facing: 'e',
position: { at: 'grid', seat: 0, coord }, movesUsed: 0,
} as never);
if (ad) area.adOccupancy.push(id);
};
place('ad1', 9, area.officeCoord, true);
place('sw1', 7, { row: area.runningRow - 1, col: 0 }, false);
const svg = divisionSvg(snapshot(s, [], null).division);
// ONE district cell, not one per Running Track card.
const districts = [...svg.matchAll(/class="bs-dcell bs-drun/g)].length;
assert.equal(districts, 1, `the district drew as ${districts} cells`);
assert.doesNotMatch(svg, /Limits/, 'a Limits sign reached the Division map');
// Both trains are on it, in two registers — the A/D one above the crew switching below.
const chips = [...svg.matchAll(/class="bs-train" data-tip="(T\d+)[^"]*"><rect x="[\d.]+" y="([\d.]+)"/g)]
.map((m) => ({ label: m[1]!, y: +m[2]! }));
const ad = chips.find((c) => c.label === 'T9');
const sw = chips.find((c) => c.label === 'T7');
assert.ok(ad, 'the train holding an A/D track is not on the map');
assert.ok(sw, 'the crew switching in the district is not on the map');
assert.ok(sw.y > ad.y, 'the switching crew should be drawn BELOW the A/D register, not beside it');
});
it('keeps every roster chip inside the Office cell it belongs to, at any occupancy', () => {
// "Two Trains, One Card": sizing the cell by OCCUPANCY moved the East Division Point sideways
// every time an A/D track filled or cleared. Sizing by CAPACITY (docs/plans/switching-paths.md)