v0.7.9.7 — a device that said it was available all day after it was gone

The last item off 0.7.9.6's sweep, parked there as the one genuine maybe.
It had a second half worth more than the first.

#101 — Telegraph (+4), Telephone (+8) and Radio (+12) are "once a day,
when dispatching facing trains, add +N to the other train's number".
`enhancementText(key)` takes only the KEY, so the tooltip could not vary
with anything: a spent Radio read "Once a day, add +12..." for the rest
of the Day, advertising a bonus that was not there. That is `trainRules`
before #100, in another corner of the same view.

THE HALF THAT ACTUALLY SURPRISES. `spendDispatchBonus` reads
`areaOf(s, s.clock.superintendent)` — the SUPERINTENDENT's own devices,
not the train owner's — and the Fedora moves every STAGES_PER_SHIFT (3)
Stages, four times a Day. So a player's Radio does nothing at all for
three-quarters of the Day, and is spent automatically, without its owner
being asked, during the quarter it is theirs. Neither half was anywhere
on the board.

The card now reads as one of three states — available and dispatching,
unspent but idle while somebody else holds the Fedora, or spent until the
next Day — and names the shift length, because "not now" without "for how
long" is half an answer. A spent device is struck through on the board.
Shown on EVERY district, not only the viewer's (Jesse's call): it is
public, and a rival's spent Radio is what you want to know before forcing
a meet.

What counts as a device is `enhancementRule(key)?.dispatchBonus` rather
than three keys written out in the view — the ladder lives in
ENHANCEMENT_RULES and a fourth rung would otherwise be silently exempt.

A STALE COMMENT CORRECTED, AND PINNED. `advance.ts` warned that indexing
a SEAT-keyed area with the PLAYER holding the Fedora "is right only while
seating is the identity map". It read as a live Employee Rotation bug and
was not one: `areaOf(s, p)` IS `areaAtSeat(s, seatOf(s, p))`. A comment
that sends the next reader chasing a bug that does not exist costs about
what the bug would. Rewritten, and the claim is now a test — seating set
to a real permutation, and the Superintendent's own district rather than
the seat with the same index is the one that reads as dispatching.

TWO THINGS MUTATION CAUGHT THAT PASSING DID NOT. A test asserted the
ABSENCE of /spent|Fedora/ with the Fedora held, and a mutant with the
`dispatchBonus` guard deleted PASSED it — the leaked text in that case
says "Available today, and this district is dispatching", which contains
neither word. A test that something was left alone has to compare it
against what it should be, so it asserts equality with `enhancementText`
now, in both Fedora states. And the replay wire format needed the field:
cells pack positionally, so the flag is index 9 and reads `?? []`, the
same tolerance `standingWest` uses — older recordings report no device
spent, which is what they drew at the time, so every published replay is
unchanged.

943 tests pass, up from 934.

