Module:BATTD costs: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 9: | Line 9: | ||
local sGsub = string.gsub | local sGsub = string.gsub | ||
-- create the table headers | |||
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 32: | Line 33: | ||
local function GetPurchasedAndAvailableUpgrades(purchasedUpgrades, availableUpgradeId) | local function GetPurchasedAndAvailableUpgrades(purchasedUpgrades, availableUpgradeId) | ||
-- skip this upgrade if we don't have all the prereqs | -- skip this upgrade if we don't have all the prereqs | ||
if | if prereqId ~= "root" then | ||
for _, prereqId in ipairs(upgradePrereqsById[availableUpgradeId]) do | for _, prereqId in ipairs(upgradePrereqsById[availableUpgradeId]) do | ||
if | if not purchasedUpgrades[prereqId] then return nil, nil end | ||
end | |||
end | |||
-- skip this upgrade if it is locked by an already purchased upgrade | |||
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do | |||
if upgradeLocksById[purchasedUpgradeId] and upgradeLocksById[purchasedUpgradeId][availableUpgradeId] then | |||
return nil, nil | |||
end | end | ||
end | end | ||
| Line 44: | Line 52: | ||
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do | for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do | ||
if upgradeLocksById[purchasedUpgradeId] then | if upgradeLocksById[purchasedUpgradeId] then | ||
upgradeLocksById[purchasedUpgradeId][availableUpgradeId] = true | |||
else | else | ||
upgradeLocksById[purchasedUpgradeId] = {[availableUpgradeId] = true} | upgradeLocksById[purchasedUpgradeId] = {[availableUpgradeId] = true} | ||
| Line 238: | Line 242: | ||
p["upgrade"] = function(frame) | p["upgrade"] = function(frame) | ||
return Upgrade(frame.args[1], frame.args[2], frame:expandTemplate{title = "Y", args = {}}, frame:expandTemplate{title = "N", args = {}}) | |||
return Upgrade(frame.args[1], frame.args[2], "Y", "N") | --return Upgrade(frame.args[1], frame.args[2], "Y", "N") | ||
end | end | ||
return p | return p | ||