mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:00:42 +00:00
## 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>
This commit is contained in:
@@ -79,7 +79,7 @@ export class WinModal extends LitElement implements Layer {
|
||||
@click=${this.hide}
|
||||
class="flex-1 px-3 py-3 text-base cursor-pointer bg-blue-500/60 text-white border-0 rounded-sm transition-all duration-200 hover:bg-blue-500/80 hover:-translate-y-px active:translate-y-px"
|
||||
>
|
||||
${this.isWin
|
||||
${this.game.myPlayer()?.isAlive()
|
||||
? translateText("win_modal.keep")
|
||||
: translateText("win_modal.spectate")}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user