feat(server): per-viewer capture tally on joined and update messages
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type {
|
||||
BoardView, Color, GameId, GameStatus, Mode, PlayerToken,
|
||||
BoardView, CaptureTally, Color, GameId, GameStatus, Mode, PlayerToken,
|
||||
PromotionType, Square, EndReason,
|
||||
} from './types.js';
|
||||
import type { Announcement } from './moderator.js';
|
||||
@@ -34,6 +34,7 @@ export type ServerMessage =
|
||||
mode: Mode;
|
||||
highlightingEnabled: boolean;
|
||||
opponentConnected: boolean;
|
||||
captures: CaptureTally;
|
||||
aiOpponent?: { color: Color; brain: 'casual' | 'recon' };
|
||||
}
|
||||
| {
|
||||
@@ -45,6 +46,7 @@ export type ServerMessage =
|
||||
drawOffer?: { from: Color } | null;
|
||||
endReason?: EndReason;
|
||||
winner?: Color | null;
|
||||
captures: CaptureTally;
|
||||
aiOpponent?: { color: Color; brain: 'casual' | 'recon' };
|
||||
}
|
||||
| { type: 'peer-status'; color: Color; connected: boolean; graceUntil?: number }
|
||||
|
||||
@@ -61,3 +61,12 @@ export function squareAt(fileIdx: number, rankIdx: number): Square | null {
|
||||
const r = String.fromCharCode('1'.charCodeAt(0) + rankIdx);
|
||||
return `${f}${r}` as Square;
|
||||
}
|
||||
|
||||
/** Count of pieces by type — used for the capture tally. */
|
||||
export type PieceTally = Partial<Record<PieceType, number>>;
|
||||
|
||||
/** Per-viewer capture tally: what you took, and what you lost. */
|
||||
export interface CaptureTally {
|
||||
byYou: PieceTally;
|
||||
byOpponent: PieceTally;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user