NOT VERIFIED AT A TABLE, like 0.7.9.6. #39 and #35 still stand.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5boPxP6JHRYMm8adXaF5R
This commit is contained in:
Jesse.Markowitz
2026-09-07 21:54:18 -04:00
co-authored by Claude Opus 5
parent 7f4e027258
commit 88a42ae9e2
8 changed files with 332 additions and 11 deletions
+10 -2
View File
@@ -688,8 +688,16 @@ function spendDispatchBonus(
const mine = tray.trainNumber ?? 99;
const theirs = other.trainNumber ?? 99;
// The Fedora is held by a PLAYER, and the dispatch devices are installed in an Office Area, which
// is keyed by SEAT. Indexing one with the other is right only while seating is the identity map.
/**
* The Fedora is held by a PLAYER; the devices are installed in an Office Area, which is keyed by
* SEAT. `areaOf` is what reconciles the two — it resolves through `seatOf` — so this is correct
* under Employee Rotation and not only while seating happens to be the identity map.
*
* This comment used to say the opposite, warning that indexing one with the other was safe only
* while seating was identity. It read as a live bug and was not one: `areaOf(s, player)` IS
* `areaAtSeat(s, seatOf(s, player))`. Pinned by test rather than asserted here — see #101's
* "spends the Superintendent's own devices under non-identity seating".
*/
const area = areaOf(s, s.clock.superintendent);
// Best device first — Radio (+12) beats Telephone (+8) beats Telegraph (+4).
+11 -1
View File
@@ -1098,9 +1098,18 @@ export function officeSvg(
// card, the old y = H-46 baseline printed the label straight along the rail itself.
// Hover text per enhancement, from the card catalogue — an Interlocking used to be a bare word
// on the card with nothing to say what it did, or that it does not do it yet.
// A SPENT dispatch device is struck through (#101). Telegraph/Telephone/Radio are "once a
// day", and the label said the same thing before and after the Superintendent spent one — so
// the card advertised a +12 that was not there. Per-`tspan` rather than per-`text` so the
// names still read as one row, and `?? []` because `piecePreview` builds a cell literal by
// hand and has no flags.
const spentFlags = cell.enhancementsSpent ?? [];
const names = cell.enhancements
.map((n, i) => (spentFlags[i] ? `<tspan class="bs-enh-spent">${esc(n)}</tspan>` : esc(n)))
.join(' · ');
out += `<text class="bs-enh" x="6" y="26" data-tip="${esc(
(cell.enhancementsWhat ?? []).join(' · '),
)}">${esc(cell.enhancements.join(' · '))}</text>`;
)}">${names}</text>`;
}
if (selectedTrain) {
/**
@@ -1336,6 +1345,7 @@ export const BOARD_CSS = `
.bs-mod{font:10px ui-monospace,monospace}
text.bs-mod{fill:#c8a04a}
.bs-enh{fill:#7fb0e6;font:9px ui-monospace,monospace}
.bs-enh-spent{fill:#5b6b7d;text-decoration:line-through}
.bs-rowlab{fill:#5f6b7a;font:600 9px ui-monospace,monospace;letter-spacing:.1em}
/* THE EDGE OF THE DISTRICT. Deliberately quiet — it is a boundary, not an action — and dashed, so it
reads as a line on the table rather than as rail. Nothing is laid outside it (§2.1). */
+6 -2
View File
@@ -230,7 +230,7 @@ export function compress(frames: Frame[]): Packed {
const fi = c.facility ? f.facilities.indexOf(c.facility) : -1;
// `trains` rides whole rather than being interned: it changes almost every frame, so a table
// of them would be as long as the frames are and buy nothing.
return [ci, wi, c.enhancements, c.cars, fi, c.trains, c.adTracks, c.enhancementsWhat, c.standingWest];
return [ci, wi, c.enhancements, c.cars, fi, c.trains, c.adTracks, c.enhancementsWhat, c.standingWest, c.enhancementsSpent];
});
return { ...f, cells } as unknown as Frame;
});
@@ -264,7 +264,7 @@ export function rehydrateCells(
facs: unknown[],
): unknown[] {
return packed.map((row) => {
const p = row as [number, number, string[], string[], number, unknown, unknown, string[], number];
const p = row as [number, number, string[], string[], number, unknown, unknown, string[], number, boolean[]];
const c = cards[p[0]] as [number, number, string, string, boolean, string[]];
// Tolerant the same way `standingWest` below is: an array rides through as-is, a lone object
// (an older recording's singular `train`) is wrapped into a one-train roster, and null or
@@ -284,6 +284,10 @@ export function rehydrateCells(
// cut ahead of or behind the engine exactly as the live board does. Absent in older recordings,
// which read as 0 — the whole cut east of the engine, which is what they used to draw anyway.
standingWest: p[8] ?? 0,
// Which dispatch devices were spent (#101), so a replay strikes a used Radio through exactly
// as the live board does. Absent in recordings made before it existed, which read as no
// device spent — the same thing they drew at the time, so an old replay is unchanged.
enhancementsSpent: p[9] ?? [],
};
});
}
+58 -2
View File
@@ -35,6 +35,7 @@ import {
REALIGNMENTS,
OFFICE_ORDER,
SPACE_USE_CARDS,
STAGES_PER_SHIFT,
crewTrayCount,
enhancementRule,
enhancementText,
@@ -47,7 +48,7 @@ import {
mainlineDescription,
} from '../engine/content.ts';
import type { Intent } from '../engine/intents.ts';
import type { Facility, GameConfig, GameState, PlayerIndex, SeatIndex, TrackCard, TurnoutOrientation } from '../engine/state.ts';
import type { Facility, GameConfig, GameState, OfficeArea, PlayerIndex, SeatIndex, TrackCard, TurnoutOrientation } from '../engine/state.ts';
import { actingPlayer, carsOn, overHandLimit, playerAtSeat, railFacingOf, seatOf, turnOf } from '../engine/state.ts';
import type { Direction, Hand, HouseRules, TrackGeometry } from '../engine/content.ts';
import type { Port } from '../engine/track.ts';
@@ -74,6 +75,14 @@ export type CellView = {
* `toString()`), so it cannot reach the card catalogue itself.
*/
enhancementsWhat: string[];
/**
* Which of those enhancements is SPENT for today, in the same order (#101).
*
* Only ever true of a dispatch device — Telegraph, Telephone, Radio — which is "once a day". The
* reason and the Fedora caveat are already written into `enhancementsWhat`; this is the flag the
* board styles from, because `board-svg.ts` imports nothing and cannot work it out for itself.
*/
enhancementsSpent: boolean[];
/**
* EVERY TRAIN STANDING HERE, in order, each with the engine in it and which way it points.
*
@@ -1253,6 +1262,52 @@ export function describeIntent(s: GameState, i: Intent): string {
* made it. For a player's own view that seat is theirs; for a spectator's view of district N it is
* N, which is the same fact asked from outside.
*/
/**
* WHAT AN ENHANCEMENT DOES — AND WHETHER IT CAN DO IT RIGHT NOW (#101).
*
* `enhancementText(key)` takes only the key, so it says the same thing for ever. That is right for
* every enhancement except the three dispatch devices, which are "once a day": a spent Radio read
* "Once a day, add +12…" all Day after it was gone, which is `trainRules` before #100 in a different
* corner of the same view.
*
* AND THE FEDORA, which is the half that actually surprises. `spendDispatchBonus` (advance.ts) reads
* the SUPERINTENDENT's own devices, not the train owner's, and the Fedora moves every
* `STAGES_PER_SHIFT` Stages — so a device does nothing at all while somebody else is dispatching,
* and is spent automatically, without its owner being asked, while they are.
*
* `dispatchBonus` decides what counts as a device, rather than a list of three keys written out
* here: the ladder lives in `ENHANCEMENT_RULES` and a fourth rung would otherwise be silently
* exempt.
*/
function enhancementState(
s: GameState,
area: OfficeArea,
seat: SeatIndex,
key: string,
): { what: string; spent: boolean } {
const base = enhancementText(key) ?? prettyKey(key);
if (enhancementRule(key)?.dispatchBonus === undefined) return { what: base, spent: false };
const spent = area.dispatchUsedToday.includes(key);
if (spent) {
return {
what: `${base} SPENT for today — it comes back at the start of the next Day.`,
spent: true,
};
}
// Available, but only to whoever is dispatching. Naming the shift length is the difference
// between "not now" and knowing how long "not now" lasts.
if (seatOf(s, s.clock.superintendent) !== seat) {
return {
what:
`${base} Unspent, but IDLE: a device is only used by the district holding the Fedora, ` +
`which moves every ${STAGES_PER_SHIFT} Stages.`,
spent: false,
};
}
return { what: `${base} Available today, and this district is dispatching.`, spent: false };
}
export function projectDistrict(
s: GameState,
seat: SeatIndex,
@@ -1287,7 +1342,8 @@ export function projectDistrict(
what: cellDescription(card, officeProfile(area.tier).name, row === area.runningRow),
links: connectionsFor(card).map(([a, b]) => `${a}${b}`),
enhancements: card.enhancements.map(prettyKey),
enhancementsWhat: card.enhancements.map((k) => enhancementText(k) ?? prettyKey(k)),
enhancementsWhat: card.enhancements.map((k) => enhancementState(s, area, seat, k).what),
enhancementsSpent: card.enhancements.map((k) => enhancementState(s, area, seat, k).spent),
trains: trainsOnCard(s, seat, key),
adTracks: card.geometry.kind === 'office' ? officeProfile(area.tier).adTracks : null,
cars: carsOn(card).map((c) => carLabel(c, seat)),