Skip to content

Commit bf03eff

Browse files
committed
fixed displayed patron order crafting costs
1 parent cbc8d94 commit bf03eff

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

Classes/PriceData.lua

+32-12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function CraftSim.PriceData:new(recipeData)
1919
self.craftingCosts = 0
2020
self.craftingCostsRequired = 0
2121
self.craftingCostsFixed = 0
22+
self.craftingCostsNoOrderReagents = 0
2223
self.expectedCostsPerItem = 0
2324
self.resourcefulnessSavedCosts = 0
2425
self.resourcefulnessSavedCostsAverage = 0
@@ -66,6 +67,7 @@ function CraftSim.PriceData:Update()
6667
self.craftingCosts = 0
6768
self.craftingCostsRequired = 0
6869
self.craftingCostsFixed = 0
70+
self.craftingCostsNoOrderReagents = 0
6971
self.expectedCostsPerItem = 0
7072
self.resourcefulnessSavedCosts = 0
7173
self.resourcefulnessSavedCostsAverage = 0
@@ -81,6 +83,8 @@ function CraftSim.PriceData:Update()
8183

8284
print("Calculating Crafting Costs: ")
8385

86+
local isWorkOrder = self.recipeData.orderData ~= 0
87+
8488
if self.recipeData.isSalvageRecipe then
8589
if reagentData.salvageReagentSlot.activeItem then
8690
local itemID = reagentData.salvageReagentSlot.activeItem:GetItemID()
@@ -98,6 +102,7 @@ function CraftSim.PriceData:Update()
98102
else
99103
print("Summing reagents:")
100104
for _, reagent in pairs(reagentData.requiredReagents) do
105+
local isOrderReagent = isWorkOrder and reagent:IsOrderReagentIn(self.recipeData)
101106
if reagent.hasQuality then
102107
local totalQuantity = 0
103108
local totalPrice = 0
@@ -106,7 +111,8 @@ function CraftSim.PriceData:Update()
106111
local itemID = reagentItem.item:GetItemID()
107112
local reagentPriceInfo = self.reagentPriceInfos[itemID]
108113
totalPrice = totalPrice + reagentPriceInfo.itemPrice * reagentItem.quantity
109-
if reagentPriceInfo.priceInfo.isExpectedCost then
114+
115+
if not isOrderReagent and reagentPriceInfo.priceInfo.isExpectedCost then
110116
tinsert(self.selfCraftedReagents, itemID)
111117
end
112118
end
@@ -121,22 +127,31 @@ function CraftSim.PriceData:Update()
121127
local reagentPriceInfoQ3 = self.reagentPriceInfos[itemIDQ3]
122128
local cheapestItemPrice = math.min(reagentPriceInfoQ1.itemPrice, reagentPriceInfoQ2.itemPrice,
123129
reagentPriceInfoQ3.itemPrice)
124-
125-
self.craftingCosts = self.craftingCosts + cheapestItemPrice * reagent.requiredQuantity
130+
local reagentCosts = cheapestItemPrice * reagent.requiredQuantity
131+
self.craftingCosts = self.craftingCosts + reagentCosts
132+
if not isOrderReagent then
133+
self.craftingCostsNoOrderReagents = self.craftingCostsNoOrderReagents + reagentCosts
134+
end
126135
else
127136
self.craftingCosts = self.craftingCosts + totalPrice
137+
if not isOrderReagent then
138+
self.craftingCostsNoOrderReagents = self.craftingCostsNoOrderReagents + totalPrice
139+
end
128140
end
129141
else
130142
local itemID = reagent.items[1].item:GetItemID()
131143
local reagentPriceInfo = self.reagentPriceInfos[itemID]
132144

133-
self.craftingCosts = self.craftingCosts + reagentPriceInfo.itemPrice * reagent.requiredQuantity
134-
self.craftingCostsFixed = self.craftingCostsFixed +
135-
reagentPriceInfo.itemPrice *
136-
reagent.requiredQuantity -- always max
145+
local reagentCosts = reagentPriceInfo.itemPrice * reagent.requiredQuantity
146+
147+
self.craftingCosts = self.craftingCosts + reagentCosts
148+
self.craftingCostsFixed = self.craftingCostsFixed + reagentCosts -- always max
137149

