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
+94
-27
@@ -262,19 +262,20 @@ describe('Local Operations: drawing (§6.2)', () => {
|
||||
assert.equal(check(s, 0, { type: 'draw.end' }), null, 'the turn cannot be ended even at the limit');
|
||||
});
|
||||
|
||||
describe('a train card is never discarded (Gitea#6)', () => {
|
||||
describe('which train cards may be discarded (Gitea#9, superseding Gitea#6)', () => {
|
||||
/**
|
||||
* Jesse's ruling, v0.4.9e playtest: "Players are not allowed to discard Train cards. They may
|
||||
* keep the card in their hand for multiple stages and even multiple days, but they may not
|
||||
* discard it. If a player has three train cards in their hand, and they draw a fourth, then they
|
||||
* must play one of those cards."
|
||||
* Gitea#6's ruling, v0.4.9e playtest, was that NO train card may be discarded. Gitea#9 narrows
|
||||
* it — Jesse, 2026-08-24: "Timetabled trains are at the choice of the player: they can either
|
||||
* play or discard. If someone else wants to pick it up, they are more than able to. The reason:
|
||||
* I don't want, if you decide to play a game longer than five days, to decide that maybe there
|
||||
* are too many trains, the stations are jammed, and the railroad doesn't need any more."
|
||||
*
|
||||
* Extras count too — an Extra is a train, even though it runs once and ends in the Salvage Yard
|
||||
* where a Timetabled card joins the timetable for the rest of the game.
|
||||
* So a Timetabled train is discardable, an EXTRA still is not — it never joins the timetable, so
|
||||
* it cannot be what jams it — and whether the Timetabled half applies is a New Game setting,
|
||||
* because the reasoning is about long games and a five-Day game may want Gitea#6's pressure.
|
||||
*
|
||||
* Note there is no new FORCING mechanism, and deliberately so: the corner is what the two
|
||||
* existing rules produce together. Nothing discardable plus "you may not end the turn over the
|
||||
* limit" leaves exactly one legal way on, and playing a train is unconditionally legal.
|
||||
* Note there is still no FORCING mechanism, and deliberately so: the corner is what the two
|
||||
* existing rules produce together whenever the setting is off.
|
||||
*/
|
||||
const handOf = (s: GameState, kinds: string[]): string[] => {
|
||||
// Hand-pick cards of the wanted kinds straight out of the catalogue, so the test does not
|
||||
@@ -292,35 +293,74 @@ describe('Local Operations: drawing (§6.2)', () => {
|
||||
return picked;
|
||||
};
|
||||
|
||||
it('refuses the discard, for a Timetabled train and for an Extra alike', () => {
|
||||
/** The same game with the setting turned off — Gitea#6's rule, still reachable. */
|
||||
const strictGame = (): GameState =>
|
||||
createGame({
|
||||
id: 'g',
|
||||
seed: 77,
|
||||
config: { ...config, houseRules: { ...(config.houseRules ?? {}), discardTimetabled: false } },
|
||||
playerNames: ['Jesse'],
|
||||
});
|
||||
|
||||
it('lets a Timetabled train be discarded, and still refuses an Extra', () => {
|
||||
const s = game();
|
||||
applyIntent(s, 0, { type: 'localOps.choose', option: 'draw' });
|
||||
const [timetabled, extra, track] = handOf(s, ['timetabledTrain', 'extraTrain', 'track']);
|
||||
assert.equal(
|
||||
check(s, 0, { type: 'card.discard', cardId: timetabled!, toSlot: 0 }),
|
||||
'TRAINS_ARE_NEVER_DISCARDED',
|
||||
null,
|
||||
'Gitea#9 allows this and it was refused',
|
||||
);
|
||||
assert.equal(
|
||||
check(s, 0, { type: 'card.discard', cardId: extra!, toSlot: 0 }),
|
||||
'TRAINS_ARE_NEVER_DISCARDED',
|
||||
'an Extra never joins the timetable, so Gitea#9 does not reach it',
|
||||
);
|
||||
// And everything else is still discardable — the rule is about trains, not about discarding.
|
||||
assert.equal(check(s, 0, { type: 'card.discard', cardId: track!, toSlot: 0 }), null);
|
||||
});
|
||||
|
||||
it('never offers the discard, so the bot needs no rule of its own', () => {
|
||||
it('puts the discarded train where a rival can pick it up', () => {
|
||||
// The other half of the ruling — "if someone else wants to pick it up, they are more than able
|
||||
// to" — needed no machinery, because a discard already goes face-up onto a Department pile.
|
||||
const s = game();
|
||||
applyIntent(s, 0, { type: 'localOps.choose', option: 'draw' });
|
||||
const [timetabled] = handOf(s, ['timetabledTrain', 'track']);
|
||||
const offered = legalActions(s, 0).filter(
|
||||
(i) => i.type === 'card.discard' && i.cardId === timetabled,
|
||||
);
|
||||
assert.deepEqual(offered, [], 'a train discard was offered as a legal action');
|
||||
assert.ok(applyIntent(s, 0, { type: 'card.discard', cardId: timetabled!, toSlot: 1 }).ok);
|
||||
const pile = s.decks.departments[1]!;
|
||||
assert.equal(pile[pile.length - 1], timetabled, 'the train is not face-up on the pile');
|
||||
});
|
||||
|
||||
it('leaves PLAYING a train as the only way out of a hand of four trains', () => {
|
||||
it('offers the discard as a legal action, so the bot can take it', () => {
|
||||
const s = game();
|
||||
applyIntent(s, 0, { type: 'localOps.choose', option: 'draw' });
|
||||
const [timetabled, extra] = handOf(s, ['timetabledTrain', 'extraTrain', 'track']);
|
||||
const offered = legalActions(s, 0).filter((i) => i.type === 'card.discard');
|
||||
assert.ok(
|
||||
offered.some((i) => i.type === 'card.discard' && i.cardId === timetabled),
|
||||
'a Timetabled train was not offered as a discard',
|
||||
);
|
||||
assert.ok(
|
||||
!offered.some((i) => i.type === 'card.discard' && i.cardId === extra),
|
||||
'an Extra was offered as a discard',
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps Gitea#6 reachable when the setting is off', () => {
|
||||
const s = strictGame();
|
||||
applyIntent(s, 0, { type: 'localOps.choose', option: 'draw' });
|
||||
const [timetabled, extra, track] = handOf(s, ['timetabledTrain', 'extraTrain', 'track']);
|
||||
for (const id of [timetabled!, extra!]) {
|
||||
assert.equal(
|
||||
check(s, 0, { type: 'card.discard', cardId: id, toSlot: 0 }),
|
||||
'TRAINS_ARE_NEVER_DISCARDED',
|
||||
);
|
||||
}
|
||||
assert.equal(check(s, 0, { type: 'card.discard', cardId: track!, toSlot: 0 }), null);
|
||||
});
|
||||
|
||||
it('leaves PLAYING a train as the only way out of a hand of four, setting off', () => {
|
||||
const s = strictGame();
|
||||
applyIntent(s, 0, { type: 'localOps.choose', option: 'draw' });
|
||||
const four = handOf(s, ['timetabledTrain', 'timetabledTrain', 'timetabledTrain', 'extraTrain']);
|
||||
assert.ok(four.length > HAND_LIMIT, 'this test needs a hand over the limit');
|
||||
|
||||
@@ -337,11 +377,26 @@ describe('Local Operations: drawing (§6.2)', () => {
|
||||
assert.equal(check(s, 0, { type: 'draw.end' }), null, 'playing a train did not free the turn');
|
||||
});
|
||||
|
||||
it('a hand of four Extras is the corner that survives Gitea#9 with the setting ON', () => {
|
||||
// Gitea#9 does not reach an Extra, so the deadlock-that-is-not-a-deadlock is still real in a
|
||||
// default game — worth pinning, since it is now the ONLY way to reach it.
|
||||
const s = game();
|
||||
applyIntent(s, 0, { type: 'localOps.choose', option: 'draw' });
|
||||
const four = handOf(s, ['extraTrain', 'extraTrain', 'extraTrain', 'extraTrain']);
|
||||
assert.equal(check(s, 0, { type: 'draw.end' }), 'HAND_LIMIT');
|
||||
for (const id of four) {
|
||||
assert.equal(check(s, 0, { type: 'card.discard', cardId: id, toSlot: 0 }), 'TRAINS_ARE_NEVER_DISCARDED');
|
||||
}
|
||||
assert.ok(applyIntent(s, 0, { type: 'card.play', cardId: four[0]! }).ok);
|
||||
assert.equal(check(s, 0, { type: 'draw.end' }), null);
|
||||
});
|
||||
|
||||
it('lets a train be held across Stages and into the next Day', () => {
|
||||
// "They may keep the card in their hand for multiple stages and even multiple days." Nothing
|
||||
// sweeps a hand at a Stage or Day boundary, and this is what says so out loud.
|
||||
// sweeps a hand at a Stage or Day boundary, and this is what says so out loud. An Extra is
|
||||
// used, because it is the card that still cannot be got rid of any other way.
|
||||
const s = game();
|
||||
const [timetabled] = handOf(s, ['timetabledTrain', 'track']);
|
||||
const [extra] = handOf(s, ['extraTrain', 'track']);
|
||||
const startDay = s.clock.day;
|
||||
|
||||
// Play out Stages by taking whatever ends the current turn, until the Day turns over.
|
||||
@@ -357,24 +412,36 @@ describe('Local Operations: drawing (§6.2)', () => {
|
||||
|
||||
assert.ok(s.clock.day > startDay, `the Day never turned (stopped at ${s.clock.day}/${s.clock.stage})`);
|
||||
assert.ok(
|
||||
(s.decks.hands.get(0) ?? []).includes(timetabled!),
|
||||
(s.decks.hands.get(0) ?? []).includes(extra!),
|
||||
'the train did not survive being held into the next Day',
|
||||
);
|
||||
assert.equal(
|
||||
check(s, 0, { type: 'card.discard', cardId: timetabled!, toSlot: 0 }),
|
||||
check(s, 0, { type: 'card.discard', cardId: extra!, toSlot: 0 }),
|
||||
'TRAINS_ARE_NEVER_DISCARDED',
|
||||
'a Day boundary made a train discardable',
|
||||
'a Day boundary made an Extra discardable',
|
||||
);
|
||||
});
|
||||
|
||||
it('tells the player on the card itself, and on the button when every card is a train', () => {
|
||||
it('tells the player on the card itself which of the two rules applies', () => {
|
||||
// The Gitea#2 lesson: a rule the player cannot see is a board with nothing to click and no
|
||||
// reason given.
|
||||
// reason given. Since Gitea#9 there are TWO reasons, so the card has to say which.
|
||||
const s = game();
|
||||
handOf(s, ['timetabledTrain', 'extraTrain', 'track']);
|
||||
const f = snapshot(s, [], null);
|
||||
// `hand` is reversed for display, so compare as a set rather than by position.
|
||||
assert.deepEqual([...f.handDiscardable].sort(), [false, false, true]);
|
||||
assert.deepEqual([...f.handDiscardable].sort(), [false, true, true]);
|
||||
const said = f.handKeepWhy.filter((w): w is string => w !== null);
|
||||
assert.equal(said.length, 1, 'exactly one card in this hand may not be discarded');
|
||||
assert.match(said[0]!, /An Extra is never discarded/);
|
||||
|
||||
const strict = strictGame();
|
||||
handOf(strict, ['timetabledTrain', 'extraTrain', 'track']);
|
||||
const sf = snapshot(strict, [], null);
|
||||
assert.deepEqual([...sf.handDiscardable].sort(), [false, false, true]);
|
||||
assert.ok(
|
||||
sf.handKeepWhy.some((w) => w !== null && /never discarded in this game/.test(w)),
|
||||
'the setting being off is not explained on the card',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+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');
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ const west = (s: GameState, n = 2): GridCoord => {
|
||||
};
|
||||
|
||||
const boxcar = (loaded = false): RollingStock => ({ type: 'boxcar', loaded });
|
||||
/** As `ROLLING_STOCK_SUPPLY` mints them: there is no empty caboose in the game. */
|
||||
const caboose = (): RollingStock => ({ type: 'caboose', loaded: true });
|
||||
const coach = (loaded = false): RollingStock => ({ type: 'coach', loaded });
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -141,6 +143,23 @@ describe('§7 — what a train may couple', () => {
|
||||
'EMPTIES_ONLY',
|
||||
);
|
||||
});
|
||||
|
||||
it('X22 Pee-Dee may still couple a caboose, which is not a load (Gitea#8)', () => {
|
||||
// Every caboose in the game is minted `loaded: true` because the supply table's loaded/empty
|
||||
// split doubles as a piece count. Taken literally that left the per-diem train unable to pick
|
||||
// up ANY caboose, its own included: set it out at the end of a sweep and it was stranded there.
|
||||
const s = game();
|
||||
switching(s, 22, true, [], [caboose()]);
|
||||
assert.equal(check(s, 0, { type: 'switch.move', trayId: 't', to: west(s), reverse: false }), null);
|
||||
|
||||
// The restriction itself is untouched — a loaded car alongside the caboose still refuses.
|
||||
const withLoad = game();
|
||||
switching(withLoad, 22, true, [], [caboose(), boxcar(true)]);
|
||||
assert.equal(
|
||||
check(withLoad, 0, { type: 'switch.move', trayId: 't', to: west(withLoad), reverse: false }),
|
||||
'EMPTIES_ONLY',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('§7 — one freight car per location (trains 3/4)', () => {
|
||||
|
||||
+98
-2
@@ -22,10 +22,11 @@ import { cardDescription, cardName, describeIntent, variantLabel } from '../src/
|
||||
import { variantsFor } from '../src/engine/track.ts';
|
||||
import { divisionSvg, officeSvg } from '../src/sim/board-svg.ts';
|
||||
import { ENHANCEMENT_RULES } from '../src/engine/content.ts';
|
||||
import { facilitiesHtml, timetableHtml } from '../src/web/panels.ts';
|
||||
import { dayEndHtml, facilitiesHtml, timetableHtml } from '../src/web/panels.ts';
|
||||
import { turnChartHtml } from '../src/sim/turnchart.ts';
|
||||
import { fieldSelectors } from '../src/web/settings-form.ts';
|
||||
import { record, renderHtml } from '../src/sim/replay.ts';
|
||||
import type { Frame } from '../src/sim/view.ts';
|
||||
import { snapshot } from '../src/sim/view.ts';
|
||||
import { createGame as createEngineGame } from '../src/engine/setup.ts';
|
||||
import {
|
||||
@@ -3090,6 +3091,84 @@ describe('the three places a game is drawn stay in step', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('the Day rolling over says so (Gitea#10)', () => {
|
||||
// "As the game rolls off the end of the day, you get a dialog saying such. Hard to keep track of
|
||||
// time." A Day turns inside the phases that run themselves, so it passes between one click and
|
||||
// the next — the phase banner and the announcement flash are both gone in a few seconds.
|
||||
const frameAt = (day: number, days = 5): Frame => {
|
||||
const s = createEngineGame({
|
||||
id: 'dayend', seed: 4021,
|
||||
config: {
|
||||
mode: 'solitaire', days, minCombinedRevenue: 12, maxCollisionsPerDay: 0, maxCollisionsTotal: 0, pvpCardsAllowed: false,
|
||||
optionalRules: { reducedVisibility: false, employeeRotation: false, emergencyToolbox: false },
|
||||
},
|
||||
playerNames: ['Solitaire'],
|
||||
});
|
||||
s.clock.day = day;
|
||||
return snapshot(s, [], null);
|
||||
};
|
||||
|
||||
it('names the Day that ENDED, not the one starting', () => {
|
||||
// Written from the frame after the rollover, so an off-by-one here would congratulate a player
|
||||
// on finishing a Day they have not played yet.
|
||||
const html = dayEndHtml(frameAt(3));
|
||||
assert.ok(html.includes('Day 2 has ended'), `wrong Day named:\n${html}`);
|
||||
assert.ok(html.includes('Day 3 of 5'), 'the Day now beginning is not named');
|
||||
assert.ok(html.includes('3 Days left'), `the Days remaining are wrong:\n${html}`);
|
||||
});
|
||||
|
||||
it('counts the last Day as the last Day rather than promising more', () => {
|
||||
const html = dayEndHtml(frameAt(6));
|
||||
assert.ok(html.includes('Day 5 has ended'), 'the final Day is misnamed');
|
||||
assert.ok(html.includes('last Day on the timetable'), `still offering Days to run:\n${html}`);
|
||||
assert.ok(!html.includes('Days left'), 'promises more Days after the last one');
|
||||
});
|
||||
|
||||
it('scores the table against the COMBINED target, not one player against it', () => {
|
||||
// `minCombinedRevenue` is a floor for the whole table. Showing one player's Revenue against a
|
||||
// four-player target reads as hopeless when the table may be well ahead.
|
||||
const f = frameAt(2);
|
||||
f.players = [
|
||||
{ index: 0, seat: 0, name: 'Ada', revenue: 4, hand: 3 },
|
||||
{ index: 1, seat: 1, name: 'Bo', revenue: 7, hand: 2 },
|
||||
];
|
||||
f.viewer = 0;
|
||||
const html = dayEndHtml(f);
|
||||
assert.ok(html.includes('<b>11</b>'), `combined Revenue is not 4 + 7:\n${html}`);
|
||||
assert.ok(html.includes('<b>12</b>'), 'the target is not shown');
|
||||
// Revenue order, so the leader is first: Bo (7) above Ada (4).
|
||||
assert.ok(html.indexOf('Bo') < html.indexOf('Ada'), 'the standings are not in Revenue order');
|
||||
assert.ok(html.includes('(you)'), 'the viewer is not marked in the standings');
|
||||
});
|
||||
|
||||
it('says nothing about collisions in a game that is not scored on them', () => {
|
||||
// §3.4's collision checks run in competitive and co-op ONLY, and `0` on a dial turns that check
|
||||
// off besides. A solitaire game carries the default dials and enforces neither, so a collision
|
||||
// budget on screen there would be a rule this game does not have.
|
||||
const solo = frameAt(2);
|
||||
assert.ok(!dayEndHtml(solo).includes('Collision'), 'reports a collision budget in solitaire');
|
||||
|
||||
const coop = frameAt(2);
|
||||
coop.mode = 'coop';
|
||||
coop.maxCollisionsTotal = 3;
|
||||
coop.collisionsTotal = 1;
|
||||
assert.ok(dayEndHtml(coop).includes('Collision'), 'hides collisions in a game scored on them');
|
||||
|
||||
const noDials = frameAt(2);
|
||||
noDials.mode = 'coop';
|
||||
noDials.maxCollisionsTotal = 0;
|
||||
noDials.maxCollisionsPerDay = 0;
|
||||
assert.ok(!dayEndHtml(noDials).includes('Collision'), 'reports collisions with both dials off');
|
||||
});
|
||||
|
||||
it('gives the page the dialog to fill', () => {
|
||||
const html = readFileSync(join(dist, 'play.html'), 'utf8');
|
||||
for (const id of ['dayenddlg', 'dayendbody']) {
|
||||
assert.ok(html.includes(`id="${id}"`), `play.html has no #${id}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('every file the build needs is actually in the repo (regression)', () => {
|
||||
it('does not gitignore a source page', () => {
|
||||
// REGRESSION. `.gitignore` carried `replay*.html` to catch the throwaway files generated at the
|
||||
@@ -3569,7 +3648,7 @@ describe('the New Game dialog', () => {
|
||||
* A seed alone stopped naming a game the moment the opening hand and the revenue rates became
|
||||
* settings, so what this really pins is that all of them ride in the URL and come back out.
|
||||
*
|
||||
* REBUILT 2026-08-23 with the five game types. The dialog and the lobby now ask the same eleven
|
||||
* REBUILT 2026-08-23 with the five game types. The dialog and the lobby now ask the same twelve
|
||||
* questions through `settings-form.ts`, which addresses its radio groups by NAME through the
|
||||
* DOCUMENT — so the stub keeps one set of groups and answers for both the document and the dialog.
|
||||
*/
|
||||
@@ -3681,6 +3760,7 @@ describe('the New Game dialog', () => {
|
||||
transit: els.get('ng-transit')!['value'],
|
||||
days: els.get('ng-days')!['value'],
|
||||
minrev: els.get('ng-minrev')!['value'],
|
||||
tossloco: els.get('ng-tossloco')!['checked'],
|
||||
});
|
||||
|
||||
it('opens on the rules in play, so a second game can be dealt to compare with the first', async () => {
|
||||
@@ -3699,6 +3779,22 @@ describe('the New Game dialog', () => {
|
||||
assert.equal(form.hand, 'sixRandom', 'the opening hand in play was not preselected');
|
||||
});
|
||||
|
||||
it('carries §6.2 in the URL, written only when it is OFF (Gitea#9)', async () => {
|
||||
// The setting defaults ON, so a link that spelled out `toss=1` every time would say nothing and
|
||||
// cost a parameter — the same reason the optional rules are written only when they are on. What
|
||||
// has to survive the trip is therefore the OFF case, which is the one that changes the game.
|
||||
const on = await load('?seed=430');
|
||||
(on.els.get('newgame')!['onclick'] as () => void)();
|
||||
assert.equal(readForm(on.els, on.groups).tossloco, true, 'a default game did not allow the discard');
|
||||
|
||||
const off = await load('?seed=430&toss=0');
|
||||
(off.els.get('newgame')!['onclick'] as () => void)();
|
||||
const form = readForm(off.els, off.groups);
|
||||
assert.equal(form.tossloco, false, '?toss=0 did not reach the dialog');
|
||||
// And it counts as a rule change, so the game is no longer the named type.
|
||||
assert.equal(form.type, 'custom', 'turning the rule off still read as Solitaire');
|
||||
});
|
||||
|
||||
it('reopens on Solitaire when the game in play is one, and on Custom when it was tuned', async () => {
|
||||
// The type is DERIVED (`presets.ts`) rather than remembered, so what the dialog says a game is
|
||||
// has to follow from its numbers — including a game whose numbers were hand-edited into the URL.
|
||||
|
||||
Reference in New Issue
Block a user