|
|
@ -443,7 +443,8 @@ public class AIGridGUI extends JPanel { |
|
|
|
} |
|
|
|
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
|
|
|
//If mouse released on cell clear for ship placement, place ship and mark appropriater cells. |
|
|
|
BSButton cell = (BSButton) e.getSource(); |
|
|
|
} |
|
|
|
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
@ -457,5 +458,15 @@ public class AIGridGUI extends JPanel { |
|
|
|
BSButton cell = b; |
|
|
|
int actionToTake = x; |
|
|
|
clear = true; |
|
|
|
|
|
|
|
//Check whether sufficient spaces are clear to place the ship. |
|
|
|
if(vertical) { |
|
|
|
for(int i = 0; i < shipToPlace.getLength(); i++) { |
|
|
|
int testing = cell.getGridLocation() + (i * columns); |
|
|
|
if(testing > (rows * columns) || buttons.get(testing).getCellContents() != null) { |
|
|
|
clear = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |