Record player stats during the game (#784)

## Description:

Record player stats for the analytics worker to import in to to
postgres. This changes defines a new Analytics schema version, `v0.0.2`,
containing additional metadata about each player.

## 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
This commit is contained in:
Scott Anderson
2025-05-21 00:10:29 -04:00
committed by GitHub
parent 228f5b13af
commit 5aa8356513
27 changed files with 581 additions and 161 deletions
+13 -1
View File
@@ -53,6 +53,9 @@ export class TradeShipExecution implements Execution {
dstPort: this._dstPort,
lastSetSafeFromPirates: ticks,
});
// Record stats
this.mg.stats().boatSendTrade(this.origOwner, this._dstPort.owner());
}
if (!this.tradeShip.isActive()) {
@@ -153,12 +156,16 @@ export class TradeShipExecution implements Execution {
const gold = this.mg.config().tradeShipGold(this.tilesTraveled);
if (this.wasCaptured) {
this.tradeShip.owner().addGold(gold);
const player = this.tradeShip.owner();
player.addGold(gold);
this.mg.displayMessage(
`Received ${renderNumber(gold)} gold from ship captured from ${this.origOwner.displayName()}`,
MessageType.SUCCESS,
this.tradeShip.owner().id(),
);
// Record stats
this.mg.stats().boatCapturedTrade(player, this.origOwner, gold);
} else {
this.srcPort.owner().addGold(gold);
this._dstPort.owner().addGold(gold);
@@ -172,6 +179,11 @@ export class TradeShipExecution implements Execution {
MessageType.SUCCESS,
this.srcPort.owner().id(),
);
// Record stats
this.mg
.stats()
.boatArriveTrade(this.srcPort.owner(), this._dstPort.owner(), gold);
}
return;
}