various fixes. added version#s and added a playable browser build of the solitaire game (including deploy to filebrowser script)

This commit is contained in:
Jesse
2026-07-31 22:03:13 -04:00
parent 160190da3f
commit 2eca9de09f
16 changed files with 2399 additions and 401 deletions
+82
View File
@@ -412,3 +412,85 @@ describe('card coverage', () => {
assert.match(poling!.effect, /TBD/i);
});
});
// ---------------------------------------------------------------------------
describe('the Limits sign moves with the Running Track (§2.1, Gap 4a)', () => {
it('keeps the Limits at the ends, never stranded mid-track', () => {
// Found by watching a replay: a district grew to
// (0,-5) (0,-4) (0,-3) (0,-2)=Power Plant [LIMITS] (0,0)=Office [LIMITS] (0,2) …
// with everything beyond (0,-2) built OUTSIDE a sign that never moved. Not cosmetic — §8.1 and
// §10 both reason about "the track between the train and the Limits", and running past a
// player's Limits is what makes a collision his fault.
const s = game();
const area = areaOf(s, 0);
s.turn.option = 'draw';
for (let n = 0; n < 4; n++) {
s.turn.laidThisTurn = false;
const target = { row: area.runningRow, col: area.limitsWest.col };
const r = applyIntent(s, 0, {
type: 'track.lay', geometry: 'straight', hand: 'none', placement: target, variant: 0,
});
assert.ok(r.ok, `extending onto the Limits should be legal (attempt ${n + 1})`);
}
const onRunning = [...area.grid.entries()]
.map(([k, c]) => ({ col: Number(k.split(',')[1]), kind: c.geometry.kind }))
.filter((x) => !Number.isNaN(x.col));
const limits = onRunning.filter((x) => x.kind === 'limits').map((x) => x.col).sort((a, b) => a - b);
const cols = onRunning.map((x) => x.col);
assert.equal(limits.length, 2, 'there must be exactly two Limits signs');
assert.equal(limits[0], Math.min(...cols), 'the west sign must be the westernmost card');
assert.equal(limits[1], Math.max(...cols), 'the east sign must be the easternmost card');
});
});
describe("a train is made up to its card's consist (§8.2)", () => {
it('takes a caboose when the card calls for one, and refuses a fourth freight car', () => {
// Train 9 "Heavy Freight" is freight 3 + caboose 1. It was being made up with FOUR hoppers and
// no caboose, because placeCar checked only MAX_CONSIST and yard availability.
const s = game();
s.clock.phase = 'newTrain';
s.trays.set('t', {
id: 't', trainNumber: 9, trainIsExtra: false, engineFront: true,
consist: [], direction: 'west', position: { at: 'divisionPoint', side: 'east' }, movesUsed: 0,
});
for (let n = 0; n < 3; n++) {
const r = applyIntent(s, 0, { type: 'newTrain.placeCar', trayId: 't', carType: 'hopper', loaded: true });
assert.ok(r.ok, `hopper ${n + 1} of 3 should be accepted`);
}
assert.equal(
check(s, 0, { type: 'newTrain.placeCar', trayId: 't', carType: 'hopper', loaded: true }),
'NO_SUITABLE_CAR',
'a fourth freight car exceeds the card',
);
assert.equal(
check(s, 0, { type: 'newTrain.placeCar', trayId: 't', carType: 'coach', loaded: true }),
'NO_SUITABLE_CAR',
'this card carries no coaches',
);
assert.equal(
check(s, 0, { type: 'newTrain.placeCar', trayId: 't', carType: 'caboose', loaded: true }),
null,
'the card calls for a caboose',
);
});
it('couples nothing behind the caboose', () => {
// §A.3 — the caboose rides last.
const s = game();
s.clock.phase = 'newTrain';
s.trays.set('t', {
id: 't', trainNumber: 9, trainIsExtra: false, engineFront: true,
consist: [{ type: 'caboose', loaded: true }],
direction: 'west', position: { at: 'divisionPoint', side: 'east' }, movesUsed: 0,
});
assert.equal(
check(s, 0, { type: 'newTrain.placeCar', trayId: 't', carType: 'hopper', loaded: true }),
'NO_SUITABLE_CAR',
);
});
});