From f2d1eb8e21e28e305b342dcfb39048f3bcfe3ea3 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 19 Sep 2024 16:14:04 -0700 Subject: [PATCH] alliance stops existing attacks --- TODO.txt | 2 +- src/core/execution/AttackExecution.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/TODO.txt b/TODO.txt index 2597b9a69..87a6c5e6b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -120,7 +120,7 @@ * break alliance makes you a traitor DONE 9/18/2024 * add traitor icon DONE 9/18/2024 * make alliance icon DONE 9/19/2024 -* bots attack traitors +* bots attack traitors DONE 9/19/2024 * BUG: alliance should stop attack * create event box * make fake humans easier diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 39a1fa23a..930deb904 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -113,6 +113,12 @@ export class AttackExecution implements Execution { this.breakAlliance = false this._owner.breakAllianceWith(this.target as Player) } + if (this.target.isPlayer() && this._owner.alliedWith(this.target)) { + // In this case a new alliance was created AFTER the attack started. + this._owner.addTroops(this.troops) + this.active = false + return + } let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.border.size + this.random.nextInt(0, 5)) // console.log(`num tiles per tick: ${numTilesPerTick}`)