Package battleship.model.game
Class Game
java.lang.Object
battleship.model.game.Game
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
(Only for recovery mode) Subscribes listener to user status changed event.void
(only for ship recovery mode) Clear list.(only for ship recovery mode)hitOnPlace
(Point point, FiringMode firingMode) Attack on specified point on ocean.void
placeShipsOnOcean
(int[] counters) Placing ship on the Ocean.recognizeMode
(int torpedoCounter, boolean recoveryMode) void
restorePreviousHealthFleet
(int healthScoresToAdd) Restore fleet health.void
setGameMode
(EnumSet<GameMode> mode, int torpedoCounter) Set the game mode.void
updatePointsToRecover
(List<Point> points) Update list of points to recover (only for ship recovery mode).
-
Constructor Details
-
Game
Create new game.- Parameters:
sizeHorizontal
- horizontal size of the oceansizeVertical
- vertical size of the ocean- Throws:
IllegalArgumentException
- cannot create ocean with this parameters
-
-
Method Details
-
setGameMode
Set the game mode.- Parameters:
mode
- enum set of optionstorpedoCounter
- torpedo counter- Throws:
IllegalArgumentException
- when torpedo counter mismatching with game mode
-
recognizeMode
- Parameters:
torpedoCounter
- number of available torpedorecoveryMode
- recovery mode turned on/off- Returns:
- Game mode
-
placeShipsOnOcean
Placing ship on the Ocean.- Parameters:
counters
- array of numbers, where these numbers are listed in the order which corresponds to ship types sizes- Throws:
RuntimeException
- if ocean size is too small for the input specified fleet
-
addListener
(Only for recovery mode) Subscribes listener to user status changed event.- Parameters:
user
- user to subscribe.
-
hitOnPlace
Attack on specified point on ocean.- Parameters:
point
- point to attackfiringMode
- general / torpedo- Returns:
- attack report
- Throws:
IllegalArgumentException
- if firing mode = torpedo and there is no available torpedo
-
restorePreviousHealthFleet
public void restorePreviousHealthFleet(int healthScoresToAdd) Restore fleet health. (only for ship recovery mode).- Parameters:
healthScoresToAdd
- health scores to add
-
updatePointsToRecover
Update list of points to recover (only for ship recovery mode).- Parameters:
points
- list of points
-
getPointsToRecover
(only for ship recovery mode)- Returns:
- list of points to recover
-
clearPointsToRecover
public void clearPointsToRecover()(only for ship recovery mode) Clear list.
-