Skip to content

Commit

Permalink
top gear use concentration value as compare point when concentrating
Browse files Browse the repository at this point in the history
  • Loading branch information
derfloh205 committed Oct 11, 2024
1 parent 5c8c9b9 commit 9845d81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Classes/TopGearResult.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ CraftSim.TopGearResult = CraftSim.CraftSimObject:extend()
---@param relativeStats CraftSim.ProfessionStats
---@param expectedQuality number
---@param expectedQualityUpgrade number
function CraftSim.TopGearResult:new(professionGearSet, averageProfit, relativeProfit, relativeStats, expectedQuality,
function CraftSim.TopGearResult:new(professionGearSet, averageProfit, relativeProfit, concentrationValue,
relativeConcentrationValue, relativeStats, expectedQuality,
expectedQualityUpgrade)
self.relativeStats = relativeStats
self.professionGearSet = professionGearSet
self.averageProfit = averageProfit
self.relativeProfit = relativeProfit
self.concentrationValue = concentrationValue
self.relativeConcentrationValue = relativeConcentrationValue
self.expectedQuality = expectedQuality
self.expectedQualityUpgrade = expectedQualityUpgrade
end
Expand Down
14 changes: 12 additions & 2 deletions Modules/TopGear/TopGear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,32 @@ function CraftSim.TOPGEAR:GetProfessionGearCombinations(recipeData)
end
end

---@param recipeData CraftSim.RecipeData
---@param topGearMode string
---@return CraftSim.TopGearResult[] topGearResults
function CraftSim.TOPGEAR:OptimizeTopGear(recipeData, topGearMode)
topGearMode = topGearMode or CraftSim.TOPGEAR:GetSimMode(CraftSim.TOPGEAR.SIM_MODES.PROFIT)
local combinations = CraftSim.TOPGEAR:GetProfessionGearCombinations(recipeData)

local previousGear = recipeData.professionGearSet
local averageProfitPreviousGear = CraftSim.CALC:GetAverageProfit(recipeData)
local concentrationValuePreviousGear = recipeData:GetConcentrationValue()

-- convert to top gear results
---@type CraftSim.TopGearResult[]
local results = GUTIL:Map(combinations, function(professionGearSet)
recipeData.professionGearSet = professionGearSet
recipeData:Update()
local averageProfit = CraftSim.CALC:GetAverageProfit(recipeData)
local concentrationValue = recipeData:GetConcentrationValue()
local relativeProfit = averageProfit - averageProfitPreviousGear
local relativeConcentrationValue = concentrationValue - concentrationValuePreviousGear
local relativeStats = professionGearSet.professionStats:Copy()
local expectedQuality = recipeData.resultData.expectedQuality
local expectedQualityUpgrade = recipeData.resultData.expectedQualityUpgrade
relativeStats:subtract(previousGear.professionStats)
local result = CraftSim.TopGearResult(professionGearSet, averageProfit, relativeProfit, relativeStats,
local result = CraftSim.TopGearResult(professionGearSet, averageProfit, relativeProfit, concentrationValue,
relativeConcentrationValue, relativeStats,
expectedQuality, expectedQualityUpgrade)
return result
end)
Expand All @@ -373,7 +379,11 @@ function CraftSim.TOPGEAR:OptimizeTopGear(recipeData, topGearMode)
return result.relativeProfit >= 1
end)
results = GUTIL:Sort(results, function(resultA, resultB)
return resultA.averageProfit > resultB.averageProfit
if recipeData.concentrating and recipeData.supportsQualities then
return resultA.concentrationValue > resultB.concentrationValue
else
return resultA.averageProfit > resultB.averageProfit
end
end)
elseif topGearMode == CraftSim.TOPGEAR:GetSimMode(CraftSim.TOPGEAR.SIM_MODES.MULTICRAFT) then
print("Top Gear Mode: Multicraft")
Expand Down

0 comments on commit 9845d81

Please sign in to comment.