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 implements Entity, ICombatActions  {
    public Assassin(String name, Weapon weapon, Armor armor) {
        super(name, 45, 60, weapon, armor);
    }

    @Override
    public void specialAbility(Entity target) {
        //Checking if the mana is enough of not
        if (getMp() < 15) {
            System.out.println("❌ Not enough mana for Devastating Spell!");
            return;
        }

        //Consuming mana
        setMp(getMp()-15);

        setInvisible(true);
        setNextAttackCritical(true);

        System.out.println("💜 " + getName() + " turns INVISIBLE!");
        System.out.println("⚡ Next attack will be CRITICAL (2x damage)!");
        System.out.println("🛡️ Will dodge the next incoming attack completely!");
        System.out.println("💙 Mana left: " + getMp());
    }

    public void lightAttack(Entity target) {
        int damage = 10;

        //Critical Action (if enabled)
        if (isNextAttackCritical()) {
            damage *= 2;
            System.out.println("⚡ CRITICAL HIT! Damage doubled to " + damage + "!");
            setNextAttackCritical(false);
        }

        target.takeDamage(damage);
        System.out.println("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
    }

    @Override
    public void heavyAttack(Entity target) {
        if (getMp() < 8) {
            System.out.println("❌ Not enough mana for Heavy Attack!");
            return;
        }
        setMp(getMp() - 8);
        int damage = 20;

        //Critical Action (if enabled)
        if (isNextAttackCritical()) {
            damage *= 2;
            System.out.println("⚡ CRITICAL HIT! Damage doubled to " + damage + "!");
            setNextAttackCritical(false);
        }

        target.takeDamage(damage);
        System.out.println("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
    }

    @Override
    public void defend() {
        if (getMp() < 6) {
            System.out.println("❌ Not enough mana to defend!");
            return;
        }
        setMp(getMp() - 6);
        setDefending(true);
        System.out.println("🛡️ " + getName() + " is defending! Next attack will be halved.");
    }

    @Override
    public void heal() {
        if (getMp() < 12) {
            System.out.println("❌ Not enough mana to heal!");
            return;
        }
        setMp(getMp() - 12);
        int healAmount = 20;
        setHp(getHp() + healAmount);
        if (getHp() > getMaxHP()) setHp(getMaxHP());
        System.out.println("💚 " + getName() + " healed " + healAmount + " HP!");
    }
}