package xyz.tbvns.rogue_block.Upgrades;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Text;
import xyz.tbvns.rogue_block.Managers.DataManager;

import java.util.ArrayList;
import java.util.List;

public interface Upgrade {
    default Class getParent() {
        return null;
    }

    default String getName() {
        return "unnamed upgrade";
    }

    default String getDesc() {
        return "no description";
    }

    default int getCost() {
        return 0;
    }

    default void onBought(ServerPlayerEntity entity) {
        DataManager.getPlayerState(entity).getUpgrades().add(this.getClass());
    }

    default UpgradeType getType() {
        return UpgradeType.Passive;
    }

    default int[] getGuiPos() {
        return new int[]{0, 0};
    }

    default ItemStack itemDisplay() {
        return Items.BEDROCK.getDefaultStack();
    }

    default UpgradeRarity getRarity() {
        return UpgradeRarity.common;
    }

    default Component generateTooltip() {
        Component component;

        switch (getRarity()) {
            case rare -> component = Component.text(getName(),
                    TextColor.color(255, 59, 208),
                    TextDecoration.BOLD);
            case medium -> component = Component.text(getName(),
                    TextColor.color(255, 211, 0),
                    TextDecoration.BOLD);
            default -> component = Component.text(getName(),
                    TextColor.color(13, 255, 0),
                    TextDecoration.BOLD);
        }

        component =
            component.appendNewline()
                .append(Component.text(getDesc())
                        .color(TextColor.color(136, 133, 136))
                        .decoration(TextDecoration.UNDERLINED, false)
                        .decoration(TextDecoration.BOLD, false)
                )
                .appendNewline()
                .append(Component.text("Type: ", TextColor.color(255, 77, 0)))
                .append(Component.text(
                        getType().toString(),
                        TextColor.color(255, 184, 0),
                        TextDecoration.BOLD,
                        TextDecoration.UNDERLINED)
                )
                .decoration(TextDecoration.UNDERLINED, false)
                .appendNewline()
                .append(Component.text("Price: ",
                        TextColor.color(94, 229, 83),
                        TextDecoration.BOLD)
                )
                .append(Component.text(getCost(),
                        TextColor.color(0, 238, 255),
                        TextDecoration.BOLD,
                        TextDecoration.UNDERLINED
                )
            );

        return component;
    }
}
