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

public abstract class Enemy implements Entity {
    protected Weapon weapon;
    protected int hp;
    protected int maxHP;
    protected int mp;
    protected int maxMP;
    protected boolean stunned;

    public Enemy(int hp, int mp, Weapon weapon) {
        this.hp = hp;
        this.maxHP = hp;
        this.mp = mp;
        this.maxMP = mp;
        this.weapon = weapon;
        this.stunned = false;
    }
    public void setStunned(boolean s) {
        stunned = s;
    }
    public boolean isStunned() {
        return stunned;
    }
    @Override
    public void attack(Entity target) {
        int damage = weapon.getDamage();
        target.takeDamage(damage);
    }
    @Override
    public void takeDamage(int damage) {
        hp -= damage;
        if (hp < 0) hp = 0;
    }
    @Override
    public void heal(int health) {
        hp += health;
        if (hp > maxHP) hp = maxHP;
    }
    @Override
    public void fillMana(int mana) {
        mp += mana;
        if (mp > maxMP) mp = maxMP;
    }
    @Override
    public boolean isAlive() {
        return 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; }
    public Weapon getWeapon() { return weapon; }
    @Override
    public void defend() {
    }
}