package project;

public class Zombie extends Monster {
  
  private boolean print;
  
  public Zombie (Player1 player, int x, int y) {
    super(x, y, ZombieAttack, ZombieHealth);
	target = player;
	text = player.text;
    print = false;
  } //constructor Zombie
  
  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 zombie melted into a pile of mud...");
	 } //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 ("You felt a arm from below grabing your leg....");
	  text.println ("The thing says:ERrrrrrr.....");
	  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>: Zombie");
	text.println ("<AttackPower>: " + ZombieAttack);
	text.println ("<Health>: " + ZombieHealth + "units");
  } //method getEnemyInfo
  
  public void AttackIntro() {
    text.println ("The Zombie bit your arms..and grab it for more...");
  } //method AttackIntro
  
} //class Zombie