|
@ -333,6 +333,22 @@ public class AIGridGUI extends JPanel { |
|
|
if(killed) { |
|
|
if(killed) { |
|
|
text = "Your " + s.getName() + " was sunk. Your turn."; |
|
|
text = "Your " + s.getName() + " was sunk. Your turn."; |
|
|
boolean unkilledCells = false; |
|
|
boolean unkilledCells = false; |
|
|
|
|
|
for(BSButton bu : buttons) { |
|
|
|
|
|
//Mark killed cells. |
|
|
|
|
|
if(bu.getCellContents() == s) { |
|
|
|
|
|
bu.setBackground(Red); |
|
|
|
|
|
cellsKilled[bu.getGridLocation()] = true; |
|
|
|
|
|
} |
|
|
|
|
|
//Mark if any cell remains that has been hit but not yet killed. If so, lock onto that cell. |
|
|
|
|
|
if(cellsHit[bu.getGridLocation()] && !cellsKilled[bu.getGridLocation()]) { |
|
|
|
|
|
f = bu.getGridLocation(); |
|
|
|
|
|
unkilledCells = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//If all hit cells have been killed, return to random guessing. |
|
|
|
|
|
if(!unkilledCells) { |
|
|
|
|
|
randomGuess = true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|