Package battleship.model.game.user
Class User
java.lang.Object
battleship.model.game.user.User
- All Implemented Interfaces:
StatusChangedListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
hitOnPlace
(Point position, FiringMode mode) Hit on place in current game session.void
onStatusChanged
(AttackReport report) (for recovery ship mode only) depends on actual state: if actualState == ATTACKING_SHIP and last attacking ship is not equal to current: undo recent actions.void
setCurrentSession
(Game game) set current game session.
-
Constructor Details
-
User
public User()
-
-
Method Details
-
setCurrentSession
set current game session.- Parameters:
game
- game
-
hitOnPlace
Hit on place in current game session.- Parameters:
position
- position to attackmode
- firing mode- Returns:
- HitReport
- Throws:
IllegalArgumentException
- if firing mode = torpedo and there is no available torpedo.
-
getActionsCounter
public int getActionsCounter()- Returns:
- number of actions.
-
getCurrentSession
- Returns:
- current game session.
-
onStatusChanged
(for recovery ship mode only) depends on actual state: if actualState == ATTACKING_SHIP and last attacking ship is not equal to current: undo recent actions. if result of current attack = MISS and user was attacking ship in previous attacks: undo recent actions. when the ship was sunk: clear all history when the ship was firstly attacked remember this attack.- Specified by:
onStatusChanged
in interfaceStatusChangedListener
- Parameters:
report
- report of the current attack.
-