Module:Buildings

local p = {} p.buildings = mw.loadData('Module:Buildings/data') p.config = { statcolumns = 6 }

local f = require('Module:Functions')

function calculate(value,time) return f.round(value/(time/60),2) end

function stat(name,money,xp,time,unlock,characters,stat,frame) local data = {} local col = 0 if(getCharacters(characters) == nil) then col = col+1 end if(unlock == nil) then col = col+1 end if(frame~=nil) then return money..' '..xp..' '..calculate(money,time)..'/min '..calculate(xp,time)..'/min '..f.time(time)..' Unlock: '..unlock end table.insert(data, '  '..stat..' '..name..' ') table.insert(data, ' ') table.insert(data, ' '..money..' ') table.insert(data, ' '..xp..' ') table.insert(data, ' '..calculate(money,time)..'/min ') table.insert(data, ' '..calculate(xp,time)..'/min ') table.insert(data, ''..f.time(time)..' ') if(unlock ~= nil) then table.insert(data, ' Unlock: '..unlock..' ') end if(getCharacters(characters) ~= nil) then	table.insert(data, ' Characters: '..getCharacters(characters)..' ') end table.insert(data, ' ') return table.concat(data, "\n") end

function getImages(images, levels, description,stats, name, frame) local _images = {'")

return frame:preprocess(table.concat(_images, "\n")) end

function getCharacters(data) local characters = "" if(data == nil) then return nil end for i, j in pairs(data) do		characters = characters..j	end return characters end

function p.table(frame) local data = { '==Buildings List==', ' '   }    for a, s in pairs(p.buildings) do    	table.insert(data,'{| class="wikitable mw-datatable sortable" style="text-align: center;"') table.insert(data,'|-') table.insert(data, '| '..getImages(s.images,s.levels, s.description,s.stats,a, frame)) table.insert(data, '|-') table.insert(data, '| style="padding:0;"|') table.insert(data, ' ') table.insert(data, '|-') table.insert(data, '|}') end table.insert(data, 'Add building ') return table.concat(data, "\n") end

return p