adjusted the server Mapcheck
inverted the else if statement in ServerGameLogic.java received() so that if the map check returns that the map is correct the programm continues on instead of throwing an error message and removed the hard limit of an 10x10 map in the checkMap() Method
This commit is contained in:
		
						parent
						
							4dcd53a660
						
					
				
				
					commit
					1bac56c92c
				
			@@ -146,7 +146,7 @@ public Player addPlayer(int id) {
 | 
			
		||||
    public void received(MapMessage msg, int from) {
 | 
			
		||||
        if (state != ServerState.SET_UP)
 | 
			
		||||
            LOGGER.log(Level.ERROR, "playerReady not allowed in {0}", state); //NON-NLS
 | 
			
		||||
        else if (checkMap(msg, from))
 | 
			
		||||
        else if (!checkMap(msg, from))
 | 
			
		||||
            LOGGER.log(Level.ERROR, "player submitted not allowed Map");
 | 
			
		||||
        else
 | 
			
		||||
            playerReady(getPlayerById(from), msg.getShips());
 | 
			
		||||
@@ -163,9 +163,6 @@ private boolean checkMap(MapMessage msg, int from) {
 | 
			
		||||
        int mapWidth = getPlayerById(from).getMap().getWidth();
 | 
			
		||||
        int mapHeight = getPlayerById(from).getMap().getHeight();
 | 
			
		||||
 | 
			
		||||
        if (mapHeight != 10 || mapWidth != 10)
 | 
			
		||||
            return false;
 | 
			
		||||
 | 
			
		||||
        // check if ship is out of bounds
 | 
			
		||||
        for (int i = 0; i < msg.getShips().size(); i++){
 | 
			
		||||
            Battleship battleship = msg.getShips().get(i);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user