package org.project.entity.players;


import org.project.entity.Entity;
import org.project.item.armors.AssassinArmor;
import org.project.item.weapons.Dagger;

public class Assassin extends Player {

    public Assassin() {
        super("ASSASSIN",100,100, new Dagger(), new AssassinArmor());
        setDefendRate(.7);
    }

    @Override
    public void lightAttack(Entity target) {
        super.lightAttack(target);
        if (((Dagger) weapon).critical()){
            setAttackMultiplier(1.5);
            attack(target);
            setAttackMultiplier(1);
        } else {
            attack(target);
        }
    }

    @Override
    public void heavyAttack(Entity target) {
        super.heavyAttack(target);
        if (getUsingSpecialAbility()) {
            setAttackMultiplier(1.8);
            attack(target);
            setAttackMultiplier(1);
            setUsingSpecialAbility(false);
        }

        else if (getMP() >= weapon.getManaCost()) {
                setAttackMultiplier(1.4);
                attack(target);
                setAttackMultiplier(1);
                setMP(getMP() - weapon.getManaCost());
            } else {
                System.out.println("Not enough MP");
                setSuccessfulAction(false);
            }

    }

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

    @Override
    public void specialAbility(Entity target) {
        if (getMP() >= 25) {
            setUsingSpecialAbility(true);
            System.out.println("Assasin using SpecialAbility");
            setMP(getMP() - 25);
        }
        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);
        }
    }

    @Override
    public void takeDamage(int damage) {
        if (getUsingSpecialAbility()) {
            System.out.println("player using special ability");
        } else {
            damage = ((AssassinArmor) (getArmor())).reduceDamage(damage, this);
            super.takeDamage(damage);

        }
    }

}

