#include "mod_hirelings.h"
#include "Chat.h"
#include "Config.h"
#include "Log.h"
#include "ScriptMgr.h"

using namespace Acore::ChatCommands;

// v0: hello-world stub. Proves the module loads, its config flag is readable, and a command
// registers and responds -- no hireling gameplay yet. See PLAN.md for the actual roadmap
// (create hirelings, summon via a world object, simple test missions).

class HirelingsCommandScript : public CommandScript
{
public:
    HirelingsCommandScript() : CommandScript("HirelingsCommandScript") { }

    ChatCommandTable GetCommands() const override
    {
        static ChatCommandTable commandTable =
        {
            { "hireling", HandleHirelingCommand, SEC_PLAYER, Console::No },
        };

        return commandTable;
    }

    static bool HandleHirelingCommand(ChatHandler* handler)
    {
        if (!sConfigMgr->GetOption("Hirelings.Enable", true))
        {
            handler->PSendSysMessage("The Hirelings module is currently disabled.");
            return true;
        }

        handler->PSendSysMessage("A Steamwheedle courier tips their hat: 'Contracts aren't ready yet, but soon (TM).'");
        return true;
    }
};

class Hirelings_World : public WorldScript
{
public:
    Hirelings_World() : WorldScript("Hirelings_World") { }

    void OnStartup() override
    {
        LOG_INFO("server.loading", "mod-hirelings: loaded (v0 hello-world stub, enabled={}).",
            sConfigMgr->GetOption("Hirelings.Enable", true));
    }
};

void AddSC_mod_hirelings()
{
    new HirelingsCommandScript();
    new Hirelings_World();
}