Ledgers close with an over line, so the digest can say who won
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
107e1893bc
commit
79947e31ba
@@ -166,6 +166,7 @@ export class Rooms {
|
||||
const actor = room.state.timeStops[0];
|
||||
this.commit(room, { t: 'turn', at: Date.now(), inputs: { [actor]: chooseBotTurn(room.state, actor) } });
|
||||
}
|
||||
if (room.state?.over) this.commit(room, { t: 'over', at: Date.now(), winner: room.state.over.winner, reason: room.state.over.reason });
|
||||
}
|
||||
|
||||
view(room: Room, seatId: WizardId): RoomView {
|
||||
@@ -228,6 +229,8 @@ function apply(room: Room, line: LedgerLine): void {
|
||||
room.state = resolveTurn(room.state, line.inputs);
|
||||
room.pending = {};
|
||||
break;
|
||||
case 'over':
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -10,7 +10,9 @@ export type LedgerLine =
|
||||
| { t: 'room'; id: string; seats: number; createdAt: number }
|
||||
| { t: 'seat'; id: WizardId; name: string; token: string; bot: boolean }
|
||||
| { t: 'start'; seed: number }
|
||||
| { t: 'turn'; at: number; inputs: Record<WizardId, TurnInput> };
|
||||
| { t: 'turn'; at: number; inputs: Record<WizardId, TurnInput> }
|
||||
/** Written after the turn that ends the duel, for anything that reads ledgers without the engine. */
|
||||
| { t: 'over'; at: number; winner: WizardId | null; reason: string };
|
||||
|
||||
export class Store {
|
||||
constructor(private dir: string) {
|
||||
|
||||
Reference in New Issue
Block a user