From 1fce721d3e2b4c40bc44ff89332ce040b931f8b4 Mon Sep 17 00:00:00 2001 From: Daniel <101683475+Koranir@users.noreply.github.com> Date: Fri, 16 May 2025 04:52:58 +1000 Subject: [PATCH] Use trade ship travelled distance instead of Manhattan distance when calculating value (#646) ## Description: This PR makes trade ships actually use their traveled distance when calculating their monetary value, instead of the the Manhattan distance from port to port. ## Please complete the following: - [x] I have added screenshots for all UI updates - [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: Koranir --- 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 6157e2063..f327ccf9a 100644 --- a/src/core/execution/TradeShipExecution.ts +++ b/src/core/execution/TradeShipExecution.ts @@ -21,6 +21,7 @@ export class TradeShipExecution implements Execution { private tradeShip: Unit; private index = 0; private wasCaptured = false; + private tilesTraveled = 0; constructor( private _owner: PlayerID, @@ -113,6 +114,7 @@ export class TradeShipExecution implements Execution { this.tradeShip.setSafeFromPirates(); } this.tradeShip.move(result.tile); + this.tilesTraveled++; break; case PathFindResultType.PathNotFound: consolex.warn("captured trade ship cannot find route"); @@ -127,11 +129,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);