2,869
edits
(Unhide Lemon Season) |
(Fix township building sticky header and add cell borders) |
||
Line 6: | Line 6: | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Num = require('Module:Number') | |||
local p = {} | local p = {} | ||
Line 333: | Line 334: | ||
-- Skips upgraded buildings | -- Skips upgraded buildings | ||
function p.getBuildingBiomeTable(frame) | function p.getBuildingBiomeTable(frame) | ||
local tbl = mw.html.create('table') | |||
local | :addClass('wikitable sortable stickyHeader') | ||
:css('text-align', 'center') | |||
- | local header = mw.html.create('tr'):addClass('headerRow-0') | ||
local | local level = mw.html.create('tr'):addClass('sorttop') | ||
local pop = mw.html.create('tr'):addClass('sorttop') | |||
header:tag('th') | |||
:css('z-index', '2') | |||
:wikitext('Building') | |||
level:tag('th') | |||
:wikitext(Icons.Icon({'Township', 'Level', type='skill', nolink=true})) | |||
pop:tag('th') | |||
:wikitext(Icons.Icon({'Township', 'Population', img='Population', type='township', section='Population' })) | |||
for _, biome in ipairs(Township.biomes) do | for _, biome in ipairs(Township.biomes) do | ||
local reqs = p._getTierRequirements(biome.tier) | local reqs = p._getTierRequirements(biome.tier) | ||
header:tag('th') | |||
:wikitext(Icons.Icon({biome.name, type='biome', notext=true, nolink=true}).. '<br/>' .. biome.name) | |||
level:tag('td') | |||
:wikitext(Num.formatnum(reqs.level)) | |||
pop:tag('td') | |||
:wikitext(Num.formatnum(reqs.population)) | |||
end | end | ||
tbl:node(header) | |||
tbl:node(level) | |||
tbl:node(pop) | |||
for _, _building in ipairs(p._sortedBuildings(false)) do | for _, _building in ipairs(p._sortedBuildings(false)) do | ||
Line 366: | Line 376: | ||
end | end | ||
local trow = tbl:tag('tr') | |||
trow:tag('th') | |||
:css('text-align', 'left') | |||
:attr('data-sort-value', building.name) | |||
:wikitext(Icons.Icon({building.name, type='building'})) | |||
for _, biome in ipairs(Township.biomes) do | for _, biome in ipairs(Township.biomes) do | ||
if buildingBiomes[biome.id] then | if buildingBiomes[biome.id] then | ||
trow:tag('td') | |||
:addClass('table-positive') | |||
:wikitext('✓') | |||
else | else | ||
trow:tag('td') | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
return | return tostring(tbl) | ||
end | end | ||
edits