refactor(server): type captureTally accumulators as PieceTally
Tighten the local byYou/byOpponent accumulators from the wider Record<string, number> to PieceTally, matching the return type's fields and preventing silent invalid-key writes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { CaptureTally, Color } from '@blind-chess/shared';
|
||||
import type { CaptureTally, Color, PieceTally } from '@blind-chess/shared';
|
||||
import type { Game } from './state.js';
|
||||
|
||||
/**
|
||||
@@ -8,8 +8,8 @@ import type { Game } from './state.js';
|
||||
* no live board state, no opponent positions.
|
||||
*/
|
||||
export function captureTally(game: Game, viewer: Color): CaptureTally {
|
||||
const byYou: Record<string, number> = {};
|
||||
const byOpponent: Record<string, number> = {};
|
||||
const byYou: PieceTally = {};
|
||||
const byOpponent: PieceTally = {};
|
||||
for (const rec of game.moveHistory) {
|
||||
const captured = rec.capturedPieceType;
|
||||
if (!captured) continue;
|
||||
|
||||
Reference in New Issue
Block a user