mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 08:38:10 +00:00
464a4a817a
## Description: The calculation is based on: 50 players per 1_000_000 land tiles, limited at 125 players because of performance Second number is 75% of that, third one 50% That way, the player counts are staying mostly the same Look at the "Dynamic Config" column, these are the new player counts: (The 125 players limit is missing in that column, only relevant for the twolakes map) <img width="930" height="1033" alt="Screenshot_2026-01-12_152758" src="https://github.com/user-attachments/assets/e1791740-e263-47b3-8b27-4f9aa358d381" /> <img width="926" height="324" alt="Screenshot_2026-01-12_152814" src="https://github.com/user-attachments/assets/78d6789b-374f-4f8b-b50f-f6f08395572b" /> This PR also removes `MapDescription` from `Maps.ts` because its unused. And this PR updates the map-generator `README.md` to reflect the changes ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: FloPinguin
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { FetchGameMapLoader } from "src/core/game/FetchGameMapLoader";
|
|
import { GameMapType } from "src/core/game/Game";
|
|
import { GameMapLoader } from "src/core/game/GameMapLoader";
|
|
import { logger } from "./Logger";
|
|
|
|
let mapLoader: GameMapLoader | null = null;
|
|
|
|
const log = logger.child({ component: "MapLandTiles" });
|
|
|
|
// Gets or creates the map loader, uses FetchGameMapLoader pointing to the master server.
|
|
function getMapLoader(): GameMapLoader {
|
|
mapLoader ??= new FetchGameMapLoader("http://localhost:3000/maps");
|
|
return mapLoader;
|
|
}
|
|
|
|
// Gets the number of land tiles for a map
|
|
// FetchGameMapLoader already caches maps, so no need for additional caching here.
|
|
export async function getMapLandTiles(map: GameMapType): Promise<number> {
|
|
try {
|
|
const loader = getMapLoader();
|
|
const mapData = loader.getMapData(map);
|
|
const manifest = await mapData.manifest();
|
|
return manifest.map.num_land_tiles;
|
|
} catch (error) {
|
|
log.error(`Failed to load manifest for ${map}: ${error}`, { map });
|
|
return 1_000_000; // Default fallback
|
|
}
|
|
}
|