package org.project.entity.players;

import org.project.entity.Entity;
import org.project.item.armors.KnightArmor;
import org.project.item.weapons.Sword;

public class Knight extends Player {

    private static final int LIGHT_BONUS = 15;
    private static final int HEAVY_COST = 10;
    private static final int SPECIAL_COST = 25;

    private static final String RESET = "\u001B[0m";
    private static final String RED = "\u001B[31m";
    private static final String GREEN = "\u001B[32m";
    private static final String YELLOW = "\u001B[33m";
    private static final String BLUE = "\u001B[34m";
    private static final String PURPLE = "\u001B[35m";

    public Knight(String name)
    {
        super(name, 150, 40, new Sword());
        new KnightArmor();
    }

    @Override
    public void lightAttack(Entity target)
    {
        int dmg = weapon.getDamage() + LIGHT_BONUS;
        target.takeDamage(dmg);

        ((Sword) weapon).addCharge(1);

        System.out.println(
                YELLOW + "⚔️ " + name +
                        " slashes the enemy for " + dmg + " damage!" +
                        RESET
        );
    }

    @Override
    public void heavyAttack(Entity target)
    {
        if (mp < HEAVY_COST)
        {
            System.out.println(RED + "❌ Not enough MP for heavy attack!" + RESET);
            return;
        }

        mp -= HEAVY_COST;
        int dmg = weapon.getDamage() + 30;
        target.takeDamage(dmg);

        ((Sword) weapon).addCharge(2);

        System.out.println(PURPLE + "💥 " + name +
                " performs a HEAVY STRIKE for " + dmg + " damage!" + RESET);
    }

    @Override
    public void defendAction()
    {
        defend();
        System.out.println(BLUE + "🛡️ " + name +
                " raises his shield!" + RESET);
    }

    @Override
    public void healAction()
    {
        heal(30);
        System.out.println(GREEN + "💖 " + name +
                " heals for 30 HP!" + RESET);
    }

    @Override
    public void specialAbility(Entity target)
    {
        if (mp < SPECIAL_COST)
        {
            System.out.println(RED + "❌ Not enough MP!" + RESET);
            return;
        }

        mp -= SPECIAL_COST;

        int dmg = weapon.getDamage() + 45;
        target.takeDamage(dmg);
        target.setStunned(true);

        ((Sword) weapon).addCharge(3);

        System.out.println(
                BLUE + "🌋 " + name +
                        " uses EARTH SHATTERING STRIKE dealing " + dmg + " damage!" +
                        RESET
        );

        System.out.println(YELLOW + "⚠️ The enemy is STUNNED!" + RESET);
    }
}