package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.util.ConsoleColors;
import org.project.util.Dice;

/**
 * Goblin 👹 — low health, but a high chance to land a devastating critical hit.
 * Drops the Goblin Key.
 */
public class Goblin extends Enemy {

    private static final int CRIT_CHANCE = 40; // percent

    public Goblin() {
        super("Goblin", 30, 8, 20, 12, KeyType.GOBLIN, 25);
    }

    @Override
    public void attack(Entity target) {
        if (Dice.chance(CRIT_CHANCE)) {
            int critDamage = damage * 2;
            System.out.println(ConsoleColors.red("👹 Goblin used Critical Strike!"));
            System.out.println(ConsoleColors.red("💥 Critical hit!"));
            target.takeDamage(critDamage);
        } else {
            System.out.println(ConsoleColors.red("👹 Goblin lunges with a rusty blade!"));
            target.takeDamage(damage);
        }
    }
}
