package project;

public class BlackDragon extends Monster {

  private boolean print;
  
  public BlackDragon (Player1 player, int x, int y) { 
    super( x, y, BlackDragonAttack, BlackDragonHealth); 
    target = player;
	text = player.text;
	print = false;
  } //constructor BlackDragon 
  
  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 Dragon vanished...and all you can hear is breeze of air.....");
	 } //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 huge black creature glared at you from the dark..");
	  text.println ("The Creature: Well, my friend, can't pass here!!");
	  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>: BlackDragon");
	text.println ("<AttackPower>: " + BlackDragonAttack);
	text.println ("<Health>: " + BlackDragonHealth + "units");
  } //method getEnemyInfo
  
  public void AttackIntro() { text.println ("The Dragon smashed you to the ground with his gigantic tail..."); } 
   
} //class BlackDragon