package org.project.entity.players;

import org.project.entity.Entity;
import org.project.item.weapons.BasicWeapon;

import java.util.Random;

public class Assassin extends Player
{

    private static final int HEAVY_COST = 15;
    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";

    private Random random = new Random();

    public Assassin(String name) {
        super(name, 90, 80, new BasicWeapon("Dagger", 18));
    }

    @Override
    public void lightAttack(Entity target)
    {

        int dmg = weapon.getDamage() + 12;

        // 25% critical chance
        if (random.nextInt(100) < 25)
        {
            dmg *= 2;
            System.out.println(PURPLE + "💀 CRITICAL HIT!" + RESET);
        }

        target.takeDamage(dmg);

        System.out.println(YELLOW + "🗡️ " + name +
                " strikes for " + dmg + " damage!" + RESET);
    }

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

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

        System.out.println(PURPLE + "⚡ Shadow Slash deals " +
                dmg + " damage!" + RESET);
    }

    @Override
    public void defendAction()
    {
        defend();
        System.out.println(BLUE + "🛡️ Quick dodge stance!" + RESET);
    }

    @Override
    public void healAction()
    {
        heal(20);
        System.out.println(GREEN + "💖 " + name +
                " uses bandage restoring 20 HP!" + RESET);
    }

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

        mp -= SPECIAL_COST;

        setInvisible(true);

        int dmg = weapon.getDamage() + 50;
        target.takeDamage(dmg);

        System.out.println(BLUE + "🌑 SHADOW STRIKE deals " +
                dmg + " damage!" + RESET);

        System.out.println(YELLOW + "👤 " + name +
                " becomes INVISIBLE!" + RESET);
    }
}