From 0789f0d7f8d977e5b3f240267140592ea2889f0b Mon Sep 17 00:00:00 2001 From: Adarsh Das <59739923+Saphereye@users.noreply.github.com> Date: Wed, 29 Oct 2025 05:10:30 +0530 Subject: [PATCH] Add Nations Vs Players Game Mode (#2233) ## Description: Fixes: #676 This PR adds Players Vs Nations as a game mode in the menu. For this change I have added two mutually exclusive option for this mode: 1. Match number of nations to number of players who have joined 2. Set the number of nations to a fixed value ### Screenshots: #### Options in Single player mode image image #### Options in lobby mode image #### Example gameplay (1 Human Vs 90 Nations) image ## 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: saphereye --------- Co-authored-by: Evan --- resources/lang/en.json | 5 ++ src/client/HostLobbyModal.ts | 98 ++++++++++++++++-------- src/client/SinglePlayerModal.ts | 65 +++++++++++----- src/core/Schemas.ts | 2 + src/core/configuration/ColorAllocator.ts | 4 + src/core/configuration/DefaultConfig.ts | 4 + src/core/game/Game.ts | 3 + src/core/game/GameImpl.ts | 20 ++++- src/server/MapPlaylist.ts | 4 +- tests/Colors.test.ts | 2 + 10 files changed, 154 insertions(+), 53 deletions(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index c11ce34d9..9240303c8 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -139,6 +139,7 @@ "options_title": "Options", "bots": "Bots: ", "bots_disabled": "Disabled", + "nations": "Nations: ", "disable_nations": "Disable Nations", "instant_build": "Instant build", "infinite_gold": "Infinite gold", @@ -146,6 +147,7 @@ "compact_map": "Mini Map", "max_timer": "Game length (minutes)", "disable_nukes": "Disable Nukes", + "automatic_difficulty": "Automatic Difficulty", "enables_title": "Enable Settings", "start": "Start Game" }, @@ -222,6 +224,7 @@ "teams_Duos": "Duos (teams of 2)", "teams_Trios": "Trios (teams of 3)", "teams_Quads": "Quads (teams of 4)", + "teams_hvn": "Humans Vs Nations", "teams": "{num} teams" }, "matchmaking_modal": { @@ -244,6 +247,7 @@ "options_title": "Options", "bots": "Bots: ", "bots_disabled": "Disabled", + "nations": "Nations: ", "disable_nations": "Disable Nations", "max_timer": "Game length (minutes)", "instant_build": "Instant build", @@ -252,6 +256,7 @@ "infinite_troops": "Infinite troops", "donate_troops": "Donate troops", "compact_map": "Mini Map", + "automatic_difficulty": "Automatic Difficulty", "enables_title": "Enable Settings", "player": "Player", "players": "Players", diff --git a/src/client/HostLobbyModal.ts b/src/client/HostLobbyModal.ts index a7a743ff1..4da086791 100644 --- a/src/client/HostLobbyModal.ts +++ b/src/client/HostLobbyModal.ts @@ -9,6 +9,7 @@ import { GameMapSize, GameMapType, GameMode, + HumansVsNations, Quads, Trios, UnitType, @@ -284,7 +285,18 @@ export class HostLobbyModal extends LitElement { ${translateText("host_modal.team_count")}
- ${[2, 3, 4, 5, 6, 7, Quads, Trios, Duos].map( + ${[ + 2, + 3, + 4, + 5, + 6, + 7, + Quads, + Trios, + Duos, + HumansVsNations, + ].map( (o) => html`
${typeof o === "string" - ? translateText(`public_lobby.teams_${o}`) + ? o === HumansVsNations + ? translateText("public_lobby.teams_hvn") + : translateText(`public_lobby.teams_${o}`) : translateText("public_lobby.teams", { num: o, })} @@ -313,42 +327,53 @@ export class HostLobbyModal extends LitElement { ${translateText("host_modal.options_title")}
- - -
- ${[2, 3, 4, 5, 6, 7, Quads, Trios, Duos].map( + ${[ + 2, + 3, + 4, + 5, + 6, + 7, + Quads, + Trios, + Duos, + HumansVsNations, + ].map( (o) => html`
${typeof o === "string" - ? translateText(`public_lobby.teams_${o}`) + ? o === HumansVsNations + ? translateText("public_lobby.teams_hvn") + : translateText(`public_lobby.teams_${o}`) : translateText(`public_lobby.teams`, { num: o })}
@@ -240,21 +254,29 @@ export class SinglePlayerModal extends LitElement {
- + ${!( + this.gameMode === GameMode.Team && + this.teamCount === HumansVsNations + ) + ? html` + + ` + : ""} +