Mercurial > wow > askmrrobot
changeset 191:4aeedce4c995 v93
Added better identification of duplicate items.
author | yellowfive |
---|---|
date | Fri, 30 Oct 2020 21:14:57 -0700 |
parents | 4232d073a90b |
children | cb5342add834 |
files | AskMrRobot-Serializer/AskMrRobot-Serializer.lua AskMrRobot.toc Export.lua Gear.lua Import.lua Junk.lua |
diffstat | 6 files changed, 76 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/AskMrRobot-Serializer/AskMrRobot-Serializer.lua Mon Oct 19 11:20:07 2020 -0700 +++ b/AskMrRobot-Serializer/AskMrRobot-Serializer.lua Fri Oct 30 21:14:57 2020 -0700 @@ -1,6 +1,6 @@ -- AskMrRobot-Serializer will serialize and communicate character data between users. -local MAJOR, MINOR = "AskMrRobot-Serializer", 92 +local MAJOR, MINOR = "AskMrRobot-Serializer", 93 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not Amr then return end -- already loaded by something else @@ -429,13 +429,22 @@ -- get currently equipped items, store with currently active spec local function readEquippedItems(ret) local equippedItems = {}; - local loc = ItemLocation.CreateEmpty() + --local loc = ItemLocation.CreateEmpty() + local item for slotNum = 1, #Amr.SlotIds do local slotId = Amr.SlotIds[slotNum] local itemLink = GetInventoryItemLink("player", slotId) if itemLink then local itemData = Amr.ParseItemLink(itemLink) if itemData then + item = Item:CreateFromEquipmentSlot(slotId) + + -- seems to be of the form Item-1147-0-4000000XXXXXXXXX, so we take just the last 9 digits + itemData.guid = item:GetItemGUID() + if itemData.guid and strlen(itemData.guid) > 9 then + itemData.guid = strsub(itemData.guid, -9) + end + --[[ -- see if this is an azerite item and read azerite power ids loc:SetEquipmentSlot(slotId) @@ -573,6 +582,7 @@ local prevLevel = 0 --local prevAzeriteId = 0 local prevRelicBonusId = 0 + for i, itemData in ipairs(itemObjects) do local itemParts = {} @@ -643,6 +653,10 @@ prevRelicBonusId = bValue end end + + if itemData.guid then + table.insert(itemParts, "!" .. itemData.guid) + end table.insert(fields, table.concat(itemParts, "")) end
--- a/AskMrRobot.toc Mon Oct 19 11:20:07 2020 -0700 +++ b/AskMrRobot.toc Fri Oct 30 21:14:57 2020 -0700 @@ -1,7 +1,7 @@ ## Interface: 90001 ## Title: Ask Mr. Robot ## Author: Team Robot, Inc. -## Version: 92 +## Version: 93 ## Notes: Gear import/export, combat logging, and more. ## URL: www.askmrrobot.com ## SavedVariables: AskMrRobotDb4
--- a/Export.lua Mon Oct 19 11:20:07 2020 -0700 +++ b/Export.lua Fri Oct 30 21:14:57 2020 -0700 @@ -115,12 +115,20 @@ local function scanBag(bagId, isBank, bagTable, bagItemsWithCount) local numSlots = GetContainerNumSlots(bagId) - local loc = ItemLocation.CreateEmpty() + --local loc = ItemLocation.CreateEmpty() + local item for slotId = 1, numSlots do local _, itemCount, _, _, _, _, itemLink = GetContainerItemInfo(bagId, slotId) if itemLink ~= nil then local itemData = Amr.Serializer.ParseItemLink(itemLink) if itemData ~= nil then + item = Item:CreateFromBagAndSlot(bagId, slotId) + + -- seems to be of the form Item-1147-0-4000000XXXXXXXXX, so we take just the last 9 digits + itemData.guid = item:GetItemGUID() + if itemData.guid and strlen(itemData.guid) > 9 then + itemData.guid = strsub(itemData.guid, -9) + end -- see if this is an azerite item and read azerite power ids --[[loc:SetBagAndSlot(bagId, slotId)
--- a/Gear.lua Mon Oct 19 11:20:07 2020 -0700 +++ b/Gear.lua Fri Oct 30 21:14:57 2020 -0700 @@ -29,17 +29,17 @@ -- one nil and other not, or different id, totally different if (not item1 and item2) or (item1 and not item2) or item1.id ~= item2.id then - return 100000 + return 1000000 end -- different versions of same item (id + bonus ids + suffix + drop level, constitutes a different physical drop) if Amr.GetItemUniqueId(item1, true, true) ~= Amr.GetItemUniqueId(item2, true, true) then - return 10000 + return 100000 end -- different upgrade levels of the same item if item1.upgradeId ~= item2.upgradeId then - return 1000 + return 10000 end -- a change that requires reforging is considered more different than a change that does not; @@ -51,7 +51,7 @@ -- azerite that needs to be reforged if item2.azerite and not item1.azerite then -- kind of a dumb case... but we would need to blank all azerite on item2 to match item1 - aztReforges = #item2.azerite * 100 + aztReforges = #item2.azerite * 1000 elseif item2.azerite then -- count up azerite on item2 but not on item1, these would need to be reforged for i = 1, #item2.azerite do @@ -62,7 +62,7 @@ end end if missing then - aztReforges = aztReforges + 100 + aztReforges = aztReforges + 1000 end end end @@ -70,7 +70,7 @@ -- azerite that needs to be selected if item1.azerite and not item2.azerite then -- item2 is blank, so just need to choose all the right ones - aztSelects = #item1.azerite * 10 + aztSelects = #item1.azerite * 100 elseif item1.azerite then -- count up azerite on item1 but not on item2, these would need to be selected for i = 1, #item1.azerite do @@ -81,7 +81,7 @@ end end if missing then - aztSelects = aztSelects + 10 + aztSelects = aztSelects + 100 end end end @@ -91,17 +91,23 @@ local gemDiffs = 0 for i = 1, 3 do if item1.gemIds[i] ~= item2.gemIds[i] then - gemDiffs = gemDiffs + 1 + gemDiffs = gemDiffs + 10 end end -- different enchants local enchantDiff = 0 if item1.enchantId ~= item2.enchantId then - enchantDiff = 1 + enchantDiff = 10 end - - return aztReforges + aztSelects + gemDiffs + enchantDiff + + -- different guid + local guidDiff = 0 + if item1.guid and item2.guid and item1.guid ~= item2.guid then + guidDiff = 1 + end + + return aztReforges + aztSelects + gemDiffs + enchantDiff + guidDiff end -- given a table of items (keyed or indexed doesn't matter) find closest match to item, or nil if none are a match @@ -134,14 +140,14 @@ if not item then return nil end local equipped = player.Equipped and player.Equipped[player.ActiveSpec] or nil - local bestItem, bestDiff, bestLoc = findMatchingItemFromTable(item, equipped, nil, 100000, nil, usedItems, "equip") + local bestItem, bestDiff, bestLoc = findMatchingItemFromTable(item, equipped, nil, 1000000, nil, usedItems, "equip") bestItem, bestDiff, bestLoc = findMatchingItemFromTable(item, player.BagItems, bestItem, bestDiff, bestLoc, usedItems, "bag") if player.BankItems then bestItem, bestDiff, bestLoc = findMatchingItemFromTable(item, player.BankItems, bestItem, bestDiff, bestLoc, usedItems, "bank") end - if bestDiff >= 100000 then - return nil, 100000 + if bestDiff >= 1000000 then + return nil, 1000000 else usedItems[bestLoc] = true return bestItem, bestDiff @@ -302,14 +308,18 @@ local isEquipped = false if equippedItem and optimalItem and Amr.GetItemUniqueId(equippedItem, false, true) == Amr.GetItemUniqueId(optimalItem, false, true) then - 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(optimalItem, equippedItem) - if aztDiff < 10 then + if optimalItem.guid then + isEquipped = optimalItem.guid == equippedItem.guid + else + --[[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(optimalItem, equippedItem) + if aztDiff < 100 then + isEquipped = true + end + else]] isEquipped = true - end - else - isEquipped = true + --end end end
--- a/Import.lua Mon Oct 19 11:20:07 2020 -0700 +++ b/Import.lua Fri Oct 30 21:14:57 2020 -0700 @@ -161,7 +161,9 @@ local token = "" local prop = "i" local tokenComplete = false - for j = 1, string.len(itemString) do + local guid = nil + + for j = 1, string.len(itemString) do local c = string.sub(itemString, j, j) if digits[c] == nil then tokenComplete = true @@ -210,6 +212,12 @@ -- we have moved on to the next token prop = c end + + if prop == "!" then + -- guid is always at the end, if present + guid = strsub(itemString, j + 1) + break + end end local obj = {} @@ -237,6 +245,10 @@ obj.bonusIds = bonusIds end + if guid then + obj.guid = guid + end + --if hasAzerites then -- obj.azerite = azerite --end
--- a/Junk.lua Mon Oct 19 11:20:07 2020 -0700 +++ b/Junk.lua Fri Oct 30 21:14:57 2020 -0700 @@ -51,11 +51,11 @@ itemData.bagId = bagId itemData.slotId = slotId return itemData - elseif diffs < 10000 then + elseif diffs < 100000 then if itemData.azerite and #itemData.azerite > 0 then - threshold = 100 + threshold = 1000 else - threshold = 10000 + threshold = 100000 end if diffs < threshold and diffs < bestMatchDiffs then -- closest match we could find @@ -454,11 +454,11 @@ itemData.bagId = bagId itemData.slotId = i return itemData - elseif diffs < 10000 then + elseif diffs < 100000 then if itemData.azerite and #itemData.azerite > 0 then - threshold = 100 + threshold = 1000 else - threshold = 10000 + threshold = 100000 end if diffs < threshold and diffs < bestMatchDiffs then -- closest match we could find