package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.entity.players.Player;


public abstract class Enemy implements Entity {
    private int hp;
    private int mp;
    private boolean stunned = false;
    private boolean critical = false;
    private boolean dead = false;
    private int enemyDamage;

    private static  double Damagemodifier = 1.5;

    public Enemy(int hp, int enemyDamage) {
        this.hp = hp;
        this.enemyDamage = enemyDamage;
    }

    public void attack(Entity target){
        if (critical){
            target.takeDamage((int)(enemyDamage * Damagemodifier));
        }
        else {
            target.takeDamage(enemyDamage);
        }
    }

    @Override
    public void takeDamage(int damage) {

        hp -= damage;
        if (hp <= 0){
            hp = 0;
            makeDie();
        }
    }

    public void makeDie() {
        dead = true;
    }

    public int getHp() {

        return hp;
    }

    public void setHp(int newHp) {
        hp = newHp;
    }

    public int getMp() {

        return mp;
    }

    @Override
    public boolean isCritical(){
        return critical;
    }

    @Override
    public void makeCritical(boolean value) {
        critical = value;
    }

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

    @Override
    public void stun(boolean value) {
        stunned = value;
    }

    @Override
    public boolean isDead() {
        return dead;
    }

    @Override
    public void heal(int health) {
        hp += health;
    }


    public abstract String getName();

    public abstract void specialAbility(Player target);
}
