mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 13:52:45 +00:00
920ae190fd
## Description: This PR resolves issue #3058 where the "win modal" incorrectly displayed a **"Keep Playing"** button instead of **"Spectate"** when a player's team won but the player themselves was already dead. ### The Problem In WinModal.ts, the button text logic only checked `this.isWin` (whether the team won) but didn't verify if the player was still alive. This caused dead players on winning teams to see "Keep Playing" instead of "Spectate". ### The Solution Updated the button rendering logic in `src/client/graphics/layers/WinModal.ts:82` to check both the win condition AND the player's alive status: ```typescript // Before ${this.isWin ? translateText("win_modal.keep") : translateText("win_modal.spectate")} // After ${this.isWin && this.game.myPlayer()?.isAlive() ? translateText("win_modal.keep") : translateText("win_modal.spectate")} ``` This approach maintains clean separation of concerns: - this.isWin continues to represent whether the player's team won (true/false) - The button text logic now checks both team victory and player alive status - This ensures the correct button appears based on the player's actual state Behavior After Fix - Alive players on the winning team → "Keep Playing" - Dead players on the winning team → "Spectate" - Any player on the losing team → "Spectate" Testing Performed 1. Code Audit: Verified myPlayer().isAlive() correctly reflects the eliminated state in Teams mode. 2. Build Verification: Ran npm run build and npm run build-prod to ensure no regressions in the UI layer. 3. Type Safety: Ran tsc --noEmit to confirm the fix is fully compliant with the project's TypeScript strictness. --- Closes #3058 ## 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: ghadi8097 --------- Co-authored-by: iamlewis <lewismmmm@gmail.com>