Skip to content

Commit 388d61d

Browse files
authored
Fix/#758 kp cost (#759)
* fixed kp cost calculation * version and news
1 parent d491762 commit 388d61d

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

CraftSim.toc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Title: CraftSim
55
## Notes: Calculates the average profit based on your profession stats and other tools for the war within gold making
66
## Author: genju
7-
## Version: 19.7.0
7+
## Version: 19.7.1
88
## X-Curse-Project-ID: 705015
99
## X-Wago-ID: 0mNwaPKo
1010
## X-WoWI-ID: 26519

Data/News.lua

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function CraftSim.NEWS:GET_NEWS(itemMap)
1717
local news = {
1818
f.bb(" Hello and thank you for using CraftSim!\n"),
1919
f.bb(" ( You are awesome! )"),
20+
newP("19.7.1"),
21+
f.p .. f.bb("CraftQueue - Queue Work Orders"),
22+
f.p .. "- Fixed " .. f.bb("KP Cost") .. " being checked before optimization",
2023
newP("19.7.0"),
2124
f.P .. "New Feature: " .. f.g("Quick Buy"),
2225
f.p .. "- Works only with " .. f.bb("Auctionator Shopping List"),

Modules/CraftQueue/CraftQueue.lua

+28-10
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,17 @@ function CraftSim.CRAFTQ:CRAFTINGORDERS_CLAIMED_ORDER_REMOVED()
175175
end
176176

177177
function CraftSim.CRAFTQ:QueueWorkOrders()
178+
local print = CraftSim.DEBUG:RegisterDebugID("Modules.CraftQueue.QueueWorkOrders")
179+
print("QueueWorkOrders", false, true)
178180
local profession = C_TradeSkillUI.GetChildProfessionInfo().profession
179181
local normalizedRealmName = GetNormalizedRealmName()
180182
local realmName = GetRealmName()
181183
local cleanedCrafterUIDs = GUTIL:Map(CraftSim.DB.CRAFTER:GetCrafterUIDs(), function(crafterUID)
182184
return select(1, gsub(crafterUID, "-" .. normalizedRealmName, ""))
183185
end)
186+
187+
local maxKPCost = CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_QUEUE_PATRON_ORDERS_KP_MAX_COST")
188+
184189
--TODO: Public Orders
185190
local workOrderTypes = {
186191
CraftSim.DB.OPTIONS:Get("CRAFTQUEUE_WORK_ORDERS_INCLUDE_PATRON_ORDERS") and Enum.CraftingOrderType.Npc,
@@ -325,16 +330,22 @@ function CraftSim.CRAFTQ:QueueWorkOrders()
325330
recipeData:SetCheapestQualityReagentsMax() -- considers patron reagents
326331
recipeData:Update()
327332

328-
if isPatronOrder and knowledgePointsRewarded > 0 and recipeData.averageProfitCached < 0 then
329-
local maxKPCost = CraftSim.DB.OPTIONS:Get(
330-
"CRAFTQUEUE_QUEUE_PATRON_ORDERS_KP_MAX_COST")
331-
local kpCost = math.abs(recipeData.averageProfitCached /
332-
knowledgePointsRewarded)
333+
print("- Knowledge Points Rewarded: " .. tostring(knowledgePointsRewarded))
333334

334-
if kpCost >= maxKPCost then
335-
distributor:Continue()
336-
return
335+
336+
local function withinKPCost(averageProfit)
337+
if isPatronOrder and knowledgePointsRewarded > 0 and averageProfit < 0 then
338+
339+
local kpCost = math.abs(averageProfit / knowledgePointsRewarded)
340+
341+
print("- kpCost: " .. GUTIL:FormatMoney(kpCost, true, nil, true))
342+
343+
if kpCost >= maxKPCost then
344+
return false
345+
end
346+
return true
337347
end
348+
return true
338349
end
339350

340351
local function queueRecipe()
@@ -343,16 +354,23 @@ function CraftSim.CRAFTQ:QueueWorkOrders()
343354
local forceConcentration = CraftSim.DB.OPTIONS:Get(
344355
"CRAFTQUEUE_WORK_ORDERS_FORCE_CONCENTRATION")
345356
-- check if the min quality is reached, if not do not queue
357+
local queueAble = false
346358
if recipeData.resultData.expectedQuality >= order.minQuality then
347-
CraftSim.CRAFTQ:AddRecipe { recipeData = recipeData }
359+
queueAble = true
348360
end
349361

350362
if (forceConcentration or allowConcentration) and
351363
recipeData.resultData.expectedQualityConcentration == order.minQuality then
352364
-- use concentration to reach and then queue
353365
recipeData.concentrating = true
354366
recipeData:Update()
355-
CraftSim.CRAFTQ:AddRecipe { recipeData = recipeData }
367+
queueAble = true
368+
end
369+
370+
if queueAble then
371+
if withinKPCost(recipeData.averageProfitCached) then
372+
CraftSim.CRAFTQ:AddRecipe { recipeData = recipeData }
373+
end
356374
end
357375

358376
distributor:Continue()

Util/Const.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ CraftSim.CONST.FONT_FILES = {
14751475

14761476
CraftSim.CONST.PATRON_ORDERS_KNOWLEDGE_REWARD_ITEMS = {
14771477
CATCHUP = {
1478-
228725, -- alchemy
1478+
228724, -- alchemy
14791479
228726, --blacksmithing
14801480
228728, --enchanting
14811481
228730, --engineering
@@ -1485,7 +1485,7 @@ CraftSim.CONST.PATRON_ORDERS_KNOWLEDGE_REWARD_ITEMS = {
14851485
228738, --tailoring
14861486
},
14871487
WEEKLY = {
1488-
228724, -- alchemy
1488+
228725, --alchemy
14891489
228727, --blacksmithing
14901490
228729, --enchanting
14911491
228731, --engineering

0 commit comments

Comments
 (0)