package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.item.weapons.Weapon;

public class Skeleton extends Enemy {
    int timesDied;

    public Skeleton(Weapon weapon) {
        int hp = 50;
        int mp = 50;
        timesDied = 0;
        super(hp, mp, weapon, 10);
    }

    @Override
    public void takeDamage(int damage) {
        super.takeDamage(damage);
        if (!isAlive)
            getKilled();
    }

    @Override
    public void getKilled() {
        if (timesDied == 0) {
            timesDied += 1;
            setHP(getMaxHP() / 2);
            System.out.println("\u001B[33myour enemy revived itself!!!\u001B[0m");
            return;
        }
        isAlive = false;
    }

    @Override
    public void attack(Entity target) {
        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 50;
    }

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