mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-11-04 11:43:44 +01:00 
			
		
		
		
	Fikser noen bugs i programmeringstimeren
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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...";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user