double multiplayer game spawn time

This commit is contained in:
Evan
2024-12-06 17:23:36 -08:00
parent 26ad663374
commit 806e65d474
5 changed files with 16 additions and 12 deletions
+4 -5
View File
@@ -5,7 +5,7 @@ import { EventBus } from "../core/EventBus";
import { Config, getConfig } from "../core/configuration/Config";
import { createRenderer, GameRenderer } from "./graphics/GameRenderer";
import { InputHandler, MouseUpEvent, ZoomEvent, DragEvent, MouseDownEvent } from "./InputHandler"
import { ClientID, ClientIntentMessageSchema, ClientJoinMessageSchema, ClientLeaveMessageSchema, ClientMessageSchema, GameID, Intent, ServerMessage, ServerMessageSchema, ServerSyncMessage, Turn } from "../core/Schemas";
import { ClientID, ClientIntentMessageSchema, ClientJoinMessageSchema, ClientMessageSchema, GameID, Intent, ServerMessage, ServerMessageSchema, ServerSyncMessage, Turn } from "../core/Schemas";
import { loadTerrainMap, TerrainMapImpl } from "../core/game/TerrainMapLoader";
import { and, bfs, dist, manhattanDist } from "../core/Util";
import { WinCheckExecution } from "../core/execution/WinCheckExecution";
@@ -36,7 +36,7 @@ export function joinLobby(lobbyConfig: LobbyConfig, onjoin: () => void): () => v
const clientID = uuidv4()
const playerID = uuidv4()
const eventBus = new EventBus()
const config = getConfig()
const config = getConfig(lobbyConfig.isLocal)
const transport = new Transport(lobbyConfig.isLocal, eventBus, lobbyConfig.gameID, lobbyConfig.ip, clientID, playerID, config, lobbyConfig.playerName)
const onconnect = () => {
@@ -54,7 +54,7 @@ export function joinLobby(lobbyConfig: LobbyConfig, onjoin: () => void): () => v
gameID: lobbyConfig.gameID,
ip: lobbyConfig.ip,
}
createClientGame(gameConfig, eventBus, transport).then(r => r.start())
createClientGame(config, gameConfig, eventBus, transport).then(r => r.start())
};
}
transport.connect(onconnect, onmessage)
@@ -65,8 +65,7 @@ export function joinLobby(lobbyConfig: LobbyConfig, onjoin: () => void): () => v
}
export async function createClientGame(gameConfig: GameConfig, eventBus: EventBus, transport: Transport): Promise<GameRunner> {
const config = getConfig()
export async function createClientGame(config: Config, gameConfig: GameConfig, eventBus: EventBus, transport: Transport): Promise<GameRunner> {
const terrainMap = await loadTerrainMap(gameConfig.map)
+3 -3
View File
@@ -1,7 +1,7 @@
import { Gold, Player, PlayerID, PlayerInfo, TerraNullius, Tick, Tile, Unit, UnitInfo, UnitType } from "../game/Game";
import { Colord, colord } from "colord";
import { devConfig } from "./DevConfig";
import { defaultConfig } from "./DefaultConfig";
import { DefaultConfig } from "./DefaultConfig";
import { GameID } from "../Schemas";
export enum GameEnv {
@@ -9,14 +9,14 @@ export enum GameEnv {
Prod
}
export function getConfig(): Config {
export function getConfig(isLocal: boolean): Config {
// TODO: 'prod' not found in prod env
if (process.env.GAME_ENV == 'dev') {
console.log('Using dev config')
return devConfig
} else {
console.log('Using prod config')
return defaultConfig
return new DefaultConfig(isLocal)
}
}
+3 -3
View File
@@ -8,6 +8,8 @@ import { pastelTheme } from "./PastelTheme";
export class DefaultConfig implements Config {
constructor(private isLocal: boolean) { }
maxUnitCost(): number {
return 99_999_999
}
@@ -141,7 +143,7 @@ export class DefaultConfig implements Config {
return 500
}
numSpawnPhaseTurns(): number {
return 100
return this.isLocal ? 100 : 200
}
numBots(): number {
return 400
@@ -282,5 +284,3 @@ export class DefaultConfig implements Config {
return adjustment
}
}
export const defaultConfig = new DefaultConfig()
+5
View File
@@ -2,6 +2,11 @@ import { Player, PlayerInfo, UnitInfo, UnitType } from "../game/Game";
import { DefaultConfig } from "./DefaultConfig";
export const devConfig = new class extends DefaultConfig {
constructor() {
super(true)
}
unitInfo(type: UnitType): UnitInfo {
const info = super.unitInfo(type)
const oldCost = info.cost
+1 -1
View File
@@ -21,7 +21,7 @@ const wss = new WebSocketServer({ server });
// Serve static files from the 'out' directory
app.use(express.static(path.join(__dirname, '../../out')));
app.use(express.json())
const gm = new GameManager(getConfig())
const gm = new GameManager(getConfig(false))
// New GET endpoint to list lobbies
app.get('/lobbies', (req, res) => {