From a25b429e1e2e6734fae7dfe0f59a700e46b37662 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Mon, 7 Jun 2021 02:08:52 +0200 Subject: [PATCH] fix: fixed bug where selectionComplete is always false --- .../server/lobbymanager/LobbyConnection.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java index e3ce86c..2976ac7 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java @@ -256,17 +256,13 @@ public class LobbyConnection implements Runnable { selectionPossibilities.item1, message.characters); Logger.info("Player 1 has selected their characters"); - Logger.trace("Sending selection confirmation message to Player1"); - Logger.trace("Sending confirmSelectionMessage to player1"); var replyMessage = new ConfirmSelectionMessage(); - replyMessage.selectionComplete = !characterSelectionActive; + replyMessage.selectionComplete = !characterSelectionInProgress(); sendMessage(origin, replyMessage); } else { Logger.debug("Player 1 tried to select characters twice, sending error"); - sendError(origin, - "Cannot select characters as characters were already selected" - ); + sendError(origin, "Cannot select characters as characters were already selected"); } } case PlayerTwo -> { @@ -278,7 +274,7 @@ public class LobbyConnection implements Runnable { Logger.trace("Sending confirmSelectionMessage to player2"); var replyMessage = new ConfirmSelectionMessage(); - replyMessage.selectionComplete = !characterSelectionActive; + replyMessage.selectionComplete = !characterSelectionInProgress(); sendMessage(origin, replyMessage); } else { Logger.debug("Player 2 tried to select characters twice, sending error"); @@ -297,6 +293,11 @@ public class LobbyConnection implements Runnable { "the CharacterSelectionPhase, sending error", origin.name); sendError(origin, "The character selection phase is already over"); } + return characterSelectionInProgress(); + } + + /** Returns whether the character selection is not yet done */ + private boolean characterSelectionInProgress() { return (playerOneSelection == null || playerTwoSelection == null) && characterSelectionActive; }