diff --git a/src/client/graphics/layers/PlayerInfoOverlay.ts b/src/client/graphics/layers/PlayerInfoOverlay.ts index 404185b15..f1b9608e5 100644 --- a/src/client/graphics/layers/PlayerInfoOverlay.ts +++ b/src/client/graphics/layers/PlayerInfoOverlay.ts @@ -144,7 +144,7 @@ export class PlayerInfoOverlay extends LitElement implements Layer { private renderPlayerInfo(player: Player) { const myPlayer = this.myPlayer(); - const isAlly = myPlayer.isAlliedWith(player) + const isAlly = myPlayer?.isAlliedWith(player) let relationHtml = null; if (player.type() == PlayerType.FakeHuman && myPlayer != null) { let classType = ''; diff --git a/src/core/GameView.ts b/src/core/GameView.ts index 9343b755c..f08954f3e 100644 --- a/src/core/GameView.ts +++ b/src/core/GameView.ts @@ -107,8 +107,11 @@ export class PlayerView implements Player { numTilesOwned(): number { return this.data.tilesOwned } - allies(): Player[] { - return this.data.allies.map(a => this.game.player(a)) + allies(): PlayerView[] { + return this.data.allies.map(a => this.game.playerBySmallID(a) as PlayerView) + } + targets(): PlayerView[] { + return this.data.targets.map(id => this.game.playerBySmallID(id) as PlayerView) } gold(): Gold { return this.data.gold @@ -127,7 +130,7 @@ export class PlayerView implements Player { } isAlliedWith(other: Player): boolean { - return this.data.alliances.some(n => other.smallID() == n) + return this.data.allies.some(n => other.smallID() == n) } allianceWith(other: Player): Alliance | null { return null @@ -163,8 +166,9 @@ export class PlayerView implements Player { return [] } transitiveTargets(): Player[] { - return [] + return [...this.targets(), ...this.allies().flatMap(p => p.targets())] } + isTraitor(): boolean { return this.data.isTraitor } diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 1b2a8eba3..90c4e186a 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -422,14 +422,14 @@ export interface PlayerUpdate { playerType: PlayerType, isAlive: boolean, tilesOwned: number, - allies: PlayerID[], gold: number, population: number, workers: number, troops: number, targetTroopRatio: number - alliances: number[] + allies: number[] isTraitor: boolean + targets: number[] } diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index bf1577b49..ab8ddd650 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -70,14 +70,14 @@ export class PlayerImpl implements MutablePlayer { playerType: this.type(), isAlive: this.isAlive(), tilesOwned: this.numTilesOwned(), - allies: this.allies().map(p => p.id()), gold: this._gold, population: this.population(), workers: this.workers(), troops: this.troops(), targetTroopRatio: this.targetTroopRatio(), - alliances: this.alliances().map(a => a.other(this).smallID()), + allies: this.alliances().map(a => a.other(this).smallID()), isTraitor: this.isTraitor(), + targets: this.targets().map(p => p.smallID()) } }