
local moduleName = "BlinkHealthTextModule"
local module = {}
_G[moduleName] = module
module.addon = {}

function module:getAuraInfo(unit, spell, filter)
	if not UnitExists(unit) then return end

	local i = 1
	local countText, r, g, b = "", 1.0, 0.5, 0.1

	local name, rank, icon, count, debufType, duration, expirationTime = UnitAura(unit, i, filter)
	while name do
		if name == spell or name:find(spell) then
			return name, rank, icon, count, debufType, duration, expirationTime
		end
		i = i + 1
		name, rank, icon, count, debufType, duration, expirationTime = UnitAura(unit, i, filter)
	end
end

function module:getAuraCount(unit, spell, filter, iconOnly)
	if not UnitExists(unit) then return "" end

	local i = 1
	local countText, r, g, b = "", 1.0, 0.5, 0.1

	local name, rank, icon, count, debufType, duration, expirationTime = self:getAuraInfo(unit, spell, filter)
	if name then
		if( count <= 0 )then
			return ""
		end

		if not expirationTime then
			-- nothing
		else
			local timeLeft = (expirationTime-GetTime()) / duration
			if timeLeft < 0.3 then -- 30%미만 - 빨간색
				r = 1.0
				g = 0.1
				b = 0.1
			elseif timeLeft < 0.6 then -- 30%~60% - 파란색
				r = 0.0
				g = 0.39
				b = 0.88
			else -- 60%이상 녹색
				r = 0.1
				g = 1.0
				b = 0.1
			end
		end
		if iconOnly then
			return (":|T%s:0|t"):format(icon)
		else
			return (":|cff%02x%02x%02x%d|r"):format(r * 255, g * 255, b * 255, count)
		end
	end
	return ""
end

function module:init() end
function module:getPlayerText() end
function module:getTargetText() end
function module:getPlayerHealthColor() end
function module:getPlayerPowerColor() end
function module:getTargetHealthColor() end
function module:getTargetPowerColor() end