-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
151 lines (133 loc) · 4.7 KB
/
main.lua
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
local SniperTips_HunterPetFood = LibStub("AceAddon-3.0"):NewAddon('SniperTips_HunterPetFood');
local LibTooltip = LibStub("SniperTips-2.0");
local tipColour = { 0.6, 0.2, 0.2 }
SniperTips_HunterPetFood.kbDEBUG = true
SniperTips_HunterPetFood.Globals = {
["TitleColour"] = {
["escape"] = "|cFFABD473",
["rgb"] = { 0.67, 0.83, 0.45 },
["rgba"] = { 0.67, 0.83, 0.45, 1 },
},
-- 170, 141, 114
["Ratings"] = {
["NA"] = {
["escape"] = "|cFF9D9D9D",
["rgba"] = { 0.62, 0.62, 0.62, 1 }
},
["Bad"] = {
["escape"] = "|cFFFFFFFF",
["rgba"] = { 1.00, 1.00, 1.00, 1 }
},
["Good"] = {
["escape"] = "|cFF00A7DD",
["rgba"] = { 0.00, 0.44, 0.87, 1 }
},
["Epic"] = {
["escape"] = "|cFFA335EE",
["rgba"] = { 0.64, 0.21, 0.93, 1 }
}
},
["NA"] = "N/A",
["Bad"] = "Bad",
["Good"] = "Good",
["Epic"] = "Epic",
}
function SniperTips_HunterPetFood:Dump(str, obj)
if ViragDevTool_AddData and SniperTips_HunterPetFood.kbDEBUG then
ViragDevTool_AddData(obj, str)
end
end
--Only load the addon if player is a hunter
function SniperTips_HunterPetFood:PlayerClassIsHunter()
local _, englishClass, _ = UnitClass('player');
return englishClass == 'HUNTER'
end
----------------
-- Core Logic --
----------------
function SniperTips_HunterPetFood:ItemIsFood(item)
-- TODO: Can this if statement be simplified with a boolean return?
if (item.classID == 0) then
return true
end
return false
end
function SniperTips_HunterPetFood:HandleItem(self, item)
if (SniperTips_HunterPetFood:PlayerClassIsHunter() == false) then
return
end
-- Only load for the consumables item category
if (SniperTips_HunterPetFood:ItemIsFood(item) == false) then
return -- void
end
local rating, ratingColour = SniperTips_HunterPetFood:GetFoodRating(item)
if (rating ~= nil and ratingColour ~= nil) then
self:AddDoubleLine(
SniperTips_HunterPetFood.Globals.TitleColour.escape.."Food Rating: ",
ratingColour..rating
);
end
end
----------------------
-- Hunter Pet Logic --
----------------------
function SniperTips_HunterPetFood:GetFoodRating(item)
local petExists = UnitExists("pet")
local petFoodRatings = {
["Cat"] = {
[8952] = { ["good"] = 61, ["bad"] = 65, ["na"] = 999 }, -- Roasted Quail
},
["Bear"] = {
},
["Boar"] = {
[8952] = { ["good"] = 99, ["bad"] = 99, ["na"] = 99 }, -- Roasted Quail
--[1015] = { ["good"] = 29, ["bad"] = 999, ["na"] = 99 }, -- Lean Wolf Flank, placeholders: bad/na
--[4536] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 }, -- Shiny Red Apple [13 = placeholder value]
--[11584] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 }, -- Cactus Apple Surprise [13 = placeholder value]
-- TODO: !important: 22 and 60 are placeholder values
-- [2677] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 },
-- [2681] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 },
--[117] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 } -- Tough Jerky [13 = placeholder value]
},
["Wolf"] = {
-- TODO: Also placeholder values for development
--[2681] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 },
--[769] = { ["good"] = 13, ["bad"] = 22, ["na"] = 60 },
}
}
if (petExists) then
-- Get the pet type: eg. Boar
local petType = UnitCreatureFamily("pet");
-- Get the pet level.
local petLevel = UnitLevel("pet");
-- Only load ratings if we have them defined for the petType
SniperTips_HunterPetFood:Dump('ratings for pet', petFoodRatings[petType])
if (petFoodRatings[petType] ~= nil) then
-- Lookup the item id against the pet type
local ratings = petFoodRatings[petType][item.id] or nil;
local rating, ratingColour;
if (ratings ~= nil) then
-- return the rating (coloured)
if (petLevel >= ratings.na) then
rating = SniperTips_HunterPetFood.Globals.NA
ratingColour = SniperTips_HunterPetFood.Globals.Ratings.NA.escape
elseif (petLevel >= ratings.bad) then
rating = SniperTips_HunterPetFood.Globals.Bad
ratingColour = SniperTips_HunterPetFood.Globals.Ratings.Bad.escape
elseif (petLevel >= ratings.good) then
rating = SniperTips_HunterPetFood.Globals.Good
ratingColour = SniperTips_HunterPetFood.Globals.Ratings.Good.escape
else
rating = SniperTips_HunterPetFood.Globals.Epic
ratingColour = SniperTips_HunterPetFood.Globals.Ratings.Epic.escape
end
return rating, ratingColour
end
end -- (/if petFoodRatings[petType])
end -- (/if petExists)
return nil, nil
end
------------------
-- Registration --
------------------
LibTooltip:AddItemHandler(SniperTips_HunterPetFood)