Module:BATTD costs: Difference between revisions

mNo edit summary
mNo edit summary
Line 9: Line 9:
local sGsub = string.gsub
local sGsub = string.gsub
local restrictedUpgrades = {}
local headerRow = {"{|class=\"wikitable sortable\" style=\"text-align:center\"\n!Total cost!!Sell value"}
local headerRow = {"{|class=\"wikitable sortable\" style=\"text-align:center\"\n!Total cost!!Sell value"}
Line 35: Line 34:
if upgradePrereqsById[availableUpgradeId] then
if upgradePrereqsById[availableUpgradeId] then
for _, prereqId in ipairs(upgradePrereqsById[availableUpgradeId]) do
for _, prereqId in ipairs(upgradePrereqsById[availableUpgradeId]) do
if prereqId ~= "root" and not purchasedUpgrades[prereqId] then
if prereqId ~= "root" and not purchasedUpgrades[prereqId] then return nil, nil end
return nil, nil
end
end
end
end
end
Line 46: Line 43:
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
if upgradeLocksById[purchasedUpgradeId] and upgradeLocksById[purchasedUpgradeId][availableUpgradeId] then
if upgradeLocksById[purchasedUpgradeId] then
return nil, nil
if upgradeLocksById[purchasedUpgradeId][availableUpgradeId] then
return nil, nil
else
upgradeLocksById[purchasedUpgradeId][availableUpgradeId] = true
end
else
upgradeLocksById[purchasedUpgradeId] = {[availableUpgradeId] = true}
end
end
Line 55: Line 58:
if upgradePrereqsOfById[purchasedUpgradeId] then
if upgradePrereqsOfById[purchasedUpgradeId] then
for _, nextUpgradeId in ipairs(upgradePrereqsOfById[purchasedUpgradeId]) do
for _, nextUpgradeId in ipairs(upgradePrereqsOfById[purchasedUpgradeId]) do
if accessibleUpgrades[nextUpgradeId] and not restrictedUpgrades[nextUpgradeId] and not purchasedUpgrades[nextUpgradeId] then availableUpgradesNext[nextUpgradeId] = true end
if accessibleUpgrades[nextUpgradeId] and not purchasedUpgrades[nextUpgradeId] then availableUpgradesNext[nextUpgradeId] = true end
end
end
end
end
Line 83: Line 86:
if purchasedUpgradesNext and availableUpgradesNext then
if purchasedUpgradesNext and availableUpgradesNext then
purchasedUpgradesNext[availableUpgradeId] = true
purchasedUpgradesNext[availableUpgradeId] = true
restrictedUpgrades[availableUpgradeId] = true
--if #outputTable == 20 then return end
--if #outputTable == 20 then return end