Skip to content

Commit

Permalink
Tww/#302 craft results (#303)
Browse files Browse the repository at this point in the history
* craft results considering concentration

* Craft Statistics Tracker First Draft

* Multicraft Tracker

* Resourcefulness Tracker
  • Loading branch information
derfloh205 authored Jul 15, 2024
1 parent c496571 commit 44f34c6
Show file tree
Hide file tree
Showing 7 changed files with 609 additions and 236 deletions.
2 changes: 1 addition & 1 deletion Classes/ProfessionGear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function CraftSim.ProfessionGear:SetItem(itemLink)
self.item = Item:CreateFromItemLink(itemLink)

-- parse stats
local extractedStats = GetItemStats(itemLink)
local extractedStats = C_Item.GetItemStats(itemLink)

if not extractedStats then
print("Could not extract item stats: " .. tostring(itemLink))
Expand Down
3 changes: 2 additions & 1 deletion Classes/RecipeData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function CraftSim.RecipeData:new(recipeID, isRecraft, isWorkOrder, crafterData)
---@type string?
self.allocationItemGUID = nil
self.maxQuality = self.recipeInfo.maxQuality
--self.isGear = self.recipeInfo.hasSingleItemOutput and self.recipeInfo.qualityIlvlBonuses ~= nil

self.supportsMulticraft = false
self.supportsResourcefulness = false
Expand Down Expand Up @@ -481,6 +480,7 @@ end
function CraftSim.RecipeData:Copy()
---@type CraftSim.RecipeData
local copy = CraftSim.RecipeData(self.recipeID, self.isRecraft, self.orderData ~= nil, self.crafterData)
copy.concentrating = self.concentrating
copy.reagentData = self.reagentData:Copy(copy)
copy.professionGearSet = self.professionGearSet:Copy()
copy.professionStats = self.professionStats:Copy()
Expand Down Expand Up @@ -611,6 +611,7 @@ function CraftSim.RecipeData:GetJSON(indent)
jb:Add("recipeID", self.recipeID)
jb:Add("categoryID", self.categoryID)
jb:Add("subtypeID", self.subtypeID)
jb:Add("concentrating", self.concentrating)
jb:Add("learned", self.learned)
jb:Add("numSkillUps", self.numSkillUps)
jb:Add("recipeIcon", self.recipeIcon)
Expand Down
6 changes: 2 additions & 4 deletions Init/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ function CraftSim.INIT:PLAYER_LOGIN()
end

function CraftSim.INIT:HideAllModules(keepControlPanel)
local craftResultsFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CRAFT_RESULTS)
local customerHistoryFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CUSTOMER_HISTORY)
local priceOverrideFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.PRICE_OVERRIDE)
local priceOverrideFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES,
Expand All @@ -431,7 +430,7 @@ function CraftSim.INIT:HideAllModules(keepControlPanel)
CraftSim.CRAFT_BUFFS.frame:Hide()
CraftSim.CRAFT_BUFFS.frameWO:Hide()
CraftSim.COOLDOWNS.frame:Hide()
craftResultsFrame:Hide()
CraftSim.CRAFT_RESULTS.frame:Hide()
customerHistoryFrame:Hide()
priceOverrideFrame:Hide()
priceOverrideFrameWO:Hide()
Expand Down Expand Up @@ -459,7 +458,6 @@ function CraftSim.INIT:TriggerModulesByRecipeType()
return
end

local craftResultsFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CRAFT_RESULTS)
local customerHistoryFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CUSTOMER_HISTORY)
local priceOverrideFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.PRICE_OVERRIDE)
local priceOverrideFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES,
Expand Down Expand Up @@ -595,7 +593,7 @@ function CraftSim.INIT:TriggerModulesByRecipeType()
CraftSim.FRAME:ToggleFrame(CraftSim.RECIPE_SCAN.frame, showRecipeScan)
CraftSim.FRAME:ToggleFrame(CraftSim.CRAFTQ.frame, showCraftQueue)
CraftSim.FRAME:ToggleFrame(CraftSim.EXPLANATIONS.frame, showExplanations)
CraftSim.FRAME:ToggleFrame(craftResultsFrame, showCraftResults)
CraftSim.FRAME:ToggleFrame(CraftSim.CRAFT_RESULTS.frame, showCraftResults)
CraftSim.FRAME:ToggleFrame(customerHistoryFrame, showCustomerHistory)
CraftSim.FRAME:ToggleFrame(cooldownsFrame, showCooldowns)

Expand Down
29 changes: 23 additions & 6 deletions Modules/CraftResults/CraftResults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ CraftSim.CRAFT_RESULTS.currentRecipeData = nil

CraftSim.CRAFT_RESULTS.currentSessionData = nil

