diff --git a/src/BoardDisplay.java b/src/BoardDisplay.java index ca2e327..1bb501e 100644 --- a/src/BoardDisplay.java +++ b/src/BoardDisplay.java @@ -110,11 +110,19 @@ public class BoardDisplay extends JPanel { } + /** + * Aktuelles Schiff auswaehlen + * @param ship + */ public void selectCurrentShip(Ship ship) { this.currentShip = ship; paintFields(); } + /** + * Zuruecksetzen von aktuellem Schiff und allen Schiffen des Spielers + * Danach blau faerben des Spielfeldes + */ public void resetAllShips() { //ships.clear(); this.currentShip = null; @@ -123,22 +131,6 @@ public class BoardDisplay extends JPanel { } paintFields(); } - /** - * TODO Funktion beschreiben etc. - * @param ship - * @param o - * @param horizontal - * @param player - * @return - */ - - /** - * TODO Funktion beschreiben etc. - * @param ship - * @param o - * @param horizontal - * @return - */ /** * Wechselt die Platzierungsrichtung zwischen horizontal und vertikal. @@ -179,8 +171,10 @@ public class BoardDisplay extends JPanel { } fields[i][j].setBackground(Color.BLUE); for(Point p : test) { - if(i==p.getX() && j==p.getY()) { - fields[i][j].setBackground(Color.YELLOW); + if(i==p.getX() && j==p.getY() && currentShip.checkValidPlacement(mousePosition,horizontal,player.getBoard().getShips(),gridSize)) { + fields[i][j].setBackground(Color.GREEN); + }else if(i==p.getX() && j==p.getY() && !currentShip.checkValidPlacement(mousePosition,horizontal,player.getBoard().getShips(),gridSize)) { + fields[i][j].setBackground(Color.RED); } } for(Ship ship: player.getBoard().getShips()) {