From 1ecd6c4ee1fb0bb632aa2a73921aceaa96d08c68 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Tue, 12 Aug 2025 11:47:45 +1000 Subject: [PATCH] Private lobby toggle donation (#1752) Resolve #1652 1. Add the ability to toggle **gold donations** and **troop donations** for private lobbies ~2. Add relevant translations.~ 3. Refactor `canDonate` to be specific to gold and troop donations 4. Add placeholders for singleplayer mode if this is to be extended to support that too. 5. Add Tests for Donate logic image _Private Lobby_ ![donatetroopsprivatelobby](https://github.com/user-attachments/assets/c6690bbc-958e-48a1-9cf1-e2b361dfb1b2) _Testing Troop Send In Private Lobby_ ![donatetroopsprivatelobby2](https://github.com/user-attachments/assets/698c7603-6b4b-4da7-91ab-7bdc38bb49a5) _Troop Send Complete In Private Lobby_ ![testtradepublicteams](https://github.com/user-attachments/assets/1010332c-3f38-4644-9218-46aa7141f578) Confirming that public teams still works - [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 - [X] I have read and accepted the CLA agreement (only required once). regression is found: DISCORD_USERNAME: cool_clarky --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com> Co-authored-by: Drills Kibo <59177241+drillskibo@users.noreply.github.com> --- resources/lang/en.json | 4 + src/client/HostLobbyModal.ts | 46 ++++ src/client/SinglePlayerModal.ts | 4 + src/client/graphics/layers/PlayerPanel.ts | 7 +- .../graphics/layers/RadialMenuElements.ts | 4 +- src/core/GameRunner.ts | 3 +- src/core/Schemas.ts | 2 + src/core/configuration/Config.ts | 2 + src/core/configuration/DefaultConfig.ts | 7 + src/core/execution/DonateGoldExecution.ts | 2 +- src/core/execution/DonateTroopExecution.ts | 2 +- src/core/game/Game.ts | 6 +- src/core/game/PlayerImpl.ts | 32 ++- src/server/GameManager.ts | 2 + src/server/GameServer.ts | 6 + src/server/MapPlaylist.ts | 2 + tests/Donate.test.ts | 252 ++++++++++++++++++ .../graphics/RadialMenuElements.test.ts | 3 +- tests/util/Setup.ts | 2 + 19 files changed, 376 insertions(+), 12 deletions(-) create mode 100644 tests/Donate.test.ts diff --git a/resources/lang/en.json b/resources/lang/en.json index 178783d1d..afe8d1d2f 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -130,7 +130,9 @@ "disable_nations": "Disable Nations", "instant_build": "Instant build", "infinite_gold": "Infinite gold", + "donate_gold": "Donate gold", "infinite_troops": "Infinite troops", + "donate_troops": "Donate troops", "disable_nukes": "Disable Nukes", "enables_title": "Enable Settings", "start": "Start Game" @@ -222,7 +224,9 @@ "disable_nations": "Disable Nations", "instant_build": "Instant build", "infinite_gold": "Infinite gold", + "donate_gold": "Donate gold", "infinite_troops": "Infinite troops", + "donate_troops": "Donate troops", "enables_title": "Enable Settings", "player": "Player", "players": "Players", diff --git a/src/client/HostLobbyModal.ts b/src/client/HostLobbyModal.ts index 8b5e256e3..ab805c62e 100644 --- a/src/client/HostLobbyModal.ts +++ b/src/client/HostLobbyModal.ts @@ -41,7 +41,9 @@ export class HostLobbyModal extends LitElement { @state() private teamCount: TeamCountConfig = 2; @state() private bots: number = 400; @state() private infiniteGold: boolean = false; + @state() private donateGold: boolean = false; @state() private infiniteTroops: boolean = false; + @state() private donateTroops: boolean = false; @state() private instantBuild: boolean = false; @state() private lobbyId = ""; @state() private copySuccess = false; @@ -362,6 +364,38 @@ export class HostLobbyModal extends LitElement { + + + +