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

------------------------------
--		Options Equates		--
------------------------------
local Current, Level, Spark, Empty = 1, 1, 1, 1
local Earned, Honor, Splinter, Vintage = 2, 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
local tokenNextUpdate = 0
local TOKEN_UPDATE_INTERVAL = 300 -- 5 minutes
function Ns.FunctionList.WowToken(HUD, data, options, ...)

	local now = GetTime()
	if now >= tokenNextUpdate then
		C_WowTokenPublic.UpdateMarketPrice()
		tokenNextUpdate = now + TOKEN_UPDATE_INTERVAL
	end
	local token = C_WowTokenPublic.GetCurrentMarketPrice() or 0
	local display, color = 0, ""

	token = floor(token / 10000)

	-- if oldToken < token then
	-- 	color = Ns.greenText
	-- elseif oldToken > token then
	-- 	color = Ns.redText
	-- else
	-- 	color = ""
	-- end

	-- print(oldToken, token)

	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, color .. 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
------------------------------------------------

-- Adventurer Dawncrest
function Ns.FunctionList.Adventurer(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(3383)
	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
----------------------------------------------

-- Veteran Dawncrest
function Ns.FunctionList.Veteran(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(3341)
	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
----------------------------------------------

-- Champion Dawncrest
function Ns.FunctionList.Champion(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(3343)
	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
----------------------------------------------

-- Hero Dawncrest
function Ns.FunctionList.Hero(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(3345)
	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
----------------------------------------------

-- Myth Dawncrest
function Ns.FunctionList.Myth(HUD, data, options, ...)

	local EB = options.Current_Earned
	local currency = C_CurrencyInfo.GetCurrencyInfo(3347)
	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
----------------------------------------------

-- Puzzling Cartel Chip
function Ns.FunctionList.Puzzling(HUD, data, options, ...)

	local item = C_Item.GetItemCount(250741, true)

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

-- Untethered Coin
-- function Ns.FunctionList.Ethereal(HUD, data, options, ...)

-- 	local currency = C_CurrencyInfo.GetCurrencyInfo(3278)
-- 	local display = 0

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

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

-- Untethered Coin
-- function Ns.FunctionList.Untethered(HUD, data, options, ...)

-- 	local currency = C_CurrencyInfo.GetCurrencyInfo(3303)
-- 	local display = 0

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

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

-- Displaced Corrupted Mementos
-- function Ns.FunctionList.Mementos(HUD, data, options, ...)

-- 	local currency = C_CurrencyInfo.GetCurrencyInfo(3149)
-- 	local display = 0

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

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

-- Dawnlight Manaflux (Catalyst)
function Ns.FunctionList.Catalyst(HUD, data, options, ...)

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

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

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

-- Market Research
-- function Ns.FunctionList.Market(HUD, data, options, ...)

-- 	local currency = C_CurrencyInfo.GetCurrencyInfo(3226)
-- 	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
----------------------------------------------

-- 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
----------------------------------------------

-- Voidlight Marl
-- function Ns.FunctionList.Voidlight(HUD, data, options, ...)

-- 	local currency = C_CurrencyInfo.GetCurrencyInfo(3316)
-- 	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
----------------------------------------------

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

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

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

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

-- Kaja'Cola Can
-- function Ns.FunctionList.KajaCola(HUD, data, options, ...)

-- 	local EB = options.Empty_Vintage
-- 	local empty = C_CurrencyInfo.GetCurrencyInfo(3218)
-- 	local vintage = C_CurrencyInfo.GetCurrencyInfo(3220)
-- 	local emptyCur, vintageCur = 0, 0
-- 	local returnText

-- 	if empty.name and tonumber(empty.quantity) then emptyCur = empty.quantity
-- 	else emptyCur = 0 end
-- 	if vintage.name and tonumber(vintage.quantity) then vintageCur = vintage.quantity
-- 	else vintageCur = 0 end

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

-- 	if Ns.Band(EB, Empty) then returnText = emptyCur end
-- 	if Ns.Band(EB, Vintage) then returnText = vintageCur end
-- 	if Ns.Band(EB, Both) then returnText = emptyCur .. "/" .. vintageCur end
-- 	if returnText == nil then returnText = 0 end

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

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

-- 	local currency = C_CurrencyInfo.GetCurrencyInfo(2815)
-- 	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
------------------------------------------------

-- Community Coupons
function Ns.FunctionList.Coupons(HUD, data, options, ...)

	local coupons = C_CurrencyInfo.GetCurrencyInfo(3363)
	local display = 0

	if coupons.name and tonumber(coupons.quantity) then display = coupons.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 Radiance
function Ns.FunctionList.Spark(HUD, data, options, ...)

	local EB = options.Splint_Spark
	local returnText
	local spark = C_Item.GetItemCount(232875, true)
	local dust = C_CurrencyInfo.GetCurrencyInfo(3212)
	local splinter = 0

	if dust.name and tonumber(dust.quantity) then splinter = dust.quantity
	else splinter = 0 end

	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
------------------------------------------------

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

-- 	local bronze = C_CurrencyInfo.GetCurrencyInfo(3252)
-- 	local display = 0

-- 	if bronze.name and tonumber(bronze.quantity) then display = bronze.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
------------------------------------------------

-- Twilight's Blade Insignia
function Ns.FunctionList.Twilight(HUD, data, options, ...)

	local currency = C_CurrencyInfo.GetCurrencyInfo(3319)
	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
------------------------------------------------

-- Love Tokens
-- function Ns.FunctionList.LoveToken(HUD, data, options, ...)

-- 	local item = C_Item.GetItemCount(49927, true)

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


-- Infinite Power
-- function Ns.FunctionList.InfPower(HUD, data, options, ...)

-- 	local power = C_CurrencyInfo.GetCurrencyInfo(3268)
-- 	local display = 0

-- 	if power.name and tonumber(power.quantity) then display = power.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
------------------------------------------------

-- Infinite Knowledge
-- function Ns.FunctionList.InfKnow(HUD, data, options, ...)

-- 	local know = C_CurrencyInfo.GetCurrencyInfo(3292)
-- 	local display = 0

-- 	if know.name and tonumber(know.quantity) then display = know.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
------------------------------------------------