-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFactionizer15.lua
More file actions
206 lines (195 loc) · 8.05 KB
/
Copy pathFactionizer15.lua
File metadata and controls
206 lines (195 loc) · 8.05 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
------5.04.00.7.2 14.4.27------------------
-- _15_ Getting reputation ready to hand In
-----------------------------------
function FIZ_GetReadyReputation(factionIndex)
local result = 0
if not factionIndex then return result end
if (not ReputationFrame:IsVisible()) then return result end
local maxFactionIndex = GetNumFactions()
if (factionIndex > maxFactionIndex) then return result end
local faction, description, standingId, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = FIZ_Orig_GetFactionInfo(factionIndex)
if (isHeader) then return result end
if (faction) then
origFaction = faction
faction = string.lower(faction)
--- fpt grr FIZ_Printtest(faction, FIZ_FactionMapping[faction],"1 grr")
if (FIZ_FactionMapping[faction]) then
--- fpt grr FIZ_Printtest(faction, FIZ_FactionMapping[faction],"2 grr")
faction = FIZ_FactionMapping[faction]
end
-- Normalize Values
local normMax = barMax - barMin
local normCurrent = barValue - barMin
local repToNext = barMax - barValue
local FIZ_FG_f=FIZ_FactionGain[faction]
if (FIZ_FG_f) then
local FIZ_FG_fs=FIZ_FG_f[standingId]
if (FIZ_FG_fs) then
-- quests (may have items)
local FIZ_FG_fs_h=FIZ_FG_fs.quests
if (FIZ_FG_fs_h) then
for i = 0, FIZ_FG_fs_h.count do
local FIZ_FG_fs_h_d=FIZ_FG_fs_h.data[i]
if (not FIZ_FG_fs_h_d.limit or (normCurrent < FIZ_FG_fs_h_d.limit)) then
local toDo = ceil(repToNext / FIZ_FG_fs_h_d.rep)
if (FIZ_FG_fs_h_d.limit) then
toDo = ceil((FIZ_FG_fs_h_d.limit - normCurrent) / FIZ_FG_fs_h_d.rep)
end
if (FIZ_FG_fs_h_d.items) then
local currentQuestTimesBag = -1
local currentQuestTimesBagBank = -1
for item in pairs(FIZ_FG_fs_h_d.items) do
if (FIZ_ItemsCarried and FIZ_ItemsCarried[item]) then
if ((FIZ_ItemsCarried[item] >= FIZ_FG_fs_h_d.items[item]) and (FIZ_FG_fs_h_d.items[item] > 0)) then
local localCurrentTimesBag = floor(FIZ_ItemsCarried[item] / FIZ_FG_fs_h_d.items[item])
if (currentQuestTimesBag == -1) then
-- first items for this quest --> take value
currentQuestTimesBag = localCurrentTimesBag
else
-- some items already Set
if (localCurrentTimesBag < currentQuestTimesBag) then
-- fewer of this item than of others, reduce quest count
currentQuestTimesBag = localCurrentTimesBag
end
end
else
-- not enough of this item for quest -> set to 0
currentQuestTimesBag = 0
end
if (FIZ_Data.Bank and
FIZ_Data.Bank[FIZ_Realm.." - "..FIZ_Player] and
FIZ_Data.Bank[FIZ_Realm.." - "..FIZ_Player][item]) then
local total = FIZ_Data.Bank[FIZ_Realm.." - "..FIZ_Player][item] + FIZ_ItemsCarried[item]
if ((total >= FIZ_FG_fs_h_d.items[item]) and (FIZ_FG_fs_h_d.items[item] > 0)) then
local localCurrentTimesBagBank = floor(total / FIZ_FG_fs_h_d.items[item])
if (currentQuestTimesBagBank == -1) then
-- first items for this quest --> take value
currentQuestTimesBagBank = localCurrentTimesBagBank
else
-- some items already Set
if (localCurrentTimesBagBank < currentQuestTimesBagBank) then
-- fewer of this item than of others, reduce quest count
currentQuestTimesBagBank = localCurrentTimesBagBank
end
end
else
-- not enough of this item for quest -> set to 0
currentQuestTimesBagBank = 0
end
else
-- none of this carried In bank
end
else
-- not enough of this item for quest -> set to 0
currentQuestTimesBag = 0
end
end
if (currentQuestTimesBag > toDo) then
currentQuestTimesBag = toDo
end
if (currentQuestTimesBagBank > toDo) then
currentQuestTimesBagBank = toDo
end
if (currentQuestTimesBagBank > 0) then
result = result + currentQuestTimesBagBank * FIZ_FG_fs_h_d.rep
elseif (currentQuestTimesBag > 0) then
result = result + currentQuestTimesBag * FIZ_FG_fs_h_d.rep
else
-- nothing to add
end
else
-- no items, check if this quest is completed
local entries, quests = GetNumQuestLogEntries()
for z=1,entries do
local title,level,tag,group,header,collapsed,complete,daily = GetQuestLogTitle(z)
if (title and not header and complete) then
if string.find(string.lower(FIZ_FG_fs_h_d.name), string.lower(title)) then
-- this quest matches
result = result + FIZ_FG_fs_h_d.rep
end
end
end
end
end
end
end
-- items
local FIZ_FG_fs_h=FIZ_FG_fs.items
if (FIZ_FG_fs_h and FIZ_Data.ShowItems) then
for i = 0, FIZ_FG_fs_h.count do
local FIZ_FG_fs_h_d=FIZ_FG_fs_h.data[i]
if (not FIZ_FG_fs_h_d.limit or (normCurrent < FIZ_FG_fs_h_d.limit)) then
local toDo = ceil(repToNext / FIZ_FG_fs_h_d.rep)
if (FIZ_FG_fs_h_d.limit) then
toDo = ceil((FIZ_FG_fs_h_d.limit - normCurrent) / FIZ_FG_fs_h_d.rep)
end
if (FIZ_FG_fs_h_d.items) then
local currentQuestTimesBag = -1
local currentQuestTimesBagBank = -1
for item in pairs(FIZ_FG_fs_h_d.items) do
if (FIZ_ItemsCarried and FIZ_ItemsCarried[item]) then
if ((FIZ_ItemsCarried[item] >= FIZ_FG_fs_h_d.items[item]) and (FIZ_FG_fs_h_d.items[item] > 0)) then
local localCurrentTimesBag = floor(FIZ_ItemsCarried[item] / FIZ_FG_fs_h_d.items[item])
if (currentQuestTimesBag == -1) then
-- first items for this quest --> take value
currentQuestTimesBag = localCurrentTimesBag
else
-- some items already Set
if (localCurrentTimesBag < currentQuestTimesBag) then
-- fewer of this item than of others, reduce quest count
currentQuestTimesBag = localCurrentTimesBag
end
end
else
-- not enough of this item for quest -> set to 0
currentQuestTimesBag = 0
end
if (FIZ_Data.Bank and
FIZ_Data.Bank[FIZ_Realm.." - "..FIZ_Player] and
FIZ_Data.Bank[FIZ_Realm.." - "..FIZ_Player][item]) then
local total = FIZ_Data.Bank[FIZ_Realm.." - "..FIZ_Player][item] + FIZ_ItemsCarried[item]
if ((total >= FIZ_FG_fs_h_d.items[item]) and (FIZ_FG_fs_h_d.items[item] > 0)) then
local localCurrentTimesBagBank = floor(total / FIZ_FG_fs_h_d.items[item])
if (currentQuestTimesBagBank == -1) then
-- first items for this quest --> take value
currentQuestTimesBagBank = localCurrentTimesBagBank
else
-- some items already Set
if (localCurrentTimesBagBank < currentQuestTimesBagBank) then
-- fewer of this item than of others, reduce quest count
currentQuestTimesBagBank = localCurrentTimesBagBank
end
end
else
-- not enough of this item for quest -> set to 0
currentQuestTimesBagBank = 0
FIZ_UpdateList[itemIndex].name = FIZ_UpdateList[itemIndex].name.." ["..total.."x]"
end
else
-- none of this carried In bank
end
else
-- not enough of this item for quest -> set to 0
currentQuestTimesBag = 0
end
end
if (currentQuestTimesBag > toDo) then
currentQuestTimesBag = toDo
end
if (currentQuestTimesBagBank > toDo) then
currentQuestTimesBagBank = toDo
end
if (currentQuestTimesBagBank > 0) then
result = result + currentQuestTimesBagBank * FIZ_FG_fs_h_d.rep
elseif (currentQuestTimesBag > 0) then
result = result + currentQuestTimesBag * FIZ_FG_fs_h_d.rep
end
end
end
end
end
end
end
end
return result;
end