annotate amr-constants.lua @ 49:90175bdc50e6 v17

fixed some localization issues and added new german translation
author yellowfive
date Sun, 09 Nov 2014 11:48:18 -0800
parents 0e78d6424532
children 6f1bb8fcf64d
rev   line source
adam@17 1 local _, AskMrRobot = ...
adam@17 2 local L = AskMrRobot.L;
adam@17 3
adam@17 4 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
adam@17 5
adam@17 6 -- get an object with all of the parts fo the item link format that we care about
adam@17 7 function AskMrRobot.parseItemLink(itemLink)
adam@17 8 if not itemLink then return nil end
adam@17 9
adam@17 10 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|")
adam@17 11 if not str then return nil end
adam@17 12
adam@17 13 local parts = { strsplit(":", str) }
adam@17 14
adam@17 15 local item = {}
adam@17 16 item.id = tonumber(parts[1])
adam@17 17 item.enchantId = tonumber(parts[2])
adam@17 18 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) }
adam@17 19 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code
adam@17 20 --item.uniqueId = tonumber(parts[8])
adam@17 21 --item.level = tonumber(parts[9])
adam@17 22 item.upgradeId = tonumber(parts[10])
adam@17 23 --item.difficultyId = tonumber(parts[11])
adam@17 24
adam@17 25 local numBonuses = tonumber(parts[12])
adam@28 26 if numBonuses and numBonuses > 0 then
adam@17 27 item.bonusIds = {}
adam@17 28 for i = 13, 12 + numBonuses do
adam@17 29 table.insert(item.bonusIds, tonumber(parts[i]))
adam@17 30 end
yellowfive@39 31 table.sort(item.bonusIds)
adam@17 32 end
adam@17 33
adam@17 34 return item
adam@17 35 end
adam@17 36
yellowfive@31 37 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
yellowfive@31 38
yellowfive@31 39 function AskMrRobot.createItemLink(itemObj)
yellowfive@31 40
yellowfive@31 41 if itemObj == nil or itemObj.id == nil or itemObj.id == 0 then return nil end
yellowfive@31 42
yellowfive@31 43 local parts = {}
yellowfive@31 44 table.insert(parts, "item")
yellowfive@31 45 table.insert(parts, itemObj.id)
yellowfive@31 46 table.insert(parts, itemObj.enchantId)
yellowfive@31 47 table.insert(parts, itemObj.gemIds[1])
yellowfive@31 48 table.insert(parts, itemObj.gemIds[2])
yellowfive@31 49 table.insert(parts, itemObj.gemIds[3])
yellowfive@31 50 table.insert(parts, itemObj.gemIds[4])
yellowfive@33 51
yellowfive@33 52 if itemObj.suffixId == 0 then
yellowfive@33 53 table.insert(parts, 0)
yellowfive@33 54 else
yellowfive@33 55 table.insert(parts, -math.abs(itemObj.suffixId))
yellowfive@33 56 end
yellowfive@33 57
yellowfive@31 58 table.insert(parts, 0)
yellowfive@31 59 table.insert(parts, UnitLevel("player"))
yellowfive@31 60 table.insert(parts, itemObj.upgradeId)
yellowfive@31 61 table.insert(parts, 0)
yellowfive@31 62
yellowfive@31 63 if itemObj.bonusIds then
yellowfive@31 64 table.insert(parts, #itemObj.bonusIds)
yellowfive@31 65 for i,v in ipairs(itemObj.bonusIds) do
yellowfive@31 66 table.insert(parts, v)
yellowfive@31 67 end
yellowfive@31 68 end
yellowfive@31 69
yellowfive@31 70 return table.concat(parts, ":")
yellowfive@31 71 end
yellowfive@31 72
yellowfive@31 73 function AskMrRobot.createGemLink(gemId)
yellowfive@31 74
yellowfive@31 75 end
yellowfive@31 76
adam@17 77 -- convenience to get just the item id (or 0 if not a valid link) from an item link
adam@17 78 function AskMrRobot.getItemIdFromLink(itemLink)
adam@17 79 if not itemLink then return 0 end
adam@17 80 local parts = { strsplit(":", itemLink) }
adam@17 81 local id = tonumber(parts[2])
adam@17 82 return (id and id ~= 0 and id or 0)
adam@17 83 end
adam@17 84
adam@17 85 function AskMrRobot.getItemUniqueId(item, noUpgrade)
adam@17 86 if item == nil then return "" end
adam@17 87 local ret = item.id .. ""
adam@17 88 if item.bonusIds then
adam@17 89 for i = 1, #item.bonusIds do
adam@17 90 ret = ret .. "b" .. item.bonusIds[i]
adam@17 91 end
adam@17 92 end
adam@17 93 if item.suffixId ~= 0 then
adam@17 94 ret = ret .. "s" .. item.suffixId
adam@17 95 end
adam@17 96 if not noUpgrade and item.upgradeId ~= 0 then
adam@17 97 ret = ret .. "u" .. item.upgradeId
adam@17 98 end
adam@17 99 return ret
adam@17 100 end
adam@17 101
adam@17 102 AskMrRobot.instanceIds = {
adam@17 103 HeartOfFear = 1009,
adam@17 104 MogushanVaults = 1008,
adam@17 105 SiegeOfOrgrimmar = 1136,
adam@17 106 TerraceOfEndlessSpring = 996,
adam@17 107 ThroneOfThunder = 1098
adam@17 108 }
adam@17 109
adam@17 110 -- instances that we currently support logging for
adam@17 111 AskMrRobot.supportedInstanceIds = {
adam@17 112 [1136] = true
adam@17 113 }
adam@17 114
adam@17 115 -- returns true if currently in a supported instance
adam@17 116 function AskMrRobot.IsSupportedInstance()
adam@17 117
adam@17 118 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
adam@17 119 if AskMrRobot.supportedInstanceIds[tonumber(instanceMapID)] then
adam@17 120 return true
adam@17 121 else
adam@17 122 return false
adam@17 123 end
adam@17 124 end
adam@17 125
yellowfive@41 126 AskMrRobot.regionNames = {
yellowfive@41 127 [1] = "US",
yellowfive@41 128 [2] = "KR",
yellowfive@41 129 [3] = "EU",
yellowfive@41 130 [4] = "TW",
yellowfive@41 131 [5] = "CN"
yellowfive@41 132 }
yellowfive@41 133
adam@17 134 AskMrRobot.classIds = {
adam@17 135 ["NONE"] = 0,
adam@17 136 ["DEATHKNIGHT"] = 1,
adam@17 137 ["DRUID"] = 2,
adam@17 138 ["HUNTER"] = 3,
adam@17 139 ["MAGE"] = 4,
adam@17 140 ["MONK"] = 5,
adam@17 141 ["PALADIN"] = 6,
adam@17 142 ["PRIEST"] = 7,
adam@17 143 ["ROGUE"] = 8,
adam@17 144 ["SHAMAN"] = 9,
adam@17 145 ["WARLOCK"] = 10,
adam@17 146 ["WARRIOR"] = 11,
adam@17 147 }
adam@17 148
adam@17 149 AskMrRobot.professionIds = {
adam@17 150 ["None"] = 0,
adam@17 151 ["Mining"] = 1,
adam@17 152 ["Skinning"] = 2,
adam@17 153 ["Herbalism"] = 3,
adam@17 154 ["Enchanting"] = 4,
adam@17 155 ["Jewelcrafting"] = 5,
adam@17 156 ["Engineering"] = 6,
adam@17 157 ["Blacksmithing"] = 7,
adam@17 158 ["Leatherworking"] = 8,
adam@17 159 ["Inscription"] = 9,
adam@17 160 ["Tailoring"] = 10,
adam@17 161 ["Alchemy"] = 11,
adam@17 162 ["Fishing"] = 12,
adam@17 163 ["Cooking"] = 13,
adam@17 164 ["First Aid"] = 14,
adam@17 165 ["Archaeology"] = 15
adam@17 166 }
adam@17 167
adam@17 168 AskMrRobot.raceIds = {
adam@17 169 ["None"] = 0,
adam@17 170 ["BloodElf"] = 1,
adam@17 171 ["Draenei"] = 2,
adam@17 172 ["Dwarf"] = 3,
adam@17 173 ["Gnome"] = 4,
adam@17 174 ["Human"] = 5,
adam@17 175 ["NightElf"] = 6,
adam@17 176 ["Orc"] = 7,
adam@17 177 ["Tauren"] = 8,
adam@17 178 ["Troll"] = 9,
adam@17 179 ["Scourge"] = 10,
adam@17 180 ["Undead"] = 10,
adam@17 181 ["Goblin"] = 11,
adam@17 182 ["Worgen"] = 12,
adam@17 183 ["Pandaren"] = 13
adam@17 184 }
adam@17 185
adam@17 186 AskMrRobot.factionIds = {
adam@17 187 ["None"] = 0,
adam@17 188 ["Alliance"] = 1,
adam@17 189 ["Horde"] = 2
adam@17 190 }
adam@17 191
adam@17 192 AskMrRobot.specIds = {
adam@17 193 [250] = 1, -- DeathKnightBlood
adam@17 194 [251] = 2, -- DeathKnightFrost
adam@17 195 [252] = 3, -- DeathKnightUnholy
adam@17 196 [102] = 4, -- DruidBalance
adam@17 197 [103] = 5, -- DruidFeral
adam@17 198 [104] = 6, -- DruidGuardian
adam@17 199 [105] = 7, -- DruidRestoration
adam@17 200 [253] = 8, -- HunterBeastMastery
adam@17 201 [254] = 9, -- HunterMarksmanship
adam@17 202 [255] = 10, -- HunterSurvival
adam@17 203 [62] = 11, -- MageArcane
adam@17 204 [63] = 12, -- MageFire
adam@17 205 [64] = 13, -- MageFrost
adam@17 206 [268] = 14, -- MonkBrewmaster
yellowfive@23 207 [270] = 15, -- MonkMistweaver
yellowfive@23 208 [269] = 16, -- MonkWindwalker
adam@17 209 [65] = 17, -- PaladinHoly
adam@17 210 [66] = 18, -- PaladinProtection
adam@17 211 [70] = 19, -- PaladinRetribution
adam@17 212 [256] = 20, -- PriestDiscipline
adam@17 213 [257] = 21, -- PriestHoly
adam@17 214 [258] = 22, -- PriestShadow
adam@17 215 [259] = 23, -- RogueAssassination
adam@17 216 [260] = 24, -- RogueCombat
adam@17 217 [261] = 25, -- RogueSubtlety
adam@17 218 [262] = 26, -- ShamanElemental
adam@17 219 [263] = 27, -- ShamanEnhancement
adam@17 220 [264] = 28, -- ShamanRestoration
adam@17 221 [265] = 29, -- WarlockAffliction
adam@17 222 [266] = 30, -- WarlockDemonology
adam@17 223 [267] = 31, -- WarlockDestruction
adam@17 224 [71] = 32, -- WarriorArms
adam@17 225 [72] = 33, -- WarriorFury
adam@17 226 [73] = 34 -- WarriorProtection
adam@17 227 }
adam@17 228
adam@17 229 -- reverse map of our spec ID to the game's spec ID
adam@17 230 AskMrRobot.gameSpecIds = {}
adam@17 231 for k,v in pairs(AskMrRobot.specIds) do
adam@17 232 AskMrRobot.gameSpecIds[v] = k
adam@17 233 end
adam@17 234
adam@17 235 -- lookup from our socket color ID to string
adam@17 236 AskMrRobot.socketColorIds = {
adam@17 237 [0] = "Prismatic",
adam@17 238 [1] = "Red",
adam@17 239 [2] = "Yellow",
adam@17 240 [3] = "Blue",
adam@17 241 [4] = "Meta",
adam@17 242 [5] = "Cogwheel",
adam@17 243 [6] = "ShaTouched"
adam@17 244 }
adam@17 245
adam@17 246 -- map of game slot names to slot IDs (same both in our code and in-game)
adam@17 247 AskMrRobot.slotNameToId = {
adam@17 248 ["HeadSlot"] = 1,
adam@17 249 ["NeckSlot"] = 2,
adam@17 250 ["ShoulderSlot"] = 3,
adam@17 251 ["ChestSlot"] = 5,
adam@17 252 ["WaistSlot"] = 6,
adam@17 253 ["LegsSlot"] = 7,
adam@17 254 ["FeetSlot"] = 8,
adam@17 255 ["WristSlot"] = 9,
adam@17 256 ["HandsSlot"] = 10,
adam@17 257 ["Finger0Slot"] = 11,
adam@17 258 ["Finger1Slot"] = 12,
adam@17 259 ["Trinket0Slot"] = 13,
adam@17 260 ["Trinket1Slot"] = 14,
adam@17 261 ["BackSlot"] = 15,
adam@17 262 ["MainHandSlot"] = 16,
adam@17 263 ["SecondaryHandSlot"] = 17
adam@17 264 }
adam@17 265
adam@17 266 -- map of slot ID to display text
adam@17 267 AskMrRobot.slotDisplayText = {
adam@17 268 [1] = _G["HEADSLOT"],
adam@17 269 [2] = _G["NECKSLOT"],
adam@17 270 [3] = _G["SHOULDERSLOT"],
adam@17 271 [5] = _G["CHESTSLOT"],
adam@17 272 [6] = _G["WAISTSLOT"],
adam@17 273 [7] = _G["LEGSSLOT"],
adam@17 274 [8] = _G["FEETSLOT"],
yellowfive@31 275 [9] = _G["WRISTSLOT"],
adam@17 276 [10] = _G["HANDSSLOT"],
yellowfive@31 277 [11] = _G["FINGER0SLOT"] .. " 1",
yellowfive@31 278 [12] = _G["FINGER1SLOT"] .. " 2",
yellowfive@31 279 [13] = _G["TRINKET0SLOT"] .. " 1",
yellowfive@31 280 [14] = _G["TRINKET1SLOT"] .. " 2",
adam@17 281 [15] = _G["BACKSLOT"],
adam@17 282 [16] = _G["MAINHANDSLOT"],
adam@17 283 [17] = _G["SECONDARYHANDSLOT"]
adam@17 284 }
adam@17 285
adam@17 286 -- all slot IDs that we care about, ordered in our standard display order
adam@17 287 AskMrRobot.slotIds = { 16, 17, 1, 2, 3, 15, 5, 9, 10, 6, 7, 8, 11, 12, 13, 14 }
adam@17 288
adam@17 289 -- cache slot orders to make slot sorting easier
adam@17 290 local _slotIdToOrder = {}
adam@17 291 for i = 1, #AskMrRobot.slotIds do
adam@17 292 _slotIdToOrder[AskMrRobot.slotIds[i]] = i
adam@17 293 end
adam@17 294
adam@17 295 -- given a table where the keys are slot IDs, sort in the standard slot order
adam@17 296 function AskMrRobot.sortSlots(t)
adam@17 297 return AskMrRobot.spairs(t, function(x, a, b)
adam@17 298 if a == nil and b == nil then return 0 end
adam@17 299 return _slotIdToOrder[a] < _slotIdToOrder[b]
adam@17 300 end)
adam@17 301 end