package org.project.entity.enemies;

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

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

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

    @Override
    public void takeDamage(int damage) {
        hp -= damage;
    }

    @Override
    public void attack(Entity target) {
        // English comment: Default enemy attack uses weapon damage.
        if (weapon != null) {
            target.takeDamage(weapon.getDamage());
        }
    }

    protected void setHp(int hp) {
        this.hp = hp;
    }

    public int getHp() {
        return hp;
    }

    public int getMp() {
        return mp;
    }

    public Weapon getWeapon() {
        return weapon;
    }
    @Override
    public void defend() {
        // English comment: Default enemy defense does nothing special.
    }

    @Override
    public void heal(int health) {
        // English comment: Clamp HP so it never exceeds maximum HP.
        hp = Math.min(maxHp, hp + health);
    }

    @Override
    public void fillMana(int mana) {
        // English comment: Clamp MP so it never exceeds maximum MP.
        mp = Math.min(maxMp, mp + mana);
    }

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

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

}
