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 06e6f724..dd8f578d 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 @@ -153,14 +153,25 @@ public void received(MapMessage msg, int from) { } } + /** + * Validates the placement of battleships on the map. + * + * Ensures that: + * + * + * @param ships the list of {@link Battleship} objects to validate + * @return {@code true} if all ships are placed correctly; {@code false} otherwise + */ private boolean checkMap(List ships){ - //Anzahl int numShips = config.getShipNums().values().stream().mapToInt(Integer::intValue).sum(); if (numShips != ships.size()) return false; List occupied = new ArrayList<>(); - //Every Ship Position Is in Map Height/Width - //Überlappen + for (Battleship battleship: ships){ int x = battleship.getX(); int y = battleship.getY();