thread_split: implement target player icon

This commit is contained in:
evanpelle
2025-01-21 20:05:07 -08:00
committed by Evan
parent 62a0642b4d
commit 05da562bba
4 changed files with 13 additions and 9 deletions
@@ -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 = '';
+8 -4
View File
@@ -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
}
+2 -2
View File
@@ -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[]
}
+2 -2
View File
@@ -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())
}
}