package org.project.entity.enemies;

import org.project.Colors;
import org.project.entity.players.Player;

import java.util.Random;

// TODO: UPDATE IMPLEMENTATION
public class Skeleton extends Enemy {

    private int lifeChance;

    public Skeleton() {
        super(60, 30);
        this.lifeChance = 1;
    }

    @Override
    public boolean isAlive() {
        if(super.getHp() <= 0)
        {
            if(lifeChance >= 1)
            {
                lifeChance--;
                super.setHp(30);
                System.out.println("Skeleton rises again with 50% of HP (current HP: 30)");
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return true;
        }
    }

    @Override
    public void dropKey(Player player) {
        if(!player.getSkeletonKey())
        {
            if (new Random().nextInt(100) < 35) {
                System.out.println("Skeleton dropped a " + Colors.KEY +"KEY" +Colors.RESET +"!");
                player.setSkeletonKey(true);
            }
        }
    }


    // TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
}
