Quantcast

Fix use of legacy armor set names, e.g., "T14", etc. for some classes.

Johnny C. Lam [04-06-14 - 18:46]
Fix use of legacy armor set names, e.g., "T14", etc. for some classes.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1273 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleEquipement.lua
diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua
index 1f6d540..e315f05 100644
--- a/OvaleEquipement.lua
+++ b/OvaleEquipement.lua
@@ -19,12 +19,13 @@ local strmatch = string.match
 local tonumber = tonumber
 local tostring = tostring
 local wipe = table.wipe
-local API_CreateFrame = CreateFrame

+local API_CreateFrame = CreateFrame
 local API_GetAuctionItemSubClasses = GetAuctionItemSubClasses
 local API_GetInventoryItemID = GetInventoryItemID
 local API_GetInventorySlotInfo = GetInventorySlotInfo
 local API_GetItemInfo = GetItemInfo
+local API_UnitClass = UnitClass
 local INVSLOT_AMMO = INVSLOT_AMMO
 local INVSLOT_BACK = INVSLOT_BACK
 local INVSLOT_BODY = INVSLOT_BODY
@@ -48,6 +49,9 @@ local INVSLOT_TRINKET2 = INVSLOT_TRINKET2
 local INVSLOT_WAIST = INVSLOT_WAIST
 local INVSLOT_WRIST = INVSLOT_WRIST

+-- Player's class.
+local _, self_class = API_UnitClass("player")
+
 -- frame for tooltip-scanning
 local self_tooltip = API_CreateFrame("GameTooltip", addonName .. "ScanningTooltip", nil, "GameTooltipTemplate")
 do
