This module is NOT able to be synced with code from other esports wikis!
The code has been significantly customized in accordance with the needs of this particular wiki. DO NOT OVERWRITE IT!!! |
local util_args = require('Module:ArgsUtil')
local util_footnote = require('Module:FootnoteUtil')
local util_table = require('Module:TableUtil')
local util_text = require('Module:TextUtil')
local util_toggle = require('Module:ToggleUtil')
local i18n = require('Module:i18nUtil')
local m_champion = require('Module:Champion')
local h = {}
local p = {
players_per_team = 5,
side_names = {
'Blue', 'Red',
['1'] = 'Blue',
['2'] = 'Red'
},
years = { 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 },
store_player_league_history = true, -- do we store to PlayerLeagueHistory from InfoboxPlayer? will prevent needing to sync a normally-unneeded dependency
}
function p.linkPatch(str)
return util_text.intLink(('Patch %s'):format(str), str)
end
---------------------------------------------------------
------------------ MatchList hooks ---------------------
---------------------------------------------------------
local MATCHLIST_PATCH_TOGGLES = {
init = 'patch_number',
order = { 'patch_all', 'patch_number', 'patch_none' },
showall = 'patch_all',
}
function p.onMatchListProcessTabRow(row, i, j, args, tab)
-- add patch as a table caption
util_table.initTable(tab, 'patchinfo', { patches = {}, hotfixes = {}, disabled = {}, footnotes = {} })
if not row.Patch then return true end
MATCH_LIST_HAS_PATCH = true
util_table.initDict(tab.patchinfo.patches, row.Patch)
if row.Hotfix then
util_table.initDict(tab.patchinfo.hotfixes, row.Hotfix)
end
if row.PatchFootnote then
util_table.initDict(tab.patchinfo.footnotes, row.PatchFootnote)
end
util_table.merge(tab.patchinfo.disabled, util_text.split(row.Disabled))
return true
end
function p.onMatchListPrintCaption(tbl, tab)
if not MATCH_LIST_HAS_PATCH then return true end
local caption = tbl:tag('caption')
util_toggle.oflCellClasses(caption, MATCHLIST_PATCH_TOGGLES, 'patch_number')
util_toggle.oflCellClasses(caption, MATCHLIST_PATCH_TOGGLES, 'patch_all')
h.printPatchNumber(caption, tab.patchinfo)
h.printDisabledText(caption, tab.patchinfo)
util_footnote.tagFootnotes(caption, tab.patchinfo.footnotes)
return true
end
function h.printPatchNumber(caption, patchinfo)
local span = caption:tag('span')
:addClass('matchlist-patch-number')
:wikitext(i18n.print('patchCaption', h.getPatchText(patchinfo.patches)))
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'patch_number')
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'patch_all')
end
function h.getPatchText(patches)
return util_table.concatNonempty(patches, ', ', p.linkPatch) or i18n.print('tbd')
end
function h.printDisabledText(caption, patchinfo)
if not patchinfo.disabled or not next(patchinfo.disabled) then return end
local span = caption:tag('span')
:addClass('matchlist-patch-disabled')
:wikitext(i18n.print('patchDisabled', h.getDisabledText(patchinfo.disabled)))
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'patch_all')
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'patch_disabled')
end
function h.getDisabledText(disabled)
return util_table.concat(disabled, '', m_champion.onlyimagelinked)
end
function p.onMatchListPrintTogglesEnd(tbl)
div = tbl:tag('div'):addClass('toggle-button')
div:wikitext(i18n.print('patchToggleLabel'))
util_toggle.printOptionFromListTogglers(div, MATCHLIST_PATCH_TOGGLES)
end
return p