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
+94
-27
@@ -260,19 +260,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
|
||||
@@ -290,35 +291,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');
|
||||
|
||||
@@ -335,11 +375,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.
|
||||
@@ -355,24 +410,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
@@ -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');
|
||||
|
||||
|
||||
@@ -71,6 +71,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 });
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -138,6 +140,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)', () => {
|
||||
|
||||
+85
-1
@@ -22,8 +22,10 @@ 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 { record, renderHtml } from '../src/sim/replay.ts';
|
||||
import type { Frame } from '../src/sim/view.ts';
|
||||
import type { GameLength } from '../src/engine/content.ts';
|
||||
import { snapshot } from '../src/sim/view.ts';
|
||||
import { createGame as createEngineGame } from '../src/engine/setup.ts';
|
||||
import {
|
||||
@@ -2682,6 +2684,88 @@ 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 is gone in 2.6 seconds.
|
||||
//
|
||||
// The goal half is written against `f.objective`, which on this line resolves a PER-PLAYER target
|
||||
// from the game length: `standard` is 20 Revenue over 5 Days. (Main asks a different question of
|
||||
// the same dialog — a combined floor off the victory dials — so that half is not a shared port.)
|
||||
const frameAt = (day: number, length: GameLength = 'standard'): Frame => {
|
||||
const s = createEngineGame({
|
||||
id: 'dayend',
|
||||
seed: 4021,
|
||||
config: {
|
||||
mode: 'solitaire',
|
||||
victory: 'firstToTarget',
|
||||
length,
|
||||
optionalRules: { reducedVisibility: false, sisterTrains: 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('reads the goal and the pace off the objective rather than working them out again', () => {
|
||||
// One implementation of "what is the target and am I keeping up" — `objectiveOf`. A dialog that
|
||||
// recomputed either would be one release away from disagreeing with the status block that shows
|
||||
// the same numbers every turn.
|
||||
const f = frameAt(3);
|
||||
const html = dayEndHtml(f);
|
||||
assert.ok(html.includes(`<b>${f.objective.target}</b>`), `the target is not shown:\n${html}`);
|
||||
assert.ok(html.includes(`<b>${f.revenue}</b>`), "the viewer's Revenue is not shown");
|
||||
// Nothing earned by Day 3 of 5 is behind a 20-Revenue pace, and the dialog says so in words.
|
||||
assert.equal(f.objective.onPace, false, 'the fixture is no longer behind pace');
|
||||
assert.ok(html.includes('behind pace'), 'the pace is not reported');
|
||||
// A campaign game is a different target, and the dialog must not have 20 baked into it.
|
||||
const long = frameAt(3, 'campaign');
|
||||
assert.ok(dayEndHtml(long).includes('<b>45</b>'), 'the target does not follow the game length');
|
||||
assert.ok(dayEndHtml(long).includes('Day 3 of 10'), 'the Day count does not follow the length');
|
||||
});
|
||||
|
||||
it('puts the leader at the top and marks which row is yours', () => {
|
||||
// The question at the end of a Day is who is ahead, which is not the order the seats are in.
|
||||
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.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');
|
||||
// Marked from `f.viewer`, not from an assumed seat 0 — so moving the viewer moves the mark.
|
||||
f.viewer = 1;
|
||||
const moved = dayEndHtml(f);
|
||||
assert.ok(moved.indexOf('(you)') < moved.indexOf('Ada'), 'the mark did not follow the viewer');
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user