FANDOM


--
-- Implements [[Template:Level up table]]
--
 
local p = {}
 
local params = require('Module:Paramtest')
 
function p.make_table(frame)
	local max_level
	local parameters = frame:getParent().args
	if not parameters['max120'] then
		max_level = 99
	else
		local param = string.lower(mw.text.trim(parameters['max120']))
 
		if param == 'yes' then
			max_level = 120
		else
			max_level = 99
		end
	end
 
	local lvl_ary = parameters
 
	-- Every table starts with this
	local ret = mw.html.create('table')
				:addClass('wikitable')
				:addClass('level-up-table')
			:tag('tr')
				:tag('th')
					:wikitext('Level')
					:done()
				:tag('th')
					:attr('colspan','2')
					:wikitext('New abilities')
					:done()
			:done()
	:done()
 
	-- Function for handling parameter names
	local function level_string(level, mems)
		local level_string
		if mems then
			level_string = "members"
		else
			level_string = "freeplay"
		end
		if level <= 9 then
			level_string = level_string.."0"..level
		else
			level_string = level_string..level
		end
		return level_string
	end
 
	--
	-- Tables for "each level"
	--
	for i=1,1,1 do
	if params.is_empty(lvl_ary.freeplayall)
		and params.is_empty(lvl_ary.membersall) then
		ret:tag('tr')
				:tag('th')
					:wikitext('Each level')
					:done()
				:tag('td')
					:attr('colspan','2')
					:wikitext('\n*No new abilities unlocked for [[free-to-play|free players]] or [[members]]\n')
					:done()
				:done()
	elseif params.is_empty(lvl_ary.freeplayall)
		or params.is_empty(lvl_ary.membersall) then
			if params.is_empty(lvl_ary.freeplayall) then
				ret:tag('tr')
					:tag('th')
						:wikitext('Each level')
						:done()
					:tag('td')
						:addClass('lvlupmem')
						:wikitext('Members')
						:done()
					:tag('td')
						:wikitext('\n'..lvl_ary.membersall..'\n')
						:done()
					:done()
			else
				ret:tag('tr')
					:tag('th')
						:wikitext('Each level')
						:done()
					:tag('td')
						:addClass('lvlupfree')
						:wikitext('Free play')
						:done()
					:tag('td')
						:wikitext('\n'..lvl_ary.freeplayall..'\n')
						:done()
					:done()
			end
		elseif params.has_content(lvl_ary.freeplayall)
			and params.has_content(lvl_ary.membersall) then
				ret:tag('tr')
					:tag('th')
					    :attr('rowspan','2')
						:wikitext('Each level')
						:done()
					:tag('td')
						:addClass('lvlupfree')
						:wikitext('Free play')
						:done()
					:tag('td')
						:wikitext('\n'..lvl_ary.freeplayall..'\n')
						:done()
					:done()
				:tag('tr')
					:tag('td')
						:addClass('lvlupmem')
						:wikitext('Members')
						:done()
					:tag('td')
						:wikitext('\n'..lvl_ary.membersall..'\n')
						:done()
				:done()
	end
	end
	--
	-- Array for levels 1 - 99/120
	--
 
	for i=1,max_level,1 do
		local free_level = level_string(i, false)
		local mems_level = level_string(i, true)
		if params.is_empty(lvl_ary[free_level])
			and params.is_empty(lvl_ary[mems_level]) then
			ret:tag('tr')
					:tag('th')
				    	:wikitext(i)
				:attr('id',i)
						:done()
					:tag('td')
						:attr('colspan','2')
						:wikitext('\n*No new abilities unlocked for [[free-to-play|free players]] or [[members]]\n')
						:done()
					:done()
		elseif params.is_empty(lvl_ary[free_level])
			or params.is_empty(lvl_ary[mems_level]) then
				if params.is_empty(lvl_ary[free_level]) then
					ret:tag('tr')
						:tag('th')
							:wikitext(i)
						  :attr('id',i)
							:done()
						:tag('td')
							:addClass('lvlupmem')
							:wikitext('Members')
							:done()
						:tag('td')
							:wikitext('\n'..lvl_ary[mems_level]..'\n')
							:done()
						:done()
				else
					ret:tag('tr')
						:tag('th')
							:wikitext(i)
							:attr('id',i)
							:done()
						:tag('td')
							:addClass('lvlupfree')
							:wikitext('Free play')
							:done()
						:tag('td')
							:wikitext('\n'..lvl_ary[free_level]..'\n')
							:done()
						:done()
				end
			elseif params.has_content(lvl_ary[free_level])
				and params.has_content(lvl_ary[mems_level]) then
					ret:tag('tr')
						:tag('th')
							:attr('rowspan','2')
							:wikitext(i)
							:attr('id',i)
							:done()
						:tag('td')
							:addClass('lvlupfree')
							:wikitext('Free play')
							:done()
						:tag('td')
							:wikitext('\n'..lvl_ary[free_level]..'\n')
							:done()
						:done()
					:tag('tr')
						:tag('td')
							:addClass('lvlupmem')
							:wikitext('Members')
							:done()
						:tag('td')
							:wikitext('\n'..lvl_ary[mems_level]..'\n')
							:done()
					:done()
		end
	end
	return ret
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.