@@ -355,206 +359,106 @@ local OVALE_ARMORSET = {
 	[99638] = "T16_heal",
 	[99664] = "T16_tank",
 	-- Hunter
-	[85294] = "T14",
 	[85294] = "T14_melee",
-	[85295] = "T14",
 	[85295] = "T14_melee",
-	[85296] = "T14",
 	[85296] = "T14_melee",
-	[85297] = "T14",
 	[85297] = "T14_melee",
-	[85298] = "T14",
 	[85298] = "T14_melee",
-	[86634] = "T14",
 	[86634] = "T14_melee",
-	[86635] = "T14",
 	[86635] = "T14_melee",
-	[86636] = "T14",
 	[86636] = "T14_melee",
-	[86637] = "T14",
 	[86637] = "T14_melee",
-	[86638] = "T14",
 	[86638] = "T14_melee",
-	[87002] = "T14",
 	[87002] = "T14_melee",
-	[87003] = "T14",
 	[87003] = "T14_melee",
-	[87004] = "T14",
 	[87004] = "T14_melee",
-	[87005] = "T14",
 	[87005] = "T14_melee",
-	[87006] = "T14",
 	[87006] = "T14_melee",
-	[95255] = "T15",
 	[95255] = "T15_melee",
-	[95256] = "T15",
 	[95256] = "T15_melee",
-	[95257] = "T15",
 	[95257] = "T15_melee",
-	[95258] = "T15",
 	[95258] = "T15_melee",
-	[95259] = "T15",
 	[95259] = "T15_melee",
-	[95882] = "T15",
 	[95882] = "T15_melee",
-	[95883] = "T15",
 	[95883] = "T15_melee",
-	[95884] = "T15",
 	[95884] = "T15_melee",
-	[95885] = "T15",
 	[95885] = "T15_melee",
-	[95886] = "T15",
 	[95886] = "T15_melee",
-	[96626] = "T15",
 	[96626] = "T15_melee",
-	[96627] = "T15",
 	[96627] = "T15_melee",
-	[96628] = "T15",
 	[96628] = "T15_melee",
-	[96629] = "T15",
 	[96629] = "T15_melee",
-	[96630] = "T15",
 	[96630] = "T15_melee",
-	[99080] = "T16",
 	[99080] = "T16_melee",
-	[99081] = "T16",
 	[99081] = "T16_melee",
-	[99082] = "T16",
 	[99082] = "T16_melee",
-	[99085] = "T16",
 	[99085] = "T16_melee",
-	[99086] = "T16",
 	[99086] = "T16_melee",
-	[99157] = "T16",
 	[99157] = "T16_melee",
-	[99158] = "T16",
 	[99158] = "T16_melee",
-	[99159] = "T16",
 	[99159] = "T16_melee",
-	[99167] = "T16",
 	[99167] = "T16_melee",
-	[99168] = "T16",
 	[99168] = "T16_melee",
-	[99402] = "T16",
 	[99402] = "T16_melee",
-	[99403] = "T16",
 	[99403] = "T16_melee",
-	[99404] = "T16",
 	[99404] = "T16_melee",
-	[99405] = "T16",
 	[99405] = "T16_melee",
-	[99406] = "T16",
 	[99406] = "T16_melee",
-	[99573] = "T16",
 	[99573] = "T16_melee",
-	[99574] = "T16",
 	[99574] = "T16_melee",
-	[99577] = "T16",
 	[99577] = "T16_melee",
-	[99578] = "T16",
 	[99578] = "T16_melee",
-	[99660] = "T16",
 	[99660] = "T16_melee",
 	-- Mage
-	[85374] = "T14",
 	[85374] = "T14_caster",
-	[85375] = "T14",
 	[85375] = "T14_caster",
-	[85376] = "T14",
 	[85376] = "T14_caster",
-	[85377] = "T14",
 	[85377] = "T14_caster",
-	[85378] = "T14",
 	[85378] = "T14_caster",
-	[86714] = "T14",
 	[86714] = "T14_caster",
-	[86715] = "T14",
 	[86715] = "T14_caster",
-	[86716] = "T14",
 	[86716] = "T14_caster",
-	[86717] = "T14",
 	[86717] = "T14_caster",
-	[86718] = "T14",
 	[86718] = "T14_caster",
-	[87007] = "T14",
 	[87007] = "T14_caster",
-	[87008] = "T14",
 	[87008] = "T14_caster",
-	[87009] = "T14",
 	[87009] = "T14_caster",
-	[87010] = "T14",
 	[87010] = "T14_caster",
-	[87011] = "T14",
 	[87011] = "T14_caster",
-	[95260] = "T15",
 	[95260] = "T15_caster",
-	[95261] = "T15",
 	[95261] = "T15_caster",
-	[95262] = "T15",
 	[95262] = "T15_caster",
-	[95263] = "T15",
 	[95263] = "T15_caster",
-	[95264] = "T15",
 	[95264] = "T15_caster",
-	[95890] = "T15",
 	[95890] = "T15_caster",
-	[95891] = "T15",
 	[95891] = "T15_caster",
-	[95892] = "T15",
 	[95892] = "T15_caster",
-	[95893] = "T15",
 	[95893] = "T15_caster",
-	[95894] = "T15",
 	[95894] = "T15_caster",
-	[96634] = "T15",
 	[96634] = "T15_caster",
-	[96635] = "T15",
 	[96635] = "T15_caster",
-	[96636] = "T15",
 	[96636] = "T15_caster",
-	[96637] = "T15",
 	[96637] = "T15_caster",
-	[96638] = "T15",
 	[96638] = "T15_caster",
-	[99077] = "T16",
 	[99077] = "T16_caster",
-	[99078] = "T16",
 	[99078] = "T16_caster",
-	[99079] = "T16",
 	[99079] = "T16_caster",
-	[99083] = "T16",
 	[99083] = "T16_caster",
-	[99084] = "T16",
 	[99084] = "T16_caster",
-	[99152] = "T16",
 	[99152] = "T16_caster",
-	[99153] = "T16",
 	[99153] = "T16_caster",
-	[99160] = "T16",
 	[99160] = "T16_caster",
-	[99161] = "T16",
 	[99161] = "T16_caster",
-	[99162] = "T16",
 	[99162] = "T16_caster",
-	[99397] = "T16",
 	[99397] = "T16_caster",
-	[99398] = "T16",
 	[99398] = "T16_caster",
-	[99399] = "T16",
 	[99399] = "T16_caster",
-	[99400] = "T16",
 	[99400] = "T16_caster",
-	[99401] = "T16",
 	[99401] = "T16_caster",
-	[99575] = "T16",
 	[99575] = "T16_caster",
-	[99576] = "T16",
 	[99576] = "T16_caster",
-	[99657] = "T16",
 	[99657] = "T16_caster",
-	[99658] = "T16",
 	[99658] = "T16_caster",
-	[99659] = "T16",
 	[99659] = "T16_caster",
 	-- Monk
 	[85394] = "T14_melee",
@@ -870,105 +774,55 @@ local OVALE_ARMORSET = {
 	[99627] = "T16_caster",
 	[99628] = "T16_caster",
 	-- Rogue
-	[85299] = "T14",
 	[85299] = "T14_melee",
-	[85300] = "T14",
 	[85300] = "T14_melee",
-	[85301] = "T14",
 	[85301] = "T14_melee",
-	[85302] = "T14",
 	[85302] = "T14_melee",
-	[85303] = "T14",
 	[85303] = "T14_melee",
-	[86639] = "T14",
 	[86639] = "T14_melee",
-	[86640] = "T14",
 	[86640] = "T14_melee",
-	[86641] = "T14",
 	[86641] = "T14_melee",
-	[86642] = "T14",
 	[86642] = "T14_melee",
-	[86643] = "T14",
 	[86643] = "T14_melee",
-	[87124] = "T14",
 	[87124] = "T14_melee",
-	[87125] = "T14",
 	[87125] = "T14_melee",
-	[87126] = "T14",
 	[87126] = "T14_melee",
-	[87127] = "T14",
 	[87127] = "T14_melee",
-	[87128] = "T14",
 	[87128] = "T14_melee",
-	[95305] = "T15",
 	[95305] = "T15_melee",
-	[95306] = "T15",
 	[95306] = "T15_melee",
-	[95307] = "T15",
 	[95307] = "T15_melee",
-	[95308] = "T15",
 	[95308] = "T15_melee",
-	[95309] = "T15",
 	[95309] = "T15_melee",
-	[95935] = "T15",
 	[95935] = "T15_melee",
-	[95936] = "T15",
 	[95936] = "T15_melee",
-	[95937] = "T15",
 	[95937] = "T15_melee",
-	[95938] = "T15",
 	[95938] = "T15_melee",
-	[95939] = "T15",
 	[95939] = "T15_melee",
-	[96679] = "T15",
 	[96679] = "T15_melee",
-	[96680] = "T15",
 	[96680] = "T15_melee",
-	[96681] = "T15",
 	[96681] = "T15_melee",
-	[96682] = "T15",
 	[96682] = "T15_melee",
-	[96683] = "T15",
 	[96683] = "T15_melee",
-	[99006] = "T16",
 	[99006] = "T16_melee",
-	[99007] = "T16",
 	[99007] = "T16_melee",
-	[99008] = "T16",
 	[99008] = "T16_melee",
-	[99009] = "T16",
 	[99009] = "T16_melee",
-	[99010] = "T16",
 	[99010] = "T16_melee",
-	[99112] = "T16",
 	[99112] = "T16_melee",
-	[99113] = "T16",
 	[99113] = "T16_melee",
-	[99114] = "T16",
 	[99114] = "T16_melee",
-	[99115] = "T16",
 	[99115] = "T16_melee",
-	[99116] = "T16",
 	[99116] = "T16_melee",
-	[99348] = "T16",
 	[99348] = "T16_melee",
-	[99349] = "T16",
 	[99349] = "T16_melee",
-	[99350] = "T16",
 	[99350] = "T16_melee",
-	[99355] = "T16",
 	[99355] = "T16_melee",
-	[99356] = "T16",
 	[99356] = "T16_melee",
-	[99629] = "T16",
 	[99629] = "T16_melee",
-	[99630] = "T16",
 	[99630] = "T16_melee",
-	[99631] = "T16",
 	[99631] = "T16_melee",
-	[99634] = "T16",
 	[99634] = "T16_melee",
-	[99635] = "T16",
 	[99635] = "T16_melee",
 	-- Shaman
 	[95315] = "T15_melee",
@@ -1062,65 +916,35 @@ local OVALE_ARMORSET = {
 	[99650] = "T16_melee",
 	[99663] = "T16_melee",
 	--Warlock
-	[85369] = "T14",
 	[85369] = "T14_caster",
-	[85370] = "T14",
 	[85370] = "T14_caster",
-	[85371] = "T14",
 	[85371] = "T14_caster",
-	[85372] = "T14",
 	[85372] = "T14_caster",
-	[85373] = "T14",
 	[85373] = "T14_caster",
-	[86709] = "T14",
 	[86709] = "T14_caster",
-	[86710] = "T14",
 	[86710] = "T14_caster",
-	[86711] = "T14",
 	[86711] = "T14_caster",
-	[86712] = "T14",
 	[86712] = "T14_caster",
-	[86713] = "T14",
 	[86713] = "T14_caster",
-	[87187] = "T14",
 	[87187] = "T14_caster",
-	[87188] = "T14",
 	[87188] = "T14_caster",
-	[87189] = "T14",
 	[87189] = "T14_caster",
-	[87190] = "T14",
 	[87190] = "T14_caster",
-	[87191] = "T14",
 	[87191] = "T14_caster",
-	[95325] = "T15",
 	[95325] = "T15_caster",
-	[95326] = "T15",
 	[95326] = "T15_caster",
-	[95327] = "T15",
 	[95327] = "T15_caster",
-	[95328] = "T15",
 	[95328] = "T15_caster",
-	[95329] = "T15",
 	[95329] = "T15_caster",
-	[95981] = "T15",
 	[95981] = "T15_caster",
-	[95982] = "T15",
 	[95982] = "T15_caster",
-	[95983] = "T15",
 	[95983] = "T15_caster",
-	[95984] = "T15",
 	[95984] = "T15_caster",
-	[95985] = "T15",
 	[95985] = "T15_caster",
-	[96725] = "T15",
 	[96725] = "T15_caster",
-	[96726] = "T15",
 	[96726] = "T15_caster",
-	[96727] = "T15",
 	[96727] = "T15_caster",
-	[96728] = "T15",
 	[96728] = "T15_caster",
-	[96729] = "T15",
 	[96729] = "T15_caster",
 	[99045] = "T16_caster",
 	[99053] = "T16_caster",
@@ -1364,8 +1188,25 @@ function OvaleEquipement:PLAYER_EQUIPMENT_CHANGED(event, slotId, hasItem)
 	self:SendMessage("Ovale_EquipmentChanged")
 end

-function OvaleEquipement:GetArmorSetCount(name)
-	return self.armorSetCount[name] or 0
+do
+	-- Legacy armor set names; no longer documented.
+	local armorSetName = {
+		HUNTER = { ["T14"] = "T14_melee", ["T15"] = "T15_melee", ["T16"] = "T16_melee" },
+		MAGE = { ["T14"] = "T14_caster", ["T15"] = "T15_caster", ["T16"] = "T16_caster" },
+		ROGUE = { ["T14"] = "T14_melee", ["T15"] = "T15_melee", ["T16"] = "T16_melee" },
+		WARLOCK = { ["T14"] = "T14_caster", ["T15"] = "T15_caster" },
+	}
+
+	function OvaleEquipement:GetArmorSetCount(name)
+		local count = self.armorSetCount[name]
+		if not count then
+			if armorSetName[self_class] and armorSetName[self_class][name] then
+				name = armorSetName[self_class][name]
+				count = self.armorSetCount[name]
+			end
+		end
+		return count or 0
+	end
 end

 function OvaleEquipement:GetEquippedItem(slotId)