v0.8.2 — every district opens on a Depot, and the docs are pages now
A second-digit bump for a playtest read back against the save file. Nine questions were asked of one three-Day game; three were bugs, three were the rules working and undocumented, three were decisions. Every save on the test server was replayed against this build BEFORE release, which is how the cost of each rule was known before it was chosen rather than discovered after. EVERY DISTRICT OPENS ON A DEPOT. A Whistle Post has one A/D track and is not a Passenger Facility, so the opening of every game was spent unable to work a passenger and one arrival away from a collision. Two A/D tracks and passengers from Stage 1 now; "Players start with Whistle Posts, not Depots" is the harder game, set when the game is created. The deck follows the choice — starting on Depots the four Depot upgrade cards are left out, because an upgrade must be to the next tier and a Depot card at a table of Depots is a dead draw. How much easier it is showed up as a test failure rather than an argument: the cue-coverage pool needed widening from 24 seeded games to 60 before it held one collision. NO SAVE WAS STRANDED BY IT, which took care. This is the one house rule that changes how a game is DEALT rather than how it plays, so replaying a save under the wrong opening is a different railroad from intent one — silently, with no error. `withSavedOpening` fills it on the replay paths ONLY. Putting it in the resolver instead made a fresh Cutthroat game deal Whistle Posts and read as Custom, which is how the distinction was found. THREE BUGS, ALL REPORTED FROM ONE GAME AND ALL CONFIRMED ON ITS SAVE. An Office held TWO TRAINS ON ONE A/D TRACK. The capacity test passed with nothing standing, the train the Interlocking had been holding at the Limits was moved into the free slot, and the arriving train was pushed in after it without anyone asking again whether there was room — so the collision §8.3 calls for never happened. The held train keeps priority; the newcomer now takes the consequence it would have met had the held train arrived first. THE HISTORY FROZE, permanently, and the log cap was not really the cause. Each seat's "what have I sent you" bookmark was an INDEX into an array the game trims, so once a seat's bookmark reached the limit the slice returned nothing for the rest of the game — at a different moment per seat, because each holds its own. That game's log ended at exactly the cap. Lines carry a sequence number now, which survives trimming; proven by pushing twice the cap through a simulated seat. §8.1 ASKED THE WRONG QUESTION TWICE. "Trains may pass" returned `clear` before the Subdivision was looked at, so a train entering a Double Track was released however busy the rest of it was — that, not anything about Control Points, is what let Train 8 out with no ruling. And a train standing at an Office was invisible to the scan, so one about to re-enter the very Subdivision being entered counted for nothing. Capacity is the test, not presence: a Depot with a track free is not in the way; a Whistle Post with its one track taken is. THINGS THAT HAPPENED SILENTLY NOW SAY SO — a train held against a facing one, a train released from the Limits (a side effect of somebody else's arrival, so it simply appeared at the Office), and the train an Interlocking is holding, whose explanatory tooltip has existed since #99 with NO renderer ever reading the flag. WHERE A MOVE IS REFUSED, AND WHY. `exploreMoves` decides where the rails go and the pick-up restrictions are enforced afterwards in `check`, so a square the rails reached and the card forbade was reachable, un-offered, and absent from the block list with nothing said. Those squares are blocked with the rule that blocks them now, and the reasons are got by ASKING `check` rather than re-deriving: a second implementation of the rules is exactly the failure the block list exists to avoid. A train may also always recover its own caboose — X13 prints "may drop but not pick up anything", and a train needs its caboose to be made up, so one that parted with it could never legally leave again. RULES DECIDED IN SEPTEMBER AND APPLIED HERE. A Modifier must sit square against its host, no diagonals. A passenger Modifier may not be played at a Whistle Post. Both were built, measured, held back for a fortnight so a playtest could finish, and applied now. A Second Section costs its card: `SECOND_SECTION` was declared in content.ts and never dealt, so the action was free and the bot ordered 26 accidental ones in a measured round. The card is dealt and spent — gating on a card the deck never holds would have deleted the mechanic rather than fixed it. THE DOCUMENTATION IS A SET OF PAGES, not five text files served as text/plain — a card reference is mostly tables, and as plain text a table is rows of pipes. Markdown is still the one copy; the build renders it, and publishes the .md beside each page. No Markdown library: this project has no runtime dependencies and one would be a poor first. The pages add what Markdown cannot carry without drifting — a nav across the set, a contents list built from the headings actually rendered, an anchor on every heading, a 70-character measure, and tables that are tables. They print as ink on paper. The references caught up with the rules, checked rather than assumed: two statements had gone from stale to misleading (the Quickstart told a new player to "get a Depot down as soon as one appears"), and four rules nobody could look up are written down — the Office tier table, §8.1 in practice, what the Circus Train pays for, and that a Realignment can be a card with no legal target. Adding one card to the deck reshuffles every seeded deal, which broke five fixtures. Each was a seed meaning "a game like this" — TODO #84, exactly — so seeds moved and pools widened rather than assertions weakening, and the clearance fixture pins its terrain the way `enhancements.test.ts` already does. The three published replays were re-recorded. Closes TODO #40, #42a, #108, #109 and #110. 1046 fast tests and 35 sim tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MUizFYCMHRWhbWwXhp7WPR
This commit is contained in:
co-authored by
Claude Opus 5
parent
517238a727
commit
3befc420da
+72
-13
@@ -44,6 +44,7 @@ import {
|
||||
DEFAULT_MAX_COLLISIONS_PER_DAY,
|
||||
DEFAULT_MAX_COLLISIONS_TOTAL,
|
||||
LEGACY_HOUSE_RULES,
|
||||
withSavedOpening,
|
||||
collectiveRevenueFloor,
|
||||
houseRules,
|
||||
industryProfile,
|
||||
@@ -229,8 +230,19 @@ export type Game = {
|
||||
seed: number;
|
||||
/** Every intent submitted, in order — the save file. */
|
||||
history: Intent[];
|
||||
/** Narrated lines, newest last. */
|
||||
log: { text: string; tone: string }[];
|
||||
/**
|
||||
* Narrated lines, newest last.
|
||||
*
|
||||
* `seq` IS A RUNNING COUNT, NOT A POSITION. The log is trimmed to `LOG_LIMIT` below, and a seat's
|
||||
* "what have I sent you" bookmark used to be an index into this array — so once the array stopped
|
||||
* growing, the bookmark ran past its end and `slice` returned nothing FOREVER. Reported from a
|
||||
* two-player game that did not reach Day 5: the history froze for one player at Day 2 Stage 8 and
|
||||
* the other at Day 2 Stage 4, at different moments because each seat had its own bookmark.
|
||||
*
|
||||
* A sequence number survives trimming, so the bookmark stays meaningful however much is dropped —
|
||||
* and a reader can tell a gap from a quiet spell, which an index could never do.
|
||||
*/
|
||||
log: { text: string; tone: string; seq: number }[];
|
||||
/**
|
||||
* True when the hand is OVER the limit, so the turn cannot end until it is played down.
|
||||
*
|
||||
@@ -313,13 +325,30 @@ const GROUP_ORDER: readonly { prefix: string; title: string }[] = [
|
||||
*/
|
||||
export const SOLO_PLAYER = 'Solitaire';
|
||||
|
||||
/**
|
||||
* The next sequence number for a game's log, and the only way a line should ever be added.
|
||||
*
|
||||
* Kept off `Game` so the type stays serialisable: the counter is derived from the last line, which
|
||||
* survives a save/restore and a trim alike.
|
||||
*/
|
||||
/**
|
||||
* How many narrated lines a game keeps in memory. Everything older is dropped; `history` still holds
|
||||
* every intent, so a trimmed game replays in full.
|
||||
*/
|
||||
export const LOG_LIMIT = 4000;
|
||||
|
||||
export function pushLine(game: Game, text: string, tone: string): void {
|
||||
const last = game.log[game.log.length - 1];
|
||||
game.log.push({ text, tone, seq: (last?.seq ?? -1) + 1 });
|
||||
}
|
||||
|
||||
export function newGame(seed: number, config: GameConfig = SOLO_CONFIG): Game {
|
||||
const state = createGame({ id: `web-${seed}`, seed, config, playerNames: [SOLO_PLAYER] });
|
||||
const game: Game = { state, seed, history: [], log: [], cues: [], scheduled: null, justDrawn: null, announced: null, display: newCollector() };
|
||||
// A history that opens mid-Stage reads as though something was missed. Say what the game IS
|
||||
// first, then let the clock take over.
|
||||
game.log.push({ text: 'Game Begins', tone: 'start' });
|
||||
game.log.push({ text: `Solitaire · one player · seed ${seed}`, tone: 'quiet' });
|
||||
pushLine(game, 'Game Begins', 'start');
|
||||
pushLine(game, `Solitaire · one player · seed ${seed}`, 'quiet');
|
||||
drain(game);
|
||||
return game;
|
||||
}
|
||||
@@ -335,7 +364,7 @@ export function newGame(seed: number, config: GameConfig = SOLO_CONFIG): Game {
|
||||
export function newMultiplayerGame(seed: number, config: GameConfig, playerNames: string[]): Game {
|
||||
const state = createGame({ id: `mp-${seed}`, seed, config, playerNames });
|
||||
const game: Game = { state, seed, history: [], log: [], cues: [], scheduled: null, justDrawn: null, announced: null, display: newCollector() };
|
||||
game.log.push({ text: 'Game Begins', tone: 'start' });
|
||||
pushLine(game, 'Game Begins', 'start');
|
||||
/**
|
||||
* NO SEED AT A TABLE WITH MORE THAN ONE SEAT (Gitea#20 step 1).
|
||||
*
|
||||
@@ -350,7 +379,7 @@ export function newMultiplayerGame(seed: number, config: GameConfig, playerNames
|
||||
* less down". The seed remains in `game.seed`, in every save (`session.ts` persistence) and in the
|
||||
* lobby record, so nothing administrative or replayable loses it.
|
||||
*/
|
||||
game.log.push({ text: `${config.mode} · ${playerNames.length} players`, tone: 'quiet' });
|
||||
pushLine(game, `${config.mode} · ${playerNames.length} players`, 'quiet');
|
||||
drain(game);
|
||||
return game;
|
||||
}
|
||||
@@ -1011,7 +1040,21 @@ function trainCardTitle(number: number, isExtra: boolean): string | null {
|
||||
const calls = parts.length > 0 ? parts.join(' + ') : 'no cars at all';
|
||||
const note = p.rules.note ? ` — ${p.rules.note}` : '';
|
||||
const name = `${p.isExtra ? 'Extra X' : 'Train '}${p.number} “${p.name}”`;
|
||||
return `Making up ${name}: its card calls for ${calls}${note}`;
|
||||
/**
|
||||
* WHAT THE CARD PAYS FOR, ON ITS OWN LINE (Jesse, 2026-09-23: "is it clear from the text
|
||||
* displayed that it earns points only if fully loaded?").
|
||||
*
|
||||
* The card's printed note has always been here, but as a clause trailing the consist — so the one
|
||||
* condition that decides whether the Circus earns anything at all read as flavour. A train whose
|
||||
* card pays for standing still is played completely differently from one that pays for running,
|
||||
* and that is worth its own sentence.
|
||||
*/
|
||||
const pays = p.rules.stopEarnsPoint
|
||||
? '\nTHIS TRAIN PAYS FOR STOPPING, not for running: a full Stage standing still in a district ' +
|
||||
'earns 1 Revenue, once per district — but ONLY if every car except the caboose is loaded. ' +
|
||||
'Made up short or carrying empties, it earns nothing however long it stands.'
|
||||
: '';
|
||||
return `Making up ${name}: its card calls for ${calls}${note}${pays}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1148,7 +1191,7 @@ export function submit(game: Game, intent: Intent, as: PlayerIndex | null = null
|
||||
|
||||
const result = applyIntent(game.state, actor, intent);
|
||||
if (!result.ok) {
|
||||
game.log.push({ text: `That is not allowed: ${result.code}`, tone: 'bad' });
|
||||
pushLine(game, `That is not allowed: ${result.code}`, 'bad');
|
||||
return false;
|
||||
}
|
||||
game.history.push(intent);
|
||||
@@ -1395,7 +1438,16 @@ function record(game: Game, events: GameEvent[], actor: PlayerIndex | null = nul
|
||||
*/
|
||||
const RULINGS = ['clearanceGiven', 'yardOfficeRuled', 'redFlagRuled'];
|
||||
const ruling = RULINGS.includes(e.type) && who !== null;
|
||||
const mine = who !== null && 'player' in e;
|
||||
/**
|
||||
* EVENTS THAT NAME THEIR OWN PLAYER, and so must not be prefixed with the actor's name as well
|
||||
* — Gitea#31's rule that no line names a player twice.
|
||||
*
|
||||
* `revenueChanged` carries the seat that EARNED it, which is not always the seat that acted: a
|
||||
* train completing its run pays everybody, with no actor at all. Prefixing it with the actor
|
||||
* would be wrong on those lines and redundant on the rest, so `narrate` resolves the name.
|
||||
*/
|
||||
const SELF_NAMED = ['revenueChanged'];
|
||||
const mine = who !== null && 'player' in e && !SELF_NAMED.includes(e.type);
|
||||
const text = ruling
|
||||
? `Superintendent Player ${who} ${uncapitalise(said)}`
|
||||
: mine
|
||||
@@ -1403,7 +1455,7 @@ function record(game: Game, events: GameEvent[], actor: PlayerIndex | null = nul
|
||||
: said;
|
||||
// `trace` is a tone the history panel does not draw — see `inHistory`. The line exists so the
|
||||
// step that caused it has narration to caption the board with, and a dwell to be watched for.
|
||||
game.log.push({ text, tone: inHistory(game, e) ? (mine || ruling ? 'act' : n.tone) : 'trace' });
|
||||
pushLine(game, text, inHistory(game, e) ? (mine || ruling ? 'act' : n.tone) : 'trace');
|
||||
|
||||
}
|
||||
game.cues.push(...cuesFor(events));
|
||||
@@ -1433,8 +1485,15 @@ function record(game: Game, events: GameEvent[], actor: PlayerIndex | null = nul
|
||||
game.announced = `${name} is now the Superintendent — the Fedora passed at the end of Stage ${e.stage}.`;
|
||||
}
|
||||
}
|
||||
// Keep the log bounded; the full history lives in `history` and can be replayed.
|
||||
if (game.log.length > 400) game.log.splice(0, game.log.length - 400);
|
||||
/**
|
||||
* Keep the log bounded; the full history lives in `history` and can be replayed.
|
||||
*
|
||||
* SAFE TO TRIM ONLY BECAUSE LINES CARRY `seq`. While a seat's bookmark was an index into this
|
||||
* array, trimming silently froze that seat's history for the rest of the game — see `Game.log`.
|
||||
* The limit is generous because a four-player game over eight or ten Days is several times the
|
||||
* two-player, five-Day game that first hit it.
|
||||
*/
|
||||
if (game.log.length > LOG_LIMIT) game.log.splice(0, game.log.length - LOG_LIMIT);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1465,7 +1524,7 @@ export function toSave(game: Game): Save {
|
||||
* in force then — never the current defaults.
|
||||
*/
|
||||
function configFor(save: Save, config: GameConfig): GameConfig {
|
||||
return { ...config, houseRules: save.rules ?? LEGACY_HOUSE_RULES };
|
||||
return withSavedOpening({ ...config, houseRules: save.rules ?? LEGACY_HOUSE_RULES });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ footer{margin-top:26px;color:var(--dim);font-size:11px;display:flex;gap:18px;fle
|
||||
</div>
|
||||
|
||||
<p class="newhere">New to Station Master?
|
||||
<a href="./quickstart.md">Read the Quickstart guide</a> — what the game is, how you win,
|
||||
<a href="./quickstart.html">Read the Quickstart guide</a> — what the game is, how you win,
|
||||
how a Stage runs, what is on the screen, and a first twenty minutes. About twenty minutes to
|
||||
read, and it will save you an hour of guessing.</p>
|
||||
|
||||
|
||||
+13
-6
@@ -582,10 +582,18 @@ function renderTurnChart(f: Frame): void {
|
||||
// chip that can never change is a chip to read past.
|
||||
const superName =
|
||||
f.players.length > 1 ? (f.players.find((p) => p.index === table.superintendent)?.name ?? null) : null;
|
||||
/**
|
||||
* IS IT YOU BEING WAITED ON? The line flashes if so — the commonest way a table stalls is a
|
||||
* player not noticing their turn has come round (playtest). Read from the move ON SCREEN, not the
|
||||
* live one, so it does not start flashing while your board is still catching up on somebody
|
||||
* else's turn and you cannot act yet.
|
||||
*/
|
||||
const yours = !replaying && actor !== null && actor === f.viewer;
|
||||
$('turnchart').innerHTML = turnChartHtml(
|
||||
replaying ? { ...f, ...table, awaiting: null } : f,
|
||||
actorName,
|
||||
superName,
|
||||
yours,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -678,12 +686,11 @@ function renderGameCard(f: Frame): void {
|
||||
* nobody sees, the same reasoning the folded body above already follows.
|
||||
*/
|
||||
const GUIDE_DOCS: readonly { href: string; label: string; what: string }[] = [
|
||||
{ href: './quickstart.md', label: 'Quickstart', what: 'What the game is and a first twenty minutes — for anyone who has not played.' },
|
||||
{ href: './rules.md', label: 'Rules', what: 'The rules in full, with the FAQ.' },
|
||||
{ href: './rules/as-built.md', label: 'Every card', what: 'Generated from the code, so it cannot drift from what the game actually does.' },
|
||||
{ href: './home-deck.md', label: 'Home deck', what: 'How the Home Office deck is dealt and played.' },
|
||||
{ href: './mainline-deck.md', label: 'Mainline deck', what: 'The Mainline cards and what each does to a train.' },
|
||||
{ href: './components.md', label: 'Components', what: 'Rolling stock, yards, trays, the Fedora.' },
|
||||
{ href: './quickstart.html', label: 'Quickstart', what: 'What the game is and a first twenty minutes — for anyone who has not played.' },
|
||||
{ href: './rules.html', label: 'Rules', what: 'The rules in full, with the FAQ.' },
|
||||
{ href: './home-deck.html', label: 'Home deck', what: 'How the Home Office deck is dealt and played.' },
|
||||
{ href: './mainline-deck.html', label: 'Mainline deck', what: 'The Mainline cards and what each does to a train.' },
|
||||
{ href: './components.html', label: 'Components', what: 'Rolling stock, yards, trays, the Fedora.' },
|
||||
];
|
||||
|
||||
const GUIDE_HTML =
|
||||
|
||||
+21
-1
@@ -441,6 +441,7 @@ ul.blocked li{padding:2px 0}
|
||||
<h2>Join a game</h2>
|
||||
<p class="ng-note">Ask whoever created the game for its code. You will see the whole rule set
|
||||
before you take a seat.</p>
|
||||
<p class="ng-note"><b>Your seat lives in this browser.</b> Rejoining uses a token kept here, so a different browser or device — or clearing this site's data — cannot take your seat back. If that happens, whoever runs the server can issue you a single-use recovery link.</p>
|
||||
<label class="ng-num"><span>Game code</span><input id="lb-code" type="text" autocomplete="off" placeholder="RAIL-1234"></label>
|
||||
<button id="lb-look" type="button">Look up game</button>
|
||||
<p class="lb-error" id="lb-join-err" role="alert"></p>
|
||||
@@ -462,6 +463,7 @@ ul.blocked li{padding:2px 0}
|
||||
<section id="lb-create-panel" hidden>
|
||||
<h2>Create a new game</h2>
|
||||
<p class="ng-note">You become the host — you choose the game type and, once everyone is seated, start the game. 2 to 4 players.</p>
|
||||
<p class="ng-note"><b>Your seat lives in this browser.</b> Rejoining uses a token kept here, so a different browser or device — or clearing this site's data — cannot take your seat back. If that happens, whoever runs the server can issue you a single-use recovery link.</p>
|
||||
|
||||
<!-- TWO COLUMNS WHERE THERE IS ROOM. One 640px-wide column made this form a very long scroll
|
||||
for what is really two short lists: what game this is, and what its rules are. -->
|
||||
@@ -628,6 +630,15 @@ ul.blocked li{padding:2px 0}
|
||||
<input id="lb-toolbox" type="checkbox"></label>
|
||||
<span class="set-hint" id="lb-toolbox-hint"></span>
|
||||
</div>
|
||||
<div class="set-row" id="lb-whistlestart-row">
|
||||
<label class="ng-num"><span>Players start with Whistle Posts, not Depots — the harder game.
|
||||
A Whistle Post has one A/D track and is not a Passenger Facility, so no passenger earns
|
||||
anything until somebody draws and plays a Depot upgrade, and a second train arriving is a
|
||||
collision. Leave this off and every district opens as a Depot, with two A/D tracks and
|
||||
passengers working from Stage 1; the Depot upgrade cards are then left out of the deck</span>
|
||||
<input id="lb-whistlestart" type="checkbox"></label>
|
||||
<span class="set-hint" id="lb-whistlestart-hint"></span>
|
||||
</div>
|
||||
<div class="set-row" id="lb-tossloco-row">
|
||||
<label class="ng-num"><span>A Timetabled train may be discarded — toss it face-up to a
|
||||
Department slot, where a rival may pick it up. Turn this off and a train card can only ever
|
||||
@@ -853,6 +864,15 @@ ul.blocked li{padding:2px 0}
|
||||
<input id="ss-toolbox" type="checkbox"></label>
|
||||
<span class="set-hint" id="ss-toolbox-hint"></span>
|
||||
</div>
|
||||
<div class="set-row" id="ss-whistlestart-row">
|
||||
<label class="ng-num"><span>Players start with Whistle Posts, not Depots — the harder game.
|
||||
A Whistle Post has one A/D track and is not a Passenger Facility, so no passenger earns
|
||||
anything until somebody draws and plays a Depot upgrade, and a second train arriving is a
|
||||
collision. Leave this off and every district opens as a Depot, with two A/D tracks and
|
||||
passengers working from Stage 1; the Depot upgrade cards are then left out of the deck</span>
|
||||
<input id="ss-whistlestart" type="checkbox"></label>
|
||||
<span class="set-hint" id="ss-whistlestart-hint"></span>
|
||||
</div>
|
||||
<div class="set-row" id="ss-tossloco-row">
|
||||
<label class="ng-num"><span>A Timetabled train may be discarded — toss it face-up to a
|
||||
Department slot. Turn this off and a train card can only ever be played onto the timetable.
|
||||
@@ -930,7 +950,7 @@ ul.blocked li{padding:2px 0}
|
||||
every load and nothing let go of it. This keeps your seat — the table waits for you — and
|
||||
your token, and puts you back at the lobby, which lists every game this browser is in. -->
|
||||
<button id="leavegame" hidden title="Go back to the lobby. Your seat is kept and the game waits for you — the lobby lists it under Games you are in, so you can come back or hand the browser to a different game.">Leave game</button>
|
||||
<a class="home" href="./replays.html" style="font-size:12px">replays</a>
|
||||
<a class="home" href="./replays.html" style="font-size:12px" data-tip="Watch a recorded game, or open a save file. A save replays under the rules of the build that opens it, so one made on an earlier build may stop part-way — your file is never altered.">replays</a>
|
||||
<span class="dim build" title="what is actually deployed">__BUILD__</span>
|
||||
</header>
|
||||
|
||||
|
||||
+12
-2
@@ -25,7 +25,7 @@ import {
|
||||
collectiveRevenueFloor,
|
||||
houseRules,
|
||||
} from '../engine/content.ts';
|
||||
import type { ExtraStartRule, RevenueRules, StartingHand } from '../engine/content.ts';
|
||||
import type { ExtraStartRule, RevenueRules, StartingHand, StartingOffice } from '../engine/content.ts';
|
||||
import type { GameConfig, GameMode } from '../engine/state.ts';
|
||||
|
||||
export type PresetName = 'solitaire' | 'coop' | 'competitive' | 'cutthroat';
|
||||
@@ -54,6 +54,8 @@ export type Settings = {
|
||||
emergencyToolbox: boolean;
|
||||
/** §6.2 (Gitea#9) — may a Timetabled train be thrown away? An Extra never may, whatever this says. */
|
||||
discardTimetabled: boolean;
|
||||
/** Ticked = everyone opens on a Whistle Post, the harder game. Unticked = a Depot. */
|
||||
startWhistlePosts: boolean;
|
||||
};
|
||||
|
||||
export const SETTING_KEYS: readonly (keyof Settings)[] = [
|
||||
@@ -69,6 +71,7 @@ export const SETTING_KEYS: readonly (keyof Settings)[] = [
|
||||
'employeeRotation',
|
||||
'emergencyToolbox',
|
||||
'discardTimetabled',
|
||||
'startWhistlePosts',
|
||||
];
|
||||
|
||||
export type Preset = {
|
||||
@@ -103,6 +106,8 @@ const NO_OPTIONAL_RULES = {
|
||||
* about how long a game runs, which is a dial the table already sets for itself.
|
||||
*/
|
||||
discardTimetabled: true,
|
||||
// The default opening is a Depot, so the harder setting is off.
|
||||
startWhistlePosts: false,
|
||||
} as const;
|
||||
|
||||
/** Every type deals six now (Jesse, 2026-08-23) — the hand limit is three, so the first turn is a
|
||||
@@ -227,6 +232,7 @@ export function settingsOf(config: GameConfig): Settings {
|
||||
employeeRotation: config.optionalRules.employeeRotation,
|
||||
emergencyToolbox: config.optionalRules.emergencyToolbox,
|
||||
discardTimetabled: rules.discardTimetabled,
|
||||
startWhistlePosts: rules.startingOffice === 'whistlePost',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -274,7 +280,7 @@ export function configFromFrame(f: {
|
||||
maxCollisionsPerDay: number;
|
||||
maxCollisionsTotal: number;
|
||||
optionalRules: GameConfig['optionalRules'];
|
||||
houseRules: { startingHand: StartingHand; extraStart: ExtraStartRule; revenue: RevenueRules; discardTimetabled: boolean };
|
||||
houseRules: { startingHand: StartingHand; extraStart: ExtraStartRule; revenue: RevenueRules; discardTimetabled: boolean; startingOffice?: StartingOffice };
|
||||
}): GameConfig {
|
||||
return {
|
||||
mode: f.mode,
|
||||
@@ -291,6 +297,9 @@ export function configFromFrame(f: {
|
||||
// Carried like the rest: this path describes SOMEONE ELSE'S game to a joiner, so a setting
|
||||
// dropped here shows them a rule the table is not playing (§6.2, Gitea#9).
|
||||
discardTimetabled: f.houseRules.discardTimetabled,
|
||||
// Spread rather than assigned: `exactOptionalPropertyTypes` refuses an explicit `undefined`,
|
||||
// and a Frame from a server that predates this setting simply does not carry it.
|
||||
...(f.houseRules.startingOffice ? { startingOffice: f.houseRules.startingOffice } : {}),
|
||||
revenue: f.houseRules.revenue,
|
||||
},
|
||||
};
|
||||
@@ -355,6 +364,7 @@ export function configFromSettings(
|
||||
startingHand: settings.startingHand,
|
||||
extraStart: settings.extraStart,
|
||||
discardTimetabled: settings.discardTimetabled,
|
||||
startingOffice: settings.startWhistlePosts ? 'whistlePost' : 'depot',
|
||||
revenue: {
|
||||
passengerPerCoach: settings.passengerPerCoach,
|
||||
freightPerLoad: settings.freightPerLoad,
|
||||
|
||||
@@ -69,6 +69,10 @@ input[type=range]{flex:1;min-width:180px}
|
||||
<p class="dim">A Station Master save is a small <code>.json</code> file — a seed and the list of
|
||||
moves made. That is enough to rebuild the whole game, so a replay can be emailed like a text file.
|
||||
Save one from inside a game with <b>Save replay</b>.</p>
|
||||
<!-- #40 — the one thing about saves a player has to be told, wherever saves are handled. -->
|
||||
<p class="dim">A save replays under the rules of the build that opens it, so one made on an
|
||||
earlier build may stop part-way. The viewer says which move it stopped on, and your file is
|
||||
never altered.</p>
|
||||
<input type="file" id="file" accept=".json,application/json">
|
||||
<div id="perr"></div>
|
||||
</section>
|
||||
|
||||
@@ -48,6 +48,7 @@ export const FIELDS: readonly Field[] = [
|
||||
{ key: 'employeeRotation', kind: 'checkbox', id: 'rotation' },
|
||||
{ key: 'emergencyToolbox', kind: 'checkbox', id: 'toolbox' },
|
||||
{ key: 'discardTimetabled', kind: 'checkbox', id: 'tossloco' },
|
||||
{ key: 'startWhistlePosts', kind: 'checkbox', id: 'whistlestart' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -73,6 +74,7 @@ const FIELD_LABELS: Record<keyof Settings, string> = {
|
||||
startingHand: 'Starting hand',
|
||||
extraStart: 'An Extra may start at',
|
||||
discardTimetabled: 'A Timetabled train may be discarded',
|
||||
startWhistlePosts: 'Players start with Whistle Posts, not Depots',
|
||||
passengerPerCoach: 'Passenger per coach',
|
||||
freightPerLoad: 'Freight per load',
|
||||
trainPerTransit: 'Train per transit',
|
||||
@@ -116,7 +118,7 @@ export function rulesListHtml(config: GameConfig, players: number, days: number)
|
||||
|
||||
return (
|
||||
head +
|
||||
`<h4>Opening</h4><dl>${rows(['startingHand', 'extraStart'])}</dl>` +
|
||||
`<h4>Opening</h4><dl>${rows(['startingHand', 'extraStart', 'startWhistlePosts'])}</dl>` +
|
||||
`<h4>Train cards</h4><dl>${rows(['discardTimetabled'])}</dl>` +
|
||||
`<h4>Revenue</h4><dl>${rows(['passengerPerCoach', 'freightPerLoad', 'trainPerTransit'])}</dl>` +
|
||||
`<h4>Victory conditions</h4><dl>${rows(['minCombinedRevenue', 'maxCollisionsPerDay', 'maxCollisionsTotal'])}</dl>` +
|
||||
@@ -209,6 +211,7 @@ export function settingsForm(prefix: string): SettingsForm {
|
||||
employeeRotation: el<HTMLInputElement>('rotation')?.checked === true,
|
||||
emergencyToolbox: el<HTMLInputElement>('toolbox')?.checked === true,
|
||||
discardTimetabled: el<HTMLInputElement>('tossloco')?.checked === true,
|
||||
startWhistlePosts: el<HTMLInputElement>('whistlestart')?.checked === true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -225,6 +228,7 @@ export function settingsForm(prefix: string): SettingsForm {
|
||||
setChecked('rotation', values.employeeRotation);
|
||||
setChecked('toolbox', values.emergencyToolbox);
|
||||
setChecked('tossloco', values.discardTimetabled);
|
||||
setChecked('whistlestart', values.startWhistlePosts);
|
||||
}
|
||||
|
||||
function setNumber(id: string, value: number): void {
|
||||
|
||||
Reference in New Issue
Block a user