Mercurial > wow > askmrrobot
comparison 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 |
comparison
equal
deleted
inserted
replaced
144:69e759e03838 | 145:df1596b1a744 |
---|---|
49 aztDiffs = #item1.azerite * 10 | 49 aztDiffs = #item1.azerite * 10 |
50 elseif item2.azerite and not item1.azerite then | 50 elseif item2.azerite and not item1.azerite then |
51 aztDiffs = #item2.azerite * 10 | 51 aztDiffs = #item2.azerite * 10 |
52 else | 52 else |
53 -- count up number in item1 but missing from item2 | 53 -- count up number in item1 but missing from item2 |
54 for i = 1, #item1.azerite do | 54 for i = 1, #item1.azerite do |
55 local missing = false | 55 local missing = true |
56 for j = 1, #item2.azerite do | 56 for j = 1, #item2.azerite do |
57 if item2[j] == item1[i] then | 57 if item2.azerite[j] == item1.azerite[i] then |
58 missing = false | 58 missing = false |
59 end | 59 end |
60 end | 60 end |
61 if missing then | 61 if missing then |
62 aztDiffs = aztDiffs + 10 | 62 aztDiffs = aztDiffs + 10 |
63 end | 63 end |
64 end | 64 end |
65 -- count up number in item2 but missing from item1 | 65 -- count up number in item2 but missing from item1 |
66 for i = 1, #item2.azerite do | 66 for i = 1, #item2.azerite do |
67 local missing = false | 67 local missing = true |
68 for j = 1, #item1.azerite do | 68 for j = 1, #item1.azerite do |
69 if item1[j] == item2[i] then | 69 if item1.azerite[j] == item2.azerite[i] then |
70 missing = false | 70 missing = false |
71 end | 71 end |
72 end | 72 end |
73 if missing then | 73 if missing then |
74 aztDiffs = aztDiffs + 10 | 74 aztDiffs = aztDiffs + 10 |
286 local optimalItemLink = Amr.CreateItemLink(optimalItem) | 286 local optimalItemLink = Amr.CreateItemLink(optimalItem) |
287 | 287 |
288 -- see if item is currently equipped, is false if don't have any item for that slot (e.g. OH for a 2-hander) | 288 -- see if item is currently equipped, is false if don't have any item for that slot (e.g. OH for a 2-hander) |
289 local isEquipped = false | 289 local isEquipped = false |
290 if equippedItem and optimalItem and Amr.GetItemUniqueId(equippedItem, false, true) == Amr.GetItemUniqueId(optimalItem, false, true) then | 290 if equippedItem and optimalItem and Amr.GetItemUniqueId(equippedItem, false, true) == Amr.GetItemUniqueId(optimalItem, false, true) then |
291 isEquipped = true | 291 |
292 if slotId == 1 or slotId == 3 or slotId == 5 then | |
293 -- show the item as not equipped if azerite doesn't match... might mean they have to switch to another version of same item | |
294 local aztDiff = countItemDifferences(equippedItem, optimalItem) | |
295 if aztDiff == 0 then | |
296 isEquipped = true | |
297 end | |
298 else | |
299 isEquipped = true | |
300 end | |
292 end | 301 end |
293 | 302 |
294 local isAzerite = optimalItem and C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItemByID(optimalItem.id) | 303 local isAzerite = optimalItem and C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItemByID(optimalItem.id) |
295 | 304 |
296 -- find the item in the player's inventory that best matches what the optimization wants to use | 305 -- find the item in the player's inventory that best matches what the optimization wants to use |
696 | 705 |
697 local setup = getSetupById(_activeSetupId) | 706 local setup = getSetupById(_activeSetupId) |
698 local setname = setup.Label -- "AMR " .. specName | 707 local setname = setup.Label -- "AMR " .. specName |
699 local setid = C_EquipmentSet.GetEquipmentSetID(setname) | 708 local setid = C_EquipmentSet.GetEquipmentSetID(setname) |
700 if setid then | 709 if setid then |
710 local oldName, oldIcon = C_EquipmentSet.GetEquipmentSetInfo(setid) | |
711 setIcon = oldIcon | |
701 C_EquipmentSet.SaveEquipmentSet(setid, setIcon) | 712 C_EquipmentSet.SaveEquipmentSet(setid, setIcon) |
702 else | 713 else |
703 C_EquipmentSet.CreateEquipmentSet(setname, setIcon) | 714 C_EquipmentSet.CreateEquipmentSet(setname, setIcon) |
704 end | 715 end |
705 end | 716 end |
1040 itemsToEquip.weapons[slotId] = {} | 1051 itemsToEquip.weapons[slotId] = {} |
1041 end | 1052 end |
1042 remaining = remaining + 1 | 1053 remaining = remaining + 1 |
1043 end | 1054 end |
1044 else | 1055 else |
1056 | |
1045 -- find the best matching item anywhere in the player's gear | 1057 -- find the best matching item anywhere in the player's gear |
1046 local bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems) | 1058 local bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems) |
1047 new = bestItem | 1059 new = bestItem |
1048 | 1060 |
1049 local diff = countItemDifferences(old, new) | 1061 local diff = countItemDifferences(old, new) |
1050 | |
1051 --[[ | |
1052 if diff > 0 and diff < 1000 then | |
1053 -- same item, see if inventory has one that is closer (e.g. a duplicate item with correct enchants/gems) | |
1054 local bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems) | |
1055 if bestDiff and bestDiff < diff then | |
1056 new = bestItem | |
1057 diff = bestDiff | |
1058 end | |
1059 end | |
1060 ]] | |
1061 | 1062 |
1062 if diff > 0 then | 1063 if diff > 0 then |
1063 list[slotId] = new | 1064 list[slotId] = new |
1064 if list == itemsToEquip.mh or list == itemsToEquip.oh then | 1065 if list == itemsToEquip.mh or list == itemsToEquip.oh then |
1065 itemsToEquip.weapons[slotId] = {} | 1066 itemsToEquip.weapons[slotId] = {} |