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;

public class Knight extends Player{

    private boolean isStunned = false;
    public Knight(String name)
    {
        super(name, 120, 60, new Sword(), new KnightArmor());
    }

    @Override
    public int getBaseDamage()
    {
        return 15;
        //Knight has the highest base dmg
    }
    @Override
    public void specialAbility(Entity target)
    {
        if (this.getMp() < costSpecial)
        {
            System.out.println(YELLOW+"Not enough Mana for shield bash!"+RESET);
            return;
        }

        this.setMp(this.getMp() - costSpecial);
        if (target instanceof Enemy) {
            Enemy enemyTarget = (Enemy) target;
            enemyTarget.setStunned(true);
            System.out.println("🛡️ " + PURPLE+getName() + " used Shield Bash!" +RESET+ "( " + BLUE+costSpecial+RESET + " Mana)");
            System.out.println("Enemy is Stunned and will skip their next turn!");
        }

        int damage = getBaseDamage() + (weapon != null ? weapon.getDamage() : 0) + 10;
        target.takeDamage(damage);
        System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+damage+RESET + " damage!");
    }

    public void heavyAttack(Entity target)
    {
        int baseDmg = getBaseDamage() * 2;
        int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
        int totalDmg = baseDmg + weaponDmg;

        if (this.getMp() < costHeavy)
        {
            System.out.println(YELLOW+"Not enough Mana for Heavy Attack!"+RESET);
            return;
        }
        this.setMp(this.getMp() - costHeavy);

        target.takeDamage(totalDmg);
        System.out.println("💥 " + name + " (Knight) used Heavy Attack! " + "( " + BLUE+costHeavy+RESET + " Mana)");
        System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " damage!");
    }

    public void lightAttack(Entity target)
    {
        int baseDmg = getBaseDamage();
        int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
        int totalDmg = baseDmg + weaponDmg;
        target.takeDamage(totalDmg);
        System.out.println("⚔️ " + name + " (Knight) used Light Attack! " + "( " + BLUE+costLight+RESET + " Mana)");
        System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " damage!");
    }

    @Override
    public void heal(int health)
    {
        setHp(getHp() + health);
        if (this.getHp() > getMaxHP()) {
            setHp(getMaxHP());
        }
        System.out.println("💚" + name + " (Knight) healed " + health + " HP!" );
    }
    @Override
    public void defend()
    {
        if (this.getMp() >= costDefend)
        {
            this.setMp(getMp() - costDefend);
            this.setDefending(true);
            System.out.println("🛡️" + name + " (Knight) is defending!" + "( " + BLUE+costDefend+RESET + " Mana)");
        }
        else
        {
            System.out.println(YELLOW+"Not enough Mana!"+RESET);
        }
    }
}
