@@ -19,6 +19,7 @@ function CraftSim.PriceData:new(recipeData)
19
19
self .craftingCosts = 0
20
20
self .craftingCostsRequired = 0
21
21
self .craftingCostsFixed = 0
22
+ self .craftingCostsNoOrderReagents = 0
22
23
self .expectedCostsPerItem = 0
23
24
self .resourcefulnessSavedCosts = 0
24
25
self .resourcefulnessSavedCostsAverage = 0
@@ -66,6 +67,7 @@ function CraftSim.PriceData:Update()
66
67
self .craftingCosts = 0
67
68
self .craftingCostsRequired = 0
68
69
self .craftingCostsFixed = 0
70
+ self .craftingCostsNoOrderReagents = 0
69
71
self .expectedCostsPerItem = 0
70
72
self .resourcefulnessSavedCosts = 0
71
73
self .resourcefulnessSavedCostsAverage = 0
@@ -81,6 +83,8 @@ function CraftSim.PriceData:Update()
81
83
82
84
print (" Calculating Crafting Costs: " )
83
85
86
+ local isWorkOrder = self .recipeData .orderData ~= 0
87
+
84
88
if self .recipeData .isSalvageRecipe then
85
89
if reagentData .salvageReagentSlot .activeItem then
86
90
local itemID = reagentData .salvageReagentSlot .activeItem :GetItemID ()
@@ -98,6 +102,7 @@ function CraftSim.PriceData:Update()
98
102
else
99
103
print (" Summing reagents:" )
100
104
for _ , reagent in pairs (reagentData .requiredReagents ) do
105
+ local isOrderReagent = isWorkOrder and reagent :IsOrderReagentIn (self .recipeData )
101
106
if reagent .hasQuality then
102
107
local totalQuantity = 0
103
108
local totalPrice = 0
@@ -106,7 +111,8 @@ function CraftSim.PriceData:Update()
106
111
local itemID = reagentItem .item :GetItemID ()
107
112
local reagentPriceInfo = self .reagentPriceInfos [itemID ]
108
113
totalPrice = totalPrice + reagentPriceInfo .itemPrice * reagentItem .quantity
109
- if reagentPriceInfo .priceInfo .isExpectedCost then
114
+
115
+ if not isOrderReagent and reagentPriceInfo .priceInfo .isExpectedCost then
110
116
tinsert (self .selfCraftedReagents , itemID )
111
117
end
112
118
end
@@ -121,22 +127,31 @@ function CraftSim.PriceData:Update()
121
127
local reagentPriceInfoQ3 = self .reagentPriceInfos [itemIDQ3 ]
122
128
local cheapestItemPrice = math.min (reagentPriceInfoQ1 .itemPrice , reagentPriceInfoQ2 .itemPrice ,
123
129
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
126
135
else
127
136
self .craftingCosts = self .craftingCosts + totalPrice
137
+ if not isOrderReagent then
138
+ self .craftingCostsNoOrderReagents = self .craftingCostsNoOrderReagents + totalPrice
139
+ end
128
140
end
129
141
else
130
142
local itemID = reagent .items [1 ].item :GetItemID ()
131
143
local reagentPriceInfo = self .reagentPriceInfos [itemID ]
132
144
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
137
149
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
140
155
end
141
156
end
142
157
end
@@ -159,14 +174,19 @@ function CraftSim.PriceData:Update()
159
174
print (" num active optionals: " .. # activeOptionalReagents )
160
175
for _ , activeOptionalReagent in pairs (activeOptionalReagents ) do
161
176
if activeOptionalReagent then
177
+ local isOrderReagent = isWorkOrder and activeOptionalReagent :IsOrderReagentIn (self .recipeData )
162
178
print (" added optional reagent to crafting cost: " .. tostring (activeOptionalReagent .item :GetItemLink ()))
163
179
local itemID = activeOptionalReagent .item :GetItemID ()
164
180
local reagentPriceInfo = self .reagentPriceInfos [itemID ]
165
181
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
167
184
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
170
190
end
171
191
end
172
192
end
0 commit comments