package org.project.entity.enemies;

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

public class Skeleton extends Enemy{

    private boolean hasResurrected = false;
    private int resurrectionThreshold;

    public Skeleton(Weapon weapon)
    {
        super(40, 0, weapon);
        this.resurrectionThreshold = 20;
    }

    @Override
    public void takeDamage(int damage)
    {
        super.takeDamage(damage);

        if (!this.isAlive() && !hasResurrected)
        {
            resurrect();
        }
    }

    @Override
    public void attack(Entity target)
    {
        if (!this.isAlive()) return;
        int damage = 0;
        if (super.getWeapon() != null)
        {
            damage = super.getWeapon().getDamage();
        }
        else
        {
            damage = 5;
        }

        target.takeDamage(damage);
    }

    public void resurrect()
    {
        int healAmount = super.getMaxHP() / 2;
        super.heal(healAmount);

        this.hasResurrected = true;
        System.out.println("👻 Skeleton is rising from the grave! HP restored to " + super.getHp());
    }
}
