package org.project.entity.enemies;

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

public abstract class Enemy extends Entity {
    Weapon weapon;
    private int hp;
    private boolean stunned = false;
    private boolean critical = false;
    private boolean dead = false;

    private static final double DAMAGE_MODIFIER = 1.5; // Used for critical hits

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

    public void attack(Entity target){
        if (critical){
            target.takeDamage((int)(weapon.getDamage() * DAMAGE_MODIFIER));
        }
        else {
            target.takeDamage(weapon.getDamage());
        }
    }

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

    @Override
    public void takeDamage(int damage) {
        hp -= damage;
        if (hp <= 0){
            dead = true;
        }
    }

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

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

    @Override
    public void makeDie() {
        dead = true;
    }

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

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

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

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

    public int getHp() {
        return hp;
    }

    public abstract String getName();

    public Weapon getWeapon() {
        return weapon;
    }

    public abstract void specialAbility(Player target);
}
