Leaguepedia | League of Legends Esports Wiki
Advertisement

To edit the documentation or categories for this module, click here.


local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local m_team = require('Module:Team')
local sep = '%s*,%s*'

local p = {}

function p.main(frame)
	local args = util_args.merge()
	
	teams = {
		Active = mw.text.split(args.active or '',sep),
		Inactive = mw.text.split(args.inactive or '',sep),
		Active_markup = {},
		Inactive_markup = {},
		allteams = {},
		allteams_markup = {}
	}
	
	-- standardize input names & make markup tables
	for _, list in pairs{"Active", "Inactive"} do
		for i, team in ipairs(teams[list]) do
			if team ~= '' then
				teams[list][i] = m_team.teamlinkname(team)
				teams[list .. '_markup'][i] = m_team.rightlonglinked(team, {size=45})
				teams.allteams[#teams.allteams+1] = teams[list][i]
				teams.allteams_markup[#teams.allteams_markup+1] = teams[list .. '_markup'][i]
			end
		end
	end
	
	-- store cargo
	other = { Active = "Inactive", Inactive = "Active" }
	for _, list in pairs{"Active", "Inactive"} do
		for i, team in ipairs(teams[list]) do
			if team ~= '' then
				table.remove(teams[list],i)
				team_markup = table.remove(teams[list .. '_markup'],i)
				data = {
					Team = team,
					Team_Markup = team_markup,
					Status = list,
					ActiveList = table.concat(teams.Active,','),
					InactiveList = table.concat(teams.Inactive,','),
					Active_Markup = table.concat(teams.Active_markup,','),
					Inactive_Markup = table.concat(teams.Inactive_markup,','),
					AllTeams = table.concat(teams.allteams,','),
					AllTeams_Markup = table.concat(teams.allteams_markup,','),
					_table = 'SisterTeams'
				}
				util_cargo.store(data)
				table.insert(teams[list],i,team)
				table.insert(teams[list .. '_markup'],i,team_markup)
			end
		end
	end
	
	local tbl = mw.html.create()
	local tr = tbl:tag('tr')
	tr:tag('td')
		:wikitext(table.concat(teams.Active_markup,' • '))
	tr:tag('td')
		:wikitext(table.concat(teams.Inactive_markup,' • '))
	
	return tbl
end
return p
Advertisement