mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-15 20:07:42 +00:00
have client send winner to server
This commit is contained in:
@@ -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 => ({
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user