merge with new changes

This commit is contained in:
Buurazu authored and GitHub committed 2021-12-04 20:04:27 -05:00
1 parent 213eb995eb
commit 0e3e3df9d0
1 file changed
+27 -26
+27 -26
View File
@@ -609,6 +609,26 @@ local function qualitySort(a, b)
end
end
--this combination algorithm was adopted from this Java code: https://stackoverflow.com/a/16256122
--note that it will run into duplicates, for example if you have eight pennies and a key, it can't tell the difference between
--PPPPPPPK (pennies 1-7) and PPPPPPPK (pennies 2-8) and PPPPPPPK (pennies 1-4,6-8) etc..., I don't know of a way to prevent that
local function combinations(arr, length, startPos, tempResult, randResults, newResults)
local length = length or 8
local startPos = startPos or 1
local tempResult = tempResult or {}
if (length == 0) then
local resultString = table.concat(tempResult,",")
if (randResults[resultString] == nil) then
randResults[resultString] = {table.unpack(tempResult)}
newResults[resultString] = {table.unpack(tempResult)}
end
return
end
for i = startPos, #arr-length+1 do
tempResult[8-length+1] = arr[i]
combinations(arr,length-1, i+1, tempResult, randResults, newResults)
end
end
--code from InputHelper in MCM
local HotkeyToString = {}
for key,num in pairs(Keyboard) do
@@ -674,8 +694,8 @@ function EID:handleBagOfCraftingRendering()
trackBagActivated()
detectBagContentShift()
local tableToCraftingIcons = EID.tableToCraftingIconsMerged
if EID.Config["BagOfCraftingDisplayIcons"] then tableToCraftingIcons = EID.tableToCraftingIconsFull end
local tableToCraftingIconsFunc = EID.tableToCraftingIconsMerged
if EID.Config["BagOfCraftingDisplayIcons"] then tableToCraftingIconsFunc = EID.tableToCraftingIconsFull end
local customDescObj = EID:getDescriptionObj(5, 100, 710)
customDescObj.Description = ""
@@ -740,8 +760,8 @@ function EID:handleBagOfCraftingRendering()
local curRoomIndex = Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex
local roomItems = {}
local results = {}
local roomItems = {}
local pickups = Isaac.FindByType(5, -1, -1, true, false)
if EID.bagOfCraftingCurPickupCount ~= #pickups then
@@ -804,7 +824,7 @@ function EID:handleBagOfCraftingRendering()
local bestQualityDesc = EID:getDescriptionEntry("CraftingBestQuality")
if (#EID.BagItems > 0) then EID:appendToDescription(customDescObj, bagQualityDesc .. " " .. bagQuality .. "#" .. bagResult .. "#") end
if (bestQuality > bagQuality) then EID:appendToDescription(customDescObj, bestQualityDesc .. " " .. bestQuality .. "#{{Blank}} " .. tableToCraftingIcons(self,mostValuableBag) .. "#" .. bestResult .. "#") end
if (bestQuality > bagQuality) then EID:appendToDescription(customDescObj, bestQualityDesc .. " " .. bestQuality .. "#{{Blank}} " .. tableToCraftingIconsFunc(self,mostValuableBag, true) .. "#" .. bestResult .. "#") end
EID:printDescription(customDescObj)
return true
@@ -841,27 +861,8 @@ function EID:handleBagOfCraftingRendering()
mostValuable[i] = itemQuery[i]
end
end
--this combination algorithm was adopted from this Java code: https://stackoverflow.com/a/16256122
--note that it will run into duplicates, for example if you have eight pennies and a key, it can't tell the difference between
--PPPPPPPK (pennies 1-7) and PPPPPPPK (pennies 2-8) and PPPPPPPK (pennies 1-4,6-8) etc..., I don't know of a way to prevent that
local function combinations(arr, length, startPos, tempResult)
local length = length or 8
local startPos = startPos or 1
local tempResult = tempResult or {}
if (length == 0) then
local resultString = table.concat(tempResult,",")
if (randResults[resultString] == nil) then
randResults[resultString] = {table.unpack(tempResult)}
newResults[resultString] = {table.unpack(tempResult)}
end
return
end
for i = startPos, #arr-length+1 do
tempResult[8-length+1] = arr[i]
combinations(arr,length-1,i+1,tempResult)
end
end
if (#mostValuable >= 8) then combinations(mostValuable) end
if (#mostValuable >= 8) then combinations(mostValuable, nil, nil, nil, randResults, newResults) end
--do random pulls for some more recipe choices
if (not skipRandom) then
@@ -1003,7 +1004,7 @@ function EID:handleBagOfCraftingRendering()
if v[3] then customDescObj.Description = customDescObj.Description.." {{Collectible" .. v[3] .. "}} " end
end
customDescObj.Description = customDescObj.Description..tableToCraftingIcons(self,v[1])
customDescObj.Description = customDescObj.Description..tableToCraftingIconsFunc(self, v[1], true)
prevItem = v[2]
end
end