package org.project.entity.players;

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

public class Assassin extends Player {
    private boolean invisible;
    private boolean guaranteedCrit;
    public Assassin(String name) {
        super(name, 90, 100,
                new Weapon(12, 0, "Dagger", 0) {
                    @Override
                    public void use(Entity target) {
                        target.takeDamage(getDamage());
                    }
                },
                new Armor(5, 18, "Leather Armor", 0) {
                    @Override
                    public void use(Entity target) { }
                });
        this.invisible = false;
        this.guaranteedCrit = false;
    }
    @Override
    public void takeDamage(int damage) {
        if (invisible) {
            System.out.println(getName() + " vanishes and dodges the attack!");
            invisible = false;
            return;
        }
        super.takeDamage(damage);
    }
    @Override
    public void lightAttack(Entity target) {
        int damage = getWeapon().getDamage();
        if (guaranteedCrit) {
            damage *= 2;
            guaranteedCrit = false;
        }
        target.takeDamage(damage);
        System.out.println(getName() + " strikes swiftly! Dealt " + damage + " damage.");
    }
    @Override
    public void heavyAttack(Entity target) {
        if (consumeMana(10)) {
            int damage = getWeapon().getDamage() * 2;
            if (guaranteedCrit) {
                damage *= 2;
                guaranteedCrit = false;
            }
            target.takeDamage(damage);
            System.out.println(getName() + " stabs viciously! Dealt " + damage + " damage.");
        }
        else {
            System.out.println(ConsoleColors.YELLOW + "Not enough mana!" + ConsoleColors.RESET);
        }
    }
    @Override
    public void defend() {
        if (consumeMana(5)) {
            defending = true;
            System.out.println(getName() + " slips into evasive stance.");
        }
        else {
            System.out.println(ConsoleColors.YELLOW + "Not enough mana to defend!" + ConsoleColors.RESET);
        }
    }
    @Override
    public void specialAbility(Entity target) {
        if (consumeMana(20)) {
            invisible = true;
            guaranteedCrit = true;
            System.out.println(getName() + " blends into shadows... next attack will be critical and incoming attack dodged!");
        }
        else {
            System.out.println(ConsoleColors.YELLOW + "Not enough mana for Shadow Cloak!" + ConsoleColors.RESET);
        }
    }
    @Override
    public void heal(int health) {
        super.heal(health);
    }
}