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) {
if (chosenCards.size() == maxCards) {
roboRallyWrapper.shouldHurry = false;
List<ProgrammingCard> newProgram = getChosenAndLockedCards();
//Save the program to get locked cards later
roboRallyWrapper.roboRallyGame.setProgram(newProgram);

View File

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

View File

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