changeset 145:df1596b1a744 v68

Tweak for handling duplicate azerite items.
author yellowfive
date Sun, 09 Dec 2018 22:53:08 -0800
parents 69e759e03838
children 54bac7ada9a3
files AskMrRobot-Serializer/AskMrRobot-Serializer.lua AskMrRobot.toc Core.lua Gear.lua
diffstat 4 files changed, 22 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/AskMrRobot-Serializer/AskMrRobot-Serializer.lua	Thu Nov 08 21:21:26 2018 -0800
+++ b/AskMrRobot-Serializer/AskMrRobot-Serializer.lua	Sun Dec 09 22:53:08 2018 -0800
@@ -1,6 +1,6 @@
 -- AskMrRobot-Serializer will serialize and communicate character data between users.
 
-local MAJOR, MINOR = "AskMrRobot-Serializer", 67
+local MAJOR, MINOR = "AskMrRobot-Serializer", 68
 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
 if not Amr then return end -- already loaded by something else
--- a/AskMrRobot.toc	Thu Nov 08 21:21:26 2018 -0800
+++ b/AskMrRobot.toc	Sun Dec 09 22:53:08 2018 -0800
@@ -1,7 +1,7 @@
 ## Interface: 80000
 ## Title: Ask Mr. Robot
 ## Author: Team Robot, Inc.
-## Version: 67
+## Version: 68
 ## Notes: Gear import/export, combat logging, and more.
 ## URL: www.askmrrobot.com
 ## SavedVariables: AskMrRobotDb4
--- a/Core.lua	Thu Nov 08 21:21:26 2018 -0800
+++ b/Core.lua	Sun Dec 09 22:53:08 2018 -0800
@@ -187,7 +187,7 @@
 	-- make sure that some initialization is deferred until after PLAYER_ENTERING_WORLD event so that data we need is available;
 	-- also delay this initialization for a few extra seconds to deal with some event spam that is otherwise hard to identify and ignore when a player logs in
 	Amr.Wait(5, function()
-		Amr:InitializeVersions()
+		--Amr:InitializeVersions()
 		Amr:InitializeGear()
 		Amr:InitializeExport()
 		Amr:InitializeCombatLog()
--- 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