572
edits
No edit summary |
No edit summary |
||
Line 502: | Line 502: | ||
function p._GetResourceByID(id) | function p._GetResourceByID(id) | ||
return GameData.getEntityByID(p.resources, id) | return GameData.getEntityByID(p.resources, id) | ||
end | |||
-- Gets text for only the biomes that have a modifier for a building | |||
function p._GetBiomeModifiers(building) | |||
if #building.biomeModifiers == 0 then | |||
return nil | |||
end | |||
local biomeRet = {} | |||
table.insert(biomeRet, '<ul>') | |||
for _, biome in ipairs(building.biomeModifiers) do | |||
local biomename = GameData.getEntityByID(Township.biomes, biome.biomeID).name | |||
local color = biome.value < 0 and 'red' or 'green' | |||
local biome_value = Shared.numStrWithSign(biome.value) | |||
table.insert(biomeRet, '<li style="color:'..color..'">'..biomename..' ('..biome_value..'%)</li>') | |||
end | |||
table.insert(biomeRet, '</ul>') | |||
return table.concat(biomeRet) | |||
end | end | ||
Line 569: | Line 587: | ||
-- Production | -- Production | ||
local production = {} | |||
local hasProduction = false | |||
for _, building in ipairs(buildingList) do | for _, building in ipairs(buildingList) do | ||
local | local product = p._GetBuildingBaseProduction(building) | ||
hasProduction = hasProduction == true or product ~= nil | |||
table.insert(ret, '\r\n|'..production) | product = product ~= nil and product or '' | ||
table.insert(production, product) | |||
end | |||
if hasProduction == true then | |||
production = table.concat(production, '\r\n|') | |||
table.insert(ret, '\r\n|-\r\n! Production\r\n|'..production) | |||
end | end | ||
-- Biomes Modifiers | -- Biomes Modifiers | ||
local biomeModifiers = {} | |||
local hasBiomeModifiers = false | |||
for _, building in ipairs(buildingList) do | for _, building in ipairs(buildingList) do | ||
local | local biomeModifier = p._GetBiomeModifiers(building) | ||
hasBiomeModifiers = hasBiomeModifiers == true or biomeModifier ~= nil | |||
biomeModifier = biomeModifier ~= nil and biomeModifier or '' | |||
table.insert(biomeModifiers, biomeModifier) | |||
table.insert( | |||
end | end | ||
if hasBiomeModifiers == true then | |||
biomeModifiers = table.concat(biomeModifiers, '\r\n|') | |||
table.insert(ret, '\r\n|-\r\n! Biome Modifiers\r\n|'..biomeModifiers) | |||
end | |||
-- End | -- End |
edits