
local module = _G["BlinkHealthTextModule"]

if select(2, UnitClass("player")) ~= "SHAMAN" or not module then return end

local L_MAELSTROM_WEAPON = "Maelstrom Weapon"
if GetLocale()=="koKR" then
L_MAELSTROM_WEAPON = "소용돌이치는 무기"
end

module.config = {
	[L_MAELSTROM_WEAPON] = {2, 27, false},
}

function module:init()
	self.addon.mainFrame:RegisterEvent("PLAYER_ALIVE")
	self.addon.mainFrame:RegisterEvent("LEARNED_SPELL_IN_TAB")
	self.addon.mainFrame:RegisterEvent("CHARACTER_POINTS_CHANGED")
	self:update()
end

function module:update()
	local talentrank = 0
	for auraName, t in pairs(self.config) do
		_, _, _, _, talentrank = GetTalentInfo(t[1], t[2])
		self.config[auraName][3] = false
		if talentrank > 0 then
			self.config[auraName][3] = true
			if t[4] and self.addon and self.addon.mainFrame then
				self.addon.mainFrame:RegisterEvent(t[4])
			end
		end
	end
end

function module:LEARNED_SPELL_IN_TAB(...)
	self:update()
end
module.CHARACTER_POINTS_CHANGED = module.LEARNED_SPELL_IN_TAB
function module:PLAYER_ALIVE(...)
	self.addon.mainFrame:UnregisterEvent("PLAYER_ALIVE")
	self:update()
end

--function module:getTargetText()
function module:getPlayerText()
	local text = ""
	--local name, rank, icon, count, debufType, duration, expirationTime
	--local r, g, b = 1, 1, 1

	if self.config[L_MAELSTROM_WEAPON][3] then
		text = self:getAuraCount("player", L_MAELSTROM_WEAPON, "HELPFUL")
	end
	return text
end
