From 3aa375b210d09ec946c0f4d5d1ff23979a603e14 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 3 Mar 2025 20:23:27 -0800 Subject: [PATCH] have warships favor attacking transport ships --- src/core/execution/WarshipExecution.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/execution/WarshipExecution.ts b/src/core/execution/WarshipExecution.ts index 088e96cfb..a297b4259 100644 --- a/src/core/execution/WarshipExecution.ts +++ b/src/core/execution/WarshipExecution.ts @@ -87,11 +87,25 @@ export class WarshipExecution implements Execution { this.target = ships.sort((a, b) => { // First compare by Warship type - if (a.type() === UnitType.Warship && b.type() !== UnitType.Warship) + if (a.type() === UnitType.Warship && b.type() !== UnitType.Warship) { return -1; - if (a.type() !== UnitType.Warship && b.type() === UnitType.Warship) + } + if (a.type() !== UnitType.Warship && b.type() === UnitType.Warship) { return 1; - + } + // Then favor transport ship + if ( + a.type() === UnitType.TransportShip && + b.type() !== UnitType.TransportShip + ) { + return -1; + } + if ( + a.type() !== UnitType.TransportShip && + b.type() === UnitType.TransportShip + ) { + return 1; + } // If both are same type, sort by distance return distSortUnit(this.mg, this.warship)(a, b); })[0] ?? null;