Anpasung an paintFields, sodass preview unterscheidet, ob setzen von Schiff valide ist
This commit is contained in:
parent
b4f1de82bd
commit
ad61fcecb7
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue