From e2d85e906fb551bfd2bb680ae9459bbc47be9439 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Fri, 23 May 2025 11:29:28 -0700 Subject: [PATCH] do not allow attacking same team --- src/core/execution/AttackExecution.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 8d62debb5..a12f78068 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -90,15 +90,23 @@ export class AttackExecution implements Execution { return; } - if ( - this.target.isPlayer() && - this.mg.config().numSpawnPhaseTurns() + - this.mg.config().spawnImmunityDuration() > + if (this.target.isPlayer()) { + if ( + this.mg.config().numSpawnPhaseTurns() + + this.mg.config().spawnImmunityDuration() > this.mg.ticks() - ) { - console.warn("cannot attack player during immunity phase"); - this.active = false; - return; + ) { + console.warn("cannot attack player during immunity phase"); + this.active = false; + return; + } + if (this._owner.isOnSameTeam(this.target)) { + console.warn( + `${this._owner.displayName()} cannot attack ${this.target.displayName()} because they are on the same team`, + ); + this.active = false; + return; + } } if (this.startTroops == null) {