mischivin@20
|
1 --PM_HERBSUBCLASS = select(6, GetAuctionItemSubClasses(6))
|
mischivin@20
|
2 --PM_ORESUBCLASS = select(4, GetAuctionItemSubClasses(6))
|
mischivin@20
|
3
|
mischivin@36
|
4 local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", }
|
Vynn@0
|
5
|
mischivin@36
|
6 local function Initialize()
|
mischivin@36
|
7 ProspectMe.FormatPrice = function (value)
|
Vynn@0
|
8
|
mischivin@36
|
9 local GSC_GOLD="ffffd100"
|
mischivin@36
|
10 local GSC_SILVER="ffe6e6e6"
|
mischivin@36
|
11 local GSC_COPPER="ffc8602c"
|
Vynn@0
|
12
|
mischivin@36
|
13 local g, s, c
|
mischivin@36
|
14 local digits = 0
|
mischivin@36
|
15 local gsc
|
Vynn@0
|
16
|
mischivin@36
|
17 g = math.floor(value/10000)
|
mischivin@36
|
18 s = math.fmod(math.floor(value/100),100)
|
mischivin@36
|
19 c = math.fmod(value,100)
|
Vynn@0
|
20
|
Vynn@0
|
21
|
mischivin@36
|
22 digits = math.floor(math.log10(value)+1)
|
Vynn@0
|
23
|
mischivin@36
|
24 if ( digits < 3 ) then
|
mischivin@36
|
25 gsc = string.format(" |c%s%2d|r", GSC_COPPER, c)
|
mischivin@36
|
26 elseif ( digits < 5 ) then
|
mischivin@36
|
27 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_SILVER, s, GSC_COPPER, c)
|
mischivin@36
|
28 elseif ( digits < 7 ) then
|
mischivin@36
|
29 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_GOLD, g, GSC_SILVER, s)
|
mischivin@36
|
30 elseif ( digits < 9 ) then
|
mischivin@36
|
31 gsc = string.format("|c%s%5d|r", GSC_GOLD, g)
|
mischivin@36
|
32 else
|
mischivin@36
|
33 gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000)
|
mischivin@36
|
34 end
|
mischivin@36
|
35
|
mischivin@36
|
36 return gsc
|
Vynn@0
|
37 end
|
Vynn@0
|
38
|
mischivin@36
|
39 ProspectMe.GetReturn = function (containerID)
|
mischivin@36
|
40 local averageReturn = 0
|
mischivin@36
|
41 if ProspectMe.Results[containerID].TimesProspected > 0 then
|
mischivin@36
|
42 for itemID, num in pairs(ProspectMe.Results[containerID]) do
|
mischivin@36
|
43 if itemID ~= "TimesProspected" then
|
mischivin@36
|
44 averageReturn = averageReturn + ProspectMe.GetItemValue(itemID) * num
|
mischivin@36
|
45 end
|
Vynn@0
|
46 end
|
mischivin@36
|
47 averageReturn = averageReturn/ProspectMe.Results[containerID].TimesProspected
|
Vynn@0
|
48 end
|
mischivin@36
|
49 return tonumber(string.format("%.0f", averageReturn))
|
Vynn@0
|
50 end
|
Vynn@0
|
51 end
|
Vynn@0
|
52
|
Vynn@0
|
53 local cleared = true
|
Vynn@0
|
54 local function OnTooltipCleared(self)
|
Vynn@0
|
55 cleared = true
|
Vynn@0
|
56 end
|
Vynn@0
|
57
|
Vynn@0
|
58 local function OnTooltipSetItem(self)
|
Vynn@0
|
59 if cleared then
|
Vynn@0
|
60 local name, tooltipLink = self:GetItem()
|
Vynn@0
|
61 if tooltipLink then
|
mischivin@36
|
62 local item = tonumber(tooltipLink:match("Hitem:(%d+)"))
|
mischivin@36
|
63 if ProspectMe.Results[item] then
|
mischivin@36
|
64 local price = ProspectMe.GetItemValue(item)
|
mischivin@36
|
65 local lifetimeReturn = ProspectMe.GetReturn(item)
|
Vynn@0
|
66 --NumofEachQuality, Percent of Each Quality
|
Vynn@0
|
67 self:AddLine(" ")
|
Vynn@0
|
68 self:AddLine("Prospect Me",0.5,1,0.5)
|
mischivin@36
|
69 self:AddLine("Times Processed: " .. ProspectMe.Results[item].TimesProspected)
|
mischivin@36
|
70 self:AddDoubleLine("Cost to Process: " .. ProspectMe.FormatPrice(5 * price), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@36
|
71 if lifetimeReturn-(5 * price) > 0 then
|
mischivin@36
|
72 self:AddLine("Estimated Profit: " ..ProspectMe.FormatPrice(lifetimeReturn-(5 * price)))
|
Vynn@0
|
73 self:AddLine(" ")
|
Vynn@0
|
74 else
|
Vynn@0
|
75 self:AddLine("No profit to be made",1,0,0)
|
Vynn@0
|
76 self:AddLine(" ")
|
Vynn@0
|
77 end
|
mischivin@36
|
78 local t
|
mischivin@36
|
79 if IsAltKeyDown() == ProspectMe.Config.PerSession then
|
mischivin@36
|
80 t = ProspectMe.Results
|
mischivin@36
|
81 self:AddDoubleLine("Lifetime Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
|
mischivin@36
|
82 else
|
mischivin@36
|
83 t = ProspectMe.Session
|
mischivin@36
|
84 self:AddDoubleLine("Session Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
|
mischivin@36
|
85 end
|
mischivin@36
|
86 if t[item] then
|
mischivin@36
|
87 for q = 7, 0, -1 do
|
mischivin@36
|
88 for result, num in pairs(t[item]) do
|
mischivin@36
|
89 if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then
|
mischivin@36
|
90 local p, n = "", ""
|
mischivin@36
|
91 if ProspectMe.Config.ShowPercent then
|
mischivin@36
|
92 p = num/t[item].TimesProspected*100
|
mischivin@36
|
93 if p < 10 then
|
mischivin@36
|
94 p = string.format("[%.1f%%]", p)
|
Vynn@0
|
95 else
|
mischivin@36
|
96 p = string.format("[%.0f%%]", p)
|
Vynn@0
|
97 end
|
mischivin@36
|
98 else
|
mischivin@36
|
99 p = ""
|
Vynn@0
|
100 end
|
mischivin@36
|
101 if ProspectMe.Config.ShowNumber then
|
mischivin@36
|
102 n = "[" .. num .. "]"
|
mischivin@36
|
103 else
|
mischivin@36
|
104 n = ""
|
mischivin@36
|
105 end
|
mischivin@36
|
106 self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result)))
|
Vynn@0
|
107 end
|
Vynn@0
|
108 end
|
Vynn@0
|
109 end
|
Vynn@0
|
110 self:AddLine(" ")
|
Vynn@0
|
111 end
|
Vynn@0
|
112 end
|
Vynn@0
|
113 cleared = true
|
Vynn@0
|
114 end
|
Vynn@0
|
115 end
|
Vynn@0
|
116 end
|
Vynn@0
|
117
|
Vynn@0
|
118 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
119 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
120 ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
121 ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
122
|
mischivin@36
|
123 local frame = CreateFrame("FRAME", "ProspectMe_Value")
|
mischivin@36
|
124 frame:RegisterEvent("VARIABLES_LOADED")
|
mischivin@36
|
125 --frame:SetScript("OnEvent", EventHandler)
|
mischivin@36
|
126 frame:SetScript("OnEvent", Initialize) |