138-
if reagentPriceInfo.priceInfo.isExpectedCost then
139-
tinsert(self.selfCraftedReagents, itemID)
150+
if not isOrderReagent then
151+
self.craftingCostsNoOrderReagents = self.craftingCostsNoOrderReagents + reagentCosts
152+
if reagentPriceInfo.priceInfo.isExpectedCost then
153+
tinsert(self.selfCraftedReagents, itemID)
154+
end
140155
end
141156
end
142157
end
@@ -159,14 +174,19 @@ function CraftSim.PriceData:Update()
159174
print("num active optionals: " .. #activeOptionalReagents)
160175
for _, activeOptionalReagent in pairs(activeOptionalReagents) do
161176
if activeOptionalReagent then
177+
local isOrderReagent = isWorkOrder and activeOptionalReagent:IsOrderReagentIn(self.recipeData)
162178
print("added optional reagent to crafting cost: " .. tostring(activeOptionalReagent.item:GetItemLink()))
163179
local itemID = activeOptionalReagent.item:GetItemID()
164180
local reagentPriceInfo = self.reagentPriceInfos[itemID]
165181

166-
self.craftingCosts = self.craftingCosts + (reagentPriceInfo.itemPrice * (quantityMap[itemID] or 1))
182+
local reagentCosts = (reagentPriceInfo.itemPrice * (quantityMap[itemID] or 1))
183+
self.craftingCosts = self.craftingCosts + reagentCosts
167184

168-
if reagentPriceInfo.priceInfo.isExpectedCost then
169-
tinsert(self.selfCraftedReagents, itemID)
185+
if not isOrderReagent then
186+
self.craftingCostsNoOrderReagents = self.craftingCostsNoOrderReagents + reagentCosts
187+
if reagentPriceInfo.priceInfo.isExpectedCost then
188+
tinsert(self.selfCraftedReagents, itemID)
189+
end
170190
end
171191
end
172192
end

Modules/CraftQueue/UI.lua

+13-2
Original file line numberDiff line numberDiff line change
@@ -1783,8 +1783,15 @@ function CraftSim.CRAFTQ.UI:UpdateEditRecipeFrameDisplay(craftQueueItem)
17831783
GUTIL:IconToText(CraftSim.CONST.CONCENTRATION_ICON, 15, 15) ..
17841784
" " .. f.gold(editRecipeFrame.craftQueueItem.recipeData.concentrationCost)
17851785
end
1786+
1787+
local craftingCosts
1788+
if recipeData.orderData then
1789+
craftingCosts = recipeData.priceData.craftingCostsNoOrderReagents
1790+
else
1791+
craftingCosts = recipeData.priceData.craftingCosts
1792+
end
17861793
editRecipeFrame.content.craftingCostsValue:SetText(GUTIL:ColorizeText(
1787-
CraftSim.UTIL:FormatMoney(recipeData.priceData.craftingCosts), GUTIL.COLORS.RED) .. concentrationCostText)
1794+
CraftSim.UTIL:FormatMoney(craftingCosts), GUTIL.COLORS.RED) .. concentrationCostText)
17881795
local concentrationValue = CraftSim.AVERAGEPROFIT:GetConcentrationWeight(recipeData,
17891796
recipeData.averageProfitCached)
17901797
editRecipeFrame.content.concentrationValue:SetText(CraftSim.UTIL:FormatMoney(concentrationValue, true))
@@ -2050,7 +2057,11 @@ function CraftSim.CRAFTQ.UI:UpdateCraftQueueRowByCraftQueueItem(row, craftQueueI
20502057
recipeData.priceData:Update()
20512058
recipeData:GetAverageProfit()
20522059

2053-
row.craftingCosts = recipeData.priceData.craftingCosts * craftQueueItem.amount
2060+
if recipeData.orderData then
2061+
row.craftingCosts = recipeData.priceData.craftingCostsNoOrderReagents * craftQueueItem.amount
2062+
else
2063+
row.craftingCosts = recipeData.priceData.craftingCosts * craftQueueItem.amount
2064+
end
20542065

20552066
row.averageProfit = (recipeData.averageProfitCached or recipeData:GetAverageProfit()) *
20562067
craftQueueItem.amount

0 commit comments

Comments
 (0)