mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Prøver å vente på at spillet er klart før det får kort
This commit is contained in:
parent
ef1a5e0e46
commit
ee4c15c999
@ -13,6 +13,7 @@ import inf112.fiasko.roborally.objects.ProgrammingCardDeck;
|
|||||||
import inf112.fiasko.roborally.objects.RoboRallyGame;
|
import inf112.fiasko.roborally.objects.RoboRallyGame;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This listener handles all receiving from the server
|
* 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
|
* @param newHand The new hand this client can choose from
|
||||||
*/
|
*/
|
||||||
private void receiveHand(ProgrammingCardDeck newHand) {
|
private void receiveHand(ProgrammingCardDeck newHand) {
|
||||||
if (newHand.isEmpty()) {
|
new Thread(() -> {
|
||||||
wrapper.roboRallyGame.setProgram(new ArrayList<>());
|
while (wrapper.roboRallyGame.getGameState() != GameState.WAITING_FOR_CARDS_FROM_SERVER) {
|
||||||
if (wrapper.roboRallyGame.getRobotPowerDown()) {
|
try {
|
||||||
wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
} else {
|
} catch (InterruptedException e) {
|
||||||
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (newHand.isEmpty()) {
|
||||||
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);
|
wrapper.roboRallyGame.setProgram(new ArrayList<>());
|
||||||
}
|
if (wrapper.roboRallyGame.getRobotPowerDown()) {
|
||||||
wrapper.roboRallyGame.setPlayerHand(newHand);
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user