local addonName, ESKP = ...

ESKP.name = addonName
ESKP.version = "0.2.0-beta"

function ESKP:Print(message)
    DEFAULT_CHAT_FRAME:AddMessage("|cff62d6ffESK Pursuit:|r " .. tostring(message))
end

local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:SetScript("OnEvent", function(_, event)
    if event == "PLAYER_LOGIN" then
        ESKP:InitializeDatabase()
        ESKP:InitializeTracker()
        ESKP:InitializeUI()
        ESKP:Print("Loaded. Type |cff00ff98/pursuit|r to begin a farm.")
    end
end)

SLASH_ESKPURSUIT1 = "/pursuit"
SLASH_ESKPURSUIT2 = "/eskpursuit"
SlashCmdList.ESKPURSUIT = function(message)
    local command = strtrim((message or ""):lower())
    if command == "ready" then
        ESKP.UI:Show("READY")
    elseif command == "watchlist" then
        ESKP.UI:Show("WATCHLIST")
    elseif command == "tracker" then
        ESKP.UI:ToggleTracker()
    elseif command == "reset" then
        ESKP:ResetWindowPosition()
        ESKP.UI:Show()
        ESKP:Print("Window position reset.")
    elseif command == "help" then
        ESKP:Print("/pursuit [ready|watchlist|tracker|reset]")
    else
        ESKP.UI:Toggle()
    end
end
