package org.project.entity.enemies;

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

// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy implements Entity {
    Weapon weapon;
    private int hp;
    private int maxHp;
    private int mp;
    private int maxMp;
    private String name;


    public Enemy(String name, int hp, int mp, Weapon weapon) {
        this.name = name;
        this.hp = hp;
        this.maxHp = hp;
        this.mp = mp;
        this.maxMp = mp;
        this.weapon = weapon;

    }

    @Override
    public void takeDamage(int damage)
    {
        hp -= damage;
        if (hp < 0)
            hp = 0;
        System.out.println("HP: " + hp + "/" + maxHp);
    }

    public int getHP() {
        return hp;
    }

    public int getMaxHP() {return maxHp;}

    public int getMP() {
        return mp;
    }

    @Override
    public void fillMana(int mana)
    {
        this.mp += mana;
        if (mp > maxMp)
            mp = maxMp;
        System.out.println( name + " restored " + mana + " MP (" + mp + "/" + maxMp + ")");
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) { this.weapon = weapon; }

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

    @Override
    public void heal(int health)
    {
        hp += health;
        if(hp > maxHp)
            hp = maxHp;
        System.out.println(name + " add " + health + " hp (" + hp + "/" + maxHp +")");
    }

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

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

    public void setHp(int hp)
    {
        this.hp = Math.max(0,Math.min(hp,maxHp));
    }

    public abstract int getXpReward();
    public abstract String getEnemyType();
}
