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