Skip to content

[CodeCleanup] Replace individual optimization calls with recipeData:Optimize#1104

Merged
derfloh205 merged 4 commits intomainfrom
copilot/refactor-recipe-optimization-calls
Mar 23, 2026
Merged

[CodeCleanup] Replace individual optimization calls with recipeData:Optimize#1104
derfloh205 merged 4 commits intomainfrom
copilot/refactor-recipe-optimization-calls

Conversation

Copy link
Contributor

Copilot AI commented Mar 21, 2026

RecipeData:Optimize is the canonical async method for orchestrating recipe optimization steps, but several call sites were still manually chaining OptimizeGear/OptimizeReagents/OptimizeConcentration/OptimizeFinishingReagents with nested callbacks and conditional branching.

Changes

  • CraftQueue:QueueOpenRecipe — replaced conditional chain of OptimizeGearOptimizeReagentsOptimizeConcentration (with split if/else for async concentration path) with a single recipeData:Optimize call; button is now consistently disabled for the full duration of optimization
  • CraftQueue/UI.lua optimizeProfitButton — resolved the existing TODO: Refactor using RecipeData:Optimize; replaced OptimizeGear + RunNextFrame(OptimizeReagents → OptimizeConcentration → OptimizeFinishingReagents) nested callback pyramid with a single recipeData:Optimize call
  • Work order reagent optimization — replaced two RunNextFrame(OptimizeReagents + queueRecipe) branches (patron vs. normal order) with a single recipeData:Optimize { optimizeReagentOptions = ..., finally = queueRecipe }

Before (UI optimize button):

if optimizeProfessionGear then
    recipeData:OptimizeGear(...)
end
RunNextFrame(function()
    recipeData:OptimizeReagents { highestProfit = ... }
    if recipeData.supportsQualities and optimizeConcentration then
        optimizeButton:SetEnabled(false)
        recipeData:OptimizeConcentration {
            finally = function()
                if optimizeFinishingReagents then
                    recipeData:OptimizeFinishingReagents { ... finally = finalizeOptimize }
                else finalizeOptimize() end
            end, ...
        }
    else
        if optimizeFinishingReagents then
            optimizeButton:SetEnabled(false)
            recipeData:OptimizeFinishingReagents { ... finally = finalizeOptimize }
        else finalizeOptimize() end
    end
end)

After:

optimizeButton:SetEnabled(false)
recipeData:Optimize {
    optimizeGear = optimizeProfessionGear,
    optimizeReagentOptions = { highestProfit = optimizeTopProfit },
    optimizeConcentration = optimizeConcentration,
    optimizeConcentrationProgressCallback = function(p) optimizeButton:SetText(...) end,
    optimizeFinishingReagentsOptions = optimizeFinishingReagents and { ... } or nil,
    finally = function() finalizeOptimize() end,
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[CodeCleanup] Optimize calls replacement</issue_title>
<issue_description>RecipeData.Optimize is now the best way to call for recipe optimizations

check where recipedata is optimized in the code and if not already using it, refactor the specific optimization calls to use the recipeData.Optimize async method with the correct optimization options configurations</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ize in CraftQueue

Co-authored-by: derfloh205 <9341090+derfloh205@users.noreply.github.com>
Agent-Logs-Url: https://github.com/derfloh205/CraftSim/sessions/be3bf98d-e82a-4e0d-a2fa-04d111a8b47b
Copilot AI changed the title [WIP] Refactor optimization calls to use RecipeData.Optimize [CodeCleanup] Replace individual optimization calls with recipeData:Optimize Mar 21, 2026
Copilot AI requested a review from derfloh205 March 21, 2026 12:58
@derfloh205 derfloh205 marked this pull request as ready for review March 23, 2026 12:39
@derfloh205 derfloh205 merged commit 3bd287e into main Mar 23, 2026
@derfloh205 derfloh205 deleted the copilot/refactor-recipe-optimization-calls branch March 23, 2026 12:40
@github-project-automation github-project-automation bot moved this from Backlog to Done in CraftSim Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[CodeCleanup] Optimize calls replacement

2 participants