package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.item.weapons.Weapon;
import java.util.Random;

public class Goblin extends Enemy {
    public Goblin(Weapon weapon) {
        int hp = 30;
        int mp = 50;
        super(hp, mp, weapon, 10);
    }

    @Override
    public void getKilled() {
        isAlive = false;
    }

    @Override
    public void attack(Entity target) {
        Random rand = new Random();
        if (rand.nextBoolean()) {
            target.takeDamage((weapon.getDamage() + getBaseDamage()) * 2);
            System.out.println("\u001B[33mGoblin did critical Hit!!!!!\u001B[0m");
            System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", (weapon.getDamage() + getBaseDamage()) * 2);
        } else {
            target.takeDamage(weapon.getDamage() + getBaseDamage());
            System.out.printf("\u001B[31mYou took %d damage.\u001B[0m\n", weapon.getDamage() + getBaseDamage());
        }
    }

    @Override
    public void heal(int health) {
        if (getHP() + health > getMaxHP())
            setHP(getMaxHP());
        else
            setHP(getHP() + health);
    }

    @Override
    public void fillMana(int mana) {
        if (getMP() + mana > getMaxMP())
            setMP(getMaxMP());
        else
            setMP(getMP() + mana);
    }

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

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