package org.project.entity.enemies;

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

public abstract class Enemy implements Entity
{

    protected String name;
    protected int hp;
    protected int mp;
    protected int maxHp;
    protected int maxMp;
    protected int level;
    protected boolean stunned;
    protected boolean invisible;
    protected Weapon weapon;

    protected static final String RESET = "\u001B[0m";
    protected static final String RED = "\u001B[31m";
    protected static final String YELLOW = "\u001B[33m";
    protected static final String PURPLE = "\u001B[35m";

    public Enemy(String name, int hp, int mp, Weapon weapon)
    {
        this.name = name;
        this.hp = hp;
        this.mp = mp;
        this.maxHp = hp;
        this.maxMp = mp;
        this.level = 1;
        this.stunned = false;
        this.invisible = false;
        this.weapon = weapon;
    }

    @Override
    public void defend()
    {
        System.out.println(name + " defends.");
    }

    @Override
    public void heal(int health)
    {
        if (health <= 0) return;
        hp += health;
        if (hp > maxHp) hp = maxHp;
    }

    @Override
    public void fillMana(int mana)
    {
        if (mana <= 0) return;
        mp += mana;
        if (mp > maxMp) mp = maxMp;
    }

    @Override
    public void takeDamage(int damage)
    {
        if (damage <= 0) return;
        hp -= damage;
        if (hp < 0) hp = 0;
    }

    @Override
    public int getHP()
    {
        return hp;
    }

    @Override
    public int getMP()
    {
        return mp;
    }

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

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

    @Override
    public int getLevel()
    {
        return level;
    }

    @Override
    public String getName()
    {
        return name;
    }

    @Override
    public void setStunned(boolean value)
    {
        this.stunned = value;
    }

    @Override
    public boolean isStunned()
    {
        return stunned;
    }

    @Override
    public void setInvisible(boolean value)
    {
        this.invisible = value;
    }

    @Override
    public boolean isInvisible()
    {
        return invisible;
    }

    @Override
    public boolean isAlive()
    {
        return hp > 0;
    }

    @Override
    public void gainXP(int xp)
    {
    }

    @Override
    public abstract void attack(Entity target);
}
