Module:BATTD costs: Difference between revisions

From Blooncyclopedia, the independent Bloons knowledge base
Jump to navigation Jump to search
yes i know this is broken i will fix it l8r
mNo edit summary
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


-- LOCAL FUNCTIONS
-- helper functions


local function GetTotalCosts(baseCost, accessibleUpgrades, upgradesById, upgradeLocksById, upgradePrereqsOfById, Y, N)
local function GetTotalCosts(baseCost, initialPurchasedUpgrades, accessibleUpgrades, startingUpgrade,
upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, Y, N)
local sFormat = string.format
local sFormat = string.format
local tConcat = table.concat
local tConcat = table.concat
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"}
for i, upgrade in ipairs(upgrades) do
for upgradeId, _ in pairs(accessibleUpgrades) do
headerRow[i+1] = sFormat("!![[%s|%s]]", upgrade._pageName, upgrade.name)
headerRow[#headerRow+1] = sFormat("!![[%s|%s]]", upgradesById[upgradeId]._pageName, upgradesById[upgradeId].name)
end
end
Line 29: Line 31:
end
end
local function RecursiveGetTotalCosts(currentCost, purchasedUpgrades, availableUpgrades)
local function RecursiveGetTotalCosts(currentCost, purchasedUpgrades, myUpgradeId)
row = {sFormat("\n|-\n|$%s||$%s", FormatNum(currentCost), FormatNum(currentCost*0.7))}
-- skip this upgrade if we don't have all the prereqs
for _, prereqId in ipairs(upgradePrereqsById[myUpgradeId]) do
if not purchasedUpgrades[prereqId] then return false end
end
-- skip this upgrade if it's locked by an already purchased upgrade
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
if upgradeLocksById[purchasedUpgradeId][myUpgradeId] then return false end
end
mw.logObject(purchasedUpgrades)
--upgradeLocksById[startingUpgrade][myUpgradeId] = true
mw.logObject(availableUpgrades)
for i, upgrade in ipairs(upgrades) do
-- shallow copy purchasedUpgrades but with this upgrade included in it now
row[i+1] = sFormat("||%s", purchasedUpgrades[upgrade.id] and Y or N)
local purchasedUpgradesNext = { [myUpgradeId] = true }
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
purchasedUpgradesNext[purchasedUpgradeId] = true
end
-- add row to output
row = {sFormat("|-\n|$%s||$%s", FormatNum(currentCost), FormatNum(currentCost*0.7))}
for accessibleUpgradeId, _ in pairs(accessibleUpgrades) do
row[#row+1] = sFormat("||%s", purchasedUpgradesNext[accessibleUpgradeId] and Y or N)
end
end
outputTable[#outputTable+1] = tConcat(row, "")
outputTable[#outputTable+1] = tConcat(row, "")
for availableUpgradeId, availableUpgrade in pairs(availableUpgrades) do
-- depth first
-- shallow copy purchasedUpgrades and availableUpgrades
for _, prereqOfId in ipairs(upgradePrereqsOfById[myUpgradeId]) do
local purchasedUpgradesNext = {}
RecursiveGetTotalCosts(currentCost + upgradesById[prereqOfId].cost, purchasedUpgradesNext, prereqOfId)
local availableUpgradesNext = {}
end
local doNext = true
-- breadth next
for purchasedUpgradeId, purchasedUpgrade in pairs(purchasedUpgrades) do
for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
if upgradeLocksById[availableUpgradeId] and upgradeLocksById[purchasedUpgradeId][purchasedUpgradeId] then
for _, prereqOfId in ipairs(upgradePrereqsOfById[purchasedUpgradeId]) do
doNext = false
--RecursiveGetTotalCosts(currentCost + upgradesById[prereqOfId].cost, purchasedUpgradesNext, prereqOfId)
break
end
purchasedUpgradesNext[purchasedUpgradeId] = purchasedUpgrade
for _, nextUpgrade in ipairs(upgradePrereqsOfById[purchasedUpgradeId]) do
if not upgradeLocksById[purchasedUpgradeId] and upgradeLocksById[purchasedUpgradeId][availableUpgradeId] then
availableUpgradesNext[nextUpgrade.id] = nextUpgrade
end
end
end
if doNext then
purchasedUpgradesNext[availableUpgradeId] = availableUpgrade
RecursiveGetTotalCosts(currentCost + availableUpgrade.cost, purchasedUpgradesNext, availableUpgradesNext)
end
end
end
end
return true
end
end
RecursiveGetTotalCosts(baseCost, {}, upgradePrereqsOfById.root)
outputTable[#outputTable+1] = "\n|}"
RecursiveGetTotalCosts(baseCost, initialPurchasedUpgrades, startingUpgrade)
return tConcat(outputTable, "")
outputTable[#outputTable+1] = "|}"
end
local a = [[-- add this combination's row to outputTable
return tConcat(outputTable, "\n")
row = {sFormat("\n|-\n|$%s||$%s", lang:formatNum(currentCost), lang:formatNum(currentCost*0.7))}
for i, upgrade in ipairs(upgrades) do
if not alreadyPurchasedUpgrades[upgrade.id] and not upgradeLocksById[upgradeId][upgrade.id] then
row[#row+1] = sFormat("||%s", purchasedUpgrades[upgrade.id] and Y or N)
end
end
end
outputTable[#outputTable+1] = tConcat(row, "\n")


for thisUpgradeId, _ in pairs(purchasedUpgrades) do
local function SetUpTables(towerName)
-- skip if this upgrade is a leaf
if upgradePrereqsOfById[thisUpgradeId] then
for _, nextUpgradeId in pairs(upgradePrereqsOfById[thisUpgradeId]) do
if not purchasedUpgrades[nextUpgradeId] then
-- shallow copy purchasedUpgrades and check if nextUpgradeId is locked by another upgrade
local purchasedUpgradesNext = {}
local doNext = true
for purchasedUpgrade, _ in pairs(purchasedUpgrades) do
-- if nextUpgradeId is locked by a purchasedUpgrade then don't proceed
if upgradeLocksById[purchasedUpgrade] and upgradeLocksById[purchasedUpgrade][nextUpgradeId] then
doNext = false
break
end
purchasedUpgradesNext[purchasedUpgrade] = true
end
if doNext then
purchasedUpgradesNext[nextUpgradeId] = true
recursiveGetTotalCosts(currentCost + upgradesById[nextUpgradeId].cost, purchasedUpgradesNext)
-- lock this combination so it isn't repeated on the graph again
if not upgradeLocksById[thisUpgradeId] then upgradeLocksById[thisUpgradeId] = {} end
upgradeLocksById[thisUpgradeId][nextUpgradeId] = true
if not upgradeLocksById[nextUpgradeId] then upgradeLocksById[nextUpgradeId] = {} end
upgradeLocksById[nextUpgradeId][thisUpgradeId] = true
end
end
end
end
end]]
 
local function upgrade(towerName, upgradeName, Y, N)
local sFormat = string.format
local sFormat = string.format
local query = mw.ext.cargo.query
local query = mw.ext.cargo.query
local lang = mw.language.new("en")
local outputTable = {}
local upgradesById = { root = {} } -- key:value table  - upgrade:upgrade data
local upgradeId = ""
local upgradeLocksById = { root = {} } -- key:values table - upgrades:upgrades that this upgrade locks
local upgradePrereqsById = { root = {} } -- key:values table - upgrade:prerequisites to purchase this upgrade
local upgradePrereqsOfById = { root = {} } -- key:values table - upgrades:upgrades this is a prerequisite of
local upgradesById = {} -- key:value table  - upgrade:upgrade data
-- tower cost + total cost of this upgrade and all its prereqs
local upgradeLocksById = {} -- key:values table - upgrades:upgrades that this upgrade locks
local baseCost = tonumber(query("battd_characters", "cost", {
local upgradePrereqsById = {} -- key:values table - upgrade:prerequisites to purchase this upgrade
where=sFormat("name='%s'", towerName)
local upgradePrereqsOfById = { -- key:values table - upgrades:upgrades this is a prerequisite of
})[1].cost)
root = {}
}
local purchasedUpgrades = {}
local accessibleUpgrades = {} -- list of upgrades that we can get from this upgrade
-- cargo queries for data
-- cargo queries for data
Line 141: Line 103:
}),
}),
query("battd_upgrades=main, battd_upgrades__previous=prev", "main.id=thisId, prev._value=prevId", {
query("battd_upgrades=main, battd_upgrades__previous=prev", "main.id=thisId, prev._value=prevId", {
where=sFormat("main.tower='%s'", towerName),
where=sFormat("main.tower='%s' AND NOT unused", towerName),
join="main._ID=prev._RowID"
join="main._ID=prev._RowID"
}),
}),
query("battd_upgrades=main, battd_upgrades__locked_by_upgrades=lock", "main.id=thisId, lock._value=lockId", {
query("battd_upgrades=main, battd_upgrades__locked_by_upgrades=lock", "main.id=thisId, lock._value=lockId", {
where=sFormat("main.tower='%s'", towerName),
where=sFormat("main.tower='%s' AND NOT unused", towerName),
join="main._ID=lock._RowID"
join="main._ID=lock._RowID"
})
})
Line 152: Line 114:
for i, upgrade in ipairs(upgrades) do
for i, upgrade in ipairs(upgrades) do
upgradesById[upgrade.id] = upgrade
upgradesById[upgrade.id] = upgrade
if upgrade.name == upgradeName then upgradeId = upgrade.id end
upgradeLocksById[upgrade.id] = {}
end
end


Line 165: Line 127:
end
end
else
else
-- if this upgrade is a root upgrade and is not already purchased
-- if this upgrade has no prereqs, give it a fake upgrade called "root" as a prereq
upgradePrereqsOfById["root"][#upgradePrereqsOfById["root"]+1] = upgrade.thisId
upgradePrereqsOfById["root"][#upgradePrereqsOfById["root"]+1] = upgrade.thisId
upgradePrereqsById[upgrade.thisId] = {"root"}
end
end
Line 176: Line 139:
end
end
end
end
-- build upgradeLocksById
for _, upgrade in ipairs(upgradeLocks) do
if upgrade.lockId then
upgradeLocksById[upgrade.thisId][upgrade.lockId] = true
end
end
return upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, baseCost
end
local function Upgrade(towerName, upgradeId, Y, N)
local upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, baseCost = SetUpTables(towerName)
-- build alreadyPurchasedUpgrades
local purchasedUpgrades = {} -- this upgrade and any other upgrades that had to already be purchased to get it
local function getAlreadyPurchasedUpgrades(myUpgradeId)
local accessibleUpgrades = {} -- list of upgrades that are possible to reach from this upgrade by some route
local cost = upgradesById[myUpgradeId].cost
purchasedUpgrades[myUpgradeId] = true
-- build purchasedUpgrades recursively
local function GetPurchasedUpgrades(myUpgradeId)
if not purchasedUpgrades[myUpgradeId] then baseCost = baseCost + upgradesById[myUpgradeId].cost end
for i, id in ipairs(upgradePrereqsById[myUpgradeId]) do
for _, prereqId in ipairs(upgradePrereqsById[myUpgradeId]) do
cost = cost + getAlreadyPurchasedUpgrades(id)
if prereqId ~= "root" then GetPurchasedUpgrades(prereqId) end
purchasedUpgrades[prereqId] = true
end
end
return cost
end
end
local function getAccessibleUpgrades(myUpgradeId)
GetPurchasedUpgrades(upgradeId)
-- generate a list of upgrades that are reachable from this upgrade, but do not have this upgrade as a prerequisite
-- also generate a list of upgrades that are immediately reachable from this upgrade
local function DetermineAccessibility(myUpgradeId)
if myUpgradeId == upgradeId then return end
for _, upgrade in ipairs(upgradePrereqsOfById[myUpgradeId]) do
-- if this upgrade is locked by an already purchased upgrade, then it is inaccessible
accessibleUpgrades[#accessibleUpgrades+1] = upgrade
for _, upgradeLock in ipairs(upgradeLocksById[myUpgradeId]) do
if purchasedUpgrades[upgradeLock] then return end
if upgradePrereqsOfById[upgrade] then
end
if upgradeLocksById[upgrade] then
for _, upgradeLock in ipairs(upgradeLocksById[upgrade]) do
-- find upgrades that are reachable from the current upgrades owned
if purchasedUpgrades[upgradeLock] then return end
for _, prereqId in ipairs(upgradePrereqsById[myUpgradeId]) do
end
-- upgrades with multiple prereqs are only accessible if we can reach all its prereqs
end
-- if it is accessible, it'll be reached again on another recursion
getAccessibleUpgrades(upgrade)
if not (accessibleUpgrades[prereqId] or purchasedUpgrades[prereqId] or prereqId == "root") or prereqId == upgradeId then return end
end
if not purchasedUpgrades[myUpgradeId] then accessibleUpgrades[myUpgradeId] = true end
-- determine accessibility of next upgrades
if upgradePrereqsOfById[myUpgradeId] then
for _, prereqOfId in ipairs(upgradePrereqsOfById[myUpgradeId]) do
DetermineAccessibility(prereqOfId)
end
end
end
end
end
end
getAccessibleUpgrades("root")


-- build upgradeLocksById
-- start with the root
for i, upgrade in ipairs(upgradeLocks) do
for _, prereqOfId in ipairs(upgradePrereqsOfById.root) do
if upgrade.lockId then
DetermineAccessibility(prereqOfId)
if upgradeLocksById[upgrade.thisId] then
upgradeLocksById[upgrade.thisId][upgrade.lockId] = true
else
upgradeLocksById[upgrade.thisId] = {[upgrade.lockId] = true}
end
end
end
end
-- tower cost + total cost of this upgrade and all its prereqs
return GetTotalCosts(baseCost, purchasedUpgrades, accessibleUpgrades, upgradeId,
local baseCost = getAlreadyPurchasedUpgrades(upgradeId) + query("battd_characters", "cost", {
upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, Y, N)
where=sFormat("name='%s'", towerName)
})[1].cost
return GetTotalCosts(baseCost, availableUpgrades, upgradesById, upgradeLocksById, upgradePrereqsOfById, Y, N)
end
end


-- GLOBAL FUNCTIONS
-- GLOBAL FUNCTIONS


function p.tower(frame)
p["tower"] = function(frame)
return ""
local upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, baseCost = SetUpTables(frame.args[1])
end
end


function p.upgrade(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], 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

Latest revision as of 21:59, 6 July 2026

Documentation for this module may be created at Module:BATTD costs/doc

local p = {}

-- helper functions

local function GetTotalCosts(baseCost, initialPurchasedUpgrades, accessibleUpgrades, startingUpgrade,
	upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, Y, N)
	local sFormat = string.format
	local tConcat = table.concat
	local sGsub = string.gsub
	
	-- create the table headers
	local headerRow = {"{|class=\"wikitable sortable\" style=\"text-align:center\"\n!Total cost!!Sell value"}
	
	for upgradeId, _ in pairs(accessibleUpgrades) do
		headerRow[#headerRow+1] = sFormat("!![[%s|%s]]", upgradesById[upgradeId]._pageName, upgradesById[upgradeId].name)
	end
	
	local outputTable = {tConcat(headerRow, "")}
	
	-- english-only alternative to FormatNum that takes up less time
	local function FormatNum(num)
	    local formatted = tostring(num)
	    
	    -- skip if less than 1000
	    local k = (num > 999 and 1 or 0)
	    while k ~= 0 do
	        formatted, k = sGsub(formatted, "^(-?%d+)(%d%d%d)", "%1,%2")
	    end
	    
	    return formatted
	end
	
	local function RecursiveGetTotalCosts(currentCost, purchasedUpgrades, myUpgradeId)
		-- skip this upgrade if we don't have all the prereqs
		for _, prereqId in ipairs(upgradePrereqsById[myUpgradeId]) do
			if not purchasedUpgrades[prereqId] then return false end
		end
		
		-- skip this upgrade if it's locked by an already purchased upgrade
		for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
			if upgradeLocksById[purchasedUpgradeId][myUpgradeId] then return false end
		end
		
		--upgradeLocksById[startingUpgrade][myUpgradeId] = true
		
		-- shallow copy purchasedUpgrades but with this upgrade included in it now
		local purchasedUpgradesNext = { [myUpgradeId] = true }
		
		for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
			purchasedUpgradesNext[purchasedUpgradeId] = true
		end
		
		-- add row to output
		row = {sFormat("|-\n|$%s||$%s", FormatNum(currentCost), FormatNum(currentCost*0.7))}
		
		for accessibleUpgradeId, _ in pairs(accessibleUpgrades) do
			row[#row+1] = sFormat("||%s", purchasedUpgradesNext[accessibleUpgradeId] and Y or N)
		end
		
		outputTable[#outputTable+1] = tConcat(row, "")
		
		-- depth first
		for _, prereqOfId in ipairs(upgradePrereqsOfById[myUpgradeId]) do
			RecursiveGetTotalCosts(currentCost + upgradesById[prereqOfId].cost, purchasedUpgradesNext, prereqOfId)
		end
		
		-- breadth next
		for purchasedUpgradeId, _ in pairs(purchasedUpgrades) do
			for _, prereqOfId in ipairs(upgradePrereqsOfById[purchasedUpgradeId]) do
				--RecursiveGetTotalCosts(currentCost + upgradesById[prereqOfId].cost, purchasedUpgradesNext, prereqOfId)
			end
		end
		
		return true
	end
	
	RecursiveGetTotalCosts(baseCost, initialPurchasedUpgrades, startingUpgrade)
	
	outputTable[#outputTable+1] = "|}"
	
	return tConcat(outputTable, "\n")
end

local function SetUpTables(towerName)
	local sFormat = string.format
	local query = mw.ext.cargo.query
	
	local upgradesById			= { root = {} }		-- key:value table  - upgrade:upgrade data
	local upgradeLocksById		= { root = {} }		-- key:values table - upgrades:upgrades that this upgrade locks
	local upgradePrereqsById	= { root = {} }		-- key:values table - upgrade:prerequisites to purchase this upgrade
	local upgradePrereqsOfById	= { root = {} }		-- key:values table - upgrades:upgrades this is a prerequisite of
	
	-- tower cost + total cost of this upgrade and all its prereqs
	local baseCost = tonumber(query("battd_characters", "cost", {
		where=sFormat("name='%s'", towerName)
	})[1].cost)
	
	-- cargo queries for data
	local upgrades, upgradePrereqs, upgradeLocks =
	query("battd_upgrades", "_pageName, id, name, tower, cost", {
		where=sFormat("tower='%s'", towerName),
		orderBy="cost"
	}),
	query("battd_upgrades=main, battd_upgrades__previous=prev", "main.id=thisId, prev._value=prevId", {
		where=sFormat("main.tower='%s' AND NOT unused", towerName),
		join="main._ID=prev._RowID"
	}),
	query("battd_upgrades=main, battd_upgrades__locked_by_upgrades=lock", "main.id=thisId, lock._value=lockId", {
		where=sFormat("main.tower='%s' AND NOT unused", towerName),
		join="main._ID=lock._RowID"
	})

	-- build upgradesById
	for i, upgrade in ipairs(upgrades) do
		upgradesById[upgrade.id] = upgrade
		upgradeLocksById[upgrade.id] = {}
	end

	-- build upgradePrereqsById, upgradePrereqsOfById
	for i, upgrade in ipairs(upgradePrereqs) do
		-- upgrade:next table
		if upgrade.prevId then
			if upgradePrereqsOfById[upgrade.prevId] then
				upgradePrereqsOfById[upgrade.prevId][#upgradePrereqsOfById[upgrade.prevId]+1] = upgrade.thisId
			else
				upgradePrereqsOfById[upgrade.prevId] = {upgrade.thisId}
			end
		else
			-- if this upgrade has no prereqs, give it a fake upgrade called "root" as a prereq
			upgradePrereqsOfById["root"][#upgradePrereqsOfById["root"]+1] = upgrade.thisId
			upgradePrereqsById[upgrade.thisId] = {"root"}
		end
		
		-- upgrade:prev table
		if upgradePrereqsById[upgrade.thisId] then
			upgradePrereqsById[upgrade.thisId][#upgradePrereqsById[upgrade.thisId]+1] = upgrade.prevId
		else
			upgradePrereqsById[upgrade.thisId] = {upgrade.prevId}
		end
	end

	-- build upgradeLocksById
	for _, upgrade in ipairs(upgradeLocks) do
		if upgrade.lockId then
			upgradeLocksById[upgrade.thisId][upgrade.lockId] = true
		end
	end

	return upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, baseCost
end

local function Upgrade(towerName, upgradeId, Y, N)
	local upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, baseCost = SetUpTables(towerName)
	
	local purchasedUpgrades = {}		-- this upgrade and any other upgrades that had to already be purchased to get it
	local accessibleUpgrades = {}		-- list of upgrades that are possible to reach from this upgrade by some route
	
	-- build purchasedUpgrades recursively
	local function GetPurchasedUpgrades(myUpgradeId)
		if not purchasedUpgrades[myUpgradeId] then baseCost = baseCost + upgradesById[myUpgradeId].cost end
		
		for _, prereqId in ipairs(upgradePrereqsById[myUpgradeId]) do
			if prereqId ~= "root" then GetPurchasedUpgrades(prereqId) end
			purchasedUpgrades[prereqId] = true
		end
	end
	
	GetPurchasedUpgrades(upgradeId)
	
	-- generate a list of upgrades that are reachable from this upgrade, but do not have this upgrade as a prerequisite
	-- also generate a list of upgrades that are immediately reachable from this upgrade
	local function DetermineAccessibility(myUpgradeId)
		if myUpgradeId == upgradeId then return end
		
		-- if this upgrade is locked by an already purchased upgrade, then it is inaccessible
		for _, upgradeLock in ipairs(upgradeLocksById[myUpgradeId]) do
			if purchasedUpgrades[upgradeLock] then return end
		end
		
		-- find upgrades that are reachable from the current upgrades owned
		for _, prereqId in ipairs(upgradePrereqsById[myUpgradeId]) do
			-- upgrades with multiple prereqs are only accessible if we can reach all its prereqs
			-- if it is accessible, it'll be reached again on another recursion
			if not (accessibleUpgrades[prereqId] or purchasedUpgrades[prereqId] or prereqId == "root") or prereqId == upgradeId then return end
		end
		
		if not purchasedUpgrades[myUpgradeId] then accessibleUpgrades[myUpgradeId] = true end
		
		-- determine accessibility of next upgrades
		if upgradePrereqsOfById[myUpgradeId] then 
			for _, prereqOfId in ipairs(upgradePrereqsOfById[myUpgradeId]) do
				DetermineAccessibility(prereqOfId)
			end
		end
	end

	-- start with the root
	for _, prereqOfId in ipairs(upgradePrereqsOfById.root) do
		DetermineAccessibility(prereqOfId)
	end
	
	return GetTotalCosts(baseCost, purchasedUpgrades, accessibleUpgrades, upgradeId,
		upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, Y, N)
end

-- GLOBAL FUNCTIONS

p["tower"] = function(frame)
	local upgradesById, upgradeLocksById, upgradePrereqsById, upgradePrereqsOfById, baseCost = SetUpTables(frame.args[1])
end

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")
end

return p