package project;

public class Rat extends Monster {
  
  private boolean print;
  
  public Rat (Player1 player, int x, int y) {
    super(x, y, RatAttack, RatHealth);
	target = player ;
	text = player.text;
    print = false;
  } //constructor Rat 
  
  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 rat fleed into 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 Giant Rat just came out from the dark..");
	  text.println ("Rat says: Get out of my way, or I'll eat you alive");
	  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>: Rat");
	text.println ("<AttackPower>: " + RatAttack);
	text.println ("<Health>: " + RatHealth + "units");
  } //method getEnemyInfo 
  
  public void AttackIntro() { text.println ("The rat bit you on your leg.."); }
 
} //class Rat