package org.project.entity.players;

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

public class Assassin extends Player {

    private boolean dodgeNext = false;
    private boolean counterReady = false;

    public Assassin(String name, Weapon weapon, Armor armor) {
        super(name, 60, 50, weapon, armor);
    }

    @Override
    public void lightAttack(Entity target) {
        if (counterReady) {
            target.takeDamage(30, this);
            System.out.println(name + " Performs a Light Attack After Dodging Enemy's Attack!");
            counterReady = false;
        } else {
            super.lightAttack(target);
            dodgeNext = false;
        }

    }

    @Override
    public void heavyAttack(Entity target) {
        if (spendStamina(weapon.getStaminaCost())) {
            if (counterReady) {
                target.takeDamage(weapon.getDamage() * 2, this);
                System.out.println(name + " Performs a Heavy Attack After Dodging Enemy's Attack!");
                counterReady = false;
            } else {
                super.heavyAttack(target);
                dodgeNext = false;
            }
        }
    }

    @Override
    public void takeDamage(int damage, Entity attacker) {
        if (dodgeNext) {
            System.out.println(name + " Dodged Enemy's Attack!");
            dodgeNext = false;
            counterReady = true;
            return;
        }
        super.takeDamage(damage, attacker);
    }

    @Override
    public void specialAbility(Entity target) {
        if (spendStamina(20)) {
            this.dodgeNext = true;
            this.counterReady = false;
            System.out.println(name + " Gets Ready To Dodge Enemy's Attack...");
        }
    }
}
