-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.lua
More file actions
136 lines (120 loc) · 3.62 KB
/
Utils.lua
File metadata and controls
136 lines (120 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
-- MythicLootMap Utilities and Constants
local ADDON_NAME, ns = ...
local MythicLootMap = ns
-- Safety fallback: if Locales.lua failed to load, create L with key-as-value fallback
if not MythicLootMap.L then
MythicLootMap.L = setmetatable({}, { __index = function(_, k) return k end })
end
-- Equipment location -> inventory slot ID (single slot items)
MythicLootMap.EQUIPLOC_TO_SLOT = {
INVTYPE_HEAD = 1,
INVTYPE_NECK = 2,
INVTYPE_SHOULDER = 3,
INVTYPE_CHEST = 5,
INVTYPE_ROBE = 5,
INVTYPE_WAIST = 6,
INVTYPE_LEGS = 7,
INVTYPE_FEET = 8,
INVTYPE_WRIST = 9,
INVTYPE_HAND = 10,
INVTYPE_CLOAK = 15,
INVTYPE_2HWEAPON = 16,
INVTYPE_WEAPONMAINHAND = 16,
INVTYPE_WEAPONOFFHAND = 17,
INVTYPE_SHIELD = 17,
INVTYPE_HOLDABLE = 17,
INVTYPE_RANGED = 16,
INVTYPE_RANGEDRIGHT = 16,
}
-- Equipment locations that map to multiple slots
MythicLootMap.MULTI_SLOT_EQUIPLOCS = {
INVTYPE_FINGER = { 11, 12 },
INVTYPE_TRINKET = { 13, 14 },
INVTYPE_WEAPON = { 16, 17 },
}
-- Armor type constants
MythicLootMap.ARMOR_TYPES = {
Cloth = 1,
Leather = 2,
Mail = 3,
Plate = 4,
}
-- Armor subclassID -> normalized type string (locale-independent)
-- Enum.ItemArmorSubclass: 1=Cloth, 2=Leather, 3=Mail, 4=Plate
MythicLootMap.ARMOR_SUBCLASS_TO_TYPE = {
[1] = "Cloth",
[2] = "Leather",
[3] = "Mail",
[4] = "Plate",
}
-- Slot ID -> display name (localized)
local L = MythicLootMap.L
MythicLootMap.SLOT_NAMES = {
[1] = L["Head"],
[2] = L["Neck"],
[3] = L["Shoulder"],
[5] = L["Chest"],
[6] = L["Waist"],
[7] = L["Legs"],
[8] = L["Feet"],
[9] = L["Wrist"],
[10] = L["Hands"],
[11] = L["Ring"],
[12] = L["Ring"],
[13] = L["Trinket"],
[14] = L["Trinket"],
[15] = L["Back"],
[16] = L["MainHand"],
[17] = L["OffHand"],
}
-- Unique slot IDs for filter dropdown (no duplicates)
MythicLootMap.FILTER_SLOTS = {
{ id = 0, name = L["AllSlots"] },
{ id = 1, name = L["Head"] },
{ id = 2, name = L["Neck"] },
{ id = 3, name = L["Shoulder"] },
{ id = 15, name = L["Back"] },
{ id = 5, name = L["Chest"] },
{ id = 9, name = L["Wrist"] },
{ id = 10, name = L["Hands"] },
{ id = 6, name = L["Waist"] },
{ id = 7, name = L["Legs"] },
{ id = 8, name = L["Feet"] },
{ id = 11, name = L["Ring"] },
{ id = 13, name = L["Trinket"] },
{ id = 16, name = L["MainHand"] },
{ id = 17, name = L["OffHand"] },
}
-- Mythic (M0) difficulty ID for Encounter Journal
MythicLootMap.MYTHIC_DIFFICULTY = 23
-- Color codes
MythicLootMap.COLORS = {
UPGRADE = "|cFF00FF00", -- green
DOWNGRADE = "|cFFFF0000", -- red
NEUTRAL = "|cFFFFFFFF", -- white
OWNED = "|cFF888888", -- gray
HEADER = "|cFFFFD100", -- gold
RESET = "|r",
}
function MythicLootMap:Print(msg)
print(MythicLootMap.COLORS.HEADER .. "MythicLootMap:|r " .. msg)
end
function MythicLootMap:GetSlotName(slotID)
return self.SLOT_NAMES[slotID] or "Unknown"
end
function MythicLootMap:ResolveSlotID(equipLoc)
if not equipLoc then return nil end
local multi = self.MULTI_SLOT_EQUIPLOCS[equipLoc]
if multi then
return multi[1]
end
return self.EQUIPLOC_TO_SLOT[equipLoc]
end
function MythicLootMap:FormatStatNames(item)
local names = {}
if item.crit and item.crit > 0 then names[#names + 1] = L["Crit"] end
if item.haste and item.haste > 0 then names[#names + 1] = L["Haste"] end
if item.mastery and item.mastery > 0 then names[#names + 1] = L["Mastery"] end
if item.vers and item.vers > 0 then names[#names + 1] = L["Vers"] end
return table.concat(names, " / ")
end