package project;

public class FireDragon extends Monster {
  
  private boolean print;     //prevents printing messages over...and over..
  
  public FireDragon (Player1 player, int x, int y) { 
    super(x, y, FireDragonAttack, FireDragonHealth); 
	target = player;
	text = player.text;
	print = false;
  } //constructor FireDragon 
  
  public void update() { if (SameLocation(target) && Alive && target.Alive) Encounter(); } 
  
  public void beAttacked(Attackable a) {
     try {
	   healthDw(a.getAttackPower());
	 } catch (NoHealthException exception) {
	  target.inBattle = false;
	  text.println ("The Dragon collapsed and vanshed in the dark...");
	 } //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 red huge dragon steped in your way....");
	  text.println ("The Dragon says: Get out here or I'll turn you to ashes....");
	  getEnemyInfo();
	  text.println ("<<<press Attack to engage in Battle>>>");
	  print = true;
	} //if
	target.inBattle = true;  //to prevent player to moveing during Encounter
	target.get(this);   //sends itself as target to player
  } //method Encounter
  
  public void getEnemyInfo() { 
     text.println ("<Enemy Type:> FireDragon");
	 text.println ("<AttackPower:> " + FireDragonAttack);
	 text.println ("<Health:> " + FireDragonHealth + "units");
  } //method getEnemyInfo
  
  public void AttackIntro() { text.println ("The Dragon blew out some flame..."); }

} //class FireDragon