package org.project.entity.players;

import org.project.entity.Entity;

public class Assassin extends Player {
    private boolean isInvisible = false;
    private boolean nextAttackCrit = false;

    public Assassin(String name) {
        super(name, 80, 120, 15);
    }

    @Override
    public void takeDamage(int damage) {
        if (isInvisible) {
            System.out.println("\u001B[35m💨 " + name + " dodged the attack completely by being invisible!\u001B[0m");
            isInvisible = false;
        } else {
            super.takeDamage(damage);
        }
    }

    @Override
    public void lightAttack(Entity target) {
        int dmg = baseDamage;
        if (nextAttackCrit) {
            System.out.println("\u001B[31m💥 Critical Hit!\u001B[0m");
            dmg *= 2;
            nextAttackCrit = false;
        }
        target.takeDamage(dmg);
    }

    @Override
    public void heavyAttack(Entity target) {
        int cost = 8;
        if (mp >= cost) {
            mp -= cost;
            int dmg = baseDamage * 2;
            if (nextAttackCrit) {
                System.out.println("\u001B[31m💥 Critical Hit!\u001B[0m");
                dmg *= 2;
                nextAttackCrit = false;
            }
            target.takeDamage(dmg);
        } else {
            lightAttack(target);
        }
    }

    @Override
    public void specialAbility(Entity target) {
        int cost = 15;
        if (mp >= cost) {
            mp -= cost;
            System.out.println("\u001B[36m🗡️ " + name + " (Assassin) used Shadow Step! (-15 Mana)\u001B[0m");
            isInvisible = true;
            nextAttackCrit = true;
            System.out.println("\u001B[35m" + name + " turned invisible! Next attack will dodge and crit.\u001B[0m");
        } else {
            System.out.println("\u001B[34mNot enough mana! Defaulting to Light Attack.\u001B[0m");
            lightAttack(target);
        }
    }
}