annotate AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 83:af2474d28bb4 v39

Added Russian translation.
author yellowfive
date Wed, 03 Aug 2016 18:04:17 -0700
parents 0515882856f1
children 8914581c912f
rev   line source
yellowfive@57 1 -- AskMrRobot-Serializer will serialize and communicate character data between users.
yellowfive@57 2 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com.
yellowfive@57 3
yellowfive@83 4 local MAJOR, MINOR = "AskMrRobot-Serializer", 39
yellowfive@57 5 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
yellowfive@57 6
yellowfive@57 7 if not Amr then return end -- already loaded by something else
yellowfive@57 8
yellowfive@57 9 -- event and comm used for player snapshotting on entering combat
yellowfive@57 10 LibStub("AceEvent-3.0"):Embed(Amr)
yellowfive@57 11 LibStub("AceComm-3.0"):Embed(Amr)
yellowfive@57 12
yellowfive@57 13 ----------------------------------------------------------------------------------------
yellowfive@57 14 -- Constants
yellowfive@57 15 ----------------------------------------------------------------------------------------
yellowfive@57 16
yellowfive@57 17 -- prefix used for communicating gear snapshots created by the AMR serializer
yellowfive@57 18 Amr.ChatPrefix = "_AMRS"
yellowfive@57 19
yellowfive@57 20 -- map of region ids to AMR region names
yellowfive@57 21 Amr.RegionNames = {
yellowfive@57 22 [1] = "US",
yellowfive@57 23 [2] = "KR",
yellowfive@57 24 [3] = "EU",
yellowfive@57 25 [4] = "TW",
yellowfive@57 26 [5] = "CN"
yellowfive@57 27 }
yellowfive@57 28
yellowfive@57 29 -- map of the skillLine returned by profession API to the AMR profession name
yellowfive@57 30 Amr.ProfessionSkillLineToName = {
yellowfive@57 31 [794] = "Archaeology",
yellowfive@57 32 [171] = "Alchemy",
yellowfive@57 33 [164] = "Blacksmithing",
yellowfive@57 34 [185] = "Cooking",
yellowfive@57 35 [333] = "Enchanting",
yellowfive@57 36 [202] = "Engineering",
yellowfive@57 37 [129] = "First Aid",
yellowfive@57 38 [356] = "Fishing",
yellowfive@57 39 [182] = "Herbalism",
yellowfive@57 40 [773] = "Inscription",
yellowfive@57 41 [755] = "Jewelcrafting",
yellowfive@57 42 [165] = "Leatherworking",
yellowfive@57 43 [186] = "Mining",
yellowfive@57 44 [393] = "Skinning",
yellowfive@57 45 [197] = "Tailoring"
yellowfive@57 46 }
yellowfive@57 47
yellowfive@57 48 -- all slot IDs that we care about, ordered in AMR standard display order
yellowfive@57 49 Amr.SlotIds = { 16, 17, 1, 2, 3, 15, 5, 9, 10, 6, 7, 8, 11, 12, 13, 14 }
yellowfive@57 50
yellowfive@57 51 Amr.SpecIds = {
yellowfive@57 52 [250] = 1, -- DeathKnightBlood
yellowfive@57 53 [251] = 2, -- DeathKnightFrost
yellowfive@57 54 [252] = 3, -- DeathKnightUnholy
yellowfive@81 55 [577] = 4, -- DemonHunterHavoc
yellowfive@81 56 [581] = 5, -- DemonHunterVengeance
yellowfive@81 57 [102] = 6, -- DruidBalance
yellowfive@81 58 [103] = 7, -- DruidFeral
yellowfive@81 59 [104] = 8, -- DruidGuardian
yellowfive@81 60 [105] = 9, -- DruidRestoration
yellowfive@81 61 [253] = 10, -- HunterBeastMastery
yellowfive@81 62 [254] = 11, -- HunterMarksmanship
yellowfive@81 63 [255] = 12, -- HunterSurvival
yellowfive@81 64 [62] = 13, -- MageArcane
yellowfive@81 65 [63] = 14, -- MageFire
yellowfive@81 66 [64] = 15, -- MageFrost
yellowfive@81 67 [268] = 16, -- MonkBrewmaster
yellowfive@81 68 [270] = 17, -- MonkMistweaver
yellowfive@81 69 [269] = 18, -- MonkWindwalker
yellowfive@81 70 [65] = 19, -- PaladinHoly
yellowfive@81 71 [66] = 20, -- PaladinProtection
yellowfive@81 72 [70] = 21, -- PaladinRetribution
yellowfive@81 73 [256] = 22, -- PriestDiscipline
yellowfive@81 74 [257] = 23, -- PriestHoly
yellowfive@81 75 [258] = 24, -- PriestShadow
yellowfive@81 76 [259] = 25, -- RogueAssassination
yellowfive@81 77 [260] = 26, -- RogueOutlaw
yellowfive@81 78 [261] = 27, -- RogueSubtlety
yellowfive@81 79 [262] = 28, -- ShamanElemental
yellowfive@81 80 [263] = 29, -- ShamanEnhancement
yellowfive@81 81 [264] = 30, -- ShamanRestoration
yellowfive@81 82 [265] = 31, -- WarlockAffliction
yellowfive@81 83 [266] = 32, -- WarlockDemonology
yellowfive@81 84 [267] = 33, -- WarlockDestruction
yellowfive@81 85 [71] = 34, -- WarriorArms
yellowfive@81 86 [72] = 35, -- WarriorFury
yellowfive@81 87 [73] = 36 -- WarriorProtection
yellowfive@57 88 }
yellowfive@57 89
yellowfive@57 90 Amr.ClassIds = {
yellowfive@57 91 ["NONE"] = 0,
yellowfive@57 92 ["DEATHKNIGHT"] = 1,
yellowfive@81 93 ["DEMONHUNTER"] = 2,
yellowfive@81 94 ["DRUID"] = 3,
yellowfive@81 95 ["HUNTER"] = 4,
yellowfive@81 96 ["MAGE"] = 5,
yellowfive@81 97 ["MONK"] = 6,
yellowfive@81 98 ["PALADIN"] = 7,
yellowfive@81 99 ["PRIEST"] = 8,
yellowfive@81 100 ["ROGUE"] = 9,
yellowfive@81 101 ["SHAMAN"] = 10,
yellowfive@81 102 ["WARLOCK"] = 11,
yellowfive@81 103 ["WARRIOR"] = 12,
yellowfive@57 104 }
yellowfive@57 105
yellowfive@57 106 Amr.ProfessionIds = {
yellowfive@57 107 ["None"] = 0,
yellowfive@57 108 ["Mining"] = 1,
yellowfive@57 109 ["Skinning"] = 2,
yellowfive@57 110 ["Herbalism"] = 3,
yellowfive@57 111 ["Enchanting"] = 4,
yellowfive@57 112 ["Jewelcrafting"] = 5,
yellowfive@57 113 ["Engineering"] = 6,
yellowfive@57 114 ["Blacksmithing"] = 7,
yellowfive@57 115 ["Leatherworking"] = 8,
yellowfive@57 116 ["Inscription"] = 9,
yellowfive@57 117 ["Tailoring"] = 10,
yellowfive@57 118 ["Alchemy"] = 11,
yellowfive@57 119 ["Fishing"] = 12,
yellowfive@57 120 ["Cooking"] = 13,
yellowfive@57 121 ["First Aid"] = 14,
yellowfive@57 122 ["Archaeology"] = 15
yellowfive@57 123 }
yellowfive@57 124
yellowfive@57 125 Amr.RaceIds = {
yellowfive@57 126 ["None"] = 0,
yellowfive@57 127 ["BloodElf"] = 1,
yellowfive@57 128 ["Draenei"] = 2,
yellowfive@57 129 ["Dwarf"] = 3,
yellowfive@57 130 ["Gnome"] = 4,
yellowfive@57 131 ["Human"] = 5,
yellowfive@57 132 ["NightElf"] = 6,
yellowfive@57 133 ["Orc"] = 7,
yellowfive@57 134 ["Tauren"] = 8,
yellowfive@57 135 ["Troll"] = 9,
yellowfive@57 136 ["Scourge"] = 10,
yellowfive@57 137 ["Undead"] = 10,
yellowfive@57 138 ["Goblin"] = 11,
yellowfive@57 139 ["Worgen"] = 12,
yellowfive@57 140 ["Pandaren"] = 13
yellowfive@57 141 }
yellowfive@57 142
yellowfive@57 143 Amr.FactionIds = {
yellowfive@57 144 ["None"] = 0,
yellowfive@57 145 ["Alliance"] = 1,
yellowfive@57 146 ["Horde"] = 2
yellowfive@57 147 }
yellowfive@57 148
yellowfive@57 149 Amr.InstanceIds = {
yellowfive@57 150 Auchindoun = 1182,
yellowfive@57 151 BloodmaulSlagMines = 1175,
yellowfive@57 152 GrimrailDepot = 1208,
yellowfive@57 153 IronDocks = 1195,
yellowfive@57 154 ShadowmoonBurialGrounds = 1176,
yellowfive@57 155 Skyreach = 1209,
yellowfive@57 156 TheEverbloom = 1279,
yellowfive@57 157 UpperBlackrockSpire = 1358,
yellowfive@57 158 Highmaul = 1228,
yellowfive@61 159 BlackrockFoundry = 1205,
yellowfive@61 160 HellfireCitadel = 1448
yellowfive@57 161 }
yellowfive@57 162
yellowfive@57 163 -- instances that AskMrRobot currently supports logging for
yellowfive@57 164 Amr.SupportedInstanceIds = {
yellowfive@57 165 --[1182] = true,
yellowfive@57 166 --[1175] = true,
yellowfive@57 167 --[1208] = true,
yellowfive@57 168 --[1195] = true,
yellowfive@57 169 --[1176] = true,
yellowfive@57 170 --[1209] = true,
yellowfive@57 171 --[1279] = true,
yellowfive@57 172 --[1358] = true,
yellowfive@57 173 [1228] = true,
yellowfive@61 174 [1205] = true,
yellowfive@61 175 [1448] = true
yellowfive@57 176 }
yellowfive@57 177
yellowfive@57 178 -- IDs of set tokens that we would care about in a player's inventory
yellowfive@57 179 Amr.SetTokenIds = {
yellowfive@63 180 [127970] = true,
yellowfive@63 181 [127969] = true,
yellowfive@63 182 [127968] = true,
yellowfive@63 183 [127967] = true,
yellowfive@63 184 [127966] = true,
yellowfive@63 185 [127965] = true,
yellowfive@63 186 [127964] = true,
yellowfive@63 187 [127963] = true,
yellowfive@63 188 [127962] = true,
yellowfive@63 189 [127961] = true,
yellowfive@63 190 [127960] = true,
yellowfive@63 191 [127959] = true,
yellowfive@63 192 [127958] = true,
yellowfive@63 193 [127957] = true,
yellowfive@63 194 [127956] = true,
yellowfive@63 195 [127955] = true,
yellowfive@63 196 [127954] = true,
yellowfive@63 197 [127953] = true,
yellowfive@57 198 [120285] = true,
yellowfive@57 199 [120284] = true,
yellowfive@57 200 [120283] = true,
yellowfive@57 201 [120282] = true,
yellowfive@57 202 [120281] = true,
yellowfive@57 203 [120280] = true,
yellowfive@57 204 [120279] = true,
yellowfive@57 205 [120278] = true,
yellowfive@57 206 [120277] = true,
yellowfive@57 207 [120256] = true,
yellowfive@57 208 [120255] = true,
yellowfive@57 209 [120254] = true,
yellowfive@57 210 [120253] = true,
yellowfive@57 211 [120252] = true,
yellowfive@57 212 [120251] = true,
yellowfive@57 213 [120250] = true,
yellowfive@57 214 [120249] = true,
yellowfive@57 215 [120248] = true,
yellowfive@57 216 [120247] = true,
yellowfive@57 217 [120246] = true,
yellowfive@57 218 [120245] = true,
yellowfive@57 219 [120244] = true,
yellowfive@57 220 [120243] = true,
yellowfive@57 221 [120242] = true,
yellowfive@57 222 [120241] = true,
yellowfive@57 223 [120240] = true,
yellowfive@57 224 [120239] = true,
yellowfive@57 225 [120238] = true,
yellowfive@57 226 [120237] = true,
yellowfive@57 227 [120236] = true,
yellowfive@57 228 [120235] = true,
yellowfive@57 229 [120234] = true,
yellowfive@57 230 [120233] = true,
yellowfive@57 231 [120232] = true,
yellowfive@57 232 [120231] = true,
yellowfive@57 233 [120230] = true,
yellowfive@57 234 [120229] = true,
yellowfive@57 235 [120228] = true,
yellowfive@57 236 [120227] = true,
yellowfive@57 237 [120226] = true,
yellowfive@57 238 [120225] = true,
yellowfive@57 239 [120224] = true,
yellowfive@57 240 [120223] = true,
yellowfive@57 241 [120222] = true,
yellowfive@57 242 [120221] = true,
yellowfive@57 243 [120220] = true,
yellowfive@57 244 [120219] = true,
yellowfive@57 245 [120218] = true,
yellowfive@57 246 [120217] = true,
yellowfive@57 247 [120216] = true,
yellowfive@57 248 [120215] = true,
yellowfive@57 249 [120214] = true,
yellowfive@57 250 [120213] = true,
yellowfive@57 251 [120212] = true,
yellowfive@57 252 [120211] = true,
yellowfive@57 253 [120210] = true,
yellowfive@57 254 [120209] = true,
yellowfive@57 255 [120208] = true,
yellowfive@57 256 [120207] = true,
yellowfive@57 257 [120206] = true,
yellowfive@57 258 [119323] = true,
yellowfive@57 259 [119322] = true,
yellowfive@57 260 [119321] = true,
yellowfive@57 261 [119320] = true,
yellowfive@57 262 [119319] = true,
yellowfive@57 263 [119318] = true,
yellowfive@57 264 [119316] = true,
yellowfive@57 265 [119315] = true,
yellowfive@57 266 [119314] = true,
yellowfive@57 267 [119313] = true,
yellowfive@57 268 [119312] = true,
yellowfive@57 269 [119311] = true,
yellowfive@57 270 [119310] = true,
yellowfive@57 271 [119309] = true,
yellowfive@57 272 [119308] = true,
yellowfive@57 273 [119307] = true,
yellowfive@57 274 [119306] = true,
yellowfive@57 275 [119305] = true,
yellowfive@57 276 [105868] = true,
yellowfive@57 277 [105867] = true,
yellowfive@57 278 [105866] = true,
yellowfive@57 279 [105865] = true,
yellowfive@57 280 [105864] = true,
yellowfive@57 281 [105863] = true,
yellowfive@57 282 [105862] = true,
yellowfive@57 283 [105861] = true,
yellowfive@57 284 [105860] = true,
yellowfive@57 285 [105859] = true,
yellowfive@57 286 [105858] = true,
yellowfive@57 287 [105857] = true,
yellowfive@57 288 [99756] = true,
yellowfive@57 289 [99755] = true,
yellowfive@57 290 [99754] = true,
yellowfive@57 291 [99753] = true,
yellowfive@57 292 [99752] = true,
yellowfive@57 293 [99751] = true,
yellowfive@57 294 [99750] = true,
yellowfive@57 295 [99749] = true,
yellowfive@57 296 [99748] = true,
yellowfive@57 297 [99747] = true,
yellowfive@57 298 [99746] = true,
yellowfive@57 299 [99745] = true,
yellowfive@57 300 [99744] = true,
yellowfive@57 301 [99743] = true,
yellowfive@57 302 [99742] = true,
yellowfive@57 303 [99740] = true,
yellowfive@57 304 [99739] = true,
yellowfive@57 305 [99738] = true,
yellowfive@57 306 [99737] = true,
yellowfive@57 307 [99736] = true,
yellowfive@57 308 [99735] = true,
yellowfive@57 309 [99734] = true,
yellowfive@57 310 [99733] = true,
yellowfive@57 311 [99732] = true,
yellowfive@57 312 [99731] = true,
yellowfive@57 313 [99730] = true,
yellowfive@57 314 [99729] = true,
yellowfive@57 315 [99728] = true,
yellowfive@57 316 [99727] = true,
yellowfive@57 317 [99726] = true,
yellowfive@57 318 [99725] = true,
yellowfive@57 319 [99724] = true,
yellowfive@57 320 [99723] = true,
yellowfive@57 321 [99722] = true,
yellowfive@57 322 [99721] = true,
yellowfive@57 323 [99720] = true,
yellowfive@57 324 [99719] = true,
yellowfive@57 325 [99718] = true,
yellowfive@57 326 [99717] = true,
yellowfive@57 327 [99716] = true,
yellowfive@57 328 [99715] = true,
yellowfive@57 329 [99714] = true,
yellowfive@57 330 [99713] = true,
yellowfive@57 331 [99712] = true,
yellowfive@57 332 [99711] = true,
yellowfive@57 333 [99710] = true,
yellowfive@57 334 [99709] = true,
yellowfive@57 335 [99708] = true,
yellowfive@57 336 [99707] = true,
yellowfive@57 337 [99706] = true,
yellowfive@57 338 [99705] = true,
yellowfive@57 339 [99704] = true,
yellowfive@57 340 [99703] = true,
yellowfive@57 341 [99702] = true,
yellowfive@57 342 [99701] = true,
yellowfive@57 343 [99700] = true,
yellowfive@57 344 [99699] = true,
yellowfive@57 345 [99698] = true,
yellowfive@57 346 [99697] = true,
yellowfive@57 347 [99696] = true,
yellowfive@57 348 [99695] = true,
yellowfive@57 349 [99694] = true,
yellowfive@57 350 [99693] = true,
yellowfive@57 351 [99692] = true,
yellowfive@57 352 [99691] = true,
yellowfive@57 353 [99690] = true,
yellowfive@57 354 [99689] = true,
yellowfive@57 355 [99688] = true,
yellowfive@57 356 [99687] = true,
yellowfive@57 357 [99686] = true,
yellowfive@57 358 [99685] = true,
yellowfive@57 359 [99684] = true,
yellowfive@57 360 [99683] = true,
yellowfive@57 361 [99682] = true,
yellowfive@57 362 [99681] = true,
yellowfive@57 363 [99680] = true,
yellowfive@57 364 [99679] = true,
yellowfive@57 365 [99678] = true,
yellowfive@57 366 [99677] = true,
yellowfive@57 367 [99676] = true,
yellowfive@57 368 [99675] = true,
yellowfive@57 369 [99674] = true,
yellowfive@57 370 [99673] = true,
yellowfive@57 371 [99672] = true,
yellowfive@57 372 [99671] = true,
yellowfive@57 373 [99670] = true,
yellowfive@57 374 [99669] = true,
yellowfive@57 375 [99668] = true,
yellowfive@57 376 [99667] = true,
yellowfive@57 377 [96701] = true,
yellowfive@57 378 [96700] = true,
yellowfive@57 379 [96699] = true,
yellowfive@57 380 [96633] = true,
yellowfive@57 381 [96632] = true,
yellowfive@57 382 [96631] = true,
yellowfive@57 383 [96625] = true,
yellowfive@57 384 [96624] = true,
yellowfive@57 385 [96623] = true,
yellowfive@57 386 [96601] = true,
yellowfive@57 387 [96600] = true,
yellowfive@57 388 [96599] = true,
yellowfive@57 389 [96568] = true,
yellowfive@57 390 [96567] = true,
yellowfive@57 391 [96566] = true,
yellowfive@57 392 [95957] = true,
yellowfive@57 393 [95956] = true,
yellowfive@57 394 [95955] = true,
yellowfive@57 395 [95889] = true,
yellowfive@57 396 [95888] = true,
yellowfive@57 397 [95887] = true,
yellowfive@57 398 [95881] = true,
yellowfive@57 399 [95880] = true,
yellowfive@57 400 [95879] = true,
yellowfive@57 401 [95857] = true,
yellowfive@57 402 [95856] = true,
yellowfive@57 403 [95855] = true,
yellowfive@57 404 [95824] = true,
yellowfive@57 405 [95823] = true,
yellowfive@57 406 [95822] = true,
yellowfive@57 407 [95583] = true,
yellowfive@57 408 [95582] = true,
yellowfive@57 409 [95581] = true,
yellowfive@57 410 [95580] = true,
yellowfive@57 411 [95579] = true,
yellowfive@57 412 [95578] = true,
yellowfive@57 413 [95577] = true,
yellowfive@57 414 [95576] = true,
yellowfive@57 415 [95575] = true,
yellowfive@57 416 [95574] = true,
yellowfive@57 417 [95573] = true,
yellowfive@57 418 [95572] = true,
yellowfive@57 419 [95571] = true,
yellowfive@57 420 [95570] = true,
yellowfive@57 421 [95569] = true,
yellowfive@57 422 [89278] = true,
yellowfive@57 423 [89277] = true,
yellowfive@57 424 [89276] = true,
yellowfive@57 425 [89275] = true,
yellowfive@57 426 [89274] = true,
yellowfive@57 427 [89273] = true,
yellowfive@57 428 [89272] = true,
yellowfive@57 429 [89271] = true,
yellowfive@57 430 [89270] = true,
yellowfive@57 431 [89269] = true,
yellowfive@57 432 [89268] = true,
yellowfive@57 433 [89267] = true,
yellowfive@57 434 [89266] = true,
yellowfive@57 435 [89265] = true,
yellowfive@57 436 [89264] = true,
yellowfive@57 437 [89263] = true,
yellowfive@57 438 [89262] = true,
yellowfive@57 439 [89261] = true,
yellowfive@57 440 [89260] = true,
yellowfive@57 441 [89259] = true,
yellowfive@57 442 [89258] = true,
yellowfive@57 443 [89257] = true,
yellowfive@57 444 [89256] = true,
yellowfive@57 445 [89255] = true,
yellowfive@57 446 [89254] = true,
yellowfive@57 447 [89253] = true,
yellowfive@57 448 [89252] = true,
yellowfive@57 449 [89251] = true,
yellowfive@57 450 [89250] = true,
yellowfive@57 451 [89249] = true,
yellowfive@57 452 [89248] = true,
yellowfive@57 453 [89247] = true,
yellowfive@57 454 [89246] = true,
yellowfive@57 455 [89245] = true,
yellowfive@57 456 [89244] = true,
yellowfive@57 457 [89243] = true,
yellowfive@57 458 [89242] = true,
yellowfive@57 459 [89241] = true,
yellowfive@57 460 [89240] = true,
yellowfive@57 461 [89239] = true,
yellowfive@57 462 [89238] = true,
yellowfive@57 463 [89237] = true,
yellowfive@57 464 [89236] = true,
yellowfive@57 465 [89235] = true,
yellowfive@57 466 [89234] = true,
yellowfive@57 467 [78876] = true,
yellowfive@57 468 [78875] = true,
yellowfive@57 469 [78874] = true,
yellowfive@57 470 [78873] = true,
yellowfive@57 471 [78872] = true,
yellowfive@57 472 [78871] = true,
yellowfive@57 473 [78867] = true,
yellowfive@57 474 [78866] = true,
yellowfive@57 475 [78865] = true,
yellowfive@57 476 [78864] = true,
yellowfive@57 477 [78863] = true,
yellowfive@57 478 [78862] = true,
yellowfive@57 479 [78861] = true,
yellowfive@57 480 [78860] = true,
yellowfive@57 481 [78859] = true,
yellowfive@57 482 [78858] = true,
yellowfive@57 483 [78857] = true,
yellowfive@57 484 [78856] = true,
yellowfive@57 485 [78855] = true,
yellowfive@57 486 [78854] = true,
yellowfive@57 487 [78853] = true,
yellowfive@57 488 [78849] = true,
yellowfive@57 489 [78848] = true,
yellowfive@57 490 [78847] = true,
yellowfive@57 491 [78184] = true,
yellowfive@57 492 [78183] = true,
yellowfive@57 493 [78181] = true,
yellowfive@57 494 [78180] = true,
yellowfive@57 495 [78179] = true,
yellowfive@57 496 [78178] = true,
yellowfive@57 497 [78176] = true,
yellowfive@57 498 [78175] = true,
yellowfive@57 499 [78174] = true,
yellowfive@57 500 [78173] = true,
yellowfive@57 501 [78171] = true,
yellowfive@57 502 [78170] = true,
yellowfive@57 503 [71687] = true,
yellowfive@57 504 [71686] = true,
yellowfive@57 505 [71685] = true,
yellowfive@57 506 [71683] = true,
yellowfive@57 507 [71682] = true,
yellowfive@57 508 [71680] = true,
yellowfive@57 509 [71679] = true,
yellowfive@57 510 [71678] = true,
yellowfive@57 511 [71676] = true,
yellowfive@57 512 [71675] = true,
yellowfive@57 513 [71673] = true,
yellowfive@57 514 [71672] = true,
yellowfive@57 515 [71671] = true,
yellowfive@57 516 [71669] = true,
yellowfive@57 517 [71668] = true,
yellowfive@57 518 [67431] = true,
yellowfive@57 519 [67430] = true,
yellowfive@57 520 [67429] = true,
yellowfive@57 521 [67428] = true,
yellowfive@57 522 [67427] = true,
yellowfive@57 523 [67426] = true,
yellowfive@57 524 [67425] = true,
yellowfive@57 525 [67424] = true,
yellowfive@57 526 [67423] = true,
yellowfive@57 527 [66998] = true,
yellowfive@57 528 [65089] = true,
yellowfive@57 529 [65088] = true,
yellowfive@57 530 [65087] = true,
yellowfive@57 531 [63684] = true,
yellowfive@57 532 [63683] = true,
yellowfive@57 533 [63682] = true,
yellowfive@63 534 [51320] = true,
yellowfive@57 535 [45652] = true,
yellowfive@57 536 [45651] = true,
yellowfive@57 537 [45650] = true,
yellowfive@57 538 [45649] = true,
yellowfive@57 539 [45648] = true,
yellowfive@57 540 [45647] = true,
yellowfive@57 541 [45643] = true,
yellowfive@57 542 [45642] = true,
yellowfive@57 543 [45641] = true,
yellowfive@57 544 [40630] = true,
yellowfive@57 545 [40629] = true,
yellowfive@57 546 [40628] = true,
yellowfive@57 547 [40621] = true,
yellowfive@57 548 [40620] = true,
yellowfive@57 549 [40619] = true,
yellowfive@57 550 [40618] = true,
yellowfive@57 551 [40617] = true,
yellowfive@57 552 [40616] = true,
yellowfive@57 553 [34544] = true,
yellowfive@57 554 [31100] = true,
yellowfive@57 555 [31099] = true,
yellowfive@57 556 [31098] = true,
yellowfive@57 557 [31097] = true,
yellowfive@57 558 [31096] = true,
yellowfive@57 559 [31095] = true,
yellowfive@57 560 [30247] = true,
yellowfive@57 561 [30246] = true,
yellowfive@57 562 [30245] = true,
yellowfive@57 563 [30244] = true,
yellowfive@57 564 [30243] = true,
yellowfive@57 565 [30242] = true,
yellowfive@57 566 [29767] = true,
yellowfive@57 567 [29766] = true,
yellowfive@57 568 [29765] = true,
yellowfive@57 569 [29761] = true,
yellowfive@57 570 [29760] = true,
yellowfive@57 571 [29759] = true
yellowfive@57 572 }
yellowfive@57 573
yellowfive@57 574
yellowfive@57 575 ----------------------------------------------------------------------------------------
yellowfive@57 576 -- Public Utility Methods
yellowfive@57 577 ----------------------------------------------------------------------------------------
yellowfive@57 578
yellowfive@81 579 local function readBonusIdList(parts, first, last)
yellowfive@81 580 local ret = {}
yellowfive@81 581 for i = first, last do
yellowfive@81 582 table.insert(ret, tonumber(parts[i]))
yellowfive@81 583 end
yellowfive@81 584 table.sort(ret)
yellowfive@81 585 return ret
yellowfive@81 586 end
yellowfive@81 587
yellowfive@81 588 local function setRelicId(item, index, relicBonuses)
yellowfive@81 589 local relicId = item.gemIds[index] .. ""
yellowfive@81 590 for i = 1, #relicBonuses do
yellowfive@81 591 relicId = relicId .. "." .. relicBonuses[i]
yellowfive@81 592 end
yellowfive@81 593 local list = item.gemItemIds or {}
yellowfive@81 594 list[i] = relicId
yellowfive@81 595 end
yellowfive@81 596
yellowfive@81 597 --|color|Hitem:135820:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:playerlevel:spec?:flags:11:numBonusIDs:bonusID1:bonusID2...:playerlevelwhengotitem, 296 for warrior artifact:upgrade ID?:num artifact bonuses?:artifact bonus 1:artifact bonus 2:artifact bonus 3:[item name]
yellowfive@81 598 -- 133004 for relic on my warrior, gem2
yellowfive@81 599 -- 296::3:767:1507:1809:[item name] this is for warrior artifact with the above relic in storm slot, for parts after the bonus IDs
yellowfive@81 600
yellowfive@81 601 --|cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:unknown:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
yellowfive@81 602
yellowfive@69 603 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:unknown:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
yellowfive@57 604 -- get an object with all of the parts of the item link format that we care about
yellowfive@57 605 function Amr.ParseItemLink(itemLink)
yellowfive@57 606 if not itemLink then return nil end
yellowfive@57 607
yellowfive@57 608 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|")
yellowfive@57 609 if not str then return nil end
yellowfive@57 610
yellowfive@57 611 local parts = { strsplit(":", str) }
yellowfive@57 612
yellowfive@57 613 local item = {}
yellowfive@81 614 item.id = tonumber(parts[1]) or 0
yellowfive@81 615 item.enchantId = tonumber(parts[2]) or 0
yellowfive@81 616 item.gemIds = { tonumber(parts[3]) or 0, tonumber(parts[4]) or 0, tonumber(parts[5]) or 0, tonumber(parts[6]) or 0 }
yellowfive@81 617 item.suffixId = math.abs(tonumber(parts[7]) or 0) -- convert suffix to positive number, that's what we use in our code
yellowfive@81 618 -- part 8 is some unique ID... we never really used it
yellowfive@81 619 -- part 9 is current player level
yellowfive@81 620 -- part 10 is player spec
yellowfive@81 621 local upgradeIdType = tonumber(parts[11]) or 0 -- part 11 indicates what kind of upgrade ID is just after the bonus IDs
yellowfive@81 622 -- part 12 is instance difficulty id
yellowfive@57 623
yellowfive@81 624 local numBonuses = tonumber(parts[13]) or 0
yellowfive@81 625 local offset = numBonuses
yellowfive@81 626 if numBonuses > 0 then
yellowfive@81 627 item.bonusIds = readBonusIdList(parts, 14, 13 + numBonuses)
yellowfive@57 628 end
yellowfive@69 629
yellowfive@81 630 item.upgradeId = 0
yellowfive@81 631 item.level = 0
yellowfive@81 632
yellowfive@81 633 -- the next part after bonus IDs depends on the upgrade id type; is either the "drop level" or upgrade ID, or not sure for artifacts
yellowfive@81 634 if upgradeIdType == 4 then
yellowfive@81 635 item.upgradeId = tonumber(parts[14 + offset]) or 0
yellowfive@81 636 elseif upgradeIdType == 512 then
yellowfive@81 637 item.level = tonumber(parts[14 + offset]) or 0
yellowfive@69 638 end
yellowfive@81 639
yellowfive@81 640 -- ignore relic stuff in the item link for now, we read the relic information directly and save it with artifact power info
yellowfive@81 641 --[[
yellowfive@81 642 -- the next part is the number of bonus IDs on the first relic slot of the artifact
yellowfive@81 643 numBonuses = tonumber(parts[15 + offset]) or 0
yellowfive@81 644 if numBonuses > 0 then
yellowfive@81 645 local relicBonuses = readBonusIdList(16 + offset, 15 + offset + numBonuses, parts)
yellowfive@81 646 setRelicId(item, 1, relicBonuses)
yellowfive@81 647 end
yellowfive@81 648
yellowfive@81 649 -- second relic slot bonus IDs
yellowfive@81 650 offset = offset + numBonuses
yellowfive@81 651 numBonuses = tonumber(parts[16 + offset]) or 0
yellowfive@81 652 if numBonuses > 0 then
yellowfive@81 653 local relicBonuses = readBonusIdList(17 + offset, 16 + offset + numBonuses, parts)
yellowfive@81 654 setRelicId(item, 2, relicBonuses)
yellowfive@81 655 end
yellowfive@81 656
yellowfive@81 657 -- third relic slot bonus IDs
yellowfive@81 658 offset = offset + numBonuses
yellowfive@81 659 numBonuses = tonumber(parts[17 + offset]) or 0
yellowfive@81 660 if numBonuses > 0 then
yellowfive@81 661 local relicBonuses = readBonusIdList(18 + offset, 17 + offset + numBonuses, parts)
yellowfive@81 662 setRelicId(item, 3, relicBonuses)
yellowfive@81 663 end
yellowfive@81 664 ]]
yellowfive@81 665
yellowfive@57 666 return item
yellowfive@57 667 end
yellowfive@57 668
yellowfive@81 669 function Amr.GetItemUniqueId(item, noUpgrade)
yellowfive@81 670 if not item then return "" end
yellowfive@81 671 local ret = item.id .. ""
yellowfive@81 672 if item.bonusIds then
yellowfive@81 673 for i = 1, #item.bonusIds do
yellowfive@81 674 ret = ret .. "b" .. item.bonusIds[i]
yellowfive@81 675 end
yellowfive@81 676 end
yellowfive@81 677 if item.suffixId ~= 0 then
yellowfive@81 678 ret = ret .. "s" .. item.suffixId
yellowfive@81 679 end
yellowfive@81 680 if not noUpgrade and item.upgradeId ~= 0 then
yellowfive@81 681 ret = ret .. "u" .. item.upgradeId
yellowfive@81 682 end
yellowfive@81 683 if item.level ~= 0 then
yellowfive@81 684 ret = ret .. "v" .. item.level
yellowfive@81 685 end
yellowfive@81 686 return ret
yellowfive@81 687 end
yellowfive@81 688
yellowfive@57 689 -- returns true if this is an instance that AskMrRobot supports for logging
yellowfive@57 690 function Amr.IsSupportedInstanceId(instanceMapID)
yellowfive@57 691 if Amr.SupportedInstanceIds[tonumber(instanceMapID)] then
yellowfive@57 692 return true
yellowfive@57 693 else
yellowfive@57 694 return false
yellowfive@57 695 end
yellowfive@57 696 end
yellowfive@57 697
yellowfive@57 698 -- returns true if currently in a supported instance for logging
yellowfive@57 699 function Amr.IsSupportedInstance()
yellowfive@57 700 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
yellowfive@57 701 return Amr.IsSupportedInstanceId(instanceMapID)
yellowfive@57 702 end
yellowfive@57 703
yellowfive@81 704 -- helper to iterate over a table in order by its keys
yellowfive@81 705 local function spairs(t, order)
yellowfive@81 706 -- collect the keys
yellowfive@81 707 local keys = {}
yellowfive@81 708 for k in pairs(t) do keys[#keys+1] = k end
yellowfive@81 709
yellowfive@81 710 -- if order function given, sort by it by passing the table and keys a, b,
yellowfive@81 711 -- otherwise just sort the keys
yellowfive@81 712 if order then
yellowfive@81 713 table.sort(keys, function(a,b) return order(t, a, b) end)
yellowfive@81 714 else
yellowfive@81 715 table.sort(keys)
yellowfive@81 716 end
yellowfive@81 717
yellowfive@81 718 -- return the iterator function
yellowfive@81 719 local i = 0
yellowfive@81 720 return function()
yellowfive@81 721 i = i + 1
yellowfive@81 722 if keys[i] then
yellowfive@81 723 return keys[i], t[keys[i]]
yellowfive@81 724 end
yellowfive@81 725 end
yellowfive@81 726 end
yellowfive@81 727
yellowfive@81 728 -- scanning tooltip b/c for some odd reason the api has no way to get basic item properties...
yellowfive@81 729 -- so you have to generate a fake item tooltip and search for pre-defined strings in the display text
yellowfive@81 730 local _scanTt
yellowfive@81 731 function Amr.GetScanningTooltip()
yellowfive@81 732 if not _scanTt then
yellowfive@81 733 _scanTt = CreateFrame("GameTooltip", "AmrUiScanTooltip", nil, "GameTooltipTemplate")
yellowfive@81 734 _scanTt:SetOwner(UIParent, "ANCHOR_NONE")
yellowfive@81 735 end
yellowfive@81 736 return _scanTt
yellowfive@81 737 end
yellowfive@81 738
yellowfive@81 739 -- get the item tooltip for the specified item in one of your bags, or if bagId is nil, an equipped item, or if slotId is also nil, the specified item link
yellowfive@81 740 function Amr.GetItemTooltip(bagId, slotId, link)
yellowfive@81 741 local tt = Amr.GetScanningTooltip()
yellowfive@81 742 tt:ClearLines()
yellowfive@81 743 if bagId then
yellowfive@81 744 tt:SetBagItem(bagId, slotId)
yellowfive@81 745 elseif slotId then
yellowfive@81 746 tt:SetInventoryItem("player", slotId)
yellowfive@81 747 else
yellowfive@81 748 tt:SetHyperlink(link)
yellowfive@81 749 end
yellowfive@81 750 return tt
yellowfive@81 751 end
yellowfive@81 752
yellowfive@81 753 function Amr.GetItemLevel(bagId, slotId, link)
yellowfive@81 754 local itemLevelPattern = _G["ITEM_LEVEL"]:gsub("%%d", "(%%d+)")
yellowfive@81 755 local tt = Amr.GetItemTooltip(bagId, slotId, link)
yellowfive@81 756
yellowfive@81 757 local regions = { tt:GetRegions() }
yellowfive@81 758 for i, region in ipairs(regions) do
yellowfive@81 759 if region and region:GetObjectType() == "FontString" then
yellowfive@81 760 local text = region:GetText()
yellowfive@81 761 if text then
yellowfive@81 762 ilvl = tonumber(text:match(itemLevelPattern))
yellowfive@81 763 if ilvl then
yellowfive@81 764 return ilvl
yellowfive@81 765 end
yellowfive@81 766 end
yellowfive@81 767 end
yellowfive@81 768 end
yellowfive@81 769
yellowfive@81 770 -- 0 means we couldn't find it for whatever reason
yellowfive@81 771 return 0
yellowfive@81 772 end
yellowfive@81 773
yellowfive@57 774
yellowfive@57 775 ----------------------------------------------------------------------------------------
yellowfive@57 776 -- Character Reading
yellowfive@57 777 ----------------------------------------------------------------------------------------
yellowfive@57 778
yellowfive@57 779 local function readProfessionInfo(prof, ret)
yellowfive@57 780 if prof then
yellowfive@57 781 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(prof);
yellowfive@57 782 if Amr.ProfessionSkillLineToName[skillLine] ~= nil then
yellowfive@57 783 ret.Professions[Amr.ProfessionSkillLineToName[skillLine]] = skillLevel;
yellowfive@57 784 end
yellowfive@57 785 end
yellowfive@57 786 end
yellowfive@57 787
yellowfive@81 788 --[[
yellowfive@81 789 local function getTalents(specPos)
yellowfive@57 790 local talentInfo = {}
yellowfive@57 791 local maxTiers = 7
yellowfive@57 792 for tier = 1, maxTiers do
yellowfive@57 793 for col = 1, 3 do
yellowfive@81 794 local id, name, _, _, _, spellId, _, t, c, selected = GetTalentInfoBySpecialization(specPos, tier, col)
yellowfive@57 795 if selected then
yellowfive@57 796 talentInfo[tier] = col
yellowfive@57 797 end
yellowfive@57 798 end
yellowfive@57 799 end
yellowfive@57 800
yellowfive@57 801 local str = ""
yellowfive@57 802 for i = 1, maxTiers do
yellowfive@57 803 if talentInfo[i] then
yellowfive@57 804 str = str .. talentInfo[i]
yellowfive@57 805 else
yellowfive@57 806 str = str .. '0'
yellowfive@57 807 end
yellowfive@57 808 end
yellowfive@57 809
yellowfive@57 810 return str
yellowfive@57 811 end
yellowfive@81 812 ]]
yellowfive@57 813
yellowfive@81 814 --[[
yellowfive@57 815 local function getGlyphs(specGroup)
yellowfive@57 816 local glyphs = {}
yellowfive@57 817 for i = 1, NUM_GLYPH_SLOTS do
yellowfive@57 818 local _, _, _, glyphSpellID, _, glyphID = GetGlyphSocketInfo(i, specGroup)
yellowfive@57 819 if (glyphID) then
yellowfive@57 820 table.insert(glyphs, glyphSpellID)
yellowfive@57 821 end
yellowfive@57 822 end
yellowfive@57 823 return glyphs;
yellowfive@57 824 end
yellowfive@81 825 ]]
yellowfive@57 826
yellowfive@81 827 -- get specs and talents
yellowfive@81 828 local function readSpecs(ret)
yellowfive@57 829
yellowfive@81 830 for pos = 1, 4 do
yellowfive@57 831 -- spec, convert game spec id to one of our spec ids
yellowfive@81 832 local specId = GetSpecializationInfo(pos)
yellowfive@57 833 if specId then
yellowfive@81 834 ret.Specs[pos] = Amr.SpecIds[specId]
yellowfive@81 835 -- TODO: figure out how to read inactive spec talents if possible... used to be able to but they changed it
yellowfive@81 836 --ret.Talents[pos] = getTalents(pos)
yellowfive@57 837 end
yellowfive@57 838 end
yellowfive@57 839 end
yellowfive@57 840
yellowfive@81 841 -- TODO: hopefully we can read artifact here when there is an API to get info when the artifact UI is not open
yellowfive@81 842 -- get artifact info
yellowfive@81 843 local function readArtifact()
yellowfive@81 844
yellowfive@81 845 end
yellowfive@81 846
yellowfive@57 847 -- get currently equipped items, store with currently active spec
yellowfive@57 848 local function readEquippedItems(ret)
yellowfive@57 849 local equippedItems = {};
yellowfive@57 850 for slotNum = 1, #Amr.SlotIds do
yellowfive@57 851 local slotId = Amr.SlotIds[slotNum]
yellowfive@57 852 local itemLink = GetInventoryItemLink("player", slotId)
yellowfive@57 853 if itemLink then
yellowfive@57 854 equippedItems[slotId] = itemLink
yellowfive@57 855 end
yellowfive@57 856 end
yellowfive@57 857
yellowfive@57 858 -- store last-seen equipped gear for each spec
yellowfive@81 859 ret.Equipped[GetSpecialization()] = equippedItems
yellowfive@57 860 end
yellowfive@57 861
yellowfive@57 862 -- Get all data about the player as an object, includes:
yellowfive@57 863 -- serializer version
yellowfive@57 864 -- region/realm/name
yellowfive@57 865 -- guild
yellowfive@57 866 -- race
yellowfive@57 867 -- faction
yellowfive@57 868 -- level
yellowfive@57 869 -- professions
yellowfive@81 870 -- spec/talent for all specs
yellowfive@81 871 -- artifact for current spec
yellowfive@57 872 -- equipped gear for the current spec
yellowfive@57 873 --
yellowfive@81 874 function Amr:GetPlayerData()
yellowfive@57 875
yellowfive@57 876 local ret = {}
yellowfive@57 877
yellowfive@57 878 ret.Region = Amr.RegionNames[GetCurrentRegion()]
yellowfive@57 879 ret.Realm = GetRealmName()
yellowfive@57 880 ret.Name = UnitName("player")
yellowfive@57 881 ret.Guild = GetGuildInfo("player")
yellowfive@81 882 ret.ActiveSpec = GetSpecialization()
yellowfive@57 883 ret.Level = UnitLevel("player");
yellowfive@57 884
yellowfive@57 885 local cls, clsEn = UnitClass("player")
yellowfive@57 886 ret.Class = clsEn;
yellowfive@57 887
yellowfive@57 888 local race, raceEn = UnitRace("player")
yellowfive@57 889 ret.Race = raceEn;
yellowfive@57 890 ret.Faction = UnitFactionGroup("player")
yellowfive@57 891
yellowfive@57 892 ret.Professions = {};
yellowfive@57 893 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions();
yellowfive@57 894 readProfessionInfo(prof1, ret)
yellowfive@57 895 readProfessionInfo(prof2, ret)
yellowfive@57 896 readProfessionInfo(archaeology, ret)
yellowfive@57 897 readProfessionInfo(fishing, ret)
yellowfive@57 898 readProfessionInfo(cooking, ret)
yellowfive@57 899 readProfessionInfo(firstAid, ret)
yellowfive@57 900
yellowfive@57 901 ret.Specs = {}
yellowfive@57 902 ret.Talents = {}
yellowfive@81 903 readSpecs(ret)
yellowfive@81 904
yellowfive@81 905 ret.Artifacts = {}
yellowfive@81 906 readArtifact()
yellowfive@57 907
yellowfive@57 908 ret.Equipped = {}
yellowfive@57 909 readEquippedItems(ret)
yellowfive@57 910
yellowfive@57 911 return ret
yellowfive@57 912 end
yellowfive@57 913
yellowfive@57 914
yellowfive@57 915 ----------------------------------------------------------------------------------------
yellowfive@57 916 -- Serialization
yellowfive@57 917 ----------------------------------------------------------------------------------------
yellowfive@57 918
yellowfive@57 919 local function toCompressedNumberList(list)
yellowfive@57 920 -- ensure the values are numbers, sorted from lowest to highest
yellowfive@57 921 local nums = {}
yellowfive@57 922 for i, v in ipairs(list) do
yellowfive@57 923 table.insert(nums, tonumber(v))
yellowfive@57 924 end
yellowfive@57 925 table.sort(nums)
yellowfive@57 926
yellowfive@57 927 local ret = {}
yellowfive@57 928 local prev = 0
yellowfive@57 929 for i, v in ipairs(nums) do
yellowfive@57 930 local diff = v - prev
yellowfive@57 931 table.insert(ret, diff)
yellowfive@57 932 prev = v
yellowfive@57 933 end
yellowfive@57 934
yellowfive@57 935 return table.concat(ret, ",")
yellowfive@57 936 end
yellowfive@57 937
yellowfive@57 938 -- make this utility publicly available
yellowfive@57 939 function Amr:ToCompressedNumberList(list)
yellowfive@57 940 return toCompressedNumberList(list)
yellowfive@57 941 end
yellowfive@57 942
yellowfive@57 943 -- appends a list of items to the export
yellowfive@57 944 local function appendItemsToExport(fields, itemObjects)
yellowfive@57 945
yellowfive@57 946 -- sort by item id so we can compress it more easily
yellowfive@57 947 table.sort(itemObjects, function(a, b) return a.id < b.id end)
yellowfive@57 948
yellowfive@57 949 -- append to the export string
yellowfive@57 950 local prevItemId = 0
yellowfive@57 951 local prevGemId = 0
yellowfive@57 952 local prevEnchantId = 0
yellowfive@57 953 local prevUpgradeId = 0
yellowfive@57 954 local prevBonusId = 0
yellowfive@81 955 local prevLevel = 0
yellowfive@57 956 for i, itemData in ipairs(itemObjects) do
yellowfive@57 957 local itemParts = {}
yellowfive@57 958
yellowfive@81 959 -- for now export the item level of artifacts as the "drop level" because it is a pain in the ass to figure it out from the bonus IDs
yellowfive@81 960 --local _, _, quality = GetItemInfo(itemData.link)
yellowfive@81 961 --if quality == 6 then
yellowfive@81 962 -- itemData.level = Amr.GetItemLevel(nil, nil, itemData.link)
yellowfive@81 963 --end
yellowfive@81 964
yellowfive@57 965 table.insert(itemParts, itemData.id - prevItemId)
yellowfive@57 966 prevItemId = itemData.id
yellowfive@57 967
yellowfive@57 968 if itemData.slot ~= nil then table.insert(itemParts, "s" .. itemData.slot) end
yellowfive@57 969 if itemData.suffixId ~= 0 then table.insert(itemParts, "f" .. itemData.suffixId) end
yellowfive@57 970 if itemData.upgradeId ~= 0 then
yellowfive@57 971 table.insert(itemParts, "u" .. (itemData.upgradeId - prevUpgradeId))
yellowfive@57 972 prevUpgradeId = itemData.upgradeId
yellowfive@57 973 end
yellowfive@81 974 if itemData.level ~= 0 then
yellowfive@81 975 table.insert(itemParts, "v" .. (itemData.level - prevLevel))
yellowfive@81 976 prevLevel = itemData.level
yellowfive@81 977 end
yellowfive@57 978 if itemData.bonusIds then
yellowfive@57 979 for bIndex, bValue in ipairs(itemData.bonusIds) do
yellowfive@57 980 table.insert(itemParts, "b" .. (bValue - prevBonusId))
yellowfive@57 981 prevBonusId = bValue
yellowfive@57 982 end
yellowfive@57 983 end
yellowfive@81 984
yellowfive@81 985 if itemData.gemIds[1] ~= 0 then
yellowfive@81 986 table.insert(itemParts, "x" .. (itemData.gemIds[1] - prevGemId))
yellowfive@81 987 prevGemId = itemData.gemIds[1]
yellowfive@81 988 end
yellowfive@81 989 if itemData.gemIds[2] ~= 0 then
yellowfive@81 990 table.insert(itemParts, "y" .. (itemData.gemIds[2] - prevGemId))
yellowfive@81 991 prevGemId = itemData.gemIds[2]
yellowfive@81 992 end
yellowfive@81 993 if itemData.gemIds[3] ~= 0 then
yellowfive@81 994 table.insert(itemParts, "z" .. (itemData.gemIds[3] - prevGemId))
yellowfive@81 995 prevGemId = itemData.gemIds[3]
yellowfive@81 996 end
yellowfive@81 997
yellowfive@57 998 if itemData.enchantId ~= 0 then
yellowfive@57 999 table.insert(itemParts, "e" .. (itemData.enchantId - prevEnchantId))
yellowfive@57 1000 prevEnchantId = itemData.enchantId
yellowfive@57 1001 end
yellowfive@57 1002
yellowfive@57 1003 table.insert(fields, table.concat(itemParts, ""))
yellowfive@57 1004 end
yellowfive@57 1005 end
yellowfive@57 1006
yellowfive@57 1007 -- Serialize just the identity portion of a player (region/realm/name) in the same format used by the full serialization
yellowfive@57 1008 function Amr:SerializePlayerIdentity(data)
yellowfive@57 1009 local fields = {}
yellowfive@57 1010 table.insert(fields, MINOR)
yellowfive@57 1011 table.insert(fields, data.Region)
yellowfive@57 1012 table.insert(fields, data.Realm)
yellowfive@57 1013 table.insert(fields, data.Name)
yellowfive@57 1014 return "$" .. table.concat(fields, ";") .. "$"
yellowfive@57 1015 end
yellowfive@57 1016
yellowfive@57 1017 -- Serialize player data gathered by GetPlayerData. This can be augmented with extra data if desired (augmenting used mainly by AskMrRobot addon).
yellowfive@57 1018 -- Pass complete = true to do a complete export of this extra information, otherwise it is ignored.
yellowfive@57 1019 -- Extra data can include:
yellowfive@57 1020 -- equipped gear for the player's inactive spec, slot id to item link dictionary
yellowfive@57 1021 -- Reputations
yellowfive@57 1022 -- BagItems, BankItems, VoidItems, lists of item links
yellowfive@57 1023 --
yellowfive@57 1024 function Amr:SerializePlayerData(data, complete)
yellowfive@57 1025
yellowfive@57 1026 local fields = {}
yellowfive@57 1027
yellowfive@57 1028 -- compressed string uses a fixed order rather than inserting identifiers
yellowfive@57 1029 table.insert(fields, MINOR)
yellowfive@57 1030 table.insert(fields, data.Region)
yellowfive@57 1031 table.insert(fields, data.Realm)
yellowfive@57 1032 table.insert(fields, data.Name)
yellowfive@57 1033
yellowfive@57 1034 -- guild name
yellowfive@57 1035 if data.Guild == nil then
yellowfive@57 1036 table.insert(fields, "")
yellowfive@57 1037 else
yellowfive@57 1038 table.insert(fields, data.Guild)
yellowfive@57 1039 end
yellowfive@57 1040
yellowfive@57 1041 -- race, default to pandaren if we can't read it for some reason
yellowfive@57 1042 local raceval = Amr.RaceIds[data.Race]
yellowfive@57 1043 if raceval == nil then raceval = 13 end
yellowfive@57 1044 table.insert(fields, raceval)
yellowfive@57 1045
yellowfive@57 1046 -- faction, default to alliance if we can't read it for some reason
yellowfive@57 1047 raceval = Amr.FactionIds[data.Faction]
yellowfive@57 1048 if raceval == nil then raceval = 1 end
yellowfive@57 1049 table.insert(fields, raceval)
yellowfive@57 1050
yellowfive@57 1051 table.insert(fields, data.Level)
yellowfive@57 1052
yellowfive@57 1053 local profs = {}
yellowfive@57 1054 local noprofs = true
yellowfive@57 1055 if data.Professions then
yellowfive@57 1056 for k, v in pairs(data.Professions) do
yellowfive@57 1057 local profval = Amr.ProfessionIds[k]
yellowfive@57 1058 if profval ~= nil then
yellowfive@57 1059 noprofs = false
yellowfive@57 1060 table.insert(profs, profval .. ":" .. v)
yellowfive@57 1061 end
yellowfive@57 1062 end
yellowfive@57 1063 end
yellowfive@57 1064
yellowfive@57 1065 if noprofs then
yellowfive@57 1066 table.insert(profs, "0:0")
yellowfive@57 1067 end
yellowfive@57 1068
yellowfive@57 1069 table.insert(fields, table.concat(profs, ","))
yellowfive@57 1070
yellowfive@57 1071 -- export specs
yellowfive@57 1072 table.insert(fields, data.ActiveSpec)
yellowfive@81 1073 for spec = 1, 4 do
yellowfive@57 1074 if data.Specs[spec] and (complete or spec == data.ActiveSpec) then
yellowfive@57 1075 table.insert(fields, ".s" .. spec) -- indicates the start of a spec block
yellowfive@81 1076 table.insert(fields, data.Specs[spec])
yellowfive@81 1077 table.insert(fields, data.Talents[spec])
yellowfive@57 1078
yellowfive@81 1079 local powerids = {}
yellowfive@81 1080 local powerranks = {}
yellowfive@81 1081 local reliclinks = {}
yellowfive@81 1082
yellowfive@81 1083 local artifactInfo = data.Artifacts and data.Artifacts[spec]
yellowfive@81 1084 if artifactInfo and artifactInfo.Powers then
yellowfive@81 1085 for k, v in spairs(artifactInfo.Powers) do
yellowfive@81 1086 table.insert(powerids, k)
yellowfive@81 1087 table.insert(powerranks, v)
yellowfive@81 1088 end
yellowfive@81 1089 end
yellowfive@81 1090 if artifactInfo and artifactInfo.Relics then
yellowfive@81 1091 for i, link in ipairs(artifactInfo.Relics) do
yellowfive@81 1092 local relic = Amr.ParseItemLink(link)
yellowfive@81 1093 table.insert(reliclinks, Amr.GetItemUniqueId(relic) or "")
yellowfive@81 1094 end
yellowfive@57 1095 end
yellowfive@57 1096
yellowfive@81 1097 table.insert(fields, toCompressedNumberList(powerids))
yellowfive@81 1098 table.insert(fields, table.concat(powerranks, ","))
yellowfive@81 1099 table.insert(fields, table.concat(reliclinks, ","))
yellowfive@81 1100
yellowfive@81 1101 --table.insert(fields, toCompressedNumberList(data.Glyphs[spec]))
yellowfive@57 1102 end
yellowfive@57 1103 end
yellowfive@57 1104
yellowfive@57 1105 -- export equipped gear
yellowfive@57 1106 if data.Equipped then
yellowfive@81 1107 for spec = 1, 4 do
yellowfive@57 1108 if data.Equipped[spec] and (complete or spec == data.ActiveSpec) then
yellowfive@57 1109 table.insert(fields, ".q" .. spec) -- indicates the start of an equipped gear block
yellowfive@57 1110
yellowfive@57 1111 local itemObjects = {}
yellowfive@57 1112 for k, v in pairs(data.Equipped[spec]) do
yellowfive@57 1113 local itemData = Amr.ParseItemLink(v)
yellowfive@57 1114 itemData.slot = k
yellowfive@81 1115 itemData.link = v
yellowfive@57 1116 table.insert(itemObjects, itemData)
yellowfive@57 1117 end
yellowfive@57 1118
yellowfive@57 1119 appendItemsToExport(fields, itemObjects)
yellowfive@57 1120 end
yellowfive@57 1121 end
yellowfive@57 1122 end
yellowfive@57 1123
yellowfive@57 1124 -- if doing a complete export, include reputations and bank/bag items too
yellowfive@57 1125 if complete then
yellowfive@57 1126
yellowfive@57 1127 -- export reputations
yellowfive@57 1128 local reps = {}
yellowfive@57 1129 local noreps = true
yellowfive@57 1130 if data.Reputations then
yellowfive@57 1131 for k, v in pairs(data.Reputations) do
yellowfive@57 1132 noreps = false
yellowfive@57 1133 table.insert(reps, k .. ":" .. v)
yellowfive@57 1134 end
yellowfive@57 1135 end
yellowfive@57 1136 if noreps then
yellowfive@57 1137 table.insert(reps, "_")
yellowfive@57 1138 end
yellowfive@57 1139
yellowfive@57 1140 table.insert(fields, ".r")
yellowfive@57 1141 table.insert(fields, table.concat(reps, ","))
yellowfive@57 1142
yellowfive@57 1143 -- export bag and bank
yellowfive@57 1144 local itemObjects = {}
yellowfive@57 1145 if data.BagItems then
yellowfive@57 1146 for i, v in ipairs(data.BagItems) do
yellowfive@57 1147 local itemData = Amr.ParseItemLink(v)
yellowfive@57 1148 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
yellowfive@81 1149 itemData.link = v
yellowfive@57 1150 table.insert(itemObjects, itemData)
yellowfive@57 1151 end
yellowfive@57 1152 end
yellowfive@57 1153 end
yellowfive@57 1154 if data.BankItems then
yellowfive@57 1155 for i, v in ipairs(data.BankItems) do
yellowfive@57 1156 local itemData = Amr.ParseItemLink(v)
yellowfive@57 1157 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
yellowfive@81 1158 itemData.link = v
yellowfive@57 1159 table.insert(itemObjects, itemData)
yellowfive@57 1160 end
yellowfive@57 1161 end
yellowfive@57 1162 end
yellowfive@57 1163 if data.VoidItems then
yellowfive@57 1164 for i, v in ipairs(data.VoidItems) do
yellowfive@57 1165 local itemData = Amr.ParseItemLink(v)
yellowfive@57 1166 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
yellowfive@81 1167 itemData.link = v
yellowfive@57 1168 table.insert(itemObjects, itemData)
yellowfive@57 1169 end
yellowfive@57 1170 end
yellowfive@57 1171 end
yellowfive@57 1172
yellowfive@57 1173 table.insert(fields, ".inv")
yellowfive@57 1174 appendItemsToExport(fields, itemObjects)
yellowfive@57 1175 end
yellowfive@57 1176
yellowfive@57 1177 return "$" .. table.concat(fields, ";") .. "$"
yellowfive@57 1178
yellowfive@57 1179 end
yellowfive@57 1180
yellowfive@57 1181 -- Shortcut for the common use case: serialize the player's currently active setup with no extras.
yellowfive@57 1182 function Amr:SerializePlayer()
yellowfive@57 1183 local data = self:GetPlayerData()
yellowfive@57 1184 return self:SerializePlayerData(data)
yellowfive@57 1185 end
yellowfive@57 1186
yellowfive@81 1187 --[[
yellowfive@57 1188 ----------------------------------------------------------------------------------------------------------------------
yellowfive@57 1189 -- Character Snapshots
yellowfive@81 1190 -- This feature snapshots a player's gear/talents/artifact when entering combat. It is enabled by default. Consumers
yellowfive@57 1191 -- of this library can create a setting to enable/disable it as desired per a user setting.
yellowfive@57 1192 --
yellowfive@57 1193 -- You should register for the AMR_SNAPSHOT_STATE_CHANGED message (sent via AceEvent-3.0 messaging) to ensure that
yellowfive@57 1194 -- your addon settings stay in sync with any other addon that may also be trying to control the enabled state.
yellowfive@57 1195 --
yellowfive@57 1196 -- Note that if a user has the main AMR addon installed, it will always enable snapshotting, and override any attempt
yellowfive@57 1197 -- to disable it by immediately re-enabling it and thus re-triggering AMR_SNAPSHOT_STATE_CHANGED.
yellowfive@57 1198 ----------------------------------------------------------------------------------------------------------------------
yellowfive@57 1199 Amr._snapshotEnabled = true
yellowfive@57 1200
yellowfive@57 1201 -- Enable snapshotting of character data when entering combat. Sends this player's character data to anyone logging with the AskMrRobot addon.
yellowfive@57 1202 function Amr:EnableSnapshots()
yellowfive@57 1203 self._snapshotEnabled = true
yellowfive@57 1204 self:SendMessage("AMR_SNAPSHOT_STATE_CHANGED", self._snapshotEnabled)
yellowfive@57 1205 end
yellowfive@57 1206
yellowfive@57 1207 -- Disable snapshotting of character data when entering combat.
yellowfive@57 1208 function Amr:DisableSnapshots()
yellowfive@57 1209 self._snapshotEnabled = false
yellowfive@57 1210 self:SendMessage("AMR_SNAPSHOT_STATE_CHANGED", self._snapshotEnabled)
yellowfive@57 1211 end
yellowfive@57 1212
yellowfive@57 1213 function Amr:IsSnapshotEnabled()
yellowfive@57 1214 return self._snapshotEnabled
yellowfive@57 1215 end
yellowfive@57 1216
yellowfive@57 1217
yellowfive@57 1218 function Amr:PLAYER_REGEN_DISABLED()
yellowfive@57 1219 --function Amr:GARRISON_MISSION_NPC_OPENED()
yellowfive@57 1220
yellowfive@57 1221 -- send data about this character when a player enters combat in a supported zone
yellowfive@57 1222 if self._snapshotEnabled and Amr.IsSupportedInstance() then
yellowfive@57 1223 local t = time()
yellowfive@57 1224 local player = self:GetPlayerData()
yellowfive@57 1225 local msg = self:SerializePlayerData(player)
yellowfive@57 1226 msg = string.format("%s\r%s\n%s\n%s\n%s\n%s", MINOR, t, player.Region, player.Realm, player.Name, msg)
yellowfive@57 1227
yellowfive@57 1228 self:SendCommMessage(Amr.ChatPrefix, msg, "RAID")
yellowfive@57 1229 end
yellowfive@57 1230 end
yellowfive@57 1231
yellowfive@57 1232 Amr:RegisterEvent("PLAYER_REGEN_DISABLED")
yellowfive@81 1233 --Amr:RegisterEvent("GARRISON_MISSION_NPC_OPENED") -- for debugging, fire this event when open mission table
yellowfive@81 1234 ]]