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))
|
Vynn@0
|
78 --NumofEachQuality, Percent of Each Quality
|
Vynn@0
|
79 self:AddLine(" ")
|
Vynn@0
|
80 self:AddLine("Prospect Me",0.5,1,0.5)
|
mischivin@46
|
81 if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then
|
mischivin@42
|
82 self:AddLine("Times Prospected: " .. ProspectMe.Results[item].TimesProspected)
|
mischivin@46
|
83 elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then
|
mischivin@42
|
84 self:AddLine("Times Milled: " .. ProspectMe.Results[item].TimesProspected)
|
mischivin@42
|
85 else
|
mischivin@42
|
86 self:AddLine("Times Processed: " .. ProspectMe.Results[item].TimesProspected)
|
mischivin@42
|
87 end
|
mischivin@39
|
88 if spellid then
|
mischivin@39
|
89 ctp = price * 20
|
mischivin@39
|
90 lifetimeReturn = lifetimeReturn * 4
|
mischivin@39
|
91 else
|
mischivin@39
|
92 ctp = price * 5
|
mischivin@39
|
93 end
|
mischivin@39
|
94 if spellid == 225902 or spellid == 225904 then
|
mischivin@39
|
95 self:AddDoubleLine("Cost to Mass Prospect: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@39
|
96 elseif spellid == 210116 then
|
mischivin@39
|
97 self:AddDoubleLine("Cost to Mass Mill: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@46
|
98 elseif subclass == ProspectMe.Vars.ORE then
|
mischivin@39
|
99 self:AddDoubleLine("Cost to Prospect: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@46
|
100 elseif subclass == ProspectMe.Vars.HERB then
|
mischivin@39
|
101 self:AddDoubleLine("Cost to Mill: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@39
|
102 else
|
mischivin@39
|
103 self:AddDoubleLine("Cost to Process: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@39
|
104 end
|
mischivin@46
|
105 self:AddLine(" ")
|
mischivin@46
|
106 local margin = (lifetimeReturn/ctp*100)-100
|
mischivin@46
|
107 if margin > 30 then
|
mischivin@46
|
108 self:AddLine("Estimated Profit: " .. ProspectMe.FormatPrice(lifetimeReturn-(ctp)) .. "\nMargin: |cff00ff00" .. string.format("[%.1f%%]", margin))
|
mischivin@46
|
109 elseif margin > 15 then
|
mischivin@46
|
110 self:AddLine("Estimated Profit: " .. ProspectMe.FormatPrice(lifetimeReturn-(ctp)) .. "\nMargin: |cffffff00" .. string.format("[%.1f%%]", margin))
|
mischivin@46
|
111 elseif margin > 0 then
|
mischivin@46
|
112 self:AddLine("Estimated Profit: " .. ProspectMe.FormatPrice(lifetimeReturn-(ctp)) .. "\nMargin: |cffff0000" .. string.format("[%.1f%%]", margin))
|
Vynn@0
|
113 else
|
Vynn@0
|
114 self:AddLine("No profit to be made",1,0,0)
|
Vynn@0
|
115 end
|
mischivin@46
|
116 self:AddLine(" ")
|
mischivin@36
|
117 local t
|
mischivin@36
|
118 if IsAltKeyDown() == ProspectMe.Config.PerSession then
|
mischivin@36
|
119 t = ProspectMe.Results
|
mischivin@36
|
120 self:AddDoubleLine("Lifetime Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
|
mischivin@36
|
121 else
|
mischivin@36
|
122 t = ProspectMe.Session
|
mischivin@36
|
123 self:AddDoubleLine("Session Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
|
mischivin@36
|
124 end
|
mischivin@36
|
125 if t[item] then
|
mischivin@36
|
126 for q = 7, 0, -1 do
|
mischivin@36
|
127 for result, num in pairs(t[item]) do
|
mischivin@36
|
128 if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then
|
mischivin@36
|
129 local p, n = "", ""
|
mischivin@36
|
130 if ProspectMe.Config.ShowPercent then
|
mischivin@36
|
131 p = num/t[item].TimesProspected*100
|
mischivin@36
|
132 if p < 10 then
|
mischivin@36
|
133 p = string.format("[%.1f%%]", p)
|
Vynn@0
|
134 else
|
mischivin@36
|
135 p = string.format("[%.0f%%]", p)
|
Vynn@0
|
136 end
|
mischivin@36
|
137 else
|
mischivin@36
|
138 p = ""
|
Vynn@0
|
139 end
|
mischivin@36
|
140 if ProspectMe.Config.ShowNumber then
|
mischivin@36
|
141 n = "[" .. num .. "]"
|
mischivin@36
|
142 else
|
mischivin@36
|
143 n = ""
|
mischivin@36
|
144 end
|
mischivin@36
|
145 self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result)))
|
Vynn@0
|
146 end
|
Vynn@0
|
147 end
|
Vynn@0
|
148 end
|
mischivin@39
|
149 --self:AddLine(" ")
|
Vynn@0
|
150 end
|
Vynn@0
|
151 end
|
Vynn@0
|
152 cleared = true
|
Vynn@0
|
153 end
|
Vynn@0
|
154 end
|
Vynn@0
|
155 end
|
Vynn@0
|
156
|
Vynn@0
|
157 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
158 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
159 ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
160 ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
161
|
mischivin@36
|
162 local frame = CreateFrame("FRAME", "ProspectMe_Value")
|
mischivin@36
|
163 frame:RegisterEvent("VARIABLES_LOADED")
|
mischivin@36
|
164 --frame:SetScript("OnEvent", EventHandler)
|
mischivin@36
|
165 frame:SetScript("OnEvent", Initialize) |