have client send winner to server

This commit is contained in:
Evan
2025-02-01 12:05:11 -08:00
parent d053a82ff6
commit a5a2f46099
8 changed files with 58 additions and 10 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ async function archiveToBigQuery(gameRecord: GameRecord) {
duration_seconds: gameRecord.durationSeconds,
number_turns: gameRecord.num_turns,
game_mode: gameRecord.gameConfig.gameType,
winner: null,
winner: gameRecord.winner,
difficulty: gameRecord.gameConfig.difficulty,
map: gameRecord.gameConfig.gameMap,
players: gameRecord.players.map(p => ({
+7 -2
View File
@@ -5,7 +5,6 @@ import WebSocket from 'ws';
import { slog } from "./StructuredLog";
import { CreateGameRecord } from "../core/Util";
import { archive } from "./Archive";
import { arc } from "d3";
export enum GamePhase {
@@ -31,6 +30,8 @@ export class GameServer {
private lastPingUpdate = 0
private winner: ClientID | null = null
constructor(
public readonly id: string,
public readonly createdAt: number,
@@ -89,6 +90,9 @@ export class GameServer {
this.lastPingUpdate = Date.now()
client.lastPing = Date.now()
}
if (clientMsg.type == "winner") {
this.winner = clientMsg.winner
}
} catch (error) {
console.log(`error handline websocket request in game server: ${error}`)
}
@@ -190,7 +194,8 @@ export class GameServer {
playerRecords,
this.turns,
this._startTime,
Date.now()
Date.now(),
this.winner
)
)
} else {