Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki
local util_args = require('Module:ArgsUtil')
local util_html = require('Module:HtmlUtil')
local i18n = require('Module:i18nUtil')
local Hook = require('Module:Hook')
local MatchHistoryPlayer = require('Module:MatchHistoryPlayer')._main
local MVP_TABLE = { series = 'MS', game = 'MSG' }
local h = {}
local p = {}
function p.main(frame)
	local args = util_args.merge()
	Hook.add('onMatchHistoryPlayerGetTables', h.onMatchHistoryPlayerGetTables)
	Hook.add('onMatchHistoryPlayerGetJoin', h.onMatchHistoryPlayerGetJoin)
	h.setOnMatchHistoryPlayerGetWhere(args.player, args.mvptype)
	h.setOnMatchHistoryPlayerPrintColspanHeader(args.player, args.mvptype)
	args.preload='Player'
	args.limit=args.limit or 50
	args.link=args.player
	args.nostats = 'yes'
	return MatchHistoryPlayer(args)
end

function h.onMatchHistoryPlayerGetTables(tbl)
	tbl[#tbl+1] = 'MatchScheduleGame=MSG'
	tbl[#tbl+1] = 'MatchSchedule=MS'
	return true
end

function h.onMatchHistoryPlayerGetJoin(tbl)
	tbl[#tbl+1] = 'SG.GameId=MSG.GameId'
	tbl[#tbl+1] = 'MSG.MatchId=MS.MatchId'
	return true
end

function h.setOnMatchHistoryPlayerGetWhere(player, mvptype)
	local function onMatchHistoryPlayerGetWhere(tbl)
		tbl[#tbl+1] = ('%s.MVP="Bjergsen"'):format(MVP_TABLE[mvptype:lower()])
	end
	Hook.add('onMatchHistoryPlayerGetWhere', onMatchHistoryPlayerGetWhere)
	return true
end

function h.setOnMatchHistoryPlayerPrintColspanHeader(player, mvptype)
	local function onMatchHistoryPlayerPrintColspanHeader(tbl, colspan)
			util_html.printColspanHeader(tbl, i18n.print('mvp_' .. mvptype:lower(), player), colspan)
	end
	Hook.add('onMatchHistoryPlayerPrintColspanHeader', onMatchHistoryPlayerPrintColspanHeader)
end

return p
Advertisement