package org.project.entity.enemies;

import org.project.item.weapons.BoneHarpoon;
import org.project.item.weapons.GoblinSickle;
import org.project.item.weapons.Weapon;

import java.util.Random;

public class Goblin extends Enemy implements Key{
    private static int DEFAULT_HP = 80;
    private static int DEFAULT_MP = 120;
    private static GoblinSickle DEFAULT_WEAPON = new GoblinSickle();
    private static int DEFAULT_HEAL_MANA_COST = 30;
    private static int DEFAULT_DEFEND_MANA_COST = 20;
    private static int keysRemaining = 1;

    public Goblin() {
        super(DEFAULT_HP, DEFAULT_MP, DEFAULT_WEAPON,
                DEFAULT_HEAL_MANA_COST, DEFAULT_DEFEND_MANA_COST);
    }

    public Goblin(String name, int hp, int mp, Weapon weapon,
                  int healManaCost, int defendManaCost) {
        super(hp, mp, weapon, healManaCost, defendManaCost);
    }

    @Override
    public String getType() {
        return "Goblin" ;
    }

    @Override
    public boolean generateKey() {
        if (keysRemaining > 0) {
            Random random = new Random();
            int dice = random.nextInt(1);
            if (dice == 0) {
                decreaseKey();
                return true;
            }
        }
        return false;
    }

    @Override
    public void decreaseKey() {
        keysRemaining -= 1;
    }

    @Override
    public int getKeysRemaining() {
        return keysRemaining;
    }

    @Override
    public String getKeyType() {
        return "Goblin";
    }

    public static void resetKeysRemaining() {
        keysRemaining = 1;
    }
}
