package org.project.entity.players;

import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;
import org.project.Colors;

// TODO: UPDATE IMPLEMENTATION
public class Player implements Entity{
    protected String name;
    Weapon weapon;
    Armor armor;
    protected int hp = 100;
    private int maxHP = 100;
    protected int mp = 100;
    private int maxMP = 100;
    private boolean isDefending = false;

    public Player(String name, Weapon weapon, Armor armor) {
        this.name = name;
        this.weapon = weapon;
        this.armor = armor;
    }

    public void SpecialAttack(Entity target, int time) {
        System.out.println("poof");
    }


    public void HeavyAttack(Entity target) {
        target.takeDamage(weapon.getHeavyDamage());
        mp -= weapon.getManaCost();

        System.out.println(Colors.CYAN + "⚡ HEAVY ATTACK! ⚡" + Colors.RESET);
        System.out.println(Colors.GREEN + "BOOM!" + Colors.RESET);
        System.out.println(Colors.YELLOW + " 🗡️  Damage: " + weapon.getHeavyDamage() + Colors.RESET);
    }

    @Override
    public void LightAttack(Entity target) {
        target.takeDamage(weapon.getLightDamage());

        System.out.println(Colors.CYAN + "⚡ LIGHT ATTACK! ⚡" + Colors.RESET);
        System.out.println(Colors.GREEN + " SMASH!" + Colors.RESET);
        System.out.println(Colors.YELLOW + " 🗡️  Damage: " + weapon.getLightDamage() + Colors.RESET);
    }

    public void defend() {
        if (!isDefending) {
            mp -= 10;
        }
        isDefending = !isDefending;

        System.out.println("🛡️  Defend! 🛡️");
        System.out.println(Colors.BLUE + "THWACK!" + Colors.RESET);
        System.out.println(" Damage reduced!");
    }

    @Override
    public void takeDamage(int damage) {
        hp -= damage - armor.getDefense();
        armor.decreacDurability();
    }

    @Override
    public void heal() {
        hp += 10;
        if (hp > maxHP) {
            hp = maxHP;
        }
        mp -= 10;

        System.out.println(Colors.GREEN + "💊 HEAL! 💊" + Colors.RESET);
        System.out.println(Colors.GREEN + "WHOOSH!" + Colors.RESET);
        System.out.println(Colors.RED + "  HP restored: +10" + Colors.RESET);
    }

    public void fillMana() {
            mp = maxMP;
    }

    public void fillHP() {hp=maxHP; }

    public void filldurability()
    {
        armor.filldur();
    }

    public String getName() {
        return name;
    }

    public int getHp() {
        return hp;
    }

    public int getMaxHP() {
        return maxHP;
    }

    public int getMp() {
        return mp;
    }

    public int getMaxMP() {
        return maxMP;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public Armor getArmor() {
        return armor;
    }

    public boolean getIsDefending() {
        return isDefending;
    }

}
