mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 05:13:48 +00:00
ab3f4fbac1
## Description: The server stores all players that have joined, and once the game starts it sends a list of players to all clients. Players cannot join after the game has started. Server now generated the PlayerID instead of the client. The is necessary for team mode, we need to know how who is playing the game before it starts so we can properly assign teams based on clans. ## 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: evan
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { generateMap } from "../../src/scripts/TerrainMapGenerator";
|
|
import fs from "fs/promises";
|
|
import path from "path";
|
|
import { createGame } from "../../src/core/game/GameImpl";
|
|
import { genTerrainFromBin } from "../../src/core/game/TerrainMapLoader";
|
|
import { TestConfig } from "./TestConfig";
|
|
import { TestServerConfig } from "./TestServerConfig";
|
|
import { UserSettings } from "../../src/core/game/UserSettings";
|
|
import { Difficulty, GameType } from "../../src/core/game/Game";
|
|
import { GameConfig } from "../../src/core/Schemas";
|
|
|
|
export async function setup(mapName: string, _gameConfig: GameConfig = {}) {
|
|
// Load the specified map
|
|
const mapPath = path.join(__dirname, "..", "testdata", `${mapName}.png`);
|
|
const imageBuffer = await fs.readFile(mapPath);
|
|
const { map, miniMap } = await generateMap(imageBuffer, false);
|
|
const gameMap = await genTerrainFromBin(String.fromCharCode.apply(null, map));
|
|
const miniGameMap = await genTerrainFromBin(
|
|
String.fromCharCode.apply(null, miniMap),
|
|
);
|
|
const nationMap = { nations: [] };
|
|
|
|
// Configure the game
|
|
const serverConfig = new TestServerConfig();
|
|
const gameConfig = {
|
|
gameMap: null,
|
|
gameType: GameType.Singleplayer,
|
|
difficulty: Difficulty.Medium,
|
|
disableNPCs: false,
|
|
bots: 0,
|
|
infiniteGold: false,
|
|
infiniteTroops: false,
|
|
instantBuild: false,
|
|
..._gameConfig,
|
|
};
|
|
const config = new TestConfig(serverConfig, gameConfig, new UserSettings());
|
|
|
|
// Create and return the game
|
|
return createGame([], gameMap, miniGameMap, nationMap, config); // TODO: !!!
|
|
}
|