lucasjoshua #16

Merged
lgc merged 8 commits from lucasjoshua into main 2024-12-15 15:02:32 +00:00
1 changed files with 12 additions and 18 deletions
Showing only changes of commit ad61fcecb7 - Show all commits

View File

@ -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()) {