From 2f1fc5e9982fb0f50b14ebabf35881ac19943651 Mon Sep 17 00:00:00 2001 From: Duwibi <86431918+Duwibi@users.noreply.github.com> Date: Wed, 21 May 2025 10:52:06 +0300 Subject: [PATCH] Lobby size (#745) ## Description: This PR makes individual max lobby sizes for all of the maps. It also makes the max players on team mode multiply by 1.5 instead of the previous 2. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Nikola123 --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com> Co-authored-by: Scott Anderson --- src/core/configuration/DefaultConfig.ts | 90 +++++++++---------------- 1 file changed, 31 insertions(+), 59 deletions(-) diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 2d9a891cd..e362b8157 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -38,6 +38,33 @@ const JwksSchema = z.object({ .min(1), }); +const numPlayersConfig = { + [GameMapType.GatewayToTheAtlantic]: [80, 60, 40], + [GameMapType.SouthAmerica]: [70, 50, 40], + [GameMapType.NorthAmerica]: [80, 60, 50], + [GameMapType.Africa]: [100, 80, 50], + [GameMapType.Europe]: [80, 50, 30], + [GameMapType.Australia]: [50, 40, 30], + [GameMapType.Iceland]: [50, 40, 30], + [GameMapType.Britannia]: [50, 40, 30], + [GameMapType.Asia]: [60, 50, 30], + [GameMapType.FalklandIslands]: [80, 50, 30], + [GameMapType.Baikal]: [60, 50, 40], + [GameMapType.Mena]: [60, 50, 30], + [GameMapType.Mars]: [50, 40, 30], + [GameMapType.Oceania]: [30, 20, 10], + [GameMapType.Japan]: [50, 40, 30], + [GameMapType.FaroeIslands]: [50, 40, 30], + [GameMapType.DeglaciatedAntarctica]: [50, 40, 30], + [GameMapType.EuropeClassic]: [80, 30, 50], + [GameMapType.BetweenTwoSeas]: [40, 50, 30], + [GameMapType.BlackSea]: [40, 50, 30], + [GameMapType.Pangaea]: [40, 20, 30], + [GameMapType.World]: [150, 80, 50], + [GameMapType.KnownWorld]: [50, 40, 30], + [GameMapType.Halkidiki]: [50, 40, 30], +} as const satisfies Record; + const TERRAIN_EFFECTS = { [TerrainType.Plains]: { mag: 0.85, speed: 0.8 }, [TerrainType.Highland]: { mag: 1, speed: 1 }, @@ -117,65 +144,10 @@ export abstract class DefaultServerConfig implements ServerConfig { } 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, - GameMapType.FalklandIslands, - GameMapType.Baikal, - GameMapType.Halkidiki, - ].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)); + const [l, m, s] = numPlayersConfig[map] ?? [50, 30, 20]; + const r = Math.random(); + const base = r < 0.3 ? l : r < 0.6 ? m : s; + return mode === GameMode.Team ? Math.ceil(base * 1.5) : base; } workerIndex(gameID: GameID): number {