Module:League

From NBA 2K Esports Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:League/doc

local p = {}

function p.league ( frame )
	local args = frame 
	local text = ''
	if frame == mw.getCurrentFrame() then
		args = require( 'Module:ProcessArgs' ).merge( true )
	else
		frame = mw.getCurrentFrame()
	end
	local leagueinput = mw.ustring.lower(args[1] or '')
	local leaguestyle = mw.ustring.lower(args[2] or 'default')
	local size = args['size']
	local text = ""
	
	local Leaguenames = mw.loadData('Module:Leaguenames')
	local Leaguestyles = mw.loadData('Module:Leaguestyles')
	
	local namevars = Leaguenames[leagueinput]
	
	if not namevars then
		namevars = {link = args[1], long = args[1], short = args[1], image = "Unknown Infobox Image - Tournament.png"}
	elseif type(namevars) == 'string' then
		namevars = Leaguenames[namevars]
	end
	
	text = Leaguestyles[leaguestyle]
	
	if not size then
		text = text:gsub("REPLACESIZE","")
	else
		text = text:gsub("REPLACESIZE(%d+)px",size)
	end
	
	text = text:gsub("REPLACE(%u+)", { ["LINK"] = (args["link"] or namevars.link), ["LONG"] = namevars.long, ["SHORT"] = namevars.short, ["FILE"] = namevars.image })
	
	return text
	
end
return p