|
@ -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. |
|
|