#include <ChatCommand/HelpCommand/HelpCommand.hpp>

HelpCommand::HelpCommand(LocalWorld &world)
{
    addVariant(
        "<THIS SHOULD NOT BE VISIBLE>",
        [&world](Player &player)
        {
            std::vector<std::string> commandNames;
            for (const auto& [commandName, _] : world.commandTable)
            {
                if (commandName == "help")
                {
                    continue;
                }

                commandNames.push_back(commandName);
            }

            std::sort(commandNames.begin(), commandNames.end());

            player.writeChat("Available commands:", Color::help);

            for (const auto &commandName : commandNames)
            {
                auto command = world.commandTable[commandName];
                command->showHelp(player, commandName, Color::help);
            }
        }
    );
}