package org.project.entity.enemies;

import org.project.entity.Entity;
import org.project.item.weapons.Sword;

public class Vampire extends Enemy{

    public Vampire() {
        super(90,90,new Sword());
        setDefendRate(.7);
    }

    @Override
    public void attack(Entity target) {
        setAttackMultiplier(1.5);
        super.attack(target);
        double damage = weapon.getDamage() * getAttackMultiplier();
        setAttackMultiplier(1);
        if (target.isDefending()) {
            heal( (int) (.3 * (damage * (1 - target.getDefendRate()))));
            setMP(getMP() + 12);
        }
        else {
            heal( (int) (.3 * damage));
            setMP(getMP() + 12);
        }
    }

    @Override
    public void defend() {
        if (getMP() >= 15) {
            super.defend();
            setMP(getMP() - 15);
        }
        else {
            System.out.println("Not enough MP");
            setSuccessfulAction(false);
        }
    }

    @Override
    public void heal(int health) {
        if (getMP() >= 12) {
            super.heal(health);
            setMP(getMP() - 12);
        }
        else  {
            System.out.println("Not enough MP");
            setSuccessfulAction(false);
        }
    }
}
