From d3c4cd6620637d76637bf6d9564a2839dc1336f4 Mon Sep 17 00:00:00 2001 From: DevelopingTom Date: Fri, 7 Nov 2025 00:38:15 +0100 Subject: [PATCH] Record missing stats (#2407) ## Description: Some stats are missing from the recorded game stats: - Unit upgrade - Gold from trade and from steal The gold from trade/steal was introduced with [PR 784](https://github.com/openfrontio/OpenFrontIO/pull/784) but was quickly reverted with [PR 927](https://github.com/openfrontio/OpenFrontIO/pull/927), probably involuntarily. ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: IngloriousTom --- src/core/execution/TradeShipExecution.ts | 8 ++++++++ tests/core/executions/TradeShipExecution.test.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/core/execution/TradeShipExecution.ts b/src/core/execution/TradeShipExecution.ts index 482fb47de..0da513b8e 100644 --- a/src/core/execution/TradeShipExecution.ts +++ b/src/core/execution/TradeShipExecution.ts @@ -148,6 +148,10 @@ export class TradeShipExecution implements Execution { this.tradeShip!.owner().id(), gold, ); + // Record stats + this.mg + .stats() + .boatCapturedTrade(this.tradeShip!.owner(), this.origOwner, gold); } else { this.srcPort.owner().addGold(gold); this._dstPort.owner().addGold(gold, this._dstPort.tile()); @@ -163,6 +167,10 @@ export class TradeShipExecution implements Execution { this.srcPort.owner().id(), gold, ); + // Record stats + this.mg + .stats() + .boatArriveTrade(this.srcPort.owner(), this._dstPort.owner(), gold); } return; } diff --git a/tests/core/executions/TradeShipExecution.test.ts b/tests/core/executions/TradeShipExecution.test.ts index 0aab3fbce..f1f367453 100644 --- a/tests/core/executions/TradeShipExecution.test.ts +++ b/tests/core/executions/TradeShipExecution.test.ts @@ -29,6 +29,7 @@ describe("TradeShipExecution", () => { units: jest.fn(() => [dstPort]), unitCount: jest.fn(() => 1), id: jest.fn(() => 1), + clientID: jest.fn(() => 1), canTrade: jest.fn(() => true), } as any; @@ -38,6 +39,7 @@ describe("TradeShipExecution", () => { displayName: jest.fn(() => "Destination"), units: jest.fn(() => [dstPort]), unitCount: jest.fn(() => 1), + clientID: jest.fn(() => 2), canTrade: jest.fn(() => true), } as any;