Fix endgame role mask bug on 5th policy liberal victory#199
Open
AnyaJain wants to merge 1 commit into
Open
Conversation
Owner
|
Thanks for your patience and for the contribution! Going to take a look at this when I have time but the changes overall look clean and simple :) Just a fair warning, it may take a while before these changes are live-- I'm having some fun and exciting new bugs on the development branch that I haven't had the motivation to chase down yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #164
Fixes #157 I think
On a 5-policy Liberal victory, the game-over screen hides the true roles of all other players (rendering them blank or defaulting them to Fascist identities). This happens due to a race condition where the game instance state is completely nullified mid-flight inside
Lobby.javabefore all players' outbound WebSocket frames finish serialization, combined with a state-machine issue where policy placement logic overwrites the victory status with a standard gameplay phase before the final broadcast evaluation.Solution
SecretHitlerGame.onEnactPolicy()to runcheckIfGameOver()and return early if a victory condition is met, preventing the victory state from being immediately overwritten by subsequent gameplay cycles.Lobby.updateAllUsers()to move the game session deletion block (game = null) to the absolute bottom of the method. This ensures every connected user's WebSocket connection finishes broadcasting unmasked identities before the state memory is torn down.Type of change
Change summary:
Steps to Verify:
docker-compose up --build.LIBERAL_POLICIES_TO_WIN = 1in your game rules configuration to test the victory end-screen state instantly.Keyfiles:
backend/src/main/java/game/SecretHitlerGame.javabackend/src/main/java/server/util/Lobby.java