572
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Icons = require('Module: | local Icons = require('Module:Icons') | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local p = {} | |||
local Township = GameData.getSkillData('melvorD:Township') | local Township = GameData.getSkillData('melvorD:Township') | ||
p.Township = Township | |||
-- Returns the namespace name (eventually we should use an icon) | -- Returns the namespace name (eventually we should use an icon) | ||
Line 369: | Line 369: | ||
-- Fixed benefits | -- Fixed benefits | ||
local benefits = | local benefits = p._GetBuildingBenefits(building) | ||
if benefits ~= nil then | |||
table.insert(ret, '\r\n|-\r\n| <b>Provides:</b> '..benefits) | |||
if | |||
table.insert(ret, '\r\n|-\r\n| <b>Provides:</b> '.. | |||
end | end | ||
Line 428: | Line 416: | ||
end | end | ||
-- Gets a string displaying the base production of a building | -- Gets a string displaying the base production of a building, or nil if no production | ||
function p._GetBuildingBaseProduction(building) | function p._GetBuildingBaseProduction(building) | ||
local production = Shared.clone(building.provides.resources) | local production = Shared.clone(building.provides.resources) | ||
Line 459: | Line 447: | ||
end | end | ||
-- | -- Gets a string displaying the building's benefits, or nil if no benefits | ||
p. | function p._GetBuildingBenefits(building) | ||
local stats = { | |||
population = 'Population', | |||
happiness = 'Happiness', | |||
education = 'Education', | |||
storage = 'Storage', | |||
deadStorage = 'Dead Storage' | |||
} | |||
for key, stat in pairs(stats) do | |||
if building.provides[key] ~= nil and building.provides[key] ~= 0 then | |||
table.insert(benefits, Icons.Icon({stat, type='township', notext=true})..' '..building.provides[key]) | |||
end | |||
end | |||
if #benefits > 0 then | |||
return table.concat(benefits, ', ') | |||
end | |||
return nil | |||
end | |||
return p | return p |
edits