mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 15:32:11 +00:00
thread_split: implement target player icon
This commit is contained in:
@@ -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 = '';
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user