---@type CraftSim.CRAFT_RESULTS.FRAME
CraftSim.CRAFT_RESULTS.frame = nil

local dataCollect = true

---@param recipeData CraftSim.RecipeData
Expand Down Expand Up @@ -96,7 +99,9 @@ end
---Saves the currentCraftResult
---@param craftResult CraftSim.CraftResult
function CraftSim.CRAFT_RESULTS:AddCraftResult(craftResult)
local craftResultFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CRAFT_RESULTS)
local craftResultFrame = CraftSim.CRAFT_RESULTS.frame
local craftProfitsTabContent = craftResultFrame.content.craftProfitsTab
.content --[[@as CraftSim.CRAFT_RESULTS.CRAFT_PROFITS_TAB.CONTENT]]

print("AddCraftResult:", false, true)
---@type CraftSim.CraftSessionData
Expand All @@ -111,7 +116,7 @@ function CraftSim.CRAFT_RESULTS:AddCraftResult(craftResult)
CraftSim.CRAFT_RESULTS.currentSessionData:AddCraftResult(craftResult)

-- update frames
craftResultFrame.content.totalProfitAllValue:SetText(GUTIL:FormatMoney(
craftProfitsTabContent.totalProfitAllValue:SetText(GUTIL:FormatMoney(
CraftSim.CRAFT_RESULTS.currentSessionData.totalProfit, true))

CraftSim.CRAFT_RESULTS.FRAMES:UpdateItemList()
Expand All @@ -122,7 +127,9 @@ end
---@param craftResult CraftSim.CraftResult
function CraftSim.CRAFT_RESULTS:AddResult(recipeData, craftResult)
CraftSim.DEBUG:StartProfiling("PROCESS_CRAFT_RESULTS_UI_UPDATE")
local craftResultFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CRAFT_RESULTS)
local craftResultFrame = CraftSim.CRAFT_RESULTS.frame
local craftProfitsTabContent = craftResultFrame.content.craftProfitsTab
.content --[[@as CraftSim.CRAFT_RESULTS.CRAFT_PROFITS_TAB.CONTENT]]

local resourcesText = ""

Expand Down Expand Up @@ -170,7 +177,7 @@ function CraftSim.CRAFT_RESULTS:AddResult(recipeData, craftResult)
((craftResult.triggeredMulticraft and (GUTIL:ColorizeText(CraftSim.LOCAL:GetText(CraftSim.CONST.TEXT.CRAFT_RESULTS_LOG_3), GUTIL.COLORS.EPIC) .. multicraftExtraItemsText)) or "") ..
((craftResult.triggeredResourcefulness and (GUTIL:ColorizeText(CraftSim.LOCAL:GetText(CraftSim.CONST.TEXT.CRAFT_RESULTS_LOG_4) .. "\n", GUTIL.COLORS.UNCOMMON) .. resourcesText .. "\n")) or "")

craftResultFrame.content.scrollingMessageFrame:AddMessage("\n" .. newText)
craftProfitsTabContent.scrollingMessageFrame:AddMessage("\n" .. newText)

CraftSim.CRAFT_RESULTS:AddCraftResult(craftResult)
CraftSim.CRAFT_RESULTS.FRAMES:UpdateRecipeData(craftResult.recipeID)
Expand All @@ -190,11 +197,21 @@ function CraftSim.CRAFT_RESULTS:GetProfitForCraft(recipeData, craftResult)

local resultValue = 0
for _, craftResultItem in pairs(craftResult.craftResultItems) do
local itemLink = craftResultItem.item:GetItemLink()
local qualityID = GUTIL:GetQualityIDFromLink(itemLink)
local quantity = craftResultItem.quantity + craftResultItem.quantityMulticraft
resultValue = resultValue +
(CraftSim.PRICEDATA:GetMinBuyoutByItemLink(craftResultItem.item:GetItemLink()) or 0) * quantity
local priceOverrideData = CraftSim.DB.PRICE_OVERRIDE:GetResultOverride(recipeData.recipeID, qualityID)
local resultItemPrice = (priceOverrideData and priceOverrideData.price) or
CraftSim.PRICEDATA:GetMinBuyoutByItemLink(itemLink) or 0
resultValue = resultValue + resultItemPrice * quantity
print("resultitem: " .. (itemLink or 0))
print("result value: " .. GUTIL:FormatMoney(resultValue, true))
if priceOverrideData then
print("(result price overridden)")
end
end


local craftProfit = (resultValue * CraftSim.CONST.AUCTION_HOUSE_CUT) - (craftingCosts - savedCosts)

return craftProfit
Expand Down
Loading

0 comments on commit 44f34c6

Please sign in to comment.