fix: store embargoes as smallID numbers (drop string[] wart)

PlayerState.embargoes was string[] of stringified smallIDs — the
renderer parsed each entry with parseInt() to use as an array index.
Flagged in the integration handoff as something that should be number[].

Switch to number[] end-to-end: renderer type, relation-matrix derive
(no parseInt), PlayerView.setEmbargoSmallIDs / hasEmbargoAgainst
(numeric Array.includes, no String() temporaries), and GameView's
embargo translation pass. Also updates the PlayerView test that pinned
the old format.
This commit is contained in:
evanpelle
2026-05-16 17:45:29 -07:00
parent e87e2cd58c
commit 8955be7667
5 changed files with 14 additions and 16 deletions
+6 -7
View File
@@ -64,8 +64,8 @@ function staticFromUpdate(pu: PlayerUpdate): PlayerStatic {
}
function stateFromUpdate(pu: PlayerUpdate): PlayerState {
// embargoes: Set<PlayerID strings> on the wire, but the renderer expects
// stringified smallIDs. GameView fills these in via setEmbargoes() because
// embargoes: Set<PlayerID strings> on the wire, but the renderer stores
// smallIDs (numbers). GameView fills these in via setEmbargoes() because
// it has the PlayerID → smallID lookup table.
return {
smallID: pu.smallID,
@@ -249,9 +249,9 @@ export class PlayerView {
applyStateUpdate(this.state, pu);
}
/** Set the renderer-format embargoes (stringified smallIDs). */
setEmbargoSmallIDs(smallIDStrings: string[]): void {
this.state.embargoes = smallIDStrings;
/** Set the renderer-format embargoes (smallIDs). */
setEmbargoSmallIDs(smallIDs: number[]): void {
this.state.embargoes = smallIDs;
}
territoryColor(tile?: TileRef): Colord {
@@ -493,8 +493,7 @@ export class PlayerView {
}
hasEmbargoAgainst(other: PlayerView): boolean {
const otherSmallIDStr = String(other.smallID());
return this.state.embargoes.includes(otherSmallIDStr);
return this.state.embargoes.includes(other.smallID());
}
hasEmbargo(other: PlayerView): boolean {