package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.item.weapons.BoneDagger;
import org.project.item.weapons.ToothedHook;
import org.project.location.NarrativeConsole;

import java.util.Random;

public class Goblin extends Enemy {
    private Random random;

    public Goblin() {
        super("Goblin", 30, 20, new ToothedHook());
        this.random = new Random();
    }

    @Override
    public void attack(Entity target) {
        int damage = 10;
        boolean isCritical = false;

        //Checking Critical Chance
        int chance = random.nextInt(100);
        if (chance > 30) {          //Critical Chance = 70%
            damage *= 2;
            isCritical = true;
        }

        target.takeDamage(damage);

        if (isCritical) {
            NarrativeConsole.printSpecial("💣 Goblin used CRITICAL STRIKE! ");
            NarrativeConsole.printDamage("💥 Goblin dealt " + damage + " damage to " + getName(target) + "!");
        } else {
            NarrativeConsole.printCombat("👹 Goblin attacked " + getName(target) + "!");
            NarrativeConsole.printDamage("💥 Goblin dealt " + damage + " damage to " + getName(target) + "!");
        }
    }

    @Override
    public int getMaxHP() {
        return 30;
    }

    @Override
    public int getMaxMP() {
        return 20;
    }
}
