diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index 783cc30..f682b1c 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -361,6 +361,19 @@ public class AIGridGUI extends JPanel { cellsHit[guessLocation] = true; } } + + //Mark game as not over unless all ships killed. + for(Ship sh : allShips) { + if(!sh.isKilled()) { + gameOver = false; + } + } + + //Game over message. + if(gameOver) { + text = "You Lost in " + numOfGuesses + " guesses."; + endGame = true; + } } //Return the location of a cell one space in the given direction, or return -1 if out of bounds.