Avslutter spillet om spilleren blir kastet ut

This commit is contained in:
Kristian Knarvik 2020-04-22 12:46:51 +02:00
parent 509759fdd1
commit 2c5a0e8acb

View File

@ -29,6 +29,11 @@ class RoboRallyClientListener extends Listener {
this.wrapper = wrapper; this.wrapper = wrapper;
} }
@Override
public void disconnected(Connection connection) {
this.wrapper.quit("The server closed the connection.");
}
@Override @Override
public void received(Connection connection, Object object) { public void received(Connection connection, Object object) {
if (object instanceof ErrorResponse) { if (object instanceof ErrorResponse) {
@ -42,16 +47,16 @@ class RoboRallyClientListener extends Listener {
wrapper.roboRallyGame = new RoboRallyGame(info.getPlayerList(), info.getBoardName(), wrapper.roboRallyGame = new RoboRallyGame(info.getPlayerList(), info.getBoardName(),
wrapper.server != null, info.getPlayerName(), wrapper.server); wrapper.server != null, info.getPlayerName(), wrapper.server);
} else if (object instanceof ProgrammingCardDeck) { } else if (object instanceof ProgrammingCardDeck) {
if(((ProgrammingCardDeck) object).isEmpty()){ if (((ProgrammingCardDeck) object).isEmpty()) {
wrapper.roboRallyGame.setProgram(new ArrayList<>()); wrapper.roboRallyGame.setProgram(new ArrayList<>());
if (wrapper.roboRallyGame.getRobotPowerdown()){ if (wrapper.roboRallyGame.getRobotPowerdown()) {
wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN); wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
} } else {
else {
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN); wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
} }
} else {
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);
} }
else {wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);}
new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start(); new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start();
} else if (object instanceof ProgamsContainer) { } else if (object instanceof ProgamsContainer) {
new Thread(() -> { new Thread(() -> {