package org.project.entity.enemies;

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

import java.util.Random;

public class Skeleton extends Enemy{

    private int initialHP;

    public Skeleton(int hp, Weapon weapon) {
        this.initialHP = hp;
        super(hp, weapon, 20, 12);
    }

    //attacks the player and resurrects (increases HP) once per battle
    @Override
    public void attack(Entity target) {
        //checks if the player has stunned them
        if (!isStunned()) {
            if ((getHP() <= 10) && !getResurrectionStatus()) {
                int addedHP;

                if (initialHP % 2 == 0) { addedHP = initialHP / 2; }
                else { addedHP = (initialHP - 1) / 2; }

                addHP(addedHP);

                setResurrectionStatus(true);
            }
            target.takeDamage(getWeapon().getDamage());
        }
    }
}
