package org.project.entity.enemies;

import org.project.util.ConsoleColors;

/**
 * Skeleton ☠️ — a bag of bones that can pull itself back together once per
 * battle, returning to 50% HP the first time it would die. Drops the Skeleton
 * Key.
 */
public class Skeleton extends Enemy {

    private boolean hasResurrected = false;

    public Skeleton() {
        super("Skeleton", 40, 10, 25, 14, KeyType.SKELETON, 25);
    }

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

        // First time it drops to 0, it revives at half health.
        if (getHp() <= 0 && !hasResurrected) {
            hasResurrected = true;
            int revived = getMaxHP() / 2;
            heal(revived); // hp was 0, so this sets it to 50% of max
            System.out.println(ConsoleColors.purple(
                    "☠️ The Skeleton collapses into a pile of bones... then reassembles with " + getHp() + " HP!"));
        }
    }
}
