mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-04 15:46:07 +00:00
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:
@@ -67,8 +67,7 @@ export function buildRelationMatrix(
|
||||
}
|
||||
|
||||
if (ps.embargoes) {
|
||||
for (const eStr of ps.embargoes) {
|
||||
const eID = parseInt(eStr, 10);
|
||||
for (const eID of ps.embargoes) {
|
||||
if (eID > 0 && eID < RELATION_SIZE) {
|
||||
matrix[sid * RELATION_SIZE + eID] = RELATION_EMBARGO;
|
||||
matrix[eID * RELATION_SIZE + sid] = RELATION_EMBARGO;
|
||||
|
||||
@@ -63,7 +63,7 @@ export interface PlayerState {
|
||||
hasSpawned: boolean;
|
||||
lastDeleteUnitTick: number;
|
||||
allies: number[];
|
||||
embargoes: string[];
|
||||
embargoes: number[];
|
||||
targets: number[];
|
||||
outgoingAttacks: AttackData[];
|
||||
incomingAttacks: AttackData[];
|
||||
|
||||
Reference in New Issue
Block a user