diff --git a/apps/server/src/rooms/room.ts b/apps/server/src/rooms/room.ts index 0bd5a5b..1571770 100644 --- a/apps/server/src/rooms/room.ts +++ b/apps/server/src/rooms/room.ts @@ -462,7 +462,7 @@ export class Room { view, events: [], active: this.game.finished ? [] : def.activePlayers(this.game.state), - deadline: this.game.finished ? null : this.effectiveDeadline(), + deadline: this.game.finished ? null : this.publicDeadline(), ...(cs !== undefined ? { cs } : {}), }; } @@ -1128,6 +1128,13 @@ export class Room { // ---------------------------------------------------------------- timers + /** The deadline clients see (`def.publicDeadline`, default the effective one); timers use `effectiveDeadline`. */ + private publicDeadline(): number | null { + const d = this.effectiveDeadline(); + const g = this.game; + return g && this.def.publicDeadline ? this.def.publicDeadline(g.state, d) : d; + } + /** Earliest time any timed player must be auto-acted for. */ effectiveDeadline(): number | null { const g = this.game; diff --git a/packages/engine/src/types.ts b/packages/engine/src/types.ts index 795daed..0cc25fa 100644 --- a/packages/engine/src/types.ts +++ b/packages/engine/src/types.ts @@ -86,6 +86,12 @@ export interface GameDefinition { * pulls forward to the end of the grace period). Real-time games use it to keep a minimum pace. */ timeoutNotBefore?(state: S): number | null; + /** + * Deadline shown to clients (`state.deadline`), given the room's effective one (the phase clock, pulled forward to + * the end of the grace period of an away timed player). Default: the effective one. Games where *who* is timed is a + * secret (아발론's assassin) hide that pull-forward; the room still times out on the effective deadline. + */ + publicDeadline?(state: S, effective: number | null): number | null; /** Grace period (ms) for disconnected timed players in this state, overriding the room's `graceSec`; null = room default. */ disconnectGraceMs?(state: S): number | null; onTimeout(state: S, player: PlayerId): A;