package org.project.entity.enemies;

import org.project.item.weapons.BoneDagger;

public class Skeleton extends Enemy {
    private boolean hasResurrected = false;

    public Skeleton() {
        super("Skeleton", 40, 25, new BoneDagger());
    }

    @Override
    public void takeDamage(int damage) {
        int newHp = getHp() - damage;

        if (newHp <= 0 && !hasResurrected) {
            //Resurrecting
            int resurrectedHp = getMaxHP() * 50 / 100;
            setHp(resurrectedHp);
            hasResurrected = true;

            System.out.println("💀 Skeleton has been defeated...");
            System.out.println("☠️ But Skeleton rises again! Resurrected with " + resurrectedHp + " HP!");
            return;
        }

        setHp(newHp);
        if (getHp() < 0) setHp(0);

        System.out.println("💥 Skeleton took " + damage + " damage! HP: " + getHp() + "/" + getMaxHP());

        if (getHp() <= 0) {
            System.out.println("☠️ Skeleton has been destroyed for good!");
        }
    }

    @Override
    public int getMaxHP() {
        return 45;
    }

    @Override
    public int getMaxMP() {
        return 25;
    }

    public boolean hasResurrected() {
        return hasResurrected;
    }

    public void setHasResurrected(boolean hasResurrected) {
        this.hasResurrected = hasResurrected;
    }
}
