package org.project.entity.enemies;

import org.project.Colors;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.weapons.AssassineWeapon;

// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy implements Entity {
    private final int maxHp;
    private int hp;
    private Boolean haveBleed;
    private int bleedingRound;
    private final int damage;
    public boolean confuse;//for Goblin Gland


    public Enemy(int maxHp, int damage) {
       this.maxHp = maxHp;
       this.hp = maxHp;
        this.damage = damage;
        this.haveBleed = false;
        this.bleedingRound = 0;
        this.confuse = false;
    }

    public void setConfuse(boolean confuse) {
        this.confuse = confuse;
    }

    public boolean isConfuse()
    {
        if(confuse)
        {
            confuse = false;
            return true;
        }
        return false;
    }

    public int getDamage() {
        return damage;
    }

    @Override
    public boolean heal(int health) {
        System.out.printf("%s healed for " + Colors.LIGHTRED + "%d" + Colors.RESET +" HP\n", this.getClass().getSimpleName(), health);
        hp += health;
        if (hp > maxHp) {
            hp = maxHp;
        }
        return true;
    }

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

    public void bleed(AssassineWeapon aw)
    {
        if(haveBleed)
        {
            if(bleedingRound > 0)
            {
                System.out.printf("%s Bleeds out!."+ Colors.RED + "-%d" +Colors.RESET  + " HP\n", this.getClass().getSimpleName(), aw.getBleedDamage());
                hp -= aw.getBleedDamage();
                this.bleedingRound--;
            }
            if(bleedingRound == 0)
            {
                this.haveBleed = false;
            }
        }
    }


    public int getBleedingRound() {
        return bleedingRound;
    }

    public void setBleedingRound(int bleedingRound) {
        this.bleedingRound = bleedingRound;
    }

    public Boolean HaveBleed() {
        return haveBleed;
    }

    public void setHaveBleed(Boolean haveBleed) {
        this.haveBleed = haveBleed;
    }

    @Override
    public boolean isAlive() {
        return hp > 0;
    }

    public int attack()
    {
        return damage;
    }





     public abstract void dropKey(Player player);

    @Override
    public void takeDamage(int damage) {
        hp -= damage;
        if(hp < 0)
        {
            hp = 0;
        }
        System.out.printf("%s took " + Colors.RED + "%d" + Colors.RESET + " damage!\n",this.getClass().getSimpleName(), damage);
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
        if(hp > maxHp)
        {
            hp = maxHp;
        }
    }
    //    public int getMp() {
//        return mp;
//    }

//    public Weapon getWeapon() {
//        return weapon;
//    }
}
