diff --git a/TODO.txt b/TODO.txt index f9a7bd6c5..61668512e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -115,6 +115,7 @@ * game mobile friendly DONE 9/16/2024 * UI: basic win condition & popup DONE 9/16/2024 * right click popup alliance option +* BUG: can't ally same person twice * make fake humans easier * click alliance sends alliance request * notification for alliance request diff --git a/src/core/execution/BotExecution.ts b/src/core/execution/BotExecution.ts index 482659f8b..2727f36b5 100644 --- a/src/core/execution/BotExecution.ts +++ b/src/core/execution/BotExecution.ts @@ -64,7 +64,11 @@ export class BotExecution implements Execution { const toAttack = border[this.random.nextInt(0, border.length)] const owner = toAttack.owner() + if (owner.isPlayer()) { + if (this.bot.alliedWith(owner)) { + return + } if (owner.type() == PlayerType.FakeHuman) { if (!this.random.chance(2)) { return diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index d1b0c3c77..c6a0da27f 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -138,6 +138,7 @@ export interface Player { incomingAllianceRequests(): AllianceRequest[] outgoingAllianceRequests(): AllianceRequest[] alliances(): Alliance[] + alliedWith(other: Player): boolean toString(): string } diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index af33c739b..76675d8ee 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -120,6 +120,11 @@ export class PlayerImpl implements MutablePlayer { return this.gs.alliances_.filter(a => a.requestor() == this || a.recipient() == this) } + alliedWith(other: Player): boolean { + return this.alliances().find(a => a.recipient() == other || a.requestor() == other) != null + } + + hash(): number { return simpleHash(this.id()) * (this.troops() + this.numTilesOwned()); }