From 74476cc52082e292408da1a150b861f10eeb58d5 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sat, 28 Jun 2025 12:26:57 -0700 Subject: [PATCH] Revert "counter attack doesn't cancel out attack (#1132)" (#1301) This reverts commit a0d17ed85ebbbff192b9d21091934bffe65b32d8. ## Description: Causes some strange edge cases. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/core/execution/AttackExecution.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 51c07c212..1926d9991 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -122,6 +122,20 @@ export class AttackExecution implements Execution { // Record stats this.mg.stats().attack(this._owner, this.target, this.startTroops); + for (const incoming of this._owner.incomingAttacks()) { + if (incoming.attacker() === this.target) { + // Target has opposing attack, cancel them out + if (incoming.troops() > this.attack.troops()) { + incoming.setTroops(incoming.troops() - this.attack.troops()); + this.attack.delete(); + this.active = false; + return; + } else { + this.attack.setTroops(this.attack.troops() - incoming.troops()); + incoming.delete(); + } + } + } for (const outgoing of this._owner.outgoingAttacks()) { if ( outgoing !== this.attack &&