package org.project.entity.enemies;

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

import java.util.Random;

public class Goblin extends Enemy{

    private int hitChance;

    public Goblin() {

        super(50, 25);
        this.hitChance = 20;
    }

    Random rand = new Random();
    @Override
    public int attack() {
        if(rand.nextInt(100) < hitChance)
        {
            System.out.println("Goblin used Critical Strike!");
            hitChance -= 5;
            return 45;
        }
        else
        {
            System.out.println("Goblin attacked");
            return super.getDamage();
        }

    }

    @Override
    public void dropKey(Player player) {
        if(!player.getGoblinKey())
        {
            if (new Random().nextInt(100) < 50) {
                System.out.println("Goblin dropped a " + Colors.KEY +"KEY" +Colors.RESET +"!");
                player.setGoblinKey(true);
            }
        }
    }
}
