From 1bac56c92cc924bad8076673239001925b2b4846 Mon Sep 17 00:00:00 2001 From: "Hanno Fleischer hanno.fleischer@unibw.de" <96438401+fletch13@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:16:46 +0200 Subject: [PATCH] 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 --- .../main/java/pp/battleship/game/server/ServerGameLogic.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Projekte/battleship/model/src/main/java/pp/battleship/game/server/ServerGameLogic.java b/Projekte/battleship/model/src/main/java/pp/battleship/game/server/ServerGameLogic.java index 6a61cfd9..41ddde08 100644 --- a/Projekte/battleship/model/src/main/java/pp/battleship/game/server/ServerGameLogic.java +++ b/Projekte/battleship/model/src/main/java/pp/battleship/game/server/ServerGameLogic.java @@ -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);