From 3d5ff8c9b4f329d41a8fec3e16d83043e26fed97 Mon Sep 17 00:00:00 2001 From: Max Lundgren Date: Sat, 7 Jun 2025 22:05:12 +0300 Subject: [PATCH] Add back #646 - trade ship gold by travelled distance (#1085) ## Description: Return #646 - gold from tradeships by travelled distance https://github.com/openfrontio/OpenFrontIO/pull/646/ ## 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: maxion_ --- src/core/execution/TradeShipExecution.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/execution/TradeShipExecution.ts b/src/core/execution/TradeShipExecution.ts index 2ae94dca1..4df07c454 100644 --- a/src/core/execution/TradeShipExecution.ts +++ b/src/core/execution/TradeShipExecution.ts @@ -18,6 +18,7 @@ export class TradeShipExecution implements Execution { private tradeShip: Unit | undefined; private wasCaptured = false; private pathFinder: PathFinder; + private tilesTraveled = 0; constructor( private origOwner: Player, @@ -109,6 +110,7 @@ export class TradeShipExecution implements Execution { this.tradeShip.setSafeFromPirates(); } this.tradeShip.move(result.tile); + this.tilesTraveled++; break; case PathFindResultType.PathNotFound: console.warn("captured trade ship cannot find route"); @@ -123,11 +125,7 @@ export class TradeShipExecution implements Execution { private complete() { this.active = false; this.tradeShip!.delete(false); - const gold = this.mg - .config() - .tradeShipGold( - this.mg.manhattanDist(this.srcPort.tile(), this._dstPort.tile()), - ); + const gold = this.mg.config().tradeShipGold(this.tilesTraveled); if (this.wasCaptured) { this.tradeShip!.owner().addGold(gold);