package org.project.entity.players;

import org.project.entity.Entity;
import org.project.entity.enemies.Enemy;
import org.project.item.armors.Armor;
import org.project.item.armors.AssassinMask;
import org.project.item.weapons.Dagger;
import org.project.item.weapons.Weapon;
import org.project.location.NarrativeConsole;

public class Assassin extends Player implements Entity, ICombatActions  {
    public Assassin(String name) {
        super(name, 45, 60, new Dagger(), new AssassinMask());
        setHp(getMaxHP());
        setMp(getMaxMP());
    }

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

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

        setInvisible(true);
        setNextAttackCritical(true);

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

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

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

        target.takeDamage(damage);
        NarrativeConsole.printDamage("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
    }

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

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

        target.takeDamage(damage);
        NarrativeConsole.printDamage("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
    }

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

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