adam@17
|
1 local _, AskMrRobot = ...
|
adam@17
|
2 local L = AskMrRobot.L;
|
adam@17
|
3
|
adam@17
|
4 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
|
adam@17
|
5
|
adam@17
|
6 -- get an object with all of the parts fo the item link format that we care about
|
adam@17
|
7 function AskMrRobot.parseItemLink(itemLink)
|
adam@17
|
8 if not itemLink then return nil end
|
adam@17
|
9
|
adam@17
|
10 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|")
|
adam@17
|
11 if not str then return nil end
|
adam@17
|
12
|
adam@17
|
13 local parts = { strsplit(":", str) }
|
adam@17
|
14
|
adam@17
|
15 local item = {}
|
adam@17
|
16 item.id = tonumber(parts[1])
|
adam@17
|
17 item.enchantId = tonumber(parts[2])
|
adam@17
|
18 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) }
|
adam@17
|
19 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code
|
adam@17
|
20 --item.uniqueId = tonumber(parts[8])
|
adam@17
|
21 --item.level = tonumber(parts[9])
|
adam@17
|
22 item.upgradeId = tonumber(parts[10])
|
adam@17
|
23 --item.difficultyId = tonumber(parts[11])
|
adam@17
|
24
|
adam@17
|
25 local numBonuses = tonumber(parts[12])
|
adam@28
|
26 if numBonuses and numBonuses > 0 then
|
adam@17
|
27 item.bonusIds = {}
|
adam@17
|
28 for i = 13, 12 + numBonuses do
|
adam@17
|
29 table.insert(item.bonusIds, tonumber(parts[i]))
|
adam@17
|
30 end
|
yellowfive@39
|
31 table.sort(item.bonusIds)
|
adam@17
|
32 end
|
adam@17
|
33
|
adam@17
|
34 return item
|
adam@17
|
35 end
|
adam@17
|
36
|
yellowfive@31
|
37 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
|
yellowfive@31
|
38
|
yellowfive@31
|
39 function AskMrRobot.createItemLink(itemObj)
|
yellowfive@31
|
40
|
yellowfive@31
|
41 if itemObj == nil or itemObj.id == nil or itemObj.id == 0 then return nil end
|
yellowfive@31
|
42
|
yellowfive@31
|
43 local parts = {}
|
yellowfive@31
|
44 table.insert(parts, "item")
|
yellowfive@31
|
45 table.insert(parts, itemObj.id)
|
yellowfive@31
|
46 table.insert(parts, itemObj.enchantId)
|
yellowfive@31
|
47 table.insert(parts, itemObj.gemIds[1])
|
yellowfive@31
|
48 table.insert(parts, itemObj.gemIds[2])
|
yellowfive@31
|
49 table.insert(parts, itemObj.gemIds[3])
|
yellowfive@31
|
50 table.insert(parts, itemObj.gemIds[4])
|
yellowfive@33
|
51
|
yellowfive@33
|
52 if itemObj.suffixId == 0 then
|
yellowfive@33
|
53 table.insert(parts, 0)
|
yellowfive@33
|
54 else
|
yellowfive@33
|
55 table.insert(parts, -math.abs(itemObj.suffixId))
|
yellowfive@33
|
56 end
|
yellowfive@33
|
57
|
yellowfive@31
|
58 table.insert(parts, 0)
|
yellowfive@31
|
59 table.insert(parts, UnitLevel("player"))
|
yellowfive@31
|
60 table.insert(parts, itemObj.upgradeId)
|
yellowfive@31
|
61 table.insert(parts, 0)
|
yellowfive@31
|
62
|
yellowfive@31
|
63 if itemObj.bonusIds then
|
yellowfive@31
|
64 table.insert(parts, #itemObj.bonusIds)
|
yellowfive@31
|
65 for i,v in ipairs(itemObj.bonusIds) do
|
yellowfive@31
|
66 table.insert(parts, v)
|
yellowfive@31
|
67 end
|
yellowfive@31
|
68 end
|
yellowfive@31
|
69
|
yellowfive@31
|
70 return table.concat(parts, ":")
|
yellowfive@31
|
71 end
|
yellowfive@31
|
72
|
yellowfive@31
|
73 function AskMrRobot.createGemLink(gemId)
|
yellowfive@31
|
74
|
yellowfive@31
|
75 end
|
yellowfive@31
|
76
|
adam@17
|
77 -- convenience to get just the item id (or 0 if not a valid link) from an item link
|
adam@17
|
78 function AskMrRobot.getItemIdFromLink(itemLink)
|
adam@17
|
79 if not itemLink then return 0 end
|
adam@17
|
80 local parts = { strsplit(":", itemLink) }
|
adam@17
|
81 local id = tonumber(parts[2])
|
adam@17
|
82 return (id and id ~= 0 and id or 0)
|
adam@17
|
83 end
|
adam@17
|
84
|
adam@17
|
85 function AskMrRobot.getItemUniqueId(item, noUpgrade)
|
adam@17
|
86 if item == nil then return "" end
|
adam@17
|
87 local ret = item.id .. ""
|
adam@17
|
88 if item.bonusIds then
|
adam@17
|
89 for i = 1, #item.bonusIds do
|
adam@17
|
90 ret = ret .. "b" .. item.bonusIds[i]
|
adam@17
|
91 end
|
adam@17
|
92 end
|
adam@17
|
93 if item.suffixId ~= 0 then
|
adam@17
|
94 ret = ret .. "s" .. item.suffixId
|
adam@17
|
95 end
|
adam@17
|
96 if not noUpgrade and item.upgradeId ~= 0 then
|
adam@17
|
97 ret = ret .. "u" .. item.upgradeId
|
adam@17
|
98 end
|
adam@17
|
99 return ret
|
adam@17
|
100 end
|
adam@17
|
101
|
adam@17
|
102 AskMrRobot.instanceIds = {
|
TuhMuffinMan>@51
|
103 Auchindoun = 1182,
|
TuhMuffinMan>@51
|
104 BloodmaulSlagMines = 1175,
|
TuhMuffinMan>@51
|
105 GrimrailDepot = 1208,
|
TuhMuffinMan>@51
|
106 IronDocks = 1195,
|
TuhMuffinMan>@51
|
107 ShadowmoonBurialGrounds = 1176,
|
TuhMuffinMan>@51
|
108 Skyreach = 1209,
|
TuhMuffinMan>@51
|
109 TheEverbloom = 1279,
|
TuhMuffinMan>@51
|
110 UpperBlackrockSpire = 1358,
|
TuhMuffinMan>@51
|
111 Highmaul = 1228,
|
TuhMuffinMan>@51
|
112 BlackrockFoundry = 1205
|
adam@17
|
113 }
|
adam@17
|
114
|
adam@17
|
115 -- instances that we currently support logging for
|
adam@17
|
116 AskMrRobot.supportedInstanceIds = {
|
TuhMuffinMan>@51
|
117 [1182] = true,
|
TuhMuffinMan>@51
|
118 [1175] = true,
|
TuhMuffinMan>@51
|
119 [1208] = true,
|
TuhMuffinMan>@51
|
120 [1195] = true,
|
TuhMuffinMan>@51
|
121 [1176] = true,
|
TuhMuffinMan>@51
|
122 [1209] = true,
|
TuhMuffinMan>@51
|
123 [1279] = true,
|
TuhMuffinMan>@51
|
124 [1358] = true,
|
TuhMuffinMan>@51
|
125 [1228] = true,
|
TuhMuffinMan>@51
|
126 [1205] = true
|
adam@17
|
127 }
|
adam@17
|
128
|
adam@17
|
129 -- returns true if currently in a supported instance
|
adam@17
|
130 function AskMrRobot.IsSupportedInstance()
|
adam@17
|
131
|
adam@17
|
132 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
|
adam@17
|
133 if AskMrRobot.supportedInstanceIds[tonumber(instanceMapID)] then
|
adam@17
|
134 return true
|
adam@17
|
135 else
|
adam@17
|
136 return false
|
adam@17
|
137 end
|
adam@17
|
138 end
|
adam@17
|
139
|
yellowfive@41
|
140 AskMrRobot.regionNames = {
|
yellowfive@41
|
141 [1] = "US",
|
yellowfive@41
|
142 [2] = "KR",
|
yellowfive@41
|
143 [3] = "EU",
|
yellowfive@41
|
144 [4] = "TW",
|
yellowfive@41
|
145 [5] = "CN"
|
yellowfive@41
|
146 }
|
yellowfive@41
|
147
|
adam@17
|
148 AskMrRobot.classIds = {
|
adam@17
|
149 ["NONE"] = 0,
|
adam@17
|
150 ["DEATHKNIGHT"] = 1,
|
adam@17
|
151 ["DRUID"] = 2,
|
adam@17
|
152 ["HUNTER"] = 3,
|
adam@17
|
153 ["MAGE"] = 4,
|
adam@17
|
154 ["MONK"] = 5,
|
adam@17
|
155 ["PALADIN"] = 6,
|
adam@17
|
156 ["PRIEST"] = 7,
|
adam@17
|
157 ["ROGUE"] = 8,
|
adam@17
|
158 ["SHAMAN"] = 9,
|
adam@17
|
159 ["WARLOCK"] = 10,
|
adam@17
|
160 ["WARRIOR"] = 11,
|
adam@17
|
161 }
|
adam@17
|
162
|
adam@17
|
163 AskMrRobot.professionIds = {
|
adam@17
|
164 ["None"] = 0,
|
adam@17
|
165 ["Mining"] = 1,
|
adam@17
|
166 ["Skinning"] = 2,
|
adam@17
|
167 ["Herbalism"] = 3,
|
adam@17
|
168 ["Enchanting"] = 4,
|
adam@17
|
169 ["Jewelcrafting"] = 5,
|
adam@17
|
170 ["Engineering"] = 6,
|
adam@17
|
171 ["Blacksmithing"] = 7,
|
adam@17
|
172 ["Leatherworking"] = 8,
|
adam@17
|
173 ["Inscription"] = 9,
|
adam@17
|
174 ["Tailoring"] = 10,
|
adam@17
|
175 ["Alchemy"] = 11,
|
adam@17
|
176 ["Fishing"] = 12,
|
adam@17
|
177 ["Cooking"] = 13,
|
adam@17
|
178 ["First Aid"] = 14,
|
adam@17
|
179 ["Archaeology"] = 15
|
adam@17
|
180 }
|
adam@17
|
181
|
adam@17
|
182 AskMrRobot.raceIds = {
|
adam@17
|
183 ["None"] = 0,
|
adam@17
|
184 ["BloodElf"] = 1,
|
adam@17
|
185 ["Draenei"] = 2,
|
adam@17
|
186 ["Dwarf"] = 3,
|
adam@17
|
187 ["Gnome"] = 4,
|
adam@17
|
188 ["Human"] = 5,
|
adam@17
|
189 ["NightElf"] = 6,
|
adam@17
|
190 ["Orc"] = 7,
|
adam@17
|
191 ["Tauren"] = 8,
|
adam@17
|
192 ["Troll"] = 9,
|
adam@17
|
193 ["Scourge"] = 10,
|
adam@17
|
194 ["Undead"] = 10,
|
adam@17
|
195 ["Goblin"] = 11,
|
adam@17
|
196 ["Worgen"] = 12,
|
adam@17
|
197 ["Pandaren"] = 13
|
adam@17
|
198 }
|
adam@17
|
199
|
adam@17
|
200 AskMrRobot.factionIds = {
|
adam@17
|
201 ["None"] = 0,
|
adam@17
|
202 ["Alliance"] = 1,
|
adam@17
|
203 ["Horde"] = 2
|
adam@17
|
204 }
|
adam@17
|
205
|
adam@17
|
206 AskMrRobot.specIds = {
|
adam@17
|
207 [250] = 1, -- DeathKnightBlood
|
adam@17
|
208 [251] = 2, -- DeathKnightFrost
|
adam@17
|
209 [252] = 3, -- DeathKnightUnholy
|
adam@17
|
210 [102] = 4, -- DruidBalance
|
adam@17
|
211 [103] = 5, -- DruidFeral
|
adam@17
|
212 [104] = 6, -- DruidGuardian
|
adam@17
|
213 [105] = 7, -- DruidRestoration
|
adam@17
|
214 [253] = 8, -- HunterBeastMastery
|
adam@17
|
215 [254] = 9, -- HunterMarksmanship
|
adam@17
|
216 [255] = 10, -- HunterSurvival
|
adam@17
|
217 [62] = 11, -- MageArcane
|
adam@17
|
218 [63] = 12, -- MageFire
|
adam@17
|
219 [64] = 13, -- MageFrost
|
adam@17
|
220 [268] = 14, -- MonkBrewmaster
|
yellowfive@23
|
221 [270] = 15, -- MonkMistweaver
|
yellowfive@23
|
222 [269] = 16, -- MonkWindwalker
|
adam@17
|
223 [65] = 17, -- PaladinHoly
|
adam@17
|
224 [66] = 18, -- PaladinProtection
|
adam@17
|
225 [70] = 19, -- PaladinRetribution
|
adam@17
|
226 [256] = 20, -- PriestDiscipline
|
adam@17
|
227 [257] = 21, -- PriestHoly
|
adam@17
|
228 [258] = 22, -- PriestShadow
|
adam@17
|
229 [259] = 23, -- RogueAssassination
|
adam@17
|
230 [260] = 24, -- RogueCombat
|
adam@17
|
231 [261] = 25, -- RogueSubtlety
|
adam@17
|
232 [262] = 26, -- ShamanElemental
|
adam@17
|
233 [263] = 27, -- ShamanEnhancement
|
adam@17
|
234 [264] = 28, -- ShamanRestoration
|
adam@17
|
235 [265] = 29, -- WarlockAffliction
|
adam@17
|
236 [266] = 30, -- WarlockDemonology
|
adam@17
|
237 [267] = 31, -- WarlockDestruction
|
adam@17
|
238 [71] = 32, -- WarriorArms
|
adam@17
|
239 [72] = 33, -- WarriorFury
|
adam@17
|
240 [73] = 34 -- WarriorProtection
|
adam@17
|
241 }
|
adam@17
|
242
|
adam@17
|
243 -- reverse map of our spec ID to the game's spec ID
|
adam@17
|
244 AskMrRobot.gameSpecIds = {}
|
adam@17
|
245 for k,v in pairs(AskMrRobot.specIds) do
|
adam@17
|
246 AskMrRobot.gameSpecIds[v] = k
|
adam@17
|
247 end
|
adam@17
|
248
|
adam@17
|
249 -- lookup from our socket color ID to string
|
adam@17
|
250 AskMrRobot.socketColorIds = {
|
adam@17
|
251 [0] = "Prismatic",
|
adam@17
|
252 [1] = "Red",
|
adam@17
|
253 [2] = "Yellow",
|
adam@17
|
254 [3] = "Blue",
|
adam@17
|
255 [4] = "Meta",
|
adam@17
|
256 [5] = "Cogwheel",
|
adam@17
|
257 [6] = "ShaTouched"
|
adam@17
|
258 }
|
adam@17
|
259
|
adam@17
|
260 -- map of game slot names to slot IDs (same both in our code and in-game)
|
adam@17
|
261 AskMrRobot.slotNameToId = {
|
adam@17
|
262 ["HeadSlot"] = 1,
|
adam@17
|
263 ["NeckSlot"] = 2,
|
adam@17
|
264 ["ShoulderSlot"] = 3,
|
adam@17
|
265 ["ChestSlot"] = 5,
|
adam@17
|
266 ["WaistSlot"] = 6,
|
adam@17
|
267 ["LegsSlot"] = 7,
|
adam@17
|
268 ["FeetSlot"] = 8,
|
adam@17
|
269 ["WristSlot"] = 9,
|
adam@17
|
270 ["HandsSlot"] = 10,
|
adam@17
|
271 ["Finger0Slot"] = 11,
|
adam@17
|
272 ["Finger1Slot"] = 12,
|
adam@17
|
273 ["Trinket0Slot"] = 13,
|
adam@17
|
274 ["Trinket1Slot"] = 14,
|
adam@17
|
275 ["BackSlot"] = 15,
|
adam@17
|
276 ["MainHandSlot"] = 16,
|
adam@17
|
277 ["SecondaryHandSlot"] = 17
|
adam@17
|
278 }
|
adam@17
|
279
|
adam@17
|
280 -- map of slot ID to display text
|
adam@17
|
281 AskMrRobot.slotDisplayText = {
|
adam@17
|
282 [1] = _G["HEADSLOT"],
|
adam@17
|
283 [2] = _G["NECKSLOT"],
|
adam@17
|
284 [3] = _G["SHOULDERSLOT"],
|
adam@17
|
285 [5] = _G["CHESTSLOT"],
|
adam@17
|
286 [6] = _G["WAISTSLOT"],
|
adam@17
|
287 [7] = _G["LEGSSLOT"],
|
adam@17
|
288 [8] = _G["FEETSLOT"],
|
yellowfive@31
|
289 [9] = _G["WRISTSLOT"],
|
adam@17
|
290 [10] = _G["HANDSSLOT"],
|
yellowfive@31
|
291 [11] = _G["FINGER0SLOT"] .. " 1",
|
yellowfive@31
|
292 [12] = _G["FINGER1SLOT"] .. " 2",
|
yellowfive@31
|
293 [13] = _G["TRINKET0SLOT"] .. " 1",
|
yellowfive@31
|
294 [14] = _G["TRINKET1SLOT"] .. " 2",
|
adam@17
|
295 [15] = _G["BACKSLOT"],
|
adam@17
|
296 [16] = _G["MAINHANDSLOT"],
|
adam@17
|
297 [17] = _G["SECONDARYHANDSLOT"]
|
adam@17
|
298 }
|
adam@17
|
299
|
adam@17
|
300 -- all slot IDs that we care about, ordered in our standard display order
|
adam@17
|
301 AskMrRobot.slotIds = { 16, 17, 1, 2, 3, 15, 5, 9, 10, 6, 7, 8, 11, 12, 13, 14 }
|
adam@17
|
302
|
adam@17
|
303 -- cache slot orders to make slot sorting easier
|
adam@17
|
304 local _slotIdToOrder = {}
|
adam@17
|
305 for i = 1, #AskMrRobot.slotIds do
|
adam@17
|
306 _slotIdToOrder[AskMrRobot.slotIds[i]] = i
|
adam@17
|
307 end
|
adam@17
|
308
|
adam@17
|
309 -- given a table where the keys are slot IDs, sort in the standard slot order
|
adam@17
|
310 function AskMrRobot.sortSlots(t)
|
adam@17
|
311 return AskMrRobot.spairs(t, function(x, a, b)
|
adam@17
|
312 if a == nil and b == nil then return 0 end
|
adam@17
|
313 return _slotIdToOrder[a] < _slotIdToOrder[b]
|
adam@17
|
314 end)
|
TuhMuffinMan>@51
|
315 end |