mischivin@36
|
1 local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", }
|
Vynn@0
|
2
|
mischivin@36
|
3 local function Initialize()
|
mischivin@36
|
4 ProspectMe.FormatPrice = function (value)
|
Vynn@0
|
5
|
mischivin@36
|
6 local GSC_GOLD="ffffd100"
|
mischivin@36
|
7 local GSC_SILVER="ffe6e6e6"
|
mischivin@36
|
8 local GSC_COPPER="ffc8602c"
|
Vynn@0
|
9
|
mischivin@36
|
10 local g, s, c
|
mischivin@36
|
11 local digits = 0
|
mischivin@36
|
12 local gsc
|
mischivin@62
|
13 local neg = false
|
mischivin@62
|
14
|
mischivin@62
|
15 --if value is negative, record it and get the absolute value so log10 works
|
mischivin@62
|
16 if value < 0 then
|
mischivin@62
|
17 neg = true
|
mischivin@62
|
18 value = math.abs(value)
|
mischivin@62
|
19 end
|
mischivin@62
|
20
|
Vynn@0
|
21
|
mischivin@36
|
22 g = math.floor(value/10000)
|
mischivin@36
|
23 s = math.fmod(math.floor(value/100),100)
|
mischivin@36
|
24 c = math.fmod(value,100)
|
Vynn@0
|
25
|
Vynn@0
|
26
|
mischivin@36
|
27 digits = math.floor(math.log10(value)+1)
|
Vynn@0
|
28
|
mischivin@36
|
29 if ( digits < 3 ) then
|
mischivin@36
|
30 gsc = string.format(" |c%s%2d|r", GSC_COPPER, c)
|
mischivin@36
|
31 elseif ( digits < 5 ) then
|
mischivin@36
|
32 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_SILVER, s, GSC_COPPER, c)
|
mischivin@36
|
33 elseif ( digits < 7 ) then
|
mischivin@36
|
34 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_GOLD, g, GSC_SILVER, s)
|
mischivin@36
|
35 elseif ( digits < 9 ) then
|
mischivin@36
|
36 gsc = string.format("|c%s%5d|r", GSC_GOLD, g)
|
mischivin@36
|
37 else
|
mischivin@36
|
38 gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000)
|
mischivin@36
|
39 end
|
mischivin@62
|
40 --if the original number was negative, add the symbol back in
|
mischivin@62
|
41 if neg then
|
mischivin@62
|
42 gsc = "|cffff0000(|r" .. gsc .. "|cffff0000)|r"
|
mischivin@62
|
43 end
|
mischivin@36
|
44 return gsc
|
Vynn@0
|
45 end
|
Vynn@0
|
46
|
mischivin@36
|
47 ProspectMe.GetReturn = function (containerID)
|
mischivin@36
|
48 local averageReturn = 0
|
mischivin@36
|
49 if ProspectMe.Results[containerID].TimesProspected > 0 then
|
mischivin@36
|
50 for itemID, num in pairs(ProspectMe.Results[containerID]) do
|
mischivin@36
|
51 if itemID ~= "TimesProspected" then
|
mischivin@36
|
52 averageReturn = averageReturn + ProspectMe.GetItemValue(itemID) * num
|
mischivin@36
|
53 end
|
Vynn@0
|
54 end
|
mischivin@36
|
55 averageReturn = averageReturn/ProspectMe.Results[containerID].TimesProspected
|
Vynn@0
|
56 end
|
mischivin@36
|
57 return tonumber(string.format("%.0f", averageReturn))
|
Vynn@0
|
58 end
|
Vynn@0
|
59 end
|
Vynn@0
|
60
|
Vynn@0
|
61 local cleared = true
|
Vynn@0
|
62 local function OnTooltipCleared(self)
|
Vynn@0
|
63 cleared = true
|
Vynn@0
|
64 end
|
Vynn@0
|
65
|
Vynn@0
|
66 local function OnTooltipSetItem(self)
|
Vynn@0
|
67 if cleared then
|
mischivin@39
|
68 local tooltipLink = select(2, self:GetItem())
|
mischivin@39
|
69 local spellid = select(3, self:GetSpell())
|
mischivin@39
|
70 local item = nil
|
mischivin@39
|
71 if spellid == 225902 then
|
mischivin@39
|
72 item = 123918
|
mischivin@39
|
73 elseif spellid == 225904 then
|
mischivin@39
|
74 item = 123919
|
mischivin@39
|
75 elseif spellid == 210116 then
|
mischivin@39
|
76 item = 128304
|
mischivin@39
|
77 elseif tooltipLink then
|
mischivin@39
|
78 item = tonumber(tooltipLink:match("Hitem:(%d+)"))
|
mischivin@39
|
79 spellid = nil
|
mischivin@39
|
80 else
|
mischivin@39
|
81 item = nil
|
mischivin@39
|
82 spellid = nil
|
mischivin@39
|
83 end
|
mischivin@39
|
84 if item then
|
mischivin@36
|
85 if ProspectMe.Results[item] then
|
mischivin@36
|
86 local price = ProspectMe.GetItemValue(item)
|
mischivin@36
|
87 local lifetimeReturn = ProspectMe.GetReturn(item)
|
mischivin@41
|
88 local subclass = select(7,GetItemInfo(item))
|
mischivin@47
|
89 local ctp = price * 5
|
Vynn@0
|
90 --NumofEachQuality, Percent of Each Quality
|
Vynn@0
|
91 self:AddLine(" ")
|
mischivin@47
|
92 local color
|
mischivin@48
|
93 if ProspectMe.Results[item].TimesProspected < 100 then
|
mischivin@48
|
94 color = "|cffff0000"
|
mischivin@48
|
95 elseif ProspectMe.Results[item].TimesProspected < 200 then
|
mischivin@48
|
96 color = "|cffffff00"
|
mischivin@48
|
97 else
|
mischivin@48
|
98 color = "|cff00ff00"
|
mischivin@48
|
99 end
|
mischivin@48
|
100
|
mischivin@48
|
101 -- SKill Text Block ""
|
mischivin@48
|
102 local skilltext
|
mischivin@46
|
103 if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then
|
mischivin@48
|
104 skilltext = "Prospected"
|
mischivin@46
|
105 elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then
|
mischivin@48
|
106 skilltext = "Milled"
|
mischivin@42
|
107 else
|
mischivin@48
|
108 skilltext = "Processed"
|
mischivin@48
|
109 end
|
mischivin@48
|
110 self:AddDoubleLine("Prospect Me","Times " .. skilltext .. ": " .. color .. ProspectMe.Results[item].TimesProspected,1,0.82,0,1,1,1)
|
mischivin@48
|
111 self:AddLine(" ")
|
mischivin@48
|
112
|
mischivin@48
|
113 -- Economics Text Block
|
mischivin@58
|
114 if ProspectMe.Config.ShowEconomics then
|
mischivin@58
|
115 local spelltext
|
mischivin@58
|
116 if spellid == 225902 or spellid == 225904 then
|
mischivin@58
|
117 spelltext = "Mass Prospect"
|
mischivin@58
|
118 elseif spellid == 210116 then
|
mischivin@58
|
119 spelltext = "Mass Mill"
|
mischivin@58
|
120 elseif subclass == ProspectMe.Vars.ORE then
|
mischivin@58
|
121 spelltext = "Prospect"
|
mischivin@58
|
122 elseif subclass == ProspectMe.Vars.HERB then
|
mischivin@58
|
123 spelltext = "Mill"
|
mischivin@58
|
124 else
|
mischivin@58
|
125 spelltext = "Process"
|
mischivin@58
|
126 end
|
mischivin@58
|
127 if spellid then
|
mischivin@58
|
128 ctp = price * 20
|
mischivin@58
|
129 lifetimeReturn = lifetimeReturn * 4
|
mischivin@58
|
130 end
|
mischivin@58
|
131 local profit = lifetimeReturn - ctp
|
mischivin@58
|
132 local margin = (lifetimeReturn / ctp * 100) - 100
|
mischivin@58
|
133 self:AddDoubleLine("Estimated Profit: " .. ProspectMe.FormatPrice(profit), "Cost to " .. spelltext .. ": " .. ProspectMe.FormatPrice(ctp),1,1,1,1,1,1)
|
mischivin@58
|
134 if margin < 15 then
|
mischivin@58
|
135 color = "|cffff0000"
|
mischivin@58
|
136 elseif margin < 30 then
|
mischivin@58
|
137 color = "|cffffff00"
|
mischivin@58
|
138 else
|
mischivin@58
|
139 color = "|cff00ff00"
|
mischivin@58
|
140 end
|
mischivin@58
|
141 self:AddDoubleLine("Margin: " .. color .. string.format("[%.1f%%]", margin), "Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn),1,1,1,1,1,1)
|
mischivin@58
|
142 self:AddLine(" ")
|
mischivin@42
|
143 end
|
mischivin@48
|
144
|
mischivin@48
|
145 -- Results Text Block
|
mischivin@58
|
146 local quals = ProspectMe.Config.ShowQualities
|
mischivin@58
|
147 if quals.Junk or quals.Common or quals.Uncommon or quals.Rare or quals.Epic then
|
mischivin@58
|
148 local hint = true
|
mischivin@58
|
149 local tab
|
mischivin@58
|
150 if IsAltKeyDown() == ProspectMe.Config.PerSession then
|
mischivin@58
|
151 tab = ProspectMe.Results
|
mischivin@58
|
152 self:AddDoubleLine("Lifetime Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5)
|
mischivin@58
|
153 else
|
mischivin@58
|
154 tab = ProspectMe.Session
|
mischivin@58
|
155 self:AddDoubleLine("Session Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5)
|
mischivin@58
|
156 end
|
mischivin@58
|
157 if tab[item] then
|
mischivin@58
|
158 for q = 7, 0, -1 do
|
mischivin@58
|
159 for result, num in pairs(tab[item]) do
|
mischivin@58
|
160 if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then
|
mischivin@58
|
161 hint = false
|
mischivin@58
|
162 local p, n = "", ""
|
mischivin@58
|
163 if ProspectMe.Config.ShowPercent then
|
mischivin@58
|
164 p = num/tab[item].TimesProspected*100
|
mischivin@58
|
165 if p < 10 then
|
mischivin@58
|
166 p = string.format("|cffffffff[%.1f%%] ", p)
|
mischivin@58
|
167 else
|
mischivin@58
|
168 p = string.format("|cffffffff[%.0f%%] ", p)
|
mischivin@58
|
169 end
|
Vynn@0
|
170 else
|
mischivin@58
|
171 p = ""
|
Vynn@0
|
172 end
|
mischivin@58
|
173 if ProspectMe.Config.ShowNumber then
|
mischivin@58
|
174 n = "|cffffffffx" .. num
|
mischivin@58
|
175 else
|
mischivin@58
|
176 n = ""
|
mischivin@58
|
177 end
|
mischivin@58
|
178 self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result)))
|
Vynn@0
|
179 end
|
Vynn@0
|
180 end
|
Vynn@0
|
181 end
|
Vynn@0
|
182 end
|
mischivin@58
|
183 if hint then
|
mischivin@58
|
184 if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then
|
mischivin@58
|
185 self:AddLine("|cffffffffTry Prospecting some ore to see your results!")
|
mischivin@58
|
186 elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then
|
mischivin@58
|
187 self:AddLine("|cffffffffTry Milling some plants to see your results!")
|
mischivin@58
|
188 else
|
mischivin@58
|
189 self:Addline("|cffffffffTry processing some material to see your results!")
|
mischivin@58
|
190 end
|
mischivin@58
|
191 end
|
mischivin@58
|
192
|
mischivin@39
|
193 --self:AddLine(" ")
|
Vynn@0
|
194 end
|
Vynn@0
|
195 end
|
Vynn@0
|
196 cleared = true
|
Vynn@0
|
197 end
|
Vynn@0
|
198 end
|
Vynn@0
|
199 end
|
Vynn@0
|
200
|
Vynn@0
|
201 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
202 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
203 ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
204 ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
205
|
mischivin@36
|
206 local frame = CreateFrame("FRAME", "ProspectMe_Value")
|
mischivin@36
|
207 frame:RegisterEvent("VARIABLES_LOADED")
|
mischivin@36
|
208 --frame:SetScript("OnEvent", EventHandler)
|
mischivin@36
|
209 frame:SetScript("OnEvent", Initialize) |