Browse Source

Update Implementation AIGridGUI class

main
Thoumi Ngonga Brice 2 years ago
parent
commit
cbdc91630f
  1. 20
      src/main/java/BattleShip/AIGridGUI.java

20
src/main/java/BattleShip/AIGridGUI.java

@ -315,6 +315,26 @@ public class AIGridGUI extends JPanel {
} }
} }
//Mark the guess on the grid.
cellsGuessed[guessLocation] = true;
b = buttons.get(guessLocation);
s = b.getCellContents();
b.setBorder(loweredBevel);
if(s == null) {
//If no ship in that cell, mark as a miss.
text = "Other player missed. Your turn.";
b.setBackground(Color.BLUE);
} else {
//Check if guess killed a ship.
killed = s.counter();
if(killed) {
text = "Your " + s.getName() + " was sunk. Your turn.";
boolean unkilledCells = false;
}
}
} }
//Return the location of a cell one space in the given direction, or return -1 if out of bounds. //Return the location of a cell one space in the given direction, or return -1 if out of bounds.

Loading…
Cancel
Save