package project;

public class PlayerBattleMode extends Attack {
  
  private Player1 player;
  private ItemEncounter item;
  private Weapon weapon;
  
  public PlayerBattleMode(Player1 p, ItemEncounter i) {
	player = p;
	item = i;
	AttackPower = player.getAttackPower();
	health = player.health;
	text = player.text;
  } //counstructor PlayerBattleMode
  
  public void update() { }
	  
  public void EnterBattleMode() throws NullTargetException { 
    if ( player.target!=null  && player.target.Alive && player.Alive) {
	  text.println ("~~Battle Mode~~");
	  player.update();
	} //if
	else throw new NullTargetException();
  } //method EnterBattleMode
  
  public void Attack() throws NullTargetException { 
    if (player.target!=null) {
	  text.println ("You Attacked the monster... ");
	  if (player.target instanceof flyable)
	    text.println ("The target fleed into air before you could reach it!");
	  else (player.target).beAttacked(player);
	} //if
	else throw new NullTargetException(); 
  } //method Attack
  
  public void WeaponAttack() throws NullTargetException {
	if (player.target!=null) {
	  try {
	    weapon = item.getWeapon();
	    weapon.Fire();
	    text.println ("You fired at the target!!");
		(player.target).beAttacked(weapon);
	  } catch (NoWeaponException exception) {
	   text.println ("You don't have any weapon now!!");
	  } catch (NoShotException exception) {
	   text.println ("You weapon just went out of ammo!!");
	   text.println ("Press <Drop Weapon> to throw it away.");
	  } //catch
	} //if
	else throw new NullTargetException();
  } //method WeaponAttack

} //class PlayerBattleMode