package org.project.entity.enemies;

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




public abstract class Enemy implements Entity {
    protected Weapon weapon;
    protected Armor armor;
    protected int hp;
    protected int mp;
    protected int maxHp;
    protected int maxMp;
    protected boolean ispossible;


    public Enemy(int hp, int mp, Weapon weapon , Armor armor) {
        this.hp = hp;
        this.maxHp=hp;
        this.mp = mp;
        this.maxMp=mp;
        this.weapon = weapon;
        this.armor = armor;
        this.ispossible = true;

    }

    public abstract void specialAbility(Entity target);


    @Override
    public void lightattack(Entity target){
        System.out.println(toString() + " do a light attaked with " + weapon.getDamage() + " damages");
        target.takeDamage(weapon.getDamage());

    }


    @Override
    public void heavyattack(Entity target){
        System.out.println(toString() + " do a heavy attaked with " + weapon.getDamage() * 2 + " damages");
        target.takeDamage((2 * weapon.getDamage()) - 10);
    }



    @Override
    public void takeDamage(int damage) {

        if(!armor.checkBreak()){
            hp -= damage - armor.getDefense();
            armor.use(this);
            System.out.println(toString() + " take " + (damage -armor.getDefense())
                    + " Damage. " + armor.getDefense() +" Defens by armor" );
        }
        else {
            hp -=damage;
            System.out.println(toString() + "take " + (damage));
        };
    }

    @Override
    public int getHp() {
        return hp;
    }
    public int getMp() {
        return mp;
    }
    public int getMaxHP(){
        return maxHp;
    }
    public int getMaxMP(){
        return maxMp;
    }
    @Override
    public Weapon getWeapon() {
        return weapon;
    }
    public Armor getArmor(){return armor;}

    @Override
    public void falsepossible(){
        ispossible = false;
    }
    public void truepossible(){
        ispossible=true;
    }

    public boolean getpossible(){
        return ispossible;
    }


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

    @Override
    public abstract String toString();
    public String getName(){return "";}
    public void repair(){}
    public void defend() {}
    public void healHp(int health){}
    public void healMp(int mp){}
}


