This commit is contained in:
evanpelle
2025-03-27 20:43:56 -07:00
committed by GitHub
parent 9ed1fe865c
commit d8fe41de7a
37 changed files with 767 additions and 387 deletions
+2 -1
View File
@@ -2,7 +2,7 @@ import { ServerConfig } from "../core/configuration/Config";
import { GameConfig, GameID } from "../core/Schemas";
import { Client } from "./Client";
import { GamePhase, GameServer } from "./GameServer";
import { Difficulty, GameMapType, GameType } from "../core/game/Game";
import { Difficulty, GameMapType, GameMode, GameType } from "../core/game/Game";
import { Logger } from "winston";
export class GameManager {
@@ -38,6 +38,7 @@ export class GameManager {
infiniteGold: false,
infiniteTroops: false,
instantBuild: false,
gameMode: GameMode.FFA,
bots: 400,
...gameConfig,
});
+8 -3
View File
@@ -5,6 +5,7 @@ import {
ClientID,
ClientMessage,
ClientMessageSchema,
ClientSendWinnerMessage,
GameConfig,
GameInfo,
Intent,
@@ -45,7 +46,7 @@ export class GameServer {
private lastPingUpdate = 0;
private winner: ClientID | null = null;
private winner: ClientSendWinnerMessage = null;
// This field is currently only filled at victory
private allPlayersStats: AllPlayersStats = {};
@@ -86,6 +87,9 @@ export class GameServer {
if (gameConfig.instantBuild != null) {
this.gameConfig.instantBuild = gameConfig.instantBuild;
}
if (gameConfig.gameMode != null) {
this.gameConfig.gameMode = gameConfig.gameMode;
}
}
public addClient(client: Client, lastTurn: number) {
@@ -171,7 +175,7 @@ export class GameServer {
client.hashes.set(clientMsg.turnNumber, clientMsg.hash);
}
if (clientMsg.type == "winner") {
this.winner = clientMsg.winner;
this.winner = clientMsg;
this.allPlayersStats = clientMsg.allPlayersStats;
}
} catch (error) {
@@ -318,7 +322,8 @@ export class GameServer {
this.turns,
this._startTime,
Date.now(),
this.winner,
this.winner.winner,
this.winner.winnerType,
this.allPlayersStats,
),
);
+1
View File
@@ -165,6 +165,7 @@ export function startWorker() {
bots: req.body.bots,
disableNPCs: req.body.disableNPCs,
disableNukes: req.body.disableNukes,
gameMode: req.body.gameMode,
});
res.status(200).json({ success: true });
}),