package org.project.entity.enemies;

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

public class Skeleton extends Enemy {

    private static final String RESET = "\033[0m";

    private static final String PURPLE = "\033[0;35m";


    private boolean hasResurrected = false;

    public Skeleton(Weapon weapon) {
        super("Skeleton", 160, 20, weapon, 0.3);
        this.xpReward = 100;
        this.coinReward = 20;
    }

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

        if (!isAlive() && !hasResurrected) {
            fillHealth(getMaxHP() / 2);
            this.hasResurrected = true;
            System.out.println(name + " Falls To The Ground... But Then" + PURPLE + " Resurrects From The Dead!" + RESET);
        }
    }

    @Override
    public int choice() {
        double roll = Math.random();

        if (this.getStamina() >= this.weapon.getStaminaCost()) {
            if (roll < 0.33) {return 1;}
            else if (roll < 0.67) {return 2;}
            else {return 3;}
        } else {
            return 1;
        }

    }
}
