From 146a7ef6573d65dc9a70336bcf10d8e5cc9d594e Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 25 Nov 2024 09:19:22 -0800 Subject: [PATCH] bugfix: destroys not capturing tradeships --- TODO.txt | 2 ++ src/core/execution/TradeShipExecution.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/TODO.txt b/TODO.txt index 64f07eb3e..5d9c318da 100644 --- a/TODO.txt +++ b/TODO.txt @@ -192,6 +192,8 @@ * BUG: fix matchmaking DONE 11/22/2024 * destroyer can capture trade ships DONE 11/22/2024 * have bots recapture after nuclear blast DONE 11/24/2022 +* BUG: destroys destroy trade ships instead of capturing them DONE 11/25/2024 +* nukes break alliance * don't capture trade ships if allied with either port * make ports cost more for more ports * BUG: Destroyers destroy instead of capture trade ships diff --git a/src/core/execution/TradeShipExecution.ts b/src/core/execution/TradeShipExecution.ts index d70aa625c..59b139329 100644 --- a/src/core/execution/TradeShipExecution.ts +++ b/src/core/execution/TradeShipExecution.ts @@ -44,17 +44,18 @@ export class TradeShipExecution implements Execution { this.active = false return } - if (!this.dstPort.isActive() || !this.tradeShip.owner().isAlliedWith(this.dstPort.owner())) { - this.tradeShip.delete() - this.active = false - return - } if (this.origOwner != this.tradeShip.owner()) { // Store as vairable in case ship is recaptured by previous owner this.wasCaptured = true } + if (!this.wasCaptured && (!this.dstPort.isActive() || !this.tradeShip.owner().isAlliedWith(this.dstPort.owner()))) { + this.tradeShip.delete() + this.active = false + return + } + if (this.wasCaptured) { const ports = this.tradeShip.owner().units(UnitType.Port).sort(distSortUnit(this.tradeShip)) if (ports.length == 0) {