From db088422433bda0f432cfb2d9a8876bfdba44c67 Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 5 May 2025 11:23:29 -0700 Subject: [PATCH] double the player count of team games (max 150), and do 3:1 ffa:team ratio --- src/core/configuration/Config.ts | 3 +- src/core/configuration/DefaultConfig.ts | 112 +++++++++++++----------- src/server/MapPlaylist.ts | 6 +- 3 files changed, 66 insertions(+), 55 deletions(-) diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index f96b90f86..2e5d095d0 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -4,6 +4,7 @@ import { Difficulty, Game, GameMapType, + GameMode, Gold, Player, PlayerInfo, @@ -26,7 +27,7 @@ export enum GameEnv { export interface ServerConfig { turnIntervalMs(): number; gameCreationRate(): number; - lobbyMaxPlayers(map: GameMapType): number; + lobbyMaxPlayers(map: GameMapType, mode: GameMode): number; discordRedirectURI(): string; numWorkers(): number; workerIndex(gameID: GameID): number; diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 6f613a520..bb3e61f87 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -72,60 +72,66 @@ export abstract class DefaultServerConfig implements ServerConfig { gameCreationRate(): number { return 60 * 1000; } - lobbyMaxPlayers(map: GameMapType): number { - // Maps with ~4 mil pixels - if ( - [ - GameMapType.GatewayToTheAtlantic, - GameMapType.SouthAmerica, - GameMapType.NorthAmerica, - GameMapType.Africa, - GameMapType.Europe, - ].includes(map) - ) { - return Math.random() < 0.2 ? 100 : 50; - } - // Maps with ~2.5 - ~3.5 mil pixels - if ( - [ - GameMapType.Australia, - GameMapType.Iceland, - GameMapType.Britannia, - GameMapType.Asia, - ].includes(map) - ) { - return Math.random() < 0.3 ? 50 : 25; - } - // Maps with ~2 mil pixels - if ( - [ - GameMapType.Mena, - GameMapType.Mars, - GameMapType.Oceania, - GameMapType.Japan, // Japan at this level because its 2/3 water - GameMapType.FaroeIslands, - GameMapType.EuropeClassic, - ].includes(map) - ) { - return Math.random() < 0.3 ? 50 : 25; - } - // Maps smaller than ~2 mil pixels - if ( - [ - GameMapType.BetweenTwoSeas, - GameMapType.BlackSea, - GameMapType.Pangaea, - ].includes(map) - ) { - return Math.random() < 0.5 ? 30 : 15; - } - // world belongs with the ~2 mils, but these amounts never made sense so I assume the insanity is intended. - if (map == GameMapType.World) { - return Math.random() < 0.2 ? 150 : 50; - } - // default return for non specified map - return Math.random() < 0.2 ? 50 : 20; + + lobbyMaxPlayers(map: GameMapType, mode: GameMode): number { + const numPlayers = () => { + // Maps with ~4 mil pixels + if ( + [ + GameMapType.GatewayToTheAtlantic, + GameMapType.SouthAmerica, + GameMapType.NorthAmerica, + GameMapType.Africa, + GameMapType.Europe, + ].includes(map) + ) { + return Math.random() < 0.2 ? 100 : 50; + } + // Maps with ~2.5 - ~3.5 mil pixels + if ( + [ + GameMapType.Australia, + GameMapType.Iceland, + GameMapType.Britannia, + GameMapType.Asia, + ].includes(map) + ) { + return Math.random() < 0.3 ? 50 : 25; + } + // Maps with ~2 mil pixels + if ( + [ + GameMapType.Mena, + GameMapType.Mars, + GameMapType.Oceania, + GameMapType.Japan, // Japan at this level because its 2/3 water + GameMapType.FaroeIslands, + GameMapType.DeglaciatedAntarctica, + GameMapType.EuropeClassic, + ].includes(map) + ) { + return Math.random() < 0.3 ? 50 : 25; + } + // Maps smaller than ~2 mil pixels + if ( + [ + GameMapType.BetweenTwoSeas, + GameMapType.BlackSea, + GameMapType.Pangaea, + ].includes(map) + ) { + return Math.random() < 0.5 ? 30 : 15; + } + // world belongs with the ~2 mils, but these amounts never made sense so I assume the insanity is intended. + if (map == GameMapType.World) { + return Math.random() < 0.2 ? 150 : 50; + } + // default return for non specified map + return Math.random() < 0.2 ? 50 : 20; + }; + return Math.min(150, numPlayers() * (mode == GameMode.Team ? 2 : 1)); } + workerIndex(gameID: GameID): number { return simpleHash(gameID) % this.numWorkers(); } diff --git a/src/server/MapPlaylist.ts b/src/server/MapPlaylist.ts index ef742d827..5418d9be0 100644 --- a/src/server/MapPlaylist.ts +++ b/src/server/MapPlaylist.ts @@ -48,7 +48,7 @@ export class MapPlaylist { // Create the default public game config (from your GameManager) return { gameMap: map, - maxPlayers: config.lobbyMaxPlayers(map), + maxPlayers: config.lobbyMaxPlayers(map, mode), gameType: GameType.Public, difficulty: Difficulty.Medium, infiniteGold: false, @@ -89,6 +89,7 @@ export class MapPlaylist { const ffa1: GameMapType[] = rand.shuffleArray([...maps]); const ffa2: GameMapType[] = rand.shuffleArray([...maps]); + const ffa3: GameMapType[] = rand.shuffleArray([...maps]); const team: GameMapType[] = rand.shuffleArray([...maps]); this.mapsPlaylist = []; @@ -99,6 +100,9 @@ export class MapPlaylist { if (!this.addNextMap(this.mapsPlaylist, ffa2, GameMode.FFA)) { return false; } + if (!this.addNextMap(this.mapsPlaylist, ffa3, GameMode.FFA)) { + return false; + } if (!this.addNextMap(this.mapsPlaylist, team, GameMode.Team)) { return false; }