annotate AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 67:932885bb1a6f v26

bug fix to gear swapping, fixed font issue with asian regions
author yellowfive
date Mon, 29 Jun 2015 17:05:47 -0700
parents e638168c3395
children 69db1c3025ac
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@67 4 local MAJOR, MINOR = "AskMrRobot-Serializer", 26
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@63 582 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
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@63 600 item.upgradeId = tonumber(parts[11])
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@57 611
yellowfive@57 612 return item
yellowfive@57 613 end
yellowfive@57 614
yellowfive@57 615 -- returns true if this is an instance that AskMrRobot supports for logging
yellowfive@57 616 function Amr.IsSupportedInstanceId(instanceMapID)
yellowfive@57 617 if Amr.SupportedInstanceIds[tonumber(instanceMapID)] then
yellowfive@57 618 return true
yellowfive@57 619 else
yellowfive@57 620 return false
yellowfive@57 621 end
yellowfive@57 622 end
yellowfive@57 623
yellowfive@57 624 -- returns true if currently in a supported instance for logging
yellowfive@57 625 function Amr.IsSupportedInstance()
yellowfive@57 626 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
yellowfive@57 627 return Amr.IsSupportedInstanceId(instanceMapID)
yellowfive@57 628 end
yellowfive@57 629
yellowfive@57 630
yellowfive@57 631 ----------------------------------------------------------------------------------------
yellowfive@57 632 -- Character Reading
yellowfive@57 633 ----------------------------------------------------------------------------------------
yellowfive@57 634
yellowfive@57 635 local function readProfessionInfo(prof, ret)
yellowfive@57 636 if prof then
yellowfive@57 637 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(prof);
yellowfive@57 638 if Amr.ProfessionSkillLineToName[skillLine] ~= nil then
yellowfive@57 639 ret.Professions[Amr.ProfessionSkillLineToName[skillLine]] = skillLevel;
yellowfive@57 640 end
yellowfive@57 641 end
yellowfive@57 642 end
yellowfive@57 643
yellowfive@57 644 local function getSpecId(specGroup)
yellowfive@57 645 local spec = GetSpecialization(false, false, specGroup);
yellowfive@57 646 return spec and GetSpecializationInfo(spec);
yellowfive@57 647 end
yellowfive@57 648
yellowfive@57 649 local function getTalents(specGroup)
yellowfive@57 650 local talentInfo = {}
yellowfive@57 651 local maxTiers = 7
yellowfive@57 652 for tier = 1, maxTiers do
yellowfive@57 653 for col = 1, 3 do
yellowfive@57 654 local id, name, texture, selected, available = GetTalentInfo(tier, col, specGroup)
yellowfive@57 655 if selected then
yellowfive@57 656 talentInfo[tier] = col
yellowfive@57 657 end
yellowfive@57 658 end
yellowfive@57 659 end
yellowfive@57 660
yellowfive@57 661 local str = ""
yellowfive@57 662 for i = 1, maxTiers do
yellowfive@57 663 if talentInfo[i] then
yellowfive@57 664 str = str .. talentInfo[i]
yellowfive@57 665 else
yellowfive@57 666 str = str .. '0'
yellowfive@57 667 end
yellowfive@57 668 end
yellowfive@57 669
yellowfive@57 670 return str
yellowfive@57 671 end
yellowfive@57 672
yellowfive@57 673 local function getGlyphs(specGroup)
yellowfive@57 674 local glyphs = {}
yellowfive@57 675 for i = 1, NUM_GLYPH_SLOTS do
yellowfive@57 676 local _, _, _, glyphSpellID, _, glyphID = GetGlyphSocketInfo(i, specGroup)
yellowfive@57 677 if (glyphID) then
yellowfive@57 678 table.insert(glyphs, glyphSpellID)
yellowfive@57 679 end
yellowfive@57 680 end
yellowfive@57 681 return glyphs;
yellowfive@57 682 end
yellowfive@57 683
yellowfive@57 684 -- get specs, talents, and glyphs
yellowfive@57 685 local function readSpecs(ret, subspecs)
yellowfive@57 686
yellowfive@57 687 for group = 1, GetNumSpecGroups() do
yellowfive@57 688 -- spec, convert game spec id to one of our spec ids
yellowfive@57 689 local specId = getSpecId(group)
yellowfive@57 690 if specId then
yellowfive@57 691 ret.Specs[group] = Amr.SpecIds[specId]
yellowfive@57 692
yellowfive@57 693 -- if this is a protection warrior, use buffs to determine subspec
yellowfive@57 694 if ret.Specs[group] == Amr.SPEC_WARRIORPROTECTION then
yellowfive@57 695 local subspec = 0
yellowfive@57 696
yellowfive@57 697 if ret.ActiveSpec ~= group then
yellowfive@57 698 -- this spec isn't active, so we can't use current buffs to determine spec, see if any old data is compatible
yellowfive@57 699 if subspecs and (subspecs[group] == Amr.SUBSPEC_WARRIORPROTECTION or subspecs[group] == Amr.SUBSPEC_WARRIORPROTECTIONGLAD) then
yellowfive@57 700 subspec = subspecs[group]
yellowfive@57 701 end
yellowfive@57 702 else
yellowfive@57 703 for i=1,40 do
yellowfive@57 704 local name,_,_,_,_,_,_,_,_,_,spellId = UnitAura("player", i, "HELPFUL")
yellowfive@57 705 if not name then break end
yellowfive@57 706
yellowfive@57 707 if spellId == Amr.SPELL_ID_DEFENSIVE_STANCE then
yellowfive@57 708 subspec = Amr.SUBSPEC_WARRIORPROTECTION
yellowfive@57 709 break
yellowfive@57 710 elseif spellId == Amr.SPELL_ID_GLADIATOR_STANCE then
yellowfive@57 711 subspec = Amr.SUBSPEC_WARRIORPROTECTIONGLAD
yellowfive@57 712 break
yellowfive@57 713 end
yellowfive@57 714 end
yellowfive@57 715 end
yellowfive@57 716
yellowfive@57 717 if subspec == 0 then
yellowfive@57 718 ret.SubSpecs[group] = nil
yellowfive@57 719 else
yellowfive@57 720 ret.SubSpecs[group] = subspec
yellowfive@57 721 end
yellowfive@57 722 end
yellowfive@57 723 else
yellowfive@57 724 ret.Specs[group] = 0
yellowfive@57 725 end
yellowfive@57 726
yellowfive@57 727 ret.Talents[group] = getTalents(group)
yellowfive@57 728 ret.Glyphs[group] = getGlyphs(group)
yellowfive@57 729 end
yellowfive@57 730 end
yellowfive@57 731
yellowfive@57 732 -- get currently equipped items, store with currently active spec
yellowfive@57 733 local function readEquippedItems(ret)
yellowfive@57 734 local equippedItems = {};
yellowfive@57 735 for slotNum = 1, #Amr.SlotIds do
yellowfive@57 736 local slotId = Amr.SlotIds[slotNum]
yellowfive@57 737 local itemLink = GetInventoryItemLink("player", slotId)
yellowfive@57 738 if itemLink then
yellowfive@57 739 equippedItems[slotId] = itemLink
yellowfive@57 740 end
yellowfive@57 741 end
yellowfive@57 742
yellowfive@57 743 -- store last-seen equipped gear for each spec
yellowfive@57 744 ret.Equipped[GetActiveSpecGroup()] = equippedItems
yellowfive@57 745 end
yellowfive@57 746
yellowfive@57 747 -- Get all data about the player as an object, includes:
yellowfive@57 748 -- serializer version
yellowfive@57 749 -- region/realm/name
yellowfive@57 750 -- guild
yellowfive@57 751 -- race
yellowfive@57 752 -- faction
yellowfive@57 753 -- level
yellowfive@57 754 -- professions
yellowfive@57 755 -- spec/talent/glyphs for both specs
yellowfive@57 756 -- equipped gear for the current spec
yellowfive@57 757 --
yellowfive@57 758 function Amr:GetPlayerData(subspecs)
yellowfive@57 759
yellowfive@57 760 local ret = {}
yellowfive@57 761
yellowfive@57 762 ret.Region = Amr.RegionNames[GetCurrentRegion()]
yellowfive@57 763 ret.Realm = GetRealmName()
yellowfive@57 764 ret.Name = UnitName("player")
yellowfive@57 765 ret.Guild = GetGuildInfo("player")
yellowfive@57 766 ret.ActiveSpec = GetActiveSpecGroup()
yellowfive@57 767 ret.Level = UnitLevel("player");
yellowfive@57 768
yellowfive@57 769 local cls, clsEn = UnitClass("player")
yellowfive@57 770 ret.Class = clsEn;
yellowfive@57 771
yellowfive@57 772 local race, raceEn = UnitRace("player")
yellowfive@57 773 ret.Race = raceEn;
yellowfive@57 774 ret.Faction = UnitFactionGroup("player")
yellowfive@57 775
yellowfive@57 776 ret.Professions = {};
yellowfive@57 777 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions();
yellowfive@57 778 readProfessionInfo(prof1, ret)
yellowfive@57 779 readProfessionInfo(prof2, ret)
yellowfive@57 780 readProfessionInfo(archaeology, ret)
yellowfive@57 781 readProfessionInfo(fishing, ret)
yellowfive@57 782 readProfessionInfo(cooking, ret)
yellowfive@57 783 readProfessionInfo(firstAid, ret)
yellowfive@57 784
yellowfive@57 785 ret.Specs = {}
yellowfive@57 786 ret.SubSpecs = {} -- only filled in for ambiguous cases, right now just prot/glad warrior
yellowfive@57 787 ret.Talents = {}
yellowfive@57 788 ret.Glyphs = {}
yellowfive@57 789 readSpecs(ret, subspecs)
yellowfive@57 790
yellowfive@57 791 ret.Equipped = {}
yellowfive@57 792 readEquippedItems(ret)
yellowfive@57 793
yellowfive@57 794 return ret
yellowfive@57 795 end
yellowfive@57 796
yellowfive@57 797
yellowfive@57 798 ----------------------------------------------------------------------------------------
yellowfive@57 799 -- Serialization
yellowfive@57 800 ----------------------------------------------------------------------------------------
yellowfive@57 801
yellowfive@57 802 local function toCompressedNumberList(list)
yellowfive@57 803 -- ensure the values are numbers, sorted from lowest to highest
yellowfive@57 804 local nums = {}
yellowfive@57 805 for i, v in ipairs(list) do
yellowfive@57 806 table.insert(nums, tonumber(v))
yellowfive@57 807 end
yellowfive@57 808 table.sort(nums)
yellowfive@57 809
yellowfive@57 810 local ret = {}
yellowfive@57 811 local prev = 0
yellowfive@57 812 for i, v in ipairs(nums) do
yellowfive@57 813 local diff = v - prev
yellowfive@57 814 table.insert(ret, diff)
yellowfive@57 815 prev = v
yellowfive@57 816 end
yellowfive@57 817
yellowfive@57 818 return table.concat(ret, ",")
yellowfive@57 819 end
yellowfive@57 820
yellowfive@57 821 -- make this utility publicly available
yellowfive@57 822 function Amr:ToCompressedNumberList(list)
yellowfive@57 823 return toCompressedNumberList(list)
yellowfive@57 824 end
yellowfive@57 825
yellowfive@57 826 -- appends a list of items to the export
yellowfive@57 827 local function appendItemsToExport(fields, itemObjects)
yellowfive@57 828
yellowfive@57 829 -- sort by item id so we can compress it more easily
yellowfive@57 830 table.sort(itemObjects, function(a, b) return a.id < b.id end)
yellowfive@57 831
yellowfive@57 832 -- append to the export string
yellowfive@57 833 local prevItemId = 0
yellowfive@57 834 local prevGemId = 0
yellowfive@57 835 local prevEnchantId = 0
yellowfive@57 836 local prevUpgradeId = 0
yellowfive@57 837 local prevBonusId = 0
yellowfive@57 838 for i, itemData in ipairs(itemObjects) do
yellowfive@57 839 local itemParts = {}
yellowfive@57 840
yellowfive@57 841 table.insert(itemParts, itemData.id - prevItemId)
yellowfive@57 842 prevItemId = itemData.id
yellowfive@57 843
yellowfive@57 844 if itemData.slot ~= nil then table.insert(itemParts, "s" .. itemData.slot) end
yellowfive@57 845 if itemData.suffixId ~= 0 then table.insert(itemParts, "f" .. itemData.suffixId) end
yellowfive@57 846 if itemData.upgradeId ~= 0 then
yellowfive@57 847 table.insert(itemParts, "u" .. (itemData.upgradeId - prevUpgradeId))
yellowfive@57 848 prevUpgradeId = itemData.upgradeId
yellowfive@57 849 end
yellowfive@57 850 if itemData.bonusIds then
yellowfive@57 851 for bIndex, bValue in ipairs(itemData.bonusIds) do
yellowfive@57 852 table.insert(itemParts, "b" .. (bValue - prevBonusId))
yellowfive@57 853 prevBonusId = bValue
yellowfive@57 854 end
yellowfive@57 855 end
yellowfive@57 856 if itemData.gemIds[1] ~= 0 then
yellowfive@57 857 table.insert(itemParts, "x" .. (itemData.gemIds[1] - prevGemId))
yellowfive@57 858 prevGemId = itemData.gemIds[1]
yellowfive@57 859 end
yellowfive@57 860 if itemData.gemIds[2] ~= 0 then
yellowfive@57 861 table.insert(itemParts, "y" .. (itemData.gemIds[2] - prevGemId))
yellowfive@57 862 prevGemId = itemData.gemIds[2]
yellowfive@57 863 end
yellowfive@57 864 if itemData.gemIds[3] ~= 0 then
yellowfive@57 865 table.insert(itemParts, "z" .. (itemData.gemIds[3] - prevGemId))
yellowfive@57 866 prevGemId = itemData.gemIds[3]
yellowfive@57 867 end
yellowfive@57 868 if itemData.enchantId ~= 0 then
yellowfive@57 869 table.insert(itemParts, "e" .. (itemData.enchantId - prevEnchantId))
yellowfive@57 870 prevEnchantId = itemData.enchantId
yellowfive@57 871 end
yellowfive@57 872
yellowfive@57 873 table.insert(fields, table.concat(itemParts, ""))
yellowfive@57 874 end
yellowfive@57 875 end
yellowfive@57 876
yellowfive@57 877 -- Serialize just the identity portion of a player (region/realm/name) in the same format used by the full serialization
yellowfive@57 878 function Amr:SerializePlayerIdentity(data)
yellowfive@57 879 local fields = {}
yellowfive@57 880 table.insert(fields, MINOR)
yellowfive@57 881 table.insert(fields, data.Region)
yellowfive@57 882 table.insert(fields, data.Realm)
yellowfive@57 883 table.insert(fields, data.Name)
yellowfive@57 884 return "$" .. table.concat(fields, ";") .. "$"
yellowfive@57 885 end
yellowfive@57 886
yellowfive@57 887 -- Serialize player data gathered by GetPlayerData. This can be augmented with extra data if desired (augmenting used mainly by AskMrRobot addon).
yellowfive@57 888 -- Pass complete = true to do a complete export of this extra information, otherwise it is ignored.
yellowfive@57 889 -- Extra data can include:
yellowfive@57 890 -- equipped gear for the player's inactive spec, slot id to item link dictionary
yellowfive@57 891 -- Reputations
yellowfive@57 892 -- BagItems, BankItems, VoidItems, lists of item links
yellowfive@57 893 --
yellowfive@57 894 function Amr:SerializePlayerData(data, complete)
yellowfive@57 895
yellowfive@57 896 local fields = {}
yellowfive@57 897
yellowfive@57 898 -- compressed string uses a fixed order rather than inserting identifiers
yellowfive@57 899 table.insert(fields, MINOR)
yellowfive@57 900 table.insert(fields, data.Region)
yellowfive@57 901 table.insert(fields, data.Realm)
yellowfive@57 902 table.insert(fields, data.Name)
yellowfive@57 903
yellowfive@57 904 -- guild name
yellowfive@57 905 if data.Guild == nil then
yellowfive@57 906 table.insert(fields, "")
yellowfive@57 907 else
yellowfive@57 908 table.insert(fields, data.Guild)
yellowfive@57 909 end
yellowfive@57 910
yellowfive@57 911 -- race, default to pandaren if we can't read it for some reason
yellowfive@57 912 local raceval = Amr.RaceIds[data.Race]
yellowfive@57 913 if raceval == nil then raceval = 13 end
yellowfive@57 914 table.insert(fields, raceval)
yellowfive@57 915
yellowfive@57 916 -- faction, default to alliance if we can't read it for some reason
yellowfive@57 917 raceval = Amr.FactionIds[data.Faction]
yellowfive@57 918 if raceval == nil then raceval = 1 end
yellowfive@57 919 table.insert(fields, raceval)
yellowfive@57 920
yellowfive@57 921 table.insert(fields, data.Level)
yellowfive@57 922
yellowfive@57 923 local profs = {}
yellowfive@57 924 local noprofs = true
yellowfive@57 925 if data.Professions then
yellowfive@57 926 for k, v in pairs(data.Professions) do
yellowfive@57 927 local profval = Amr.ProfessionIds[k]
yellowfive@57 928 if profval ~= nil then
yellowfive@57 929 noprofs = false
yellowfive@57 930 table.insert(profs, profval .. ":" .. v)
yellowfive@57 931 end
yellowfive@57 932 end
yellowfive@57 933 end
yellowfive@57 934
yellowfive@57 935 if noprofs then
yellowfive@57 936 table.insert(profs, "0:0")
yellowfive@57 937 end
yellowfive@57 938
yellowfive@57 939 table.insert(fields, table.concat(profs, ","))
yellowfive@57 940
yellowfive@57 941 -- export specs
yellowfive@57 942 table.insert(fields, data.ActiveSpec)
yellowfive@57 943 for spec = 1, 2 do
yellowfive@57 944 if data.Specs[spec] and (complete or spec == data.ActiveSpec) then
yellowfive@57 945 table.insert(fields, ".s" .. spec) -- indicates the start of a spec block
yellowfive@57 946
yellowfive@57 947 -- we use subspec for some ambiguous specs like prot/glad warrior
yellowfive@57 948 if data.SubSpecs[spec] then
yellowfive@57 949 table.insert(fields, string.format("s%s", data.SubSpecs[spec]))
yellowfive@57 950 else
yellowfive@57 951 table.insert(fields, data.Specs[spec])
yellowfive@57 952 end
yellowfive@57 953
yellowfive@57 954 table.insert(fields, data.Talents[spec])
yellowfive@57 955 table.insert(fields, toCompressedNumberList(data.Glyphs[spec]))
yellowfive@57 956 end
yellowfive@57 957 end
yellowfive@57 958
yellowfive@57 959 -- export equipped gear
yellowfive@57 960 if data.Equipped then
yellowfive@57 961 for spec = 1, 2 do
yellowfive@57 962 if data.Equipped[spec] and (complete or spec == data.ActiveSpec) then
yellowfive@57 963 table.insert(fields, ".q" .. spec) -- indicates the start of an equipped gear block
yellowfive@57 964
yellowfive@57 965 local itemObjects = {}
yellowfive@57 966 for k, v in pairs(data.Equipped[spec]) do
yellowfive@57 967 local itemData = Amr.ParseItemLink(v)
yellowfive@57 968 itemData.slot = k
yellowfive@57 969 table.insert(itemObjects, itemData)
yellowfive@57 970 end
yellowfive@57 971
yellowfive@57 972 appendItemsToExport(fields, itemObjects)
yellowfive@57 973 end
yellowfive@57 974 end
yellowfive@57 975 end
yellowfive@57 976
yellowfive@57 977 -- if doing a complete export, include reputations and bank/bag items too
yellowfive@57 978 if complete then
yellowfive@57 979
yellowfive@57 980 -- export reputations
yellowfive@57 981 local reps = {}
yellowfive@57 982 local noreps = true
yellowfive@57 983 if data.Reputations then
yellowfive@57 984 for k, v in pairs(data.Reputations) do
yellowfive@57 985 noreps = false
yellowfive@57 986 table.insert(reps, k .. ":" .. v)
yellowfive@57 987 end
yellowfive@57 988 end
yellowfive@57 989 if noreps then
yellowfive@57 990 table.insert(reps, "_")
yellowfive@57 991 end
yellowfive@57 992
yellowfive@57 993 table.insert(fields, ".r")
yellowfive@57 994 table.insert(fields, table.concat(reps, ","))
yellowfive@57 995
yellowfive@57 996 -- export bag and bank
yellowfive@57 997 local itemObjects = {}
yellowfive@57 998 if data.BagItems then
yellowfive@57 999 for i, v in ipairs(data.BagItems) do
yellowfive@57 1000 local itemData = Amr.ParseItemLink(v)
yellowfive@57 1001 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
yellowfive@57 1002 table.insert(itemObjects, itemData)
yellowfive@57 1003 end
yellowfive@57 1004 end
yellowfive@57 1005 end
yellowfive@57 1006 if data.BankItems then
yellowfive@57 1007 for i, v in ipairs(data.BankItems) 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.VoidItems then
yellowfive@57 1015 for i, v in ipairs(data.VoidItems) 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
yellowfive@57 1023 table.insert(fields, ".inv")
yellowfive@57 1024 appendItemsToExport(fields, itemObjects)
yellowfive@57 1025 end
yellowfive@57 1026
yellowfive@57 1027 return "$" .. table.concat(fields, ";") .. "$"
yellowfive@57 1028
yellowfive@57 1029 end
yellowfive@57 1030
yellowfive@57 1031 -- Shortcut for the common use case: serialize the player's currently active setup with no extras.
yellowfive@57 1032 function Amr:SerializePlayer()
yellowfive@57 1033 local data = self:GetPlayerData()
yellowfive@57 1034 return self:SerializePlayerData(data)
yellowfive@57 1035 end
yellowfive@57 1036
yellowfive@57 1037
yellowfive@57 1038 ----------------------------------------------------------------------------------------------------------------------
yellowfive@57 1039 -- Character Snapshots
yellowfive@57 1040 -- This feature snapshots a player's gear/talents/glyphs when entering combat. It is enabled by default. Consumers
yellowfive@57 1041 -- of this library can create a setting to enable/disable it as desired per a user setting.
yellowfive@57 1042 --
yellowfive@57 1043 -- You should register for the AMR_SNAPSHOT_STATE_CHANGED message (sent via AceEvent-3.0 messaging) to ensure that
yellowfive@57 1044 -- your addon settings stay in sync with any other addon that may also be trying to control the enabled state.
yellowfive@57 1045 --
yellowfive@57 1046 -- Note that if a user has the main AMR addon installed, it will always enable snapshotting, and override any attempt
yellowfive@57 1047 -- to disable it by immediately re-enabling it and thus re-triggering AMR_SNAPSHOT_STATE_CHANGED.
yellowfive@57 1048 ----------------------------------------------------------------------------------------------------------------------
yellowfive@57 1049 Amr._snapshotEnabled = true
yellowfive@57 1050
yellowfive@57 1051 -- Enable snapshotting of character data when entering combat. Sends this player's character data to anyone logging with the AskMrRobot addon.
yellowfive@57 1052 function Amr:EnableSnapshots()
yellowfive@57 1053 self._snapshotEnabled = true
yellowfive@57 1054 self:SendMessage("AMR_SNAPSHOT_STATE_CHANGED", self._snapshotEnabled)
yellowfive@57 1055 end
yellowfive@57 1056
yellowfive@57 1057 -- Disable snapshotting of character data when entering combat.
yellowfive@57 1058 function Amr:DisableSnapshots()
yellowfive@57 1059 self._snapshotEnabled = false
yellowfive@57 1060 self:SendMessage("AMR_SNAPSHOT_STATE_CHANGED", self._snapshotEnabled)
yellowfive@57 1061 end
yellowfive@57 1062
yellowfive@57 1063 function Amr:IsSnapshotEnabled()
yellowfive@57 1064 return self._snapshotEnabled
yellowfive@57 1065 end
yellowfive@57 1066
yellowfive@57 1067
yellowfive@57 1068 function Amr:PLAYER_REGEN_DISABLED()
yellowfive@57 1069 --function Amr:GARRISON_MISSION_NPC_OPENED()
yellowfive@57 1070
yellowfive@57 1071 -- send data about this character when a player enters combat in a supported zone
yellowfive@57 1072 if self._snapshotEnabled and Amr.IsSupportedInstance() then
yellowfive@57 1073 local t = time()
yellowfive@57 1074 local player = self:GetPlayerData()
yellowfive@57 1075 local msg = self:SerializePlayerData(player)
yellowfive@57 1076 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 1077
yellowfive@57 1078 self:SendCommMessage(Amr.ChatPrefix, msg, "RAID")
yellowfive@57 1079 end
yellowfive@57 1080 end
yellowfive@57 1081
yellowfive@57 1082 Amr:RegisterEvent("PLAYER_REGEN_DISABLED")
yellowfive@57 1083 --Amr:RegisterEvent("GARRISON_MISSION_NPC_OPENED") -- for debugging, fire this event when open mission table