Module:MatchList

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_esports = require('Module:EsportsUtil') local util_footnote = require('Module:FootnoteUtil') local util_game = require('Module:GameUtil') local util_map = require('Module:MapUtil') local util_html = require('Module:HtmlUtil') local util_matches = require('Module:MatchesUtil') local util_table = require('Module:TableUtil') local util_text = require('Module:TextUtil') local util_time = require('Module:TimeUtil') local util_toggle = require('Module:ToggleUtil') local util_vars = require('Module:VarsUtil') local m_team = require('Module:Team') local i18n = require('Module:i18nUtil') local Phase = require('Module:PhaseClass')

local lang = mw.getLanguage('en')

local ML = require('Module:MatchListAbstract'):extends

local USE_COLUMNS_LAYOUT = false;

local h = {} local p = {}

function ML:makeMatchFields(args) local fields = self:super('makeMatchFields', args) fields[#fields+1] = 'MS.Team1Rounds' fields[#fields+1] = 'MS.Team2Rounds' return fields end

function ML:printScore(tr, row, suppresstoggle) if USE_COLUMNS_LAYOUT then h.printRound(self:printOneScore(tr, row, 1, true), row, 1, suppresstoggle) self:super('printScore', tr, row, suppresstoggle) h.printRound(self:printOneScore(tr, row, 2, true), row, 2, suppresstoggle) else self:super('printScore', tr, row, suppresstoggle) end end

function ML:printOneScore(tr, row, n, isRound) local td = tr:tag('td'):wikitext(self:getOneScore(row, n, isRound)) :addClass('matchlist-score') util_esports.addTeamHighlighter(td, row[('Team%sFinal'):format(n)]) return td end

function ML:getOneScore(row, n, isRound) if isRound then return row[('Team%sRounds'):format(n)] end return row[('Team%sScore'):format(n)] end

function ML:processMatchRow(row, i, j, args, tab) self:super('processMatchRow', row, i, j, args, tab) if not row['Team1Rounds'] or not row['Team2Rounds'] then return elseif not (row.BestOf > 1) then return else h.setDefaultsForRounds end end

function p.main(frame) local args = util_args.merge return ML:init(args) end

function h.setDefaultsForRounds ML.COLSPAN = 6 USE_COLUMNS_LAYOUT = true ML.WIDTHS = { 110, 25, 25, 25, 25, 110 } end

function h.printRound(td, row, index, suppresstoggle) if row.Winner == index then td:addClass('matchlist-winner-score') elseif row.Winner == 0 then td:addClass('matchlist-tied-score') end if not suppresstoggle then util_toggle.oflCellClasses(td, ML.RS_TOGGLES, 'res') end end

return p