package org.project.entity.players;

import org.project.entity.Entity;
import org.project.item.armors.WizardArmor;
import org.project.item.weapons.Bow;

public class Wizard extends Player{

    public Wizard() {
        super("Wizard",90,90,new Bow(),new WizardArmor());
        setDefendRate(.6);
    }

    @Override
    public void lightAttack(Entity target) {
        super.lightAttack(target);
        if (((Bow) weapon).charge()){
            setAttackMultiplier(1.4);
            attack(target);
            attack(target);
            setAttackMultiplier(1);
        } else {
            attack(target);
        }
    }

    @Override
    public void heavyAttack(Entity target) {
        super.heavyAttack(target);
        if (getMP() >= weapon.getManaCost()) {
            setAttackMultiplier(1.3);
            attack(target);
            setAttackMultiplier(1);
            setMP(getMP() - weapon.getManaCost());
        }
        else {
            System.out.println("Not enough MP");
            setSuccessfulAction(false);
        }
    }

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

    @Override
    public void specialAbility(Entity target) {
        if (getMP() >= 20) {
            setAttackMultiplier(1.6);
            attack(target);
            setAttackMultiplier(1);
            setMP(getMP() - 20);
            setHP(getHP() + 10);
        }
        else {
            System.out.println("Not enough MP");
            setSuccessfulAction(false);
        }
    }

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

    @Override
    public void takeDamage(int damage) {
        if (!getArmor().checkBrake()) {
            int finalDamage = ((WizardArmor) armor).absorbDamage(damage, getMP());
            super.takeDamage(finalDamage);
        }
        else {
            super.takeDamage(damage);
        }
    }
}
