Module:Sandbox/GauTest/Township: Difference between revisions

no edit summary
(Pull out functions from GetBuildingTable into helper functions)
No edit summary
Line 349: Line 349:
local upgradesFrom = p._GetBuildingDowngrade(building)
local upgradesFrom = p._GetBuildingDowngrade(building)
if upgradesFrom ~= nil then
if upgradesFrom ~= nil then
table.insert(ret, '<br>'..Icons.Icon({upgradesFrom.name, type='building'})..'<br>')
table.insert(ret, '<br>'..Icons.Icon({upgradesFrom.name, type='building'}))
end
end
-- Cost
-- Cost
local cost = p._GetBuildingBaseCost(building)
local cost = p._GetBuildingBaseCost(building)
table.insert(ret, cost)
table.insert(ret, '<br>'..cost)
-- Upgrades To
-- Upgrades To
Line 488: Line 488:
local join = _join ~= nil and _join or ', '
local join = _join ~= nil and _join or ', '
local cost = {}
local cost = {}
for _, resource in ipairs(upgradesTo.cost) do
for _, resource in ipairs(building.cost) do
local resource_data = p._GetResourceByID(resource.id)
local resource_data = p._GetResourceByID(resource.id)
table.insert(upgrade_cost, Icons.Icon({resource_data.name, type='resource', notext=true})..'&nbsp;'..resource.quantity)
table.insert(cost, Icons.Icon({resource_data.name, type='resource', notext=true})..'&nbsp;'..resource.quantity)
end
end
table.insert(ret, '<br>'..table.concat(upgrade_cost, join))
return table.concat(cost, join)
end
end


572

edits