Class User

java.lang.Object
battleship.model.game.user.User
All Implemented Interfaces:
StatusChangedListener

public class User extends Object implements StatusChangedListener
  • Constructor Details

    • User

      public User()
  • Method Details

    • setCurrentSession

      public void setCurrentSession(Game game)
      set current game session.
      Parameters:
      game - game
    • hitOnPlace

      public AttackReport hitOnPlace(Point position, FiringMode mode) throws IllegalArgumentException
      Hit on place in current game session.
      Parameters:
      position - position to attack
      mode - 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

      public Game getCurrentSession()
      Returns:
      current game session.
    • onStatusChanged

      public 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. 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 interface StatusChangedListener
      Parameters:
      report - report of the current attack.