diff Modules/Utils.lua @ 58:bdf3aba93aa9

Refactored the way the window for /ia invested works so I can add more tabs.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sun, 25 Jul 2010 15:51:00 -0700
parents 003de902ae64
children e7d287cc3b02
line wrap: on
line diff
--- a/Modules/Utils.lua	Sun Jul 25 12:52:14 2010 -0700
+++ b/Modules/Utils.lua	Sun Jul 25 15:51:00 2010 -0700
@@ -39,6 +39,31 @@
 	return format("%s%s%s%s", prefix, gold, silver, copper)
 end
 
+-- Copied from QuickAuctions
+function ItemAuditor.validateMoney(value)
+	local gold = tonumber(string.match(value, "([0-9]+)|c([0-9a-fA-F]+)g|r") or string.match(value, "([0-9]+)g"))
+	local silver = tonumber(string.match(value, "([0-9]+)|c([0-9a-fA-F]+)s|r") or string.match(value, "([0-9]+)s"))
+	local copper = tonumber(string.match(value, "([0-9]+)|c([0-9a-fA-F]+)c|r") or string.match(value, "([0-9]+)c"))
+	
+	if( not gold and not silver and not copper ) then
+		return false;
+		-- return L["Invalid monney format entered, should be \"#g#s#c\", \"25g4s50c\" is 25 gold, 4 silver, 50 copper."]
+	end
+	
+	return true
+end
+
+-- Copied from QuickAuctions
+function ItemAuditor.parseMoney(value)
+	local gold = tonumber(string.match(value, "([0-9]+)|c([0-9a-fA-F]+)g|r") or string.match(value, "([0-9]+)g"))
+	local silver = tonumber(string.match(value, "([0-9]+)|c([0-9a-fA-F]+)s|r") or string.match(value, "([0-9]+)s"))
+	local copper = tonumber(string.match(value, "([0-9]+)|c([0-9a-fA-F]+)c|r") or string.match(value, "([0-9]+)c"))
+		
+	-- Convert it all into copper
+	return (copper or 0) + ((gold or 0) * COPPER_PER_GOLD) + ((silver or 0) * COPPER_PER_SILVER)
+	
+end
+
 -- This is only here to make sure this doesn't blow up if ReplaceItemCache is never called
 local item_db = {}