mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-18 02:49:26 +00:00
Create ranked type enum, last person not afk wins in 1v1 (#2892)
## Description: * Add RankedType enum, for now it's just 1v1 * Add new method to MapPlaylist to create 1v1 game config * Update WinCheck so the last player is declared a winner on 1v1. ## 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: evan
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
HumansVsNations,
|
||||
PublicGameModifiers,
|
||||
Quads,
|
||||
RankedType,
|
||||
Trios,
|
||||
} from "../core/game/Game";
|
||||
import { PseudoRandom } from "../core/PseudoRandom";
|
||||
@@ -140,6 +141,40 @@ export class MapPlaylist {
|
||||
} satisfies GameConfig;
|
||||
}
|
||||
|
||||
public get1v1Config(): GameConfig {
|
||||
const ffaMaps = [
|
||||
GameMapType.Iceland,
|
||||
GameMapType.World,
|
||||
GameMapType.EuropeClassic,
|
||||
GameMapType.Australia,
|
||||
GameMapType.FaroeIslands,
|
||||
GameMapType.Pangaea,
|
||||
GameMapType.Italia,
|
||||
GameMapType.FalklandIslands,
|
||||
GameMapType.Sierpinski,
|
||||
];
|
||||
return {
|
||||
donateGold: false,
|
||||
donateTroops: false,
|
||||
gameMap: ffaMaps[Math.floor(Math.random() * ffaMaps.length)],
|
||||
maxPlayers: 2,
|
||||
gameType: GameType.Public,
|
||||
gameMapSize: GameMapSize.Compact,
|
||||
difficulty: Difficulty.Easy,
|
||||
rankedType: RankedType.OneVOne,
|
||||
infiniteGold: false,
|
||||
infiniteTroops: false,
|
||||
maxTimerValue: 10, // 10 minutes
|
||||
instantBuild: false,
|
||||
randomSpawn: false,
|
||||
disableNations: false,
|
||||
gameMode: GameMode.FFA,
|
||||
bots: 100,
|
||||
spawnImmunityDuration: 5 * 10,
|
||||
disabledUnits: [],
|
||||
} satisfies GameConfig;
|
||||
}
|
||||
|
||||
private getNextMap(): MapWithMode {
|
||||
if (this.mapsPlaylist.length === 0) {
|
||||
const numAttempts = 10000;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { fileURLToPath } from "url";
|
||||
import { WebSocket, WebSocketServer } from "ws";
|
||||
import { z } from "zod";
|
||||
import { getServerConfigFromServer } from "../core/configuration/ConfigLoader";
|
||||
import { GameMapSize, GameType } from "../core/game/Game";
|
||||
import { GameType } from "../core/game/Game";
|
||||
import {
|
||||
ClientMessageSchema,
|
||||
GameID,
|
||||
@@ -522,8 +522,7 @@ async function pollLobby(gm: GameManager) {
|
||||
log.info(`Lobby poll successful:`, data);
|
||||
|
||||
if (data.assignment) {
|
||||
const gameConfig = await playlist.gameConfig();
|
||||
gameConfig.gameMapSize = GameMapSize.Compact;
|
||||
const gameConfig = playlist.get1v1Config();
|
||||
const game = gm.createGame(gameId, gameConfig);
|
||||
setTimeout(() => {
|
||||
// Wait a few seconds to allow clients to connect.
|
||||
|
||||
Reference in New Issue
Block a user