package project;

public class DraculaBat extends Monster implements flyable {
  
  private boolean print;
  
  public DraculaBat (Player1 player, int x, int y) { 
    super(x, y, DraculaBatAttack, DraculaBatHealth); 
    target = player;
	text = target.text;
	print = false;
  } //constructor DraculaBat
  
  public void update() { if (SameLocation(target) && Alive && target.Alive) Encounter(); } //method update
  
  public void beAttacked(Attackable a) {
     try {
	   healthDw(a.getAttackPower());
	 } catch (NoHealthException exception) {
	  target.inBattle = false;
	  text.println ("The bat fleed away into the trees...");
	 } //catch
  } //method beAttacked
  
  public void healthDw(int x) throws NoHealthException {
    if(health-x > 0)
  	  health = health - x;
  	else {
  	   Disable();
  	   throw new NoHealthException();
  	} //else
  } //method healthDw
  
  public void Encounter() {
    if (!print) {
      text.println ("A Giant Bat flew from behind and knocked you down.....");
	  text.println ("The Bat says: You seem like a delicious meal to me...");
	  getEnemyInfo();
	  text.println ("<<<Press Attack to engage in Battle>>>");
	  print = true;
	} //if
	target.inBattle = true;
	target.get(this);
  } //method Encounter
  
  public void getEnemyInfo() { 
    text.println ("<Enemy Type>: DraculaBat");
	text.println ("<AttackPower>: " + DraculaBatAttack);
	text.println ("<Health:> " + DraculaBatHealth + "units");
  } //method getEnemyInfo
  
  public void AttackIntro() {
    text.println ("The bat bit your neck with its giant fangs...");
  } //method AttackIntro
  
  public void fly() { text.println ("and it flied up and landed on a tree...");  } 
  
} //class DraculaBat