diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index cf58c54..b1b4a38 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -14,6 +14,7 @@ public class GridGUI { ArrayList allShips = new ArrayList(); int[] testLocations; int numOfGuesses = 0; + String text = ""; int rows; int columns; boolean clicked = false; @@ -80,6 +81,30 @@ public class GridGUI { boolean killed = false; numOfGuesses++; boolean gameOver = true; + cell.setEnabled(false); + cell.setBorder(loweredBevel); + + if(s == null) { + //Mark cell as missed. + text = "You missed. Other player's turn..."; + cell.setBackground(Color.lightGray); + } else { + killed = s.counter(); + if(killed) { + //Mark all of the ship's cells as killed. + text = "You sunk the " + s.getName() + "! Other player's turn..."; + for(BSButton bu : buttons) { + if(bu.getCellContents() == s) { + bu.setBackground(darkRed); + } + } + } else { + //Mark cell as hit. + text = "You got a hit. Other player's turn..."; + cell.setBackground(Color.red); + } + } + } } }