local AddName, Ns = ...
local L = Ns.L

------------------------------
--		Options Equates		--
------------------------------
local Current, Level, Spark = 1, 1, 1
local Earned, Honor, Splinter = 2, 2, 2
local Both = 3

--------------------------
--		Currency		--
--------------------------

-- Money
function Ns.FunctionList.Gold(HUD, data, options, ...)

	local money = GetMoney()
	local gold = floor(money / 1e4)
	local formattedMoney = (C_CurrencyInfo.GetCoinTextureString(money))

	if options.Display_Gold then
		if options.Decimals_Default == 0 then
			formattedMoney = BreakUpLargeNumbers(gold)
		elseif options.Decimals_Default == 1 then
			formattedMoney = Ns.ShortNumbers(gold, 0)
		elseif options.Decimals_Default == 2 then
			formattedMoney = Ns.ShortNumbers(gold, 1)
		else
			formattedMoney = Ns.ShortNumbers(gold, 2)
		end
	end

	HUD:UpdateText(data, formattedMoney)
end
------------------------------------------------

-- WoW Token
function Ns.FunctionList.WowToken(HUD, data, options, ...)

	C_WowTokenPublic.UpdateMarketPrice()
	local token = C_WowTokenPublic.GetCurrentMarketPrice() or 0
	local display = 0

	token = floor(token / 10000)

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(token)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(token, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(token, 1)
	else
		display = Ns.ShortNumbers(token, 2)
	end

	HUD:UpdateText(data, display)
end
------------------------------------------------

-- Honor
function Ns.FunctionList.Honor(HUD, data, options, ...)

	local EB = options.Level_HonorPoints
	local honorLevel = UnitHonorLevel("player")
	local honorPoints = C_CurrencyInfo.GetCurrencyInfo(1792)--UnitHonor("player")
	local ratedHonor = C_CurrencyInfo.GetCurrencyInfo(1891)
	local ratedTotal, hpDisplay = 0, 0
	local returnText

	if honorPoints.name and tonumber(honorPoints.quantity) then hpDisplay = honorPoints.quantity else hpDisplay = 0 end
	if ratedHonor.name and tonumber(ratedHonor.quantity) then ratedTotal = ratedHonor.quantity end

	if options.Display_Rated then hpDisplay = ratedTotal end

	if Ns.Band(EB, Level) then returnText = honorLevel end
	if Ns.Band(EB, Honor) then returnText = hpDisplay end
	if Ns.Band(EB, Both) then returnText = honorLevel .. "/" .. hpDisplay end
	if returnText == nil then returnText = 0 end

	HUD:UpdateText(data, returnText)
end
------------------------------------------------

-- Valorstones
function Ns.FunctionList.Valorstones(HUD, data, options, ...)

	local valorstones = C_CurrencyInfo.GetCurrencyInfo(3008)
	local display = 0

	if valorstones.name and tonumber(valorstones.quantity) then display = valorstones.quantity
	else display = 0 end

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(display)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(display, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(display, 1)
	else
		display = Ns.ShortNumbers(display, 2)
	end

	HUD:UpdateText(data, display)
end
------------------------------------------------

-- Weathered Harbinger Crest
function Ns.FunctionList.Weathered(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(2914)
	local max = currency.maxQuantity or 0
	local earn = currency.totalEarned or 0
	local display = 0
	local capColor = ""
	local cap = ""
	local returnText

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	if options.Display_Weekly then cap = "/" .. max end
	if options.Display_Max and earn == max then capColor = Ns.redText end

	if Ns.Band(EB, Current) then returnText = capColor .. display .. cap end
	if Ns.Band(EB, Earned) then returnText = capColor .. earn .. cap end
	if Ns.Band(EB, Both) then returnText = capColor .. display .. "/" .. earn .. cap end
	if returnText == nil then returnText = 0 end

	HUD:UpdateText(data, returnText)
end
----------------------------------------------

-- Carved Harbinger Crest
function Ns.FunctionList.Carved(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(2915)
	local max = currency.maxQuantity or 0
	local earn = currency.totalEarned or 0
	local display = 0
	local capColor = ""
	local cap = ""
	local returnText

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	if options.Display_Weekly then cap = "/" .. max end
	if options.Display_Max and earn == max then capColor = Ns.redText end

	if Ns.Band(EB, Current) then returnText = capColor .. display .. cap end
	if Ns.Band(EB, Earned) then returnText = capColor .. earn .. cap end
	if Ns.Band(EB, Both) then returnText = capColor .. display .. "/" .. earn .. cap end
	if returnText == nil then returnText = 0 end

	HUD:UpdateText(data, returnText)
end
----------------------------------------------

-- Runed Harbinger Crest
function Ns.FunctionList.Runed(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(2916)
	local max = currency.maxQuantity or 0
	local earn = currency.totalEarned or 0
	local display = 0
	local capColor = ""
	local cap = ""
	local returnText

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	if options.Display_Weekly then cap = "/" .. max end
	if options.Display_Max and earn == max then capColor = Ns.redText end

	if Ns.Band(EB, Current) then returnText = capColor .. display .. cap end
	if Ns.Band(EB, Earned) then returnText = capColor .. earn .. cap end
	if Ns.Band(EB, Both) then returnText = capColor .. display .. "/" .. earn .. cap end
	if returnText == nil then returnText = 0 end

	HUD:UpdateText(data, returnText)
end
----------------------------------------------

-- Gilded Harbinger Crest
function Ns.FunctionList.Gilded(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(2917)
	local max = currency.maxQuantity or 0
	local earn = currency.totalEarned or 0
	local display = 0
	local capColor = ""
	local cap = ""
	local returnText

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	if options.Display_Weekly then cap = "/" .. max end
	if options.Display_Max and earn == max then capColor = Ns.redText end

	if Ns.Band(EB, Current) then returnText = capColor .. display .. cap end
	if Ns.Band(EB, Earned) then returnText = capColor .. earn .. cap end
	if Ns.Band(EB, Both) then returnText = capColor .. display .. "/" .. earn .. cap end
	if returnText == nil then returnText = 0 end

	HUD:UpdateText(data, returnText)
end
----------------------------------------------

-- Harmonized Silk (Catalyst)
function Ns.FunctionList.Catalyst(HUD, data, options, ...)

	local currency = C_CurrencyInfo.GetCurrencyInfo(2813)
	local display = 0

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	HUD:UpdateText(data, display)
end
----------------------------------------------

-- Sizzling Cinderpollen
function Ns.FunctionList.Cinder(HUD, data, options, ...)

	local item = C_Item.GetItemCount(225557, true)

	HUD:UpdateText(data, item)
end
----------------------------------------------

-- Undercoin
function Ns.FunctionList.Undercoin(HUD, data, options, ...)

	local currency = C_CurrencyInfo.GetCurrencyInfo(2803)
	local display = 0

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(display)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(display, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(display, 1)
	else
		display = Ns.ShortNumbers(display, 2)
	end

	HUD:UpdateText(data, display)
end
----------------------------------------------

-- Restored Coffer Key
function Ns.FunctionList.CofferKey(HUD, data, options, ...)

	local currency = C_CurrencyInfo.GetCurrencyInfo(3028)
	local display = 0

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	HUD:UpdateText(data, display)
end
----------------------------------------------

-- Resonance Crystals
function Ns.FunctionList.Crystals(HUD, data, options, ...)

	local crystals = C_CurrencyInfo.GetCurrencyInfo(2815)
	local display = 0

	if crystals.name and tonumber(crystals.quantity) then display = crystals.quantity
	else display = 0 end

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(display)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(display, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(display, 1)
	else
		display = Ns.ShortNumbers(display, 2)
	end

	HUD:UpdateText(data, display)
end
----------------------------------------------

-- Kej
function Ns.FunctionList.Kej(HUD, data, options, ...)

	local currency = C_CurrencyInfo.GetCurrencyInfo(3056)
	local display = 0

	if currency.name and tonumber(currency.quantity) then display = currency.quantity
	else display = 0 end

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(display)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(display, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(display, 1)
	else
		display = Ns.ShortNumbers(display, 2)
	end

	HUD:UpdateText(data, display)
end
----------------------------------------------


-- Bloody Tokens
function Ns.FunctionList.BloodyTokens(HUD, data, options, ...)

	local bloodyTokens = C_CurrencyInfo.GetCurrencyInfo(2123)
	local bloodyDisplay = 0

	if bloodyTokens.name and tonumber(bloodyTokens.quantity) then bloodyDisplay = bloodyTokens.quantity
	else bloodyDisplay = 0 end

	HUD:UpdateText(data, bloodyDisplay)
end
------------------------------------------------

-- Valor points
function Ns.FunctionList.ValorPoints(HUD, data, options, ...)

	local valor = C_CurrencyInfo.GetCurrencyInfo(1191)
	local valorDisplay = 0

	if valor.name and tonumber(valor.quantity) then valorDisplay = valor.quantity
	else valorDisplay = 0 end

	HUD:UpdateText(data, valorDisplay)
end
------------------------------------------------

-- Conquest
function Ns.FunctionList.Conquest(HUD, data, options, ...)

	local conquest = C_CurrencyInfo.GetCurrencyInfo(1602)
	local conquestDisplay = 0

	if conquest.name and tonumber(conquest.quantity) then conquestDisplay = conquest.quantity
	else conquestDisplay = 0 end

	HUD:UpdateText(data, conquestDisplay)
end
------------------------------------------------

-- Timewarped Badges
function Ns.FunctionList.Timewarped(HUD, data, options, ...)

	local timewarped = C_CurrencyInfo.GetCurrencyInfo(1166)
	local display = 0

	if timewarped.name and tonumber(timewarped.quantity) then display = timewarped.quantity
	else display = 0 end

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(display)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(display, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(display, 1)
	else
		display = Ns.ShortNumbers(display, 2)
	end

	HUD:UpdateText(data, display)
end
------------------------------------------------

-- Trader's Tender
function Ns.FunctionList.TraderTender(HUD, data, options, ...)

	local trader = C_CurrencyInfo.GetCurrencyInfo(2032)
	local display = 0

	if trader.name and tonumber(trader.quantity) then display = trader.quantity
	else display = 0 end

	if options.Decimals_Default == 0 then
		display = BreakUpLargeNumbers(display)
	elseif options.Decimals_Default == 1 then
		display = Ns.ShortNumbers(display, 0)
	elseif options.Decimals_Default == 2 then
		display = Ns.ShortNumbers(display, 1)
	else
		display = Ns.ShortNumbers(display, 2)
	end

	HUD:UpdateText(data, display)
end
------------------------------------------------

-- Spark of Omens
function Ns.FunctionList.Spark(HUD, data, options, ...)

	local EB = options.Splint_Spark
	local returnText
	local spark = C_Item.GetItemCount(211296, true)
	local splinter = C_Item.GetItemCount(211297, true)

	if Ns.Band(EB, Spark) then returnText = spark end
	if Ns.Band(EB, Splinter) then returnText = splinter end
	if Ns.Band(EB, Both) then returnText = spark .. " (" .. splinter .. ")" end
	if returnText == nil then returnText = 0 end

	HUD:UpdateText(data, returnText)
end
------------------------------------------------