annotate AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 73:304d7ebb8e30 v29

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