Fikser noen bugs i programmeringstimeren

This commit is contained in:
Kristian Knarvik 2020-04-30 15:35:15 +02:00
parent b02e665e86
commit 89f2a4545e
3 changed files with 7 additions and 10 deletions

View File

@ -123,6 +123,7 @@ public class CardChoiceScreen extends InteractiveScreen implements Screen {
*/ */
private void confirmCards(Boolean requestPowerDown) { private void confirmCards(Boolean requestPowerDown) {
if (chosenCards.size() == maxCards) { if (chosenCards.size() == maxCards) {
roboRallyWrapper.shouldHurry = false;
List<ProgrammingCard> newProgram = getChosenAndLockedCards(); List<ProgrammingCard> newProgram = getChosenAndLockedCards();
//Save the program to get locked cards later //Save the program to get locked cards later
roboRallyWrapper.roboRallyGame.setProgram(newProgram); roboRallyWrapper.roboRallyGame.setProgram(newProgram);

View File

@ -56,7 +56,6 @@ public class LoadingScreen extends AbstractScreen {
} }
return "Loading..."; return "Loading...";
} }
System.out.println(roboRallyWrapper.roboRallyGame.getGameState());
switch (roboRallyWrapper.roboRallyGame.getGameState()) { switch (roboRallyWrapper.roboRallyGame.getGameState()) {
case WAITING_FOR_OTHER_PLAYERS_PROGRAMS: case WAITING_FOR_OTHER_PLAYERS_PROGRAMS:
return "Waiting for other players to finish programming..."; return "Waiting for other players to finish programming...";
@ -71,7 +70,6 @@ public class LoadingScreen extends AbstractScreen {
default: default:
return "Waiting for something..."; return "Waiting for something...";
} }
} }
/** /**

View File

@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* This listener handles all sending and responses for the server * This listener handles all sending and responses for the server
@ -172,13 +171,12 @@ class RoboRallyServerListener extends Listener {
programs = new HashMap<>(); programs = new HashMap<>();
} else { } else {
List<Connection> notReceivedFrom = playersNotYetReceivedFrom(programs); List<Connection> notReceivedFrom = playersNotYetReceivedFrom(programs);
if (notReceivedFrom.size() != 1) { if (notReceivedFrom.size() == 1) {
return;
}
Connection hurryUp = notReceivedFrom.get(0); Connection hurryUp = notReceivedFrom.get(0);
hurryUp.sendTCP(new HurryResponse()); hurryUp.sendTCP(new HurryResponse());
} }
} }
}
/** /**
* Checks whether the input map contains data received by all expected connections * Checks whether the input map contains data received by all expected connections
@ -188,7 +186,7 @@ class RoboRallyServerListener extends Listener {
* @return True if information has been received by all alive players * @return True if information has been received by all alive players
*/ */
private <K> boolean receivedDataFromAllConnections(Map<Connection, K> data) { private <K> boolean receivedDataFromAllConnections(Map<Connection, K> data) {
Set<Connection> connections = clients.keySet(); List<Connection> connections = new ArrayList<>(clients.keySet());
connections.removeAll(deadPlayers); connections.removeAll(deadPlayers);
return data.keySet().containsAll(connections); return data.keySet().containsAll(connections);
} }
@ -201,10 +199,10 @@ class RoboRallyServerListener extends Listener {
* @return All active connections for which the map has no data * @return All active connections for which the map has no data
*/ */
private <K> List<Connection> playersNotYetReceivedFrom(Map<Connection, K> data) { private <K> List<Connection> playersNotYetReceivedFrom(Map<Connection, K> data) {
Set<Connection> connections = clients.keySet(); List<Connection> connections = new ArrayList<>(clients.keySet());
connections.removeAll(deadPlayers); connections.removeAll(deadPlayers);
connections.removeAll(data.keySet()); connections.removeAll(data.keySet());
return new ArrayList<>(connections); return connections;
} }
@Override @Override