package org.project.entity.enemies;


import org.project.entity.Entity;
import org.project.item.weapons.Sword;

public class Skeleton extends Enemy{

    private boolean incarnation = false;
    public Skeleton() {
        super(70,100,new Sword());
        setDefendRate(.3);

    }

    @Override
    public void attack(Entity target) {
        super.attack(target);
    }

    @Override
    public void defend() {
        if (getMP() >= 8) {
            super.defend();
            setMP(getMP() - 8);
        }
        else {
            System.out.println("Not enough MP");
            setSuccessfulAction(false);
        }
    }

    @Override
    public void heal(int health) {
        if (getMP() >= 18) {
            super.heal(health);
            setMP(getMP() - 18);
        }
        else  {
            System.out.println("Not enough MP");
            setSuccessfulAction(false);
        }
    }

    @Override
    public void takeDamage(int damage) {
        super.takeDamage(damage);
        if (getHP() <= 0 && !incarnation) {
            setHP(getMaxHP() / 2);
            incarnation = true;
        }
    }


}
