v0.7.0 — four game types, a lobby you can read and leave, and a multiplayer game that makes a sound

The multiplayer set-up, the lobby, the start of a game, and four signals a remote client had never
been sent. Reasoning, the preset table and what was verified how: CHANGELOG.md.

- Co-op, Competitive, Cutthroat, Solitaire and Custom, on both screens, from one shared block —
  they had drifted, and each was missing a question the other asked.
- A player reads the whole rule set before taking a seat, may leave a lobby or a running game, and
  keeps a seat across a reload. The host may clear a chair. The browser remembers every game it is
  in, not just the last one.
- The start of a game is drawn: a handoff beat, an announcement, the code and type in the header.
- Sound, the timetable flash, announcements and the just-drawn badge now reach a remote client;
  justDrawn goes to the seat that drew it and nobody else.
- Played on StartOS, which found the rest: an Extra belongs to the player who played it, the board
  never named the Superintendent, bot seats were reported as absent players, and rule section
  numbers are out of every string a player reads.

Also carries the previous session's Heavy Grade documentation work — asked again, answer unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016JczK5i33ZNSf2PtzZqdhS
This commit is contained in:
Jesse.Markowitz
2026-08-23 05:46:42 -04:00
co-authored by Claude Opus 5
parent 42adfda390
commit 06db36e5b5
41 changed files with 4387 additions and 588 deletions
+74 -10
View File
@@ -99,9 +99,23 @@ export type Session = {
* the seat and waits; this is what lets the page say why, instead of going quiet with no
* explanation. Reflects the last presence push for each seat the server has ever mentioned, not
* only the ones currently disconnected — a seat that reconnects updates its own entry rather than
* disappearing, so the page can tell "never heard from" apart from "was here, then left."
* disappearing.
*
* `seen` is what separates the two absences the page must not conflate: a seat that has connected
* at some point and dropped, against one that has never opened the game at all. The server now
* reports every other seat on connect (2026-08-23), so this is answerable at the moment a game
* starts — which is exactly when "is everyone here?" is the question.
*/
presence(): { seat: PlayerIndex; connected: boolean }[];
presence(): { seat: PlayerIndex; connected: boolean; seen: boolean }[];
/**
* Stop listening, for good.
*
* Only a remote session has anything to close, and only one caller needs it: a player LEAVING a
* running game (2026-08-23). Without it the page went back to the lobby with its `EventSource`
* still open, so the server — and therefore every other seat — went on reporting them as present
* at a table they had walked away from.
*/
close?(): void;
};
/**
@@ -205,7 +219,24 @@ type Push = {
frame?: FrameDelta;
menu: Menu | null;
lines: { text: string; tone: string }[];
presence?: { seat: PlayerIndex; connected: boolean };
/** One entry for a change; every other seat at once on the connect push. */
presence?: { seat: PlayerIndex; connected: boolean; seen: boolean }[];
/**
* THE FOUR TRANSIENT SIGNALS, added 2026-08-23.
*
* A remote session used to return nothing for any of them, so multiplayer had no sound at all, no
* timetable flash when the D12 filled a slot, no announcement when a completed run paid the table,
* and no highlight on the card you had just drawn — four things solitaire has had all along, and
* most of why a multiplayer game felt inert.
*
* `cues` and `announcement` are SHARED events (a collision anywhere, the Stage bell, a train
* leaving the Division) and reach every seat; `justDrawn` is the recipient's own card and nobody
* else's — `test/redaction.test.ts` covers exactly that.
*/
cues?: string[];
scheduled?: number | null;
announcement?: string | null;
justDrawn?: string | null;
};
/**
@@ -239,7 +270,11 @@ export function createRemoteSession(
let frame: Frame | null = null;
let menu: Menu | null = null;
let lines: { text: string; tone: string }[] = [];
const presence = new Map<PlayerIndex, boolean>();
const presence = new Map<PlayerIndex, { connected: boolean; seen: boolean }>();
let cues: string[] = [];
let scheduled: number | null = null;
let announcement: string | null = null;
let justDrawnCard: string | null = null;
let nextSeq = 1;
const listeners = new Set<() => void>();
const changed = (): void => {
@@ -282,7 +317,14 @@ export function createRemoteSession(
menu = push.menu;
}
lines = [...lines, ...push.lines];
if (push.presence) presence.set(push.presence.seat, push.presence.connected);
for (const p of push.presence ?? []) presence.set(p.seat, { connected: p.connected, seen: p.seen });
// Accumulated rather than replaced: two pushes can arrive between two renders, and a cue that
// was earned is a cue that should be heard.
if (push.cues) cues = [...cues, ...push.cues];
if (push.scheduled !== undefined && push.scheduled !== null) scheduled = push.scheduled;
if (push.announcement !== undefined && push.announcement !== null) announcement = push.announcement;
// Persists until another draw replaces it, matching the local session's own `justDrawn`.
if (push.justDrawn !== undefined) justDrawnCard = push.justDrawn;
changed();
};
@@ -317,10 +359,32 @@ export function createRemoteSession(
capabilities: { undo: false, saveLocal: false, newGame: false },
lines: () => lines,
takeCues: () => [],
takeScheduled: () => null,
takeAnnouncement: () => null,
justDrawn: () => null,
presence: () => [...presence].map(([s, connected]) => ({ seat: s, connected })),
// Draining, exactly as the local session's are: each of these marks a moment, so it plays once
// and is gone by the next render rather than re-firing on every redraw.
takeCues: () => {
const out = cues;
cues = [];
return out;
},
takeScheduled: () => {
const out = scheduled;
scheduled = null;
return out;
},
takeAnnouncement: () => {
const out = announcement;
announcement = null;
return out;
},
justDrawn: () => justDrawnCard,
presence: () => [...presence].map(([seat, p]) => ({ seat, connected: p.connected, seen: p.seen })),
close() {
// `reportedGone` first: closing the stream fires `onerror`, and this is a deliberate exit, not
// a game that vanished — `onGone` must not be called and land the page in "that game is no
// longer on this server".
reportedGone = true;
source.close();
listeners.clear();
},
};
}