feat: remove LocalPersistantStats so we locally save GameRecords

GameRecords also now include PlayerStats
This commit is contained in:
ilan schemoul
2025-03-08 17:30:08 +01:00
parent 2b8cc2cf28
commit 1b76c46bc5
15 changed files with 157 additions and 123 deletions
+5
View File
@@ -1,6 +1,7 @@
import { RateLimiterMemory } from "rate-limiter-flexible";
import WebSocket from "ws";
import {
AllPlayersStats,
ClientID,
ClientMessage,
ClientMessageSchema,
@@ -45,6 +46,8 @@ export class GameServer {
private lastPingUpdate = 0;
private winner: ClientID | null = null;
// This field is currently only filled at victory
private allPlayersStats: AllPlayersStats = {};
constructor(
public readonly id: string,
@@ -162,6 +165,7 @@ export class GameServer {
}
if (clientMsg.type == "winner") {
this.winner = clientMsg.winner;
this.allPlayersStats = clientMsg.allPlayersStats;
}
} catch (error) {
console.log(
@@ -298,6 +302,7 @@ export class GameServer {
this._startTime,
Date.now(),
this.winner,
this.allPlayersStats,
),
);
} else {