comparison AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 63:f1d5827dbde0 v24

tweak to read new item link format
author yellowfive
date Tue, 23 Jun 2015 12:56:57 -0700
parents cf2b6b9a8337
children e638168c3395
comparison
equal deleted inserted replaced
62:8b37293e9ea5 63:f1d5827dbde0
1 -- AskMrRobot-Serializer will serialize and communicate character data between users. 1 -- AskMrRobot-Serializer will serialize and communicate character data between users.
2 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com. 2 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com.
3 3
4 local MAJOR, MINOR = "AskMrRobot-Serializer", 23 4 local MAJOR, MINOR = "AskMrRobot-Serializer", 24
5 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) 5 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
6 6
7 if not Amr then return end -- already loaded by something else 7 if not Amr then return end -- already loaded by something else
8 8
9 -- event and comm used for player snapshotting on entering combat 9 -- event and comm used for player snapshotting on entering combat
178 Amr.SPELL_ID_GLADIATOR_STANCE = 156291 178 Amr.SPELL_ID_GLADIATOR_STANCE = 156291
179 Amr.SPELL_ID_DEFENSIVE_STANCE = 71 179 Amr.SPELL_ID_DEFENSIVE_STANCE = 71
180 180
181 -- IDs of set tokens that we would care about in a player's inventory 181 -- IDs of set tokens that we would care about in a player's inventory
182 Amr.SetTokenIds = { 182 Amr.SetTokenIds = {
183 [127970] = true,
184 [127969] = true,
185 [127968] = true,
186 [127967] = true,
187 [127966] = true,
188 [127965] = true,
189 [127964] = true,
190 [127963] = true,
191 [127962] = true,
192 [127961] = true,
193 [127960] = true,
194 [127959] = true,
195 [127958] = true,
196 [127957] = true,
197 [127956] = true,
198 [127955] = true,
199 [127954] = true,
200 [127953] = true,
183 [120285] = true, 201 [120285] = true,
184 [120284] = true, 202 [120284] = true,
185 [120283] = true, 203 [120283] = true,
186 [120282] = true, 204 [120282] = true,
187 [120281] = true, 205 [120281] = true,
514 [65088] = true, 532 [65088] = true,
515 [65087] = true, 533 [65087] = true,
516 [63684] = true, 534 [63684] = true,
517 [63683] = true, 535 [63683] = true,
518 [63682] = true, 536 [63682] = true,
537 [51320] = true,
519 [45652] = true, 538 [45652] = true,
520 [45651] = true, 539 [45651] = true,
521 [45650] = true, 540 [45650] = true,
522 [45649] = true, 541 [45649] = true,
523 [45648] = true, 542 [45648] = true,
558 577
559 ---------------------------------------------------------------------------------------- 578 ----------------------------------------------------------------------------------------
560 -- Public Utility Methods 579 -- Public Utility Methods
561 ---------------------------------------------------------------------------------------- 580 ----------------------------------------------------------------------------------------
562 581
563 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r 582 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
564 -- get an object with all of the parts of the item link format that we care about 583 -- get an object with all of the parts of the item link format that we care about
565 function Amr.ParseItemLink(itemLink) 584 function Amr.ParseItemLink(itemLink)
566 if not itemLink then return nil end 585 if not itemLink then return nil end
567 586
568 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|") 587 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|")
575 item.enchantId = tonumber(parts[2]) 594 item.enchantId = tonumber(parts[2])
576 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) } 595 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) }
577 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code 596 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code
578 --item.uniqueId = tonumber(parts[8]) 597 --item.uniqueId = tonumber(parts[8])
579 --item.level = tonumber(parts[9]) 598 --item.level = tonumber(parts[9])
580 item.upgradeId = tonumber(parts[10]) 599 item.upgradeId = tonumber(parts[11])
581 --item.difficultyId = tonumber(parts[11]) 600 --item.difficultyId = tonumber(parts[12])
582 601
583 local numBonuses = tonumber(parts[12]) 602 local numBonuses = tonumber(parts[13])
584 if numBonuses and numBonuses > 0 then 603 if numBonuses and numBonuses > 0 then
585 item.bonusIds = {} 604 item.bonusIds = {}
586 for i = 13, 12 + numBonuses do 605 for i = 14, 13 + numBonuses do
587 table.insert(item.bonusIds, tonumber(parts[i])) 606 table.insert(item.bonusIds, tonumber(parts[i]))
588 end 607 end
589 table.sort(item.bonusIds) 608 table.sort(item.bonusIds)
590 end 609 end
591 610