endre til objktet Boolean

This commit is contained in:
Tobydrama 2020-04-20 18:05:24 +02:00
parent 48384686fb
commit ea72a6848a
4 changed files with 24 additions and 13 deletions

View File

@ -71,7 +71,7 @@ public class PowerDownScreen extends AbstractScreen {
stage.draw();
if (elapsedTime > 10) {
sendPowerDownStatus(false);
sendPowerDownStatus(Boolean.FALSE);
}
}

View File

@ -24,8 +24,8 @@ public class RoboRallyClient {
client.start();
NetworkUtil.registerClasses(client.getKryo());
client.connect(5000, ipAddress, 54555, 54777);
client.addListener(new RoboRallyClientListener(wrapper));
}
/**
@ -35,6 +35,9 @@ public class RoboRallyClient {
*/
public void sendElement(Object object) {
try {
if(!client.isConnected()){
client.reconnect();
}
client.sendTCP(object);
} catch (Exception e) {
e.printStackTrace();

View File

@ -41,15 +41,17 @@ class RoboRallyClientListener extends Listener {
wrapper.server != null, info.getPlayerName(), wrapper.server);
} else if (object instanceof ProgrammingCardDeck) {
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);
wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object);
new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start();
} else if (object instanceof ProgamsContainer) {
new Thread(() -> {
try {
wrapper.roboRallyGame.receiveAllPrograms((ProgamsContainer) object);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
} else if (object instanceof PowerDownContainer) {
wrapper.roboRallyGame.receiveStayInPowerDown((PowerDownContainer) object);
new Thread(() -> wrapper.roboRallyGame.receiveStayInPowerDown((PowerDownContainer) object)).start();
}
}

View File

@ -6,8 +6,14 @@ import java.util.Map;
* This class is used to contain power down status for all players
*/
public class PowerDownContainer {
private final Map<String, Boolean> powerDown;
private Map<String, Boolean> powerDown;
/**
* IMPORTANT!!!
* DO NOT USE!
* Kryonet demands a no args constructor or else it throws a exception
*/
public PowerDownContainer(){}
/**
* Instantiates a new power down container
*