local AddonName, PrivateTable = ...
local Cerebro = LibStub("AceAddon-3.0"):GetAddon(AddonName)
local TooltipInjector = Cerebro:NewModule("TooltipInjector", "AceHook-3.0", "AceEvent-3.0")

function TooltipInjector:OnEnable()
    self:SecureHook(GameTooltip, "OnTooltipSetUnit")
end

function TooltipInjector:OnTooltipSetUnit(tooltip)
	local _, unit = tooltip:GetUnit()
	if not unit or not UnitIsPlayer(unit) then return end
	if not UnitIsFriend("player", unit) then return end

	local targetName = Cerebro:GetFullPlayerName(UnitName(unit))
	if not targetName then return end

	-- Add EPGP Info
	local player = Cerebro.Player:New(targetName)
	local ep = player:GetEP()
	local gp = player:GetRawGP() -- Show raw GP maybe?
	local pr = player:GetPR()
	
	tooltip:AddLine(" ")
	tooltip:AddLine("|cffffd700Cerebro:|r")
	tooltip:AddDoubleLine("PR:", string.format("|cffffffff%.2f|r", pr))
	tooltip:AddDoubleLine("EP / GP:", string.format("|cffffffff%d / %d|r", ep, gp))
	
	tooltip:Show()
end
