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.KnightArmor;
import org.project.item.weapons.Sword;
import org.project.item.weapons.Weapon;

import java.util.ArrayList;


public class Knight extends Player implements ICombatActions {
    public Knight(String name) {
        super(name, 45, 45, new Sword(), new KnightArmor());
    }

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

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

        //Stunning the enemies
        if (getWeapon() instanceof Sword) {
            ((Sword) getWeapon()).uniqueAbility(target);
        }

        System.out.println("💥 Shield Bash! Enemy is stunned!");
    }

    public void lightAttack(Entity target) {
        int damage = 10;
        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;
        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!");
    }
}
