show alliance icon

This commit is contained in:
evanpelle
2025-01-21 16:47:18 -08:00
committed by Evan
parent ba654fd7ea
commit ab183e4f59
7 changed files with 22 additions and 20 deletions
+5 -2
View File
@@ -119,12 +119,15 @@ export class GameRunner {
throw new Error(`player with id ${playerID} not found`);
}
return {
const rel = {
relations: Object.fromEntries(
player.allRelationsSorted()
.map(({ player, relation }) => [player.smallID(), relation])
)
),
alliances: player.alliances().map(a => a.other(player).smallID())
};
console.log(`got relations: ${JSON.stringify(rel)}`)
return rel
}
private canBoat(myPlayer: Player, tile: TileRef): boolean {
+1 -1
View File
@@ -127,7 +127,7 @@ export class PlayerView implements Player {
}
isAlliedWith(other: Player): boolean {
return false
return this.data.alliances.some(n => other.smallID() == n)
}
allianceWith(other: Player): Alliance | null {
return null
+1 -2
View File
@@ -30,8 +30,7 @@ export class DevConfig extends DefaultConfig {
return info
}
// tradeShipSpawnRate(): number {
// return 10
// tradeShipSpawnRate(): number { // return 10
// }
// boatMaxDistance(): number {
// return 5000
+2 -1
View File
@@ -370,7 +370,7 @@ export interface PlayerActions {
export interface PlayerProfile {
relations: Record<number, Relation>
// TODO: add alliances etc
alliances: number[]
}
export interface PlayerInteraction {
@@ -428,6 +428,7 @@ export interface PlayerUpdate {
workers: number,
troops: number,
targetTroopRatio: number
alliances: number[]
}
+2 -1
View File
@@ -75,7 +75,8 @@ export class PlayerImpl implements MutablePlayer {
population: this.population(),
workers: this.workers(),
troops: this.troops(),
targetTroopRatio: this.targetTroopRatio()
targetTroopRatio: this.targetTroopRatio(),
alliances: this.alliances().map(a => a.other(this).smallID())
}
}