comparison Export.lua @ 112:57c6cac5143c v52

7.3 update, preparation for reading crucible.
author yellowfive
date Mon, 28 Aug 2017 19:33:14 -0700
parents e635cd648e01
children 4cd98aa90d78
comparison
equal deleted inserted replaced
111:2f78f6c96183 112:57c6cac5143c
267 end 267 end
268 268
269 Amr.db.char.Talents[specPos] = str 269 Amr.db.char.Talents[specPos] = str
270 end 270 end
271 271
272 local function scanCrucible()
273 if not Amr.db or not Amr.db.char or not Amr.db.char.Artifacts or not C_ArtifactRelicForgeUI or not C_ArtifactRelicForgeUI.GetSocketedRelicTalents then return end
274
275 local equipped = {}
276 local preview = nil
277
278 for i = 1,4 do
279 local talents = nil
280 if i == 4 then
281 talents = C_ArtifactRelicForgeUI.GetPreviewRelicTalents()
282 --talents = nil
283 else
284 talents = C_ArtifactRelicForgeUI.GetSocketedRelicTalents(i)
285
286 --[[
287 if i == 1 then
288 talents = {}
289 table.insert(talents, {
290 powerID = 1739,
291 isChosen = true
292 })
293 table.insert(talents, {
294 powerID = 1781,
295 isChosen = true
296 })
297 table.insert(talents, {
298 powerID = 1770,
299 isChosen = false
300 })
301 table.insert(talents, {
302 powerID = 791,
303 isChosen = false
304 })
305 table.insert(talents, {
306 powerID = 786,
307 isChosen = false
308 })
309 table.insert(talents, {
310 powerID = 1537,
311 isChosen = false
312 })
313 end
314 ]]
315 end
316
317 if talents then
318 local obj = {
319 Powers = {},
320 Active = {}
321 }
322
323 if i == 4 then
324 obj.ItemLink = C_ArtifactRelicForgeUI.GetPreviewRelicItemLink()
325 if not obj.ItemLink then
326 talents = nil
327 else
328 preview = obj
329 end
330 else
331 table.insert(equipped, obj)
332 end
333
334 if talents then
335 for k,v in ipairs(talents) do
336 table.insert(obj.Powers, v.powerID)
337 table.insert(obj.Active, v.isChosen)
338 end
339 end
340
341 elseif i ~= 4 then
342 table.insert(equipped, {})
343 end
344 end
345
346
347 local itemID = C_ArtifactUI.GetArtifactInfo()
348 local spec = Amr.ArtifactIdToSpecNumber[itemID]
349
350 if spec then
351
352 -- sometimes this event can fire when no crucible data is available, don't overwrite non-blank crucible data with blank crucible data
353 if Amr.db.char.Artifacts[spec] then
354 local oldCrucible = Amr.db.char.Artifacts[spec].Crucible
355 if oldCrucible then
356 if #oldCrucible.Equipped > 0 and oldCrucible.Equipped[1] and not equipped[1] then
357 return
358 end
359 end
360 end
361
362 local dataz = Amr.db.char.Artifacts[spec]
363 if not dataz then
364 dataz = {}
365 Amr.db.char.Artifacts[spec] = dataz
366 end
367
368 if not dataz.Crucible then
369 dataz.Crucible = {
370 Equipped = {},
371 Inventory = {}
372 }
373 end
374
375 local crucible = dataz.Crucible
376 crucible.Equipped = equipped
377 if preview then
378 crucible.Inventory[preview.ItemLink] = preview
379 end
380 end
381 end
382
272 local function scanArtifact() 383 local function scanArtifact()
273 if not Amr.db or not Amr.db.char or not Amr.db.char.Artifacts then return end 384 if not Amr.db or not Amr.db.char or not Amr.db.char.Artifacts then return end
274 385
275 local powers = C_ArtifactUI.GetPowers() 386 local powers = C_ArtifactUI.GetPowers()
276 if not powers then return end 387 if not powers then return end
297 local itemID = C_ArtifactUI.GetArtifactInfo() 408 local itemID = C_ArtifactUI.GetArtifactInfo()
298 local spec = Amr.ArtifactIdToSpecNumber[itemID] 409 local spec = Amr.ArtifactIdToSpecNumber[itemID]
299 --local spec = GetSpecialization() 410 --local spec = GetSpecialization()
300 411
301 if spec then 412 if spec then
302 Amr.db.char.Artifacts[spec] = { 413
303 Powers = powerRanks, 414 -- sometimes this event can fire when no relic data is available, don't overwrite non-blank relic data with blank relic data
304 Relics = relicInfo 415 if Amr.db.char.Artifacts[spec] then
305 } 416 local oldRelics = Amr.db.char.Artifacts[spec].Relics
306 end 417 if oldRelics then
418 for i = 1,3 do
419 if oldRelics[i] and oldRelics[i] ~= "" and (not relicInfo[i] or relicInfo[i] == "") then
420 relicInfo[i] = oldRelics[i]
421 end
422 end
423 end
424 end
425
426 local dataz = Amr.db.char.Artifacts[spec]
427 if not dataz then
428 dataz = {}
429 Amr.db.char.Artifacts[spec] = dataz
430 end
431
432 if not dataz.Crucible then
433 dataz.Crucible = {
434 Equipped = {},
435 Inventory = {}
436 }
437 end
438
439 dataz.Powers = powerRanks
440 dataz.Relics = relicInfo
441
442 end
443
444 --scanCrucible()
307 end 445 end
308 446
309 -- Returns a data object containing all information about the current player needed for an export: 447 -- Returns a data object containing all information about the current player needed for an export:
310 -- gear, spec, reputations, bag, bank, and void storage items. 448 -- gear, spec, reputations, bag, bank, and void storage items.
311 function Amr:ExportCharacter() 449 function Amr:ExportCharacter()
342 Amr:AddEventHandler("VOID_STORAGE_DEPOSIT_UPDATE", scanVoid) 480 Amr:AddEventHandler("VOID_STORAGE_DEPOSIT_UPDATE", scanVoid)
343 Amr:AddEventHandler("VOID_STORAGE_UPDATE", scanVoid) 481 Amr:AddEventHandler("VOID_STORAGE_UPDATE", scanVoid)
344 482
345 Amr:AddEventHandler("PLAYER_TALENT_UPDATE", scanTalents) 483 Amr:AddEventHandler("PLAYER_TALENT_UPDATE", scanTalents)
346 Amr:AddEventHandler("ARTIFACT_UPDATE", scanArtifact) 484 Amr:AddEventHandler("ARTIFACT_UPDATE", scanArtifact)
485 Amr:AddEventHandler("ARTIFACT_RELIC_FORGE_UPDATE", scanCrucible)
486 Amr:AddEventHandler("ARTIFACT_RELIC_FORGE_PREVIEW_RELIC_CHANGED", scanCrucible)