mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-09 13:36:33 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user