-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGH_QuestReward.lua
executable file
·128 lines (109 loc) · 4.31 KB
/
GH_QuestReward.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
local L = LibStub("AceLocale-3.0"):GetLocale("GearHelper")
-- TODO: Overlay buttons needs to be rework, because they don't seems to work
-- TODO: Split that shit
function GearHelper:GetQuestReward()
local numQuestChoices = GetNumQuestChoices()
local isBetter = false
if self.db.profile.autoAcceptQuestReward and numQuestChoices < 1 then
GetQuestReward()
elseif self.db.profile.autoAcceptQuestReward and numQuestChoices == 1 then
GetQuestReward(1)
else
local weightTable = {}
local prixTable = {}
local altTable = {}
for i = 1, numQuestChoices do
local item = GHItem:Create(GetQuestItemLink("choice", i))
if item.type ~= ARMOR and item.type ~= WEAPON then
return
end
local status, res = pcall(self.NewWeightCalculation, self, item)
if (false == status) then
self:Print('-----------------("if (true ~= status and true ~= res) then")-----------------', 'quest')
self:Print("status : " .. tostring(status), 'quest')
self:Print("status res : " .. tostring(res), 'quest')
end
if status then
local tmpTable = {}
for _, result in pairs(res) do
if result > 0 then
table.insert(tmpTable, result)
end
end
if GHToolbox:GetArraySize(tmpTable) == 0 then
table.insert(weightTable, -10)
table.insert(prixTable, item.sellPrice)
table.insert(altTable, item.sellPrice, item.itemLink)
else
local highestResult = 0
for _, v in ipairs(tmpTable) do
if v > highestResult then
highestResult = v
end
end
table.insert(weightTable, highestResult)
end
end
end
local maxWeight = weightTable[1]
local keyWeight = 1
local maxPrix = prixTable[1]
local keyPrix = 1
for i = 1, table.getn(weightTable) do
if weightTable[i] > maxWeight then
maxWeight = weightTable[i]
keyWeight = i
end
end
for i = 1, table.getn(prixTable) do
if prixTable[i] > maxPrix then
maxPrix = prixTable[i]
keyPrix = i
end
end
local prixTriee = prixTable
table.sort(prixTriee)
if maxWeight > 0 and not isBetter then
local button = _G["QuestInfoRewardsFrameQuestInfoItem" .. keyWeight]
-- table.insert(GearHelper.ButtonQuestReward, button)
if button.overlay then
button.overlay:SetShown(false)
button.overlay = nil
end
if not button.overlay then
button.overlay = button:CreateTexture(nil, "OVERLAY")
button.overlay:SetSize(18, 18)
button.overlay:SetPoint("TOPLEFT")
button.overlay:SetAtlas("bags-greenarrow", true)
button.overlay:SetShown(true)
end
if GearHelper.db.profile.autoAcceptQuestReward then
local objetI = GetQuestItemLink("choice", keyWeight)
-- print("On prend " .. objetI)
GetQuestReward(keyWeight)
if button.overlay then
button.overlay:SetShown(false)
button.overlay = nil
end
end
isBetter = true
else
local button = _G["QuestInfoRewardsFrameQuestInfoItem" .. keyPrix]
if button.overlay then
button.overlay:SetShown(false)
button.overlay = nil
end
if not button.overlay then
button.overlay = button:CreateTexture(nil, "OVERLAY")
button.overlay:SetSize(18, 18)
button.overlay:SetPoint("TOPLEFT")
button.overlay:SetAtlas("bags-junkcoin", true)
button.overlay:SetShown(true)
end
local objetI = GetQuestItemLink("choice", keyPrix)
do
return
end
end
end
end