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 boolean canPlayThisTurn = true;
    private boolean isDefendingThisTurn = false;
    private boolean isAlive;
    private int healManaCost;
    private int defendManaCost;
    public Enemy(int hp, int mp, Weapon weapon,
        int healManaCost, int defendManaCost) {
        this.hp = hp;
        this.mp = mp;
        this.maxHP = hp;
        this.maxMP = mp;
        this.weapon = weapon;
        this.healManaCost = healManaCost;
        this.defendManaCost = defendManaCost;
    }
    @Override
    public void defend() {
       isDefendingThisTurn = true;
    }


    @Override
    public void takeDamage(int damage) {
        if (!isDefendingThisTurn) {
            hp -= damage;
            if (hp < 0) {
                hp = 0;
            }
        } else {
            isDefendingThisTurn = false;
        }
    }
    @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 void reduceMana(int mana) {
        mp -= mana;
        if (mp < 0) {
            mp = 0;
        }
    }
    @Override
    public void skipNextTurn() {
        this.canPlayThisTurn = false;
    }
    @Override
    public void skipTurn() {
        this.canPlayThisTurn = true;
    }
    @Override
    public String getType() {
        return "Enemy";
    }

    public int getHp() {
        return hp;
    }

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

    public int getMp() {
        return mp;
    }

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

    public int getHealManaCost() {
        return healManaCost;
    }

    public int getDefendManaCost() {
        return defendManaCost;
    }

    public Weapon getWeapon() {
        return weapon;
    }
}
