diff Gear.lua @ 145:df1596b1a744 v68

Tweak for handling duplicate azerite items.
author yellowfive
date Sun, 09 Dec 2018 22:53:08 -0800
parents 55823e37403b
children cfdb5e5c828e
line wrap: on
line diff
--- a/Gear.lua	Thu Nov 08 21:21:26 2018 -0800
+++ b/Gear.lua	Sun Dec 09 22:53:08 2018 -0800
@@ -51,10 +51,10 @@
 			aztDiffs = #item2.azerite * 10
 		else
 			-- count up number in item1 but missing from item2
-			for i = 1, #item1.azerite do
-				local missing = false
+			for i = 1, #item1.azerite do				
+				local missing = true
 				for j = 1, #item2.azerite do
-					if item2[j] == item1[i] then
+					if item2.azerite[j] == item1.azerite[i] then
 						missing = false
 					end
 				end
@@ -64,9 +64,9 @@
 			end
 			-- count up number in item2 but missing from item1
 			for i = 1, #item2.azerite do
-				local missing = false
+				local missing = true
 				for j = 1, #item1.azerite do
-					if item1[j] == item2[i] then
+					if item1.azerite[j] == item2.azerite[i] then
 						missing = false
 					end
 				end
@@ -288,7 +288,16 @@
 			-- see if item is currently equipped, is false if don't have any item for that slot (e.g. OH for a 2-hander)
 			local isEquipped = false			
 			if equippedItem and optimalItem and Amr.GetItemUniqueId(equippedItem, false, true) == Amr.GetItemUniqueId(optimalItem, false, true) then
-				isEquipped = true
+
+				if slotId == 1 or slotId == 3 or slotId == 5 then
+					-- show the item as not equipped if azerite doesn't match... might mean they have to switch to another version of same item
+					local aztDiff = countItemDifferences(equippedItem, optimalItem)
+					if aztDiff == 0 then
+						isEquipped = true
+					end
+				else
+					isEquipped = true
+				end
 			end
 
 			local isAzerite = optimalItem and C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItemByID(optimalItem.id)
@@ -698,6 +707,8 @@
 	local setname = setup.Label -- "AMR " .. specName
 	local setid = C_EquipmentSet.GetEquipmentSetID(setname)
 	if setid then
+		local oldName, oldIcon = C_EquipmentSet.GetEquipmentSetInfo(setid)
+		setIcon = oldIcon
 		C_EquipmentSet.SaveEquipmentSet(setid, setIcon)
 	else
 		C_EquipmentSet.CreateEquipmentSet(setname, setIcon)
@@ -1042,22 +1053,12 @@
 					remaining = remaining + 1
 				end
 			else
+
 				-- find the best matching item anywhere in the player's gear
 				local bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems)
 				new = bestItem
 
-				local diff = countItemDifferences(old, new)
-
-				--[[
-				if diff > 0 and diff < 1000 then
-					-- same item, see if inventory has one that is closer (e.g. a duplicate item with correct enchants/gems)
-					local bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems)
-					if bestDiff and bestDiff < diff then
-						new = bestItem
-						diff = bestDiff
-					end
-				end
-				]]
+				local diff = countItemDifferences(old, new)				
 
 				if diff > 0 then	
 					list[slotId] = new