Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

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


local util_args = require("Module:ArgsUtil")
local util_esports = require("Module:EsportsUtil")
local util_stats = require("Module:StatsUtil")
local util_table = require("Module:TableUtil")
local util_vars = require("Module:VarsUtil")
local Team = require('Module:TeamClass')

local PBT = require('Module:PickBanHistory')
local PBQuery = require('Module:PickBanHistoryQuery/Team')
local PBFormatterPretty = require('Module:PickBanHistoryFormatter/Pretty'):extends()
local PBFormatterText = require('Module:PickBanHistoryFormatter/Text'):extends()

PBFormatterPretty.INTRO_COLUMNS = { 'Tournament', 'Phase', 'Blue', 'Red', 'Score', 'Result', 'Patch', }

PBFormatterText.INTRO_COLUMNS = { 'Region', 'Tournament', 'Phase', 'Blue', 'Red', 'Score', 'Result', 'Patch', }

local p = {}

function p.main(frame)
	local args = util_args.merge()
	local page = args.page or args[1] or mw.title.getCurrentTitle().baseText
	args.team = Team(page):get()
	local queryClass = PBQuery(args, page)
	local textonly = util_args.castAsBool(args.textonly)
	local formatterClass = textonly and PBFormatterText() or PBFormatterPretty()
	formatterClass.team = Team(args.team)
	return PBT(args, page, queryClass, formatterClass):run()
end

function PBFormatterPretty:formatRow(row)
	self:super('formatRow', row)
	row.data.Tournament = util_stats.tournamentAndRegion(row)
	row.classes.Tournament = { 'pbh-tournament' }
	local winTeam = row.Winner == 1 and row.Team1 or row.Team2
	local isWinner = winTeam == self.team:get()
	row.data.Result = isWinner and 'Win' or 'Loss'
	row.classes.Result = isWinner and { 'pbh-winner' }
end

function PBFormatterText:formatRow(row)
	self:super('formatRow', row)
	row.data.Region = row.Region:get()
	row.data.Tournament = row.Tournament
	local winTeam = row.Winner == 1 and row.Team1 or row.Team2
	local isWinner = winTeam == self.team:get()
	row.data.Result = isWinner and 'Win' or 'Loss'
	row.classes.Result = isWinner and { 'pbh-winner' }
end

return p
Advertisement