A game may take drafts: an input it does not call settled can be replaced, and the round waits for settled ones

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
Eric Wagoner
2026-09-29 12:14:33 -04:00
co-authored by Claude Opus 5.5
parent 6133a2469a
commit 927e49cf79
4 changed files with 48 additions and 2 deletions
+8 -2
View File
@@ -360,6 +360,7 @@ export class Rooms<State, Input> {
/**
* Record a seat's move on the ledger, so a restart keeps it; resolve the round once nobody else is awaited.
* A draft (an input the game does not call settled) may be replaced until it is settled.
* `resolved` is how many rounds the page had seen played when the move was made: a move that
* arrives after its round was played (a slow connection, a second click, a stale tab) is refused
* rather than taken as the move for the next round.
@@ -386,6 +387,11 @@ export class Rooms<State, Input> {
this.driveBots(room);
}
/** Whether an input is final; a game without drafts makes every input final. */
private settled(input: unknown): boolean {
return this.game.settled ? this.game.settled(input as Input) : true;
}
/** Table talk, from a seat to everyone at the table and in the gallery. */
say(room: Room<State>, token: string | undefined, raw: unknown): void {
const seat = this.seatOf(room, token);
@@ -402,11 +408,11 @@ export class Rooms<State, Input> {
return text;
}
/** Seats whose input the next resolution needs and has not yet received. */
/** Seats whose input the next resolution needs and has not yet received settled; a draft still waits. */
waitingOn(room: Room<State>): SeatId[] {
if (!room.state || this.game.over(room.state)) return [];
return room.seats
.filter((s) => !s.bot && this.game.needsInput(room.state!, s.id) && !(s.id in room.pending))
.filter((s) => !s.bot && this.game.needsInput(room.state!, s.id) && !(s.id in room.pending && this.settled(room.pending[s.id])))
.map((s) => s.id);
}