Skip to content

Commit 3b0f609

Browse files
committed
Apply stat transform in data.powerStatList.GetFromOutput and fix anoint
1 parent 1157810 commit 3b0f609

6 files changed

Lines changed: 35 additions & 34 deletions

File tree

src/Classes/CalcsTab.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,6 @@ end
674674
function CalcsTabClass:CalculatePowerStat(selection, original, modified)
675675
local originalValue = data.powerStatList.GetFromOutput(original, selection)
676676
local modifiedValue = data.powerStatList.GetFromOutput(modified, selection)
677-
if selection.transform then
678-
originalValue = selection.transform(originalValue)
679-
modifiedValue = selection.transform(modifiedValue)
680-
end
681677
return originalValue - modifiedValue
682678
end
683679

src/Classes/CompareTab.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,10 +2652,7 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26522652
end
26532653

26542654
-- Get baseline stat value for percentage calculation
2655-
local baseStatValue = data.powerStatList.GetFromOutput(calcBase, powerStat)[powerStat.stat]
2656-
if powerStat.transform then
2657-
baseStatValue = powerStat.transform(baseStatValue)
2658-
end
2655+
local baseStatValue = data.powerStatList.GetFromOutput(calcBase, powerStat)
26592656

26602657
-- Helper to format an impact value and compute percentage
26612658
local function formatImpact(impact)

src/Classes/ItemDBControl.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ function ItemDBClass:ListBuilder()
244244
if self.itemsTab:IsItemValidForSlot(item, slotName) and not slot.inactive and (not slot.weaponSet or slot.weaponSet == (self.itemsTab.activeItemSet.useSecondWeaponSet and 2 or 1)) then
245245
local output = calcFunc(item.base.flask and { toggleFlask = item } or item.base.charm and { toggleCharm = item } or { repSlotName = slotName, repItem = item }, useFullDPS)
246246
local measuredPower = data.powerStatList.GetFromOutput(output, self.sortDetail)
247-
if self.sortDetail.transform then
248-
measuredPower = self.sortDetail.transform(measuredPower)
249-
end
250247
item.measuredPower = item.measuredPower and m_max(item.measuredPower, measuredPower) or measuredPower
251248
end
252249
end

src/Classes/ItemsTab.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,15 @@ function ItemsTabClass:Load(xml, dbFileName)
11441144
stat = child.attrib.stat,
11451145
weightMult = tonumber(child.attrib.weightMult)
11461146
}
1147-
t_insert(self.tradeQuery.statSortSelectionList, statSort)
1147+
for _, statEntry in ipairs(data.powerStatList) do
1148+
if statSort.stat == statEntry.stat then
1149+
-- update information which can be out of data or missing in the xml
1150+
statSort.label = statEntry.label
1151+
statSort.transform = statEntry.transform
1152+
t_insert(self.tradeQuery.statSortSelectionList, statSort)
1153+
break
1154+
end
1155+
end
11481156
end
11491157
end
11501158
end

src/Classes/NotableDBControl.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ end
135135

136136
function NotableDBClass:BuildSortOrder()
137137
wipeTable(self.sortDropList)
138-
for id,stat in pairs(data.powerStatList) do
138+
for id, stat in ipairs(data.powerStatList) do
139139
if not stat.ignoreForItems then
140140
t_insert(self.sortDropList, {
141141
label="Sort by "..stat.label,
@@ -161,10 +161,6 @@ end
161161
function NotableDBClass:CalculatePowerStat(selection, original, modified)
162162
local originalValue = data.powerStatList.GetFromOutput(original, selection)
163163
local modifiedValue = data.powerStatList.GetFromOutput(modified, selection)
164-
if selection.transform then
165-
originalValue = selection.transform(originalValue)
166-
modifiedValue = selection.transform(modifiedValue)
167-
end
168164
return originalValue - modifiedValue
169165
end
170166

src/Modules/Data.lua

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,27 +180,34 @@ data.powerStatList = {
180180

181181
---@param output any Calc output
182182
---@param statTable StatTable Table with stats as in data.powerStatList
183+
---@param skipTransform? boolean Whether the stat transform should be skipped. This is useful if you want to e.g. divide two less is better stats
183184
---@return number
184-
function data.powerStatList.GetFromOutput(output, statTable)
185-
if statTable.stat == "FullDPS" then
186-
if output[statTable.stat] ~= nil then
187-
return output[statTable.stat] or 0
185+
function data.powerStatList.GetFromOutput(output, statTable, skipTransform)
186+
local function getEntry()
187+
if statTable.stat == "FullDPS" then
188+
if output[statTable.stat] ~= nil then
189+
return output[statTable.stat] or 0
190+
end
191+
-- if the user doesn't have full dps, we default to adding the player and minion dps together
192+
return (output.CombinedDPS or 0) + (output.Minion and output.Minion.CombinedDPS)
188193
end
189-
-- if the user doesn't have full dps, we default to adding the player and minion dps together
190-
return (output.CombinedDPS or 0) + (output.Minion and output.Minion.CombinedDPS)
191-
end
192-
-- minion-only stats
193-
local minionStat = statTable.stat:match("^Minion(.+)")
194-
if minionStat then
195-
return output.Minion and output.Minion[minionStat] or 0
194+
-- minion-only stats
195+
local minionStat = statTable.stat:match("^Minion(.+)")
196+
if minionStat then
197+
return output.Minion and output.Minion[minionStat] or 0
198+
end
199+
-- damage stats use a combination of player and minion dps
200+
local isDamageStat = statTable.stat == "AverageDamage" or statTable.stat == "TotalDot" or
201+
statTable.stat:match("DPS")
202+
if isDamageStat then
203+
return (output[statTable.stat] or 0) + (output.Minion and output.Minion[statTable.stat] or 0)
204+
end
205+
return output[statTable.stat] or 0
196206
end
197-
-- damage stats use a combination of player and minion dps
198-
local isDamageStat = statTable.stat == "AverageDamage" or statTable.stat == "TotalDot" or
199-
statTable.stat:match("DPS")
200-
if isDamageStat then
201-
return (output[statTable.stat] or 0) + (output.Minion and output.Minion[statTable.stat] or 0)
207+
if statTable.transform and not skipTransform then
208+
return statTable.transform(getEntry())
202209
end
203-
return output[statTable.stat] or 0
210+
return getEntry()
204211
end
205212
-- these stats don't exist on minions or generally don't exist on both player and minion
206213
local minionNonApplicableStats = {

0 commit comments

Comments
 (0)