From ee4c15c999830ae7d03985bbc47b9c6ae1343c34 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 27 Apr 2020 16:10:24 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=B8ver=20=C3=A5=20vente=20p=C3=A5=20at=20s?= =?UTF-8?q?pillet=20er=20klart=20f=C3=B8r=20det=20f=C3=A5r=20kort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../networking/RoboRallyClientListener.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/networking/RoboRallyClientListener.java b/src/main/java/inf112/fiasko/roborally/networking/RoboRallyClientListener.java index faa60d4..2695dcd 100644 --- a/src/main/java/inf112/fiasko/roborally/networking/RoboRallyClientListener.java +++ b/src/main/java/inf112/fiasko/roborally/networking/RoboRallyClientListener.java @@ -13,6 +13,7 @@ import inf112.fiasko.roborally.objects.ProgrammingCardDeck; import inf112.fiasko.roborally.objects.RoboRallyGame; import java.util.ArrayList; +import java.util.concurrent.TimeUnit; /** * This listener handles all receiving from the server @@ -108,17 +109,26 @@ class RoboRallyClientListener extends Listener { * @param newHand The new hand this client can choose from */ private void receiveHand(ProgrammingCardDeck newHand) { - if (newHand.isEmpty()) { - wrapper.roboRallyGame.setProgram(new ArrayList<>()); - if (wrapper.roboRallyGame.getRobotPowerDown()) { - wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN); - } else { - wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN); + new Thread(() -> { + while (wrapper.roboRallyGame.getGameState() != GameState.WAITING_FOR_CARDS_FROM_SERVER) { + try { + TimeUnit.MILLISECONDS.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } } - } else { - wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS); - } - wrapper.roboRallyGame.setPlayerHand(newHand); + if (newHand.isEmpty()) { + wrapper.roboRallyGame.setProgram(new ArrayList<>()); + if (wrapper.roboRallyGame.getRobotPowerDown()) { + wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN); + } else { + wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN); + } + } else { + wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS); + } + wrapper.roboRallyGame.setPlayerHand(newHand); + }).start(); } /**