Prøver å vente på at spillet er klart før det får kort

This commit is contained in:
Kristian Knarvik 2020-04-27 16:10:24 +02:00
parent ef1a5e0e46
commit ee4c15c999

View File

@ -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,6 +109,14 @@ class RoboRallyClientListener extends Listener {
* @param newHand The new hand this client can choose from
*/
private void receiveHand(ProgrammingCardDeck newHand) {
new Thread(() -> {
while (wrapper.roboRallyGame.getGameState() != GameState.WAITING_FOR_CARDS_FROM_SERVER) {
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (newHand.isEmpty()) {
wrapper.roboRallyGame.setProgram(new ArrayList<>());
if (wrapper.roboRallyGame.getRobotPowerDown()) {
@ -119,6 +128,7 @@ class RoboRallyClientListener extends Listener {
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);
}
wrapper.roboRallyGame.setPlayerHand(newHand);
}).start();
}
/**