From 54466207888c5c541e5589101d12fa08b109ddfb Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 28 May 2025 11:40:37 -0700 Subject: [PATCH] fix null vs undefined trade ship check --- src/core/execution/TradeShipExecution.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/execution/TradeShipExecution.ts b/src/core/execution/TradeShipExecution.ts index bed5803dc..3094b9384 100644 --- a/src/core/execution/TradeShipExecution.ts +++ b/src/core/execution/TradeShipExecution.ts @@ -18,7 +18,7 @@ export class TradeShipExecution implements Execution { private active = true; private mg: Game; private origOwner: Player; - private tradeShip: Unit; + private tradeShip: Unit | undefined; private wasCaptured = false; private pathFinder: PathFinder; @@ -35,7 +35,7 @@ export class TradeShipExecution implements Execution { } tick(ticks: number): void { - if (this.tradeShip === null) { + if (this.tradeShip === undefined) { const spawn = this.origOwner.canBuild( UnitType.TradeShip, this.srcPort.tile(), @@ -126,7 +126,7 @@ export class TradeShipExecution implements Execution { private complete() { this.active = false; - this.tradeShip.delete(false); + this.tradeShip!.delete(false); const gold = this.mg .config() .tradeShipGold( @@ -134,11 +134,11 @@ export class TradeShipExecution implements Execution { ); if (this.wasCaptured) { - this.tradeShip.owner().addGold(gold); + this.tradeShip!.owner().addGold(gold); this.mg.displayMessage( `Received ${renderNumber(gold)} gold from ship captured from ${this.origOwner.displayName()}`, MessageType.SUCCESS, - this.tradeShip.owner().id(), + this.tradeShip!.owner().id(), ); } else { this.srcPort.owner().addGold(gold);