diff --git a/lua/wikis/ageofempires/MatchMaps/Legacy.lua b/lua/wikis/ageofempires/MatchMaps/Legacy.lua index e0b70c48771..47da3b969e3 100644 --- a/lua/wikis/ageofempires/MatchMaps/Legacy.lua +++ b/lua/wikis/ageofempires/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') local Template = Lua.import('Module:Template') @@ -72,11 +73,11 @@ function MatchMapsLegacy._readMaps(matchArgs) end --handle MatchMaps mapXwin local mapWinners = Table.filterByKey(matchArgs, function (key) - local winner = key:match('map(%d+)win') + local winner = string.match(key, 'map(%d+)win') return winner ~= nil end) Table.iter.forEachPair(mapWinners, function (key) - local mapKey = key:match('(map%d+)') + local mapKey = string.match(key, '(map%d+)') local mapWinner = Table.extract(matchArgs, mapKey .. 'win') matchArgs[mapKey] = matchArgs[mapKey] or {} matchArgs[mapKey].winner = matchArgs[mapKey].winner or mapWinner @@ -87,11 +88,17 @@ end ---@param frame Frame ---@return Html function MatchMapsLegacy.convertMatch(frame) - local matchArgs = MatchMapsLegacy._mergeDetailsIntoArgs(Arguments.getArgs(frame)) + local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local matchArgs = MatchMapsLegacy._mergeDetailsIntoArgs(args) MatchMapsLegacy._readOpponents(matchArgs) MatchMapsLegacy._readMaps(matchArgs) matchArgs.winner = matchArgs.winner or Table.extract(matchArgs, 'win') + if generate then + return Json.stringify(matchArgs) + end + Template.stashReturnValue(matchArgs, 'LegacyMatchlist') return mw.html.create('div'):css('display', 'none') end @@ -121,7 +128,7 @@ function MatchMapsLegacy.showmatch(frame) id = id, hide = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, R1M1 = match }) @@ -202,4 +209,65 @@ function MatchMapsLegacy.matchlistEnd() return MatchGroup.MatchList(matchListArgs) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '320px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + matchsection = args.matchsection, + patch = args.patch, + } + + local gsl = args.gsl + if Logic.isNotEmpty(gsl) then + if gsl == GSL_WINNERS or gsl == GSL_LOSERS then + gsl = gsl .. 'first' + parsedArgs.gsl = gsl + end + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return args[index + offset] + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +---@param frame Frame +---@return string +function MatchMapsLegacy.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.convertMatch(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacy diff --git a/lua/wikis/arenafps/MatchMaps/Legacy.lua b/lua/wikis/arenafps/MatchMaps/Legacy.lua index afe4e3875aa..1ff21450ceb 100644 --- a/lua/wikis/arenafps/MatchMaps/Legacy.lua +++ b/lua/wikis/arenafps/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -110,7 +111,7 @@ function MatchMapsLegacy.showmatch(frame) id = id, hide = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, R1M1 = match }) @@ -120,10 +121,17 @@ function MatchMapsLegacy.showmatch(frame) }) end +---@param frame any +---@return string +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + -- invoked by Template:LegacyMatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) globalVars:set('islegacy', 'true') local args = Arguments.getArgs(frame) assert(args.id, 'Missing id') @@ -133,7 +141,7 @@ function MatchMapsLegacy.matchList(frame) Table.mergeInto(args, { isLegacy = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = Logic.nilOr(Table.extract(args, 'title'), args[1]), @@ -148,7 +156,28 @@ function MatchMapsLegacy.matchList(frame) end globalVars:delete('islegacy') + + if generate then + args.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + return MatchGroup.MatchList(args) end +---@param frame Frame +---@return string +function MatchMapsLegacy.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.convertMatch(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacy diff --git a/lua/wikis/battalion/MatchGroup/Legacy/MatchList.lua b/lua/wikis/battalion/MatchGroup/Legacy/MatchList.lua index 4f9bf872242..e28fbea0b1f 100644 --- a/lua/wikis/battalion/MatchGroup/Legacy/MatchList.lua +++ b/lua/wikis/battalion/MatchGroup/Legacy/MatchList.lua @@ -8,10 +8,12 @@ local Lua = require('Module:Lua') local Arguments = Lua.import('Module:Arguments') +local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -24,6 +26,42 @@ local LegacyMatchList = {} local NUMBER_OF_OPPONENTS = 2 +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchList.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + -- invoked by Template:Legacy Match list start ---@param frame Frame function LegacyMatchList.init(frame) @@ -42,9 +80,12 @@ end -- invoked by Template:Match maps ---@param frame Frame +---@return string? function LegacyMatchList.matchMaps(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local processedArgs = Table.copy(args) LegacyMatchList._handleOpponents(processedArgs) @@ -57,6 +98,10 @@ function LegacyMatchList.matchMaps(frame) -- all other args from the match maps calls are just passed along directly -- as they can be read by the match2 processing + if generate then + return Json.stringify(processedArgs) + end + Template.stashReturnValue(processedArgs, 'LegacyMatchlist') end diff --git a/lua/wikis/brawlstars/MatchMaps/Legacy.lua b/lua/wikis/brawlstars/MatchMaps/Legacy.lua index 8655b06ea0d..8fcf0dde8cb 100644 --- a/lua/wikis/brawlstars/MatchMaps/Legacy.lua +++ b/lua/wikis/brawlstars/MatchMaps/Legacy.lua @@ -13,6 +13,7 @@ local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') local Template = Lua.import('Module:Template') @@ -226,6 +227,8 @@ end ---@return Html function MatchMapsLegacy.convertMatch(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local details = Json.parseIfString(args.details or '{}') args, details = MatchMapsLegacy._handleDetails(args, details) @@ -233,6 +236,10 @@ function MatchMapsLegacy.convertMatch(frame) args = MatchMapsLegacy._setHeaderIfEmpty(args, details) args = MatchMapsLegacy._copyDetailsToArgs(args, details) + if generate then + return Json.stringify(args) + end + Template.stashReturnValue(args, 'LegacyMatchlist') return mw.html.create('div'):css('display', 'none') end @@ -257,7 +264,7 @@ function MatchMapsLegacy.showmatch(frame) id = args.id, hide = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, R1M1 = matches[1] }) @@ -299,7 +306,7 @@ function MatchMapsLegacy.matchListEnd() isLegacy = true, id = bracketId, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = matchlistVars:get('matchListTitle'), @@ -325,4 +332,60 @@ function MatchMapsLegacy.matchListEnd() return MatchGroup.MatchList(args) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return args[index + offset] + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +---@param frame Frame +---@return string +function MatchMapsLegacy.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.convertMatch(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacy diff --git a/lua/wikis/callofduty/MatchMaps/Legacy.lua b/lua/wikis/callofduty/MatchMaps/Legacy.lua index 2506e72d9ac..95ae7dae5a5 100644 --- a/lua/wikis/callofduty/MatchMaps/Legacy.lua +++ b/lua/wikis/callofduty/MatchMaps/Legacy.lua @@ -17,6 +17,7 @@ local Template = Lua.import('Module:Template') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') @@ -48,11 +49,19 @@ function MatchMapsLegacy.init(frame) end ---@param frame Frame +---@return string? function MatchMapsLegacy.match(frame) - local matchArgs = MatchMapsLegacy._mergeDetailsIntoArgs(Arguments.getArgs(frame)) + local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + + local matchArgs = MatchMapsLegacy._mergeDetailsIntoArgs(args) MatchMapsLegacy._readMaps(matchArgs) MatchMapsLegacy._readOpponents(matchArgs) + if generate then + return Json.stringify(matchArgs) + end + Template.stashReturnValue(matchArgs, 'LegacyMatchlist') end @@ -148,4 +157,45 @@ function MatchMapsLegacy._resetVars() matchlistVars:delete('width') end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + return MatchMapsLegacy diff --git a/lua/wikis/clashroyale/MatchGroup/Legacy/MatchList.lua b/lua/wikis/clashroyale/MatchGroup/Legacy/MatchList.lua index 72e085f988c..329eb5aad9b 100644 --- a/lua/wikis/clashroyale/MatchGroup/Legacy/MatchList.lua +++ b/lua/wikis/clashroyale/MatchGroup/Legacy/MatchList.lua @@ -13,6 +13,7 @@ local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -155,7 +156,7 @@ end -- handle the second version of matchlists ... -- invoked by Template:LegacyMatchList -function LegacyMatchList.run(frame) +function LegacyMatchList.run(frame, generate) local args = Arguments.getArgs(frame) local store = Logic.nilOr( Logic.readBoolOrNil(args.store), @@ -166,6 +167,7 @@ function LegacyMatchList.run(frame) return args['match' .. matchIndex] end) + ---@type table local matchListArgs = Table.copy(matches) matchListArgs.id = args.id matchListArgs.isLegacy = true @@ -185,7 +187,54 @@ function LegacyMatchList.run(frame) matchListArgs.store = false end + if generate then + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + return MatchGroup.MatchList(matchListArgs) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchList.generate(frame) + return LegacyMatchList.run(frame, true) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchList.generate2(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + return LegacyMatchList diff --git a/lua/wikis/commons/MatchGroup/Legacy.lua b/lua/wikis/commons/MatchGroup/Legacy.lua index 9fb93574ea3..0ff6d2855e0 100644 --- a/lua/wikis/commons/MatchGroup/Legacy.lua +++ b/lua/wikis/commons/MatchGroup/Legacy.lua @@ -446,14 +446,16 @@ function MatchGroupLegacy:generate() self:_populateNewArgs(match2mapping) self:handleOtherBracketParams() - return MatchGroupLegacy._generateWikiCode(self.newArgs) + return MatchGroupLegacy._generateWikiCodeForBracket(self.newArgs) end -function MatchGroupLegacy._generateWikiCode(args) +---@param args table +---@return string +function MatchGroupLegacy._generateWikiCodeForBracket(args) local bracketType = Table.extract(args, 1) local bracketTypeWithoutPrefix = bracketType:gsub('^[bB]racket/', '') local bracketDataList = CopyPaste._getBracketData(bracketTypeWithoutPrefix) - local matches = Array.map(bracketDataList, function(bracketData, matchIndex) + local matches = Array.map(bracketDataList, function(bracketData) local matchKey = bracketData.matchKey local match = Table.extract(args, matchKey) if Logic.isEmpty(match) then return end @@ -481,18 +483,77 @@ function MatchGroupLegacy._generateWikiCode(args) return table.concat(lines, '\n') end +---@param args table +---@return string +function MatchGroupLegacy.generateWikiCodeForMatchList(args) + local headers = {} + local matches = Array.mapIndexes(function(matchIndex) + local matchKey = 'M' .. matchIndex + ---@type table|string? + local matchJson = Table.extract(args, matchKey) + local match = matchJson + if type(matchJson) == 'string' then + match = Json.parseIfTable(matchJson) + end + if Logic.isEmpty(match) then return end + ---@cast match table + + local headerKey = matchKey .. 'header' + local header = Table.extract(args, headerKey) or Table.extract(match, 'header') + if Logic.isNotEmpty(header) then + table.insert(headers, '|' .. headerKey .. '=' .. header) + end + return '|' .. matchKey .. '=' .. MatchGroupLegacy._generateMatch(match) + end) + + local lines = Array.extend( + {'{{Matchlist|id=' .. Table.extract(args, 'id')}, + MatchGroupLegacy._argsToString(args), + headers, + matches, + '}}' + ) + + return table.concat(lines, '\n') +end + +---@param args table +---@return string +function MatchGroupLegacy.generateWikiCodeForSingleMatch(args) + local matchJson = Table.extract(args, 'match') + local match = matchJson + if type(matchJson) == 'string' then + match = Json.parseIfTable(matchJson) + end + ---@cast match table + + local lines = Array.extend( + {'{{SingleMatch|id=' .. Table.extract(args, 'id')}, + MatchGroupLegacy._argsToString(args), + '|R1M1=' .. MatchGroupLegacy._generateMatch(match), + '}}' + ) + + return table.concat(lines, '\n') +end + ---@param match table ---@return string function MatchGroupLegacy._generateMatch(match) local opponents = Array.mapIndexes(function(opponentIndex) local opp = Table.extract(match, 'opponent' .. opponentIndex) - if Logic.isEmpty(opp) then return end + if opponentIndex > 2 and Logic.isEmpty(opp) then return end return '|opponent' .. opponentIndex .. '=' .. MatchGroupLegacy._generateOpponent(opp) end) local maps = Array.mapIndexes(function(mapIndex) local map = Table.extract(match, 'map' .. mapIndex) + if type(map) == 'string' then + map = Json.parseIfTable(map) or map + end if Logic.isEmpty(map) then return end + ---@cast map table + map.winner = map.winner or map.win -- for wow return '|map' .. mapIndex .. '=' .. MatchGroupLegacy._generateMap(map) end) @@ -500,10 +561,15 @@ function MatchGroupLegacy._generateMatch(match) return Array.map(arr, function(item) return ' ' .. item end) end + local rawMapVeto = Table.extract(match, 'mapveto') + local mapVeto = Logic.nilIfEmpty(Json.parseIfTable(rawMapVeto) or rawMapVeto) + local mapVetoDisplay = mapVeto and ('|mapveto={{MapVeto' .. MatchGroupLegacy._argsToString(mapVeto) .. '}}') or nil + return table.concat(Array.extend({'{{Match'}, addIndents({MatchGroupLegacy._argsToString(match)}), addIndents(opponents), addIndents(maps), + addIndents({mapVetoDisplay}), '}}' ), '\n') end @@ -511,6 +577,7 @@ end ---@param opp table ---@return string function MatchGroupLegacy._generateOpponent(opp) + if Logic.isEmpty(opp) then return '' end local opponentType = Table.extract(opp, 'type') local opponentTemplate = String.upperCaseFirst(opponentType) .. 'Opponent' @@ -532,6 +599,7 @@ end ---@param args table ---@return string function MatchGroupLegacy._argsToString(args) + if Logic.isEmpty(args) then return '' end local otherArgs = {} local compare = function(tbl, a, b) if type(a) == type(b) then @@ -544,7 +612,17 @@ function MatchGroupLegacy._argsToString(args) end for key, value in Table.iter.spairs(args, compare) do - table.insert(otherArgs, '|' .. key .. '=' .. tostring(value)) + value = Json.parseIfTable(value) or value + local val + if type(value) == 'table' and Logic.isNotEmpty(value) then + val = '{{Json' .. MatchGroupLegacy._argsToString(value) .. '}}' + elseif type(value) ~= 'table' then + val = tostring(value) + end + val = Logic.nilIfEmpty(val) + if val then + table.insert(otherArgs, '|' .. key .. '=' .. val) + end end return table.concat(otherArgs) diff --git a/lua/wikis/dota2/MatchMaps/Legacy.lua b/lua/wikis/dota2/MatchMaps/Legacy.lua index d48d03502cb..7da289fb0e0 100644 --- a/lua/wikis/dota2/MatchMaps/Legacy.lua +++ b/lua/wikis/dota2/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') @@ -210,6 +211,8 @@ end ---@return string|Html function MatchMapsLegacy.convertMatch(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local details = Json.parseIfString(args.details or '{}') args, details = MatchMapsLegacy._handleDetails(args, details) @@ -217,7 +220,7 @@ function MatchMapsLegacy.convertMatch(frame) args = MatchMapsLegacy._setHeaderIfEmpty(args, details) args = MatchMapsLegacy._copyDetailsToArgs(args, details) - if Logic.readBool(matchlistVars:get('isOldMatchList')) then + if generate or Logic.readBool(matchlistVars:get('isOldMatchList')) then return Json.stringify(args) else Template.stashReturnValue(args, 'LegacyMatchlist') @@ -245,7 +248,7 @@ function MatchMapsLegacy.showmatch(frame) id = args.id, hide = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, R1M1 = matches[1] }) @@ -258,8 +261,9 @@ end -- invoked by Template:MatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) local args = Arguments.getArgs(frame) assert(args.id, 'Missing id') @@ -270,7 +274,7 @@ function MatchMapsLegacy.matchList(frame) local hide = Logic.nilOr(Logic.readBoolOrNil(args.hide), true) args.isLegacy = true args.store = store - args.noDuplicateCheck = not store + args.noDuplicateCheck = not store or nil args.collapsed = hide args.attached = hide args.title = Logic.nilOr(args.title, args[1]) @@ -293,6 +297,10 @@ function MatchMapsLegacy.matchList(frame) args[1] = nil args.hide = nil + if generate then + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + return MatchGroup.MatchList(args) end @@ -329,7 +337,7 @@ function MatchMapsLegacy.matchListEnd() isLegacy = true, id = bracketId, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = matchlistVars:get('matchListTitle'), @@ -374,4 +382,84 @@ function MatchMapsLegacy.matchListEnd() return MatchGroup.MatchList(args) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate2(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + local gsl = args.gsl + if Logic.isNotEmpty(gsl) then + gsl = gsl:lower() + if String.endsWith(gsl, GSL_WINNERS) then + gsl = 'winnersfirst' + elseif String.endsWith(gsl, GSL_SEEDING) then + gsl = 'winnersfirst' + parsedArgs['M4header'] = 'Losers Match' + elseif String.endsWith(gsl, GSL_LOSERS) then + if String.startsWith(gsl, GSL_SEEDING) then + parsedArgs['M3header'] = 'Losers Match' + end + gsl = 'losersfirst' + end + parsedArgs.gsl = gsl + end + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return args[index + offset] + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +---@param frame Frame +---@return string +function MatchMapsLegacy.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.convertMatch(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacy diff --git a/lua/wikis/hearthstone/MatchGroup/Legacy/Default.lua b/lua/wikis/hearthstone/MatchGroup/Legacy/Default.lua index 3293817bb0e..920a5b858dd 100644 --- a/lua/wikis/hearthstone/MatchGroup/Legacy/Default.lua +++ b/lua/wikis/hearthstone/MatchGroup/Legacy/Default.lua @@ -66,6 +66,11 @@ end ---@param match table function MatchGroupLegacyDefault:handleOtherMatchParams(isReset, match) match.winner = Table.extract(match, 'win') + for key in pairs(match) do + if string.match(key, '^p%d+') then + match[key] = nil + end + end end ---@param frame Frame diff --git a/lua/wikis/hearthstone/MatchMaps/Legacy.lua b/lua/wikis/hearthstone/MatchMaps/Legacy.lua index ae3dfa9499d..7bd573ce08e 100644 --- a/lua/wikis/hearthstone/MatchMaps/Legacy.lua +++ b/lua/wikis/hearthstone/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -68,12 +69,15 @@ end ---@param frame Frame ---@return string|Html function MatchMapsLegacy.convertMatch(frame) - local matchArgs = MatchMapsLegacy._mergeDetailsIntoArgs(Arguments.getArgs(frame)) + local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + + local matchArgs = MatchMapsLegacy._mergeDetailsIntoArgs(args) MatchMapsLegacy._readOpponents(matchArgs) MatchMapsLegacy._readMaps(matchArgs) - if Logic.readBool(matchlistVars:get('isOldMatchList')) then + if generate or Logic.readBool(matchlistVars:get('isOldMatchList')) then return Json.stringify(matchArgs) else Template.stashReturnValue(matchArgs, 'LegacyMatchlist') @@ -103,7 +107,7 @@ function MatchMapsLegacy._start(args) collapsed = hide, attached = hide, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, gsl = Logic.isNotEmpty(args.gsl) and args.gsl .. 'first' or nil } @@ -112,8 +116,9 @@ end -- invoked by Template:LegacyMatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) local args = Arguments.getArgs(frame) local matchListArgs = MatchMapsLegacy._start(args) @@ -130,6 +135,11 @@ function MatchMapsLegacy.matchList(frame) matchlistVars:delete('isOldMatchList') globalVars:delete('islegacy') + if generate then + matchListArgs.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(matchListArgs) + end + return MatchGroup.MatchList(matchListArgs) end @@ -159,4 +169,54 @@ function MatchMapsLegacy.matchListEnd() globalVars:delete('islegacy') return MatchGroup.MatchList(matchListArgs) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate2(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.readBoolOrNil(args.hide), + attached = Logic.readBoolOrNil(args.hide), + store = store, + patch = args.patch, + gsl = Logic.isNotEmpty(args.gsl) and args.gsl .. 'first' or nil, + } + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + return MatchMapsLegacy diff --git a/lua/wikis/heroes/MatchMaps/Legacy.lua b/lua/wikis/heroes/MatchMaps/Legacy.lua index 222d6e3aa09..5cd85a46eff 100644 --- a/lua/wikis/heroes/MatchMaps/Legacy.lua +++ b/lua/wikis/heroes/MatchMaps/Legacy.lua @@ -11,6 +11,7 @@ local Arguments = Lua.import('Module:Arguments') local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -125,10 +126,15 @@ function MatchMapsLegacy.convertMatch(frame) return Match.makeEncodedJson(matchArgs) end +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + -- invoked by Template:MatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) local args = Arguments.getArgs(frame) assert(args.id, 'Missing id') local store = Logic.nilOr( @@ -142,7 +148,7 @@ function MatchMapsLegacy.matchList(frame) width = args.width, isLegacy = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide } @@ -153,6 +159,11 @@ function MatchMapsLegacy.matchList(frame) end globalVars:delete('islegacy') + if generate then + newArgs.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(newArgs) + end + return MatchGroup.MatchList(newArgs) end diff --git a/lua/wikis/honorofkings/MatchMaps/Legacy.lua b/lua/wikis/honorofkings/MatchMaps/Legacy.lua index ded6462f0a0..e9db5764d8f 100644 --- a/lua/wikis/honorofkings/MatchMaps/Legacy.lua +++ b/lua/wikis/honorofkings/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -60,6 +61,16 @@ function MatchMapsLegacy._handleMaps(args) args[mapKey .. 'winner'] = Table.extract(args, mapKey .. 'win') args[matchKey] = nil end + + --need to determine bestof here already for brackets... + --need to create a copy here to not affect the real args + local copy = Table.deepCopy(args) + + if not args.bestof then + local res = MatchMapsLegacy._handleDetails({}, copy) + args.bestof = res.bestof + end + return args end @@ -91,7 +102,7 @@ end function MatchMapsLegacy._handleDetails(args, details) local getMapFromDetails = function (index) local prefix = 'map' .. index - if not details[prefix] then + if not details[prefix] and not details[prefix .. 'winner'] then return nil end local map = { @@ -124,7 +135,7 @@ function MatchMapsLegacy._handleDetails(args, details) } end - Array.mapIndexes(function (index) + local maps = Array.mapIndexes(function (index) local map = getMapFromDetails(index) or getMapOnlyWithWinner(index) if map and map.winner then args.mapWinnersSet = true @@ -134,9 +145,33 @@ function MatchMapsLegacy._handleDetails(args, details) return map end) + -- determine bestofFromMaps + args.bestof = args.bestof or MatchMapsLegacy._bestofHeuristic(maps) + return args, details end +---@param maps table[] +---@return integer? +function MatchMapsLegacy._bestofHeuristic(maps) + if Logic.isEmpty(maps) then return end + + local wins = {0, 0} + Array.forEach(maps, function(map) + local winner = tonumber(map.winner) + if winner == 1 then + wins[1] = wins[1] + 1 + elseif winner == 2 then + wins[2] = wins[2] + 1 + end + end) + + local firstTo = math.max(unpack(wins)) + local bestof = firstTo * 2 - 1 + if bestof <= 0 then return end + return bestof +end + ---@param args table ---@return table function MatchMapsLegacy._handleOpponents(args) @@ -221,8 +256,9 @@ end -- invoked by Template:MatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) local args = Arguments.getArgs(frame) assert(args.id, 'Missing id') @@ -233,7 +269,7 @@ function MatchMapsLegacy.matchList(frame) local hide = Logic.nilOr(Logic.readBoolOrNil(args.hide), true) args.isLegacy = true args.store = store - args.noDuplicateCheck = not store + args.noDuplicateCheck = not store or nil args.collapsed = hide args.attached = hide args.title = Logic.nilOr(args.title, args[1]) @@ -258,7 +294,16 @@ function MatchMapsLegacy.matchList(frame) args.hide = nil args.lpdb_title = nil + if generate then + args.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + return MatchGroup.MatchList(args) end +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + return MatchMapsLegacy diff --git a/lua/wikis/leagueoflegends/MatchMaps/Legacy.lua b/lua/wikis/leagueoflegends/MatchMaps/Legacy.lua index 2bea18b4012..0754e1a7668 100644 --- a/lua/wikis/leagueoflegends/MatchMaps/Legacy.lua +++ b/lua/wikis/leagueoflegends/MatchMaps/Legacy.lua @@ -14,6 +14,7 @@ local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') local Template = Lua.import('Module:Template') @@ -214,6 +215,8 @@ end ---@return string|Html function MatchMapsLegacy.convertMatch(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local details = Json.parseIfString(args.details or '{}') args, details = MatchMapsLegacy.handleDetails(args, details) @@ -222,7 +225,7 @@ function MatchMapsLegacy.convertMatch(frame) args = MatchMapsLegacy.setHeaderIfEmpty(args, details) args = MatchMapsLegacy.copyDetailsToArgs(args, details) - if Logic.readBool(matchlistVars:get('isOldMatchList')) then + if generate or Logic.readBool(matchlistVars:get('isOldMatchList')) then return Json.stringify(args) else Template.stashReturnValue(args, 'LegacyMatchlist') @@ -232,8 +235,9 @@ end -- invoked by Template:MatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) local args = Arguments.getArgs(frame) assert(args.id, 'Missing id') @@ -244,7 +248,7 @@ function MatchMapsLegacy.matchList(frame) local hide = Logic.nilOr(Logic.readBoolOrNil(args.hide), true) args.isLegacy = true args.store = store - args.noDuplicateCheck = not store + args.noDuplicateCheck = not store or nil args.collapsed = hide args.attached = hide args.title = Logic.nilOr(args.title, args[1]) @@ -272,6 +276,10 @@ function MatchMapsLegacy.matchList(frame) args.hide = nil args.lpdb_title = nil + if generate then + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + return MatchGroup.MatchList(args) end @@ -311,7 +319,7 @@ function MatchMapsLegacy.matchListEnd() isLegacy = true, id = bracketId, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = matchlistVars:get('matchListTitle'), @@ -340,4 +348,53 @@ function MatchMapsLegacy.matchListEnd() return MatchGroup.MatchList(args) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate2(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + patch = args.patch, + } + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return args[index + offset] + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + return MatchMapsLegacy diff --git a/lua/wikis/overwatch/MatchMaps/Legacy.lua b/lua/wikis/overwatch/MatchMaps/Legacy.lua index e605c0a9b1c..ee0e0448a2c 100644 --- a/lua/wikis/overwatch/MatchMaps/Legacy.lua +++ b/lua/wikis/overwatch/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') local Template = Lua.import('Module:Template') @@ -184,6 +185,8 @@ end ---@return string|Html function MatchMapsLegacy.convertMatch(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local details = Json.parseIfString(args.details or '{}') args, details = MatchMapsLegacy._handleDetails(args, details) @@ -191,7 +194,7 @@ function MatchMapsLegacy.convertMatch(frame) args = MatchMapsLegacy._setHeaderIfEmpty(args, details) args = MatchMapsLegacy._copyDetailsToArgs(args, details) - if Logic.readBool(matchlistVars:get('isOldMatchList')) then + if generate or Logic.readBool(matchlistVars:get('isOldMatchList')) then return Json.stringify(args) else Template.stashReturnValue(args, 'LegacyMatchlist') @@ -219,7 +222,7 @@ function MatchMapsLegacy.showmatch(frame) id = args.id, hide = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, R1M1 = matches[1] }) @@ -231,8 +234,9 @@ end -- invoked by Template:MatchList ---@param frame Frame +---@param generate true? ---@return string -function MatchMapsLegacy.matchList(frame) +function MatchMapsLegacy.matchList(frame, generate) local args = Arguments.getArgs(frame) assert(args.id, 'Missing id') @@ -243,7 +247,7 @@ function MatchMapsLegacy.matchList(frame) local hide = Logic.nilOr(Logic.readBoolOrNil(args.hide), true) args.isLegacy = true args.store = store - args.noDuplicateCheck = not store + args.noDuplicateCheck = not store or nil args.collapsed = hide args.attached = hide args.title = Logic.nilOr(args.title, args[1]) @@ -270,6 +274,11 @@ function MatchMapsLegacy.matchList(frame) args.hide = nil args.lpdb_title = nil + if generate then + args.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + return MatchGroup.MatchList(args) end @@ -304,7 +313,7 @@ function MatchMapsLegacy.matchListEnd() isLegacy = true, id = bracketId, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = matchlistVars:get('matchListTitle'), @@ -328,4 +337,63 @@ function MatchMapsLegacy.matchListEnd() return MatchGroup.MatchList(args) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + return MatchMapsLegacy.matchList(frame, true) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate2(frame) + local args = Arguments.getArgs(frame) + args.isLegacy = nil + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return args[index + offset] + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +---@param frame Frame +---@return string +function MatchMapsLegacy.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.convertMatch(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacy diff --git a/lua/wikis/rainbowsix/MatchMaps/Legacy.lua b/lua/wikis/rainbowsix/MatchMaps/Legacy.lua index 11ee4d19c30..7bd5a660d65 100644 --- a/lua/wikis/rainbowsix/MatchMaps/Legacy.lua +++ b/lua/wikis/rainbowsix/MatchMaps/Legacy.lua @@ -31,105 +31,110 @@ function MatchMaps.main(frame) end function MatchMaps._main(args) - -- Data storage (LPDB) - if Logic.readBool(matchlistVars:get('store')) then - - --preparing storage as match2 in lpdb id bracketid is set - if matchlistVars:get('bracketid') then - --convert params for match2 storage - local storage_args = {} - local details = Json.parseIfString(args.details) or {} - - storage_args.title = args.date - - --opponents - for i = 1, 2 do - if args['team' .. i] and args['team' .. i]:lower() == 'bye' then - storage_args['opponent' .. i] = { - ['type'] = 'literal', - name = 'BYE', - } - elseif args['team' .. i] == '' then - storage_args['opponent' .. i] = { - ['type'] = 'literal', - name = '', - } - else - storage_args['opponent' .. i] = { - ['type'] = 'team', - template = args['team' .. i], - score = args['games' .. i], - } - end - end - - if tonumber(args.walkover) then - storage_args['opponent1'].score = tonumber(args.walkover) == 1 and 'W' or 'FF' - storage_args['opponent2'].score = tonumber(args.walkover) == 2 and 'W' or 'FF' - end - - --maps - for i = 1, MAX_GAME_NUM do - local prefix = 'map' .. i - if Logic.isNotEmpty(details[prefix]) or Logic.isNotEmpty(details[prefix ..'finished']) then - storage_args[prefix] = { - map = Table.extract(details, prefix) or 'Unknown', - finished = Table.extract(details, prefix..'finished'), - score1 = Table.extract(details, prefix..'score1'), - score2 = Table.extract(details, prefix..'score2'), - t1ban1 = Table.extract(details, prefix..'t1ban1'), - t1ban2 = Table.extract(details, prefix..'t1ban2'), - t2ban1 = Table.extract(details, prefix..'t2ban1'), - t2ban2 = Table.extract(details, prefix..'t2ban2'), - t1firstside = Table.extract(details, prefix..'t1firstside'), - t1firstsideot = Table.extract(details, prefix..'o1t1firstside'), - t1atk = Table.extract(details, prefix..'t1atk'), - t1def = Table.extract(details, prefix..'t1def'), - t2atk = Table.extract(details, prefix..'t2atk'), - t2def = Table.extract(details, prefix..'t2def'), - t1otatk = Table.extract(details, prefix..'o1t1atk'), - t1otdef = Table.extract(details, prefix..'o1t1def'), - t2otatk = Table.extract(details, prefix..'o1t2atk'), - t2otdef = Table.extract(details, prefix..'o1t2def'), - vod = Table.extract(details, 'vod'..i), - winner = Table.extract(details, prefix .. 'win'), - } - else - break - end - end - - storage_args.mapveto = Json.parseIfString(Table.extract(details, 'mapveto')) - - storage_args.date = Table.extract(details, 'date') - -- It's legacy, let's assume it's finished - storage_args.finished = true - details.finished = nil - - for key, value in pairs(details) do - storage_args[key] = value - end - - local opp1score, opp2score = storage_args.opponent1.score, storage_args.opponent2.score - -- Legacy maps are Bo10 or Bo12, while >Bo5 in legacy matches are non existent - -- Let's assume that if the sum of the scores is less than 6, it's a match, otherwise it's a map - if (tonumber(opp1score) or 0) + (tonumber(opp2score) or 0) < 6 then - Template.stashReturnValue(storage_args, 'LegacyMatchlist') - return - end - - storage_args.opponent1.score = nil - storage_args.opponent2.score = nil - storage_args.map1 = storage_args.map1 or { - map = 'Unknown', - finished = true, - score1 = opp1score, - score2 = opp2score, + local generate = Logic.readBool(Table.extract(args, 'generate')) + + if not generate and (not Logic.readBool(matchlistVars:get('store')) or not matchlistVars:get('bracketid')) then + return + end + + local storage_args = {} + local details = Json.parseIfString(args.details) or {} + + storage_args.title = args.date + + --opponents + for i = 1, 2 do + if args['team' .. i] and args['team' .. i]:lower() == 'bye' then + storage_args['opponent' .. i] = { + ['type'] = 'literal', + name = 'BYE', + } + elseif args['team' .. i] == '' then + storage_args['opponent' .. i] = { + ['type'] = 'literal', + name = '', + } + else + storage_args['opponent' .. i] = { + ['type'] = 'team', + template = args['team' .. i], + score = args['games' .. i], + } + end + end + + if tonumber(args.walkover) then + storage_args['opponent1'].score = tonumber(args.walkover) == 1 and 'W' or 'FF' + storage_args['opponent2'].score = tonumber(args.walkover) == 2 and 'W' or 'FF' + end + + --maps + for i = 1, MAX_GAME_NUM do + local prefix = 'map' .. i + if Logic.isNotEmpty(details[prefix]) or Logic.isNotEmpty(details[prefix ..'finished']) then + storage_args[prefix] = { + map = Table.extract(details, prefix) or 'Unknown', + finished = Table.extract(details, prefix..'finished'), + score1 = Table.extract(details, prefix..'score1'), + score2 = Table.extract(details, prefix..'score2'), + t1ban1 = Table.extract(details, prefix..'t1ban1'), + t1ban2 = Table.extract(details, prefix..'t1ban2'), + t2ban1 = Table.extract(details, prefix..'t2ban1'), + t2ban2 = Table.extract(details, prefix..'t2ban2'), + t1firstside = Table.extract(details, prefix..'t1firstside'), + t1firstsideot = Table.extract(details, prefix..'o1t1firstside'), + t1atk = Table.extract(details, prefix..'t1atk'), + t1def = Table.extract(details, prefix..'t1def'), + t2atk = Table.extract(details, prefix..'t2atk'), + t2def = Table.extract(details, prefix..'t2def'), + t1otatk = Table.extract(details, prefix..'o1t1atk'), + t1otdef = Table.extract(details, prefix..'o1t1def'), + t2otatk = Table.extract(details, prefix..'o1t2atk'), + t2otdef = Table.extract(details, prefix..'o1t2def'), + vod = Table.extract(details, 'vod'..i), + winner = Table.extract(details, prefix .. 'win'), } + else + break + end + end + + storage_args.mapveto = Json.parseIfString(Table.extract(details, 'mapveto')) + + storage_args.date = Table.extract(details, 'date') + -- It's legacy, let's assume it's finished + storage_args.finished = true + details.finished = nil - Template.stashReturnValue(storage_args, 'LegacyMatchlist') + for key, value in pairs(details) do + storage_args[key] = value + end + + local opp1score, opp2score = storage_args.opponent1.score, storage_args.opponent2.score + -- Legacy maps are Bo10 or Bo12, while >Bo5 in legacy matches are non existent + -- Let's assume that if the sum of the scores is less than 6, it's a match, otherwise it's a map + if (tonumber(opp1score) or 0) + (tonumber(opp2score) or 0) < 6 then + if generate then + return Json.stringify(storage_args) end + Template.stashReturnValue(storage_args, 'LegacyMatchlist') + return end + + storage_args.opponent1.score = nil + storage_args.opponent2.score = nil + storage_args.map1 = storage_args.map1 or { + map = 'Unknown', + finished = true, + score1 = opp1score, + score2 = opp2score, + } + + if generate then + return Json.stringify(storage_args) + end + + Template.stashReturnValue(storage_args, 'LegacyMatchlist') end return MatchMaps diff --git a/lua/wikis/rainbowsix/MatchMaps/Legacy/Store.lua b/lua/wikis/rainbowsix/MatchMaps/Legacy/Store.lua index dfc00bb3eeb..dfb2349aa90 100644 --- a/lua/wikis/rainbowsix/MatchMaps/Legacy/Store.lua +++ b/lua/wikis/rainbowsix/MatchMaps/Legacy/Store.lua @@ -16,9 +16,12 @@ local Lua = require('Module:Lua') local Arguments = Lua.import('Module:Arguments') +local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') +local MatchMapsLegacy = Lua.import('Module:MatchMaps/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Template = Lua.import('Module:Template') @@ -113,7 +116,6 @@ function MatchMapsLegacyStore.close() return matchHtml end - -- Invoked by LegacySingleMatch (previously Template:Showmatch) function MatchMapsLegacyStore.closeSingle(frame) local args = Arguments.getArgs(frame) @@ -151,4 +153,78 @@ function MatchMapsLegacyStore.closeSingle(frame) return matchHtml end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string? +function MatchMapsLegacyStore.generate2(frame) + local args = Arguments.getArgs(frame) + + local bracketId = args.id + if bracketId == 'abcs' then + return + end + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = bracketId, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + local gsl = args.gsl + + Array.forEach(matches, function(match, matchIndex) + local header = match.title + if matchIndex == 1 and (gsl == 'winners' or gsl == 'losers') then + header = 'Opening Matches' + elseif (matchIndex == 3 and gsl == 'winners') or (matchIndex == 4 and gsl == 'losers') then + header = 'Winners Match' + elseif (matchIndex == 4 and gsl == 'winners') or (matchIndex == 3 and gsl == 'losers') then + header = 'Elimination Match' + elseif matchIndex == 5 and (gsl == 'winners' or gsl == 'losers') then + header = 'Decider Match' + end + parsedArgs['M' .. matchIndex .. 'header'] = header + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +---@param frame Frame +---@return string +function MatchMapsLegacyStore.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.main(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacyStore diff --git a/lua/wikis/rocketleague/LegacyMatchList.lua b/lua/wikis/rocketleague/LegacyMatchList.lua index 6151fd2a6aa..5564cf13a08 100644 --- a/lua/wikis/rocketleague/LegacyMatchList.lua +++ b/lua/wikis/rocketleague/LegacyMatchList.lua @@ -13,12 +13,17 @@ local Logic = Lua.import('Module:Logic') local Table = Lua.import('Module:Table') local Arguments = Lua.import('Module:Arguments') local Json = Lua.import('Module:Json') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local ALLOWED_STATUSES = { 'W', 'FF', 'DQ', 'L' } local _MAX_NUMBER_OF_MATCHES = 64 local _MAX_NUMBER_OF_MAPS = 15 -function LegacyMatchList.convertMatchList(frame) +function LegacyMatchList.generate(frame) + return LegacyMatchList.convertMatchList(frame, true) +end + +function LegacyMatchList.convertMatchList(frame, generate) local args = Arguments.getArgs(frame) --switch matches (and headers) to the correct parameters for the new system @@ -50,6 +55,11 @@ function LegacyMatchList.convertMatchList(frame) args.title = args[1] end args[1] = nil + + if generate then + return MatchGroupLegacy.generateWikiCodeForMatchList(args) + end + args.isLegacy = true --pass the adjusted arguments to the MatchGroup diff --git a/lua/wikis/squadrons/MatchGroup/Legacy/MatchList.lua b/lua/wikis/squadrons/MatchGroup/Legacy/MatchList.lua index 92a1444ed9f..63cef32a30f 100644 --- a/lua/wikis/squadrons/MatchGroup/Legacy/MatchList.lua +++ b/lua/wikis/squadrons/MatchGroup/Legacy/MatchList.lua @@ -8,10 +8,12 @@ local Lua = require('Module:Lua') local Arguments = Lua.import('Module:Arguments') +local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -24,6 +26,42 @@ local MatchMapsLegacy = {} local NUMBER_OF_OPPONENTS = 2 +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + -- invoked by Template:Legacy Match list start function MatchMapsLegacy.init(frame) local args = Arguments.getArgs(frame) @@ -43,6 +81,8 @@ end function MatchMapsLegacy.matchMaps(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local processedArgs = Table.copy(args) MatchMapsLegacy._handleOpponents(processedArgs) @@ -58,6 +98,10 @@ function MatchMapsLegacy.matchMaps(frame) -- all other args from the match maps calls are just passed along directly -- as they can be read by the match2 processing + if generate then + return Json.stringify(processedArgs) + end + Template.stashReturnValue(processedArgs, 'LegacyMatchlist') end diff --git a/lua/wikis/starcraft/MatchMaps/Legacy.lua b/lua/wikis/starcraft/MatchMaps/Legacy.lua index 541d067301a..a90c8ae332d 100644 --- a/lua/wikis/starcraft/MatchMaps/Legacy.lua +++ b/lua/wikis/starcraft/MatchMaps/Legacy.lua @@ -12,6 +12,7 @@ local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') local Variables = Lua.import('Module:Variables') @@ -27,7 +28,13 @@ function MatchMapsLegacy.matchlist(frame) return MatchMapsLegacy._matchlist(args) end -function MatchMapsLegacy._matchlist(args) +-- invoked by Template:LegacyMatchList +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + return MatchMapsLegacy._matchlist(args, true) +end + +function MatchMapsLegacy._matchlist(args, generate) local store = Logic.nilOr( Logic.readBoolOrNil(args.store), not Logic.readBool(Variables.varDefault('disable_LPDB_storage')) @@ -61,7 +68,7 @@ function MatchMapsLegacy._matchlist(args) end matches.id = bracketId - matches.isLegacy = true + matches.isLegacy = not generate or nil matches.title = Logic.emptyOr(args.title, args[1], 'Match List') matches.width = args.width local hide = Logic.readBool(Logic.emptyOr(args.hide, true)) @@ -78,6 +85,10 @@ function MatchMapsLegacy._matchlist(args) matches.store = false end + if generate then + return MatchGroupLegacy.generateWikiCodeForMatchList(matches) + end + -- generate Display -- this also stores the MatchData local matchListHtml = MatchGroup.MatchList(matches) diff --git a/lua/wikis/starcraft2/MatchMaps/Legacy.lua b/lua/wikis/starcraft2/MatchMaps/Legacy.lua index 83ca0b8938e..785c9cc9f82 100644 --- a/lua/wikis/starcraft2/MatchMaps/Legacy.lua +++ b/lua/wikis/starcraft2/MatchMaps/Legacy.lua @@ -8,12 +8,16 @@ local Lua = require('Module:Lua') local Arguments = Lua.import('Module:Arguments') -local String = Lua.import('Module:StringUtils') +local Array = Lua.import('Module:Array') +local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') -local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') -local Template = Lua.import('Module:Template') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') +local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') +local String = Lua.import('Module:StringUtils') +local Table = Lua.import('Module:Table') +local Template = Lua.import('Module:Template') local globalVars = PageVariableNamespace() local matchlistVars = PageVariableNamespace('LegacyMatchlist') @@ -24,6 +28,42 @@ local _storageArgs local _NUMBER_OF_OPPONENTS = 2 +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + -- invoked by Template:Legacy Match list start function MatchMapsLegacy.init(frame) local args = Arguments.getArgs(frame) @@ -52,6 +92,9 @@ end function MatchMapsLegacy._preProcess(args) _storageArgs = args + + local generate = Logic.readBool(Table.extract(args, 'generate')) + MatchMapsLegacy._handleOpponents() MatchMapsLegacy._handleMaps() @@ -62,6 +105,10 @@ function MatchMapsLegacy._preProcess(args) -- all other args from the match maps calls are just passed along directly -- as they can be read by the match2 processing + if generate then + return Json.stringify(args) + end + Template.stashReturnValue(args, 'LegacyMatchlist') end diff --git a/lua/wikis/starcraft2/MatchMapsTeam/Legacy.lua b/lua/wikis/starcraft2/MatchMapsTeam/Legacy.lua deleted file mode 100644 index fd0ca263147..00000000000 --- a/lua/wikis/starcraft2/MatchMapsTeam/Legacy.lua +++ /dev/null @@ -1,177 +0,0 @@ ---- --- @Liquipedia --- page=Module:MatchMapsTeam/Legacy --- --- Please see https://github.com/Liquipedia/Lua-Modules to contribute --- - -local Lua = require('Module:Lua') - -local Arguments = Lua.import('Module:Arguments') -local String = Lua.import('Module:StringUtils') -local Logic = Lua.import('Module:Logic') -local Template = Lua.import('Module:Template') -local Json = Lua.import('Module:Json') -local Table = Lua.import('Module:Table') - -local MatchMapsTeamLegacy = {} - -local _match2Args -local _args -local _opponentPlayers = {{}, {}} - -local _NUMBER_OF_OPPONENTS = 2 - --- invoked by Template:Match maps team -function MatchMapsTeamLegacy.preprocess(frame) - local args = Arguments.getArgs(frame) - return MatchMapsTeamLegacy._preProcess(args) -end - -function MatchMapsTeamLegacy._preProcess(args) - _match2Args = Json.parse(args.details or '{}') - - args.details = nil - _args = args - - MatchMapsTeamLegacy._handleMaps() - - MatchMapsTeamLegacy._handleOpponents() - - if args.date then - args.dateheader = true - end - - Template.stashReturnValue(Table.merge(args, _match2Args), 'LegacyMatchlist') -end - -function MatchMapsTeamLegacy._handleMaps() - local gameIndex = 1 - local prefix = 'm' .. gameIndex - local map = _match2Args[prefix .. 'map'] - local mapWinner = _match2Args[prefix .. 'win'] - - while map or mapWinner do - _match2Args['map' .. gameIndex] = MatchMapsTeamLegacy._processSingleMap(prefix, map, mapWinner, gameIndex) - - gameIndex = gameIndex + 1 - prefix = 'm' .. gameIndex - map = _match2Args[prefix .. 'map'] - mapWinner = _match2Args[prefix .. 'win'] - end - - prefix = 'ace' - map = _match2Args[prefix .. 'map'] - mapWinner = _match2Args[prefix .. 'win'] - - if map or mapWinner then - _match2Args['map' .. gameIndex] = MatchMapsTeamLegacy._processSingleMap(prefix, map, mapWinner, gameIndex) - end -end - -function MatchMapsTeamLegacy._processSingleMap(prefix, map, mapWinner, gameIndex) - local archon = Logic.readBool(_match2Args[prefix .. 'archon']) - - local mapArgs = { - map = map or 'unknown', - winner = mapWinner, - vod = _match2Args['vodgame' .. gameIndex], - } - mapArgs = MatchMapsTeamLegacy._processMapOpponent(1, prefix, mapArgs, archon) - mapArgs = MatchMapsTeamLegacy._processMapOpponent(2, prefix, mapArgs, archon) - - MatchMapsTeamLegacy._removeProcessedMapInput(prefix) - - return mapArgs -end - -function MatchMapsTeamLegacy._processMapOpponent(side, prefix, mapArgs, archon) - local addToMapArgs = { - ['t' .. side .. 'p1'] = String.isNotEmpty(_match2Args[prefix .. 'p' .. side .. 'link']) - and _match2Args[prefix .. 'p' .. side .. 'link'] - or _match2Args[prefix .. 'p' .. side], - ['t' .. side .. 'p1race'] = _match2Args[prefix .. 'p' .. side .. 'race'], - ['t' .. side .. 'p1flag'] = _match2Args[prefix .. 'p' .. side .. 'flag'], - - ['opponent' .. side .. 'archon'] = archon and 'true' or nil, - ['opponent' .. side .. 'race'] = archon and _match2Args[prefix .. 'p' .. side .. 'race'] or nil, - - ['t' .. side .. 'p2'] = String.isNotEmpty(_match2Args[prefix .. 't' .. side .. 'p2link']) - and _match2Args[prefix .. 't' .. side .. 'p2link'] - or _match2Args[prefix .. 't' .. side .. 'p2'], - ['t' .. side .. 'p2race'] = _match2Args[prefix .. 't' .. side .. 'p2race'], - ['t' .. side .. 'p2flag'] = _match2Args[prefix .. 't' .. side .. 'p2flag'], - - ['t' .. side .. 'p3'] = String.isNotEmpty(_match2Args[prefix .. 't' .. side .. 'p3link']) - and _match2Args[prefix .. 't' .. side .. 'p3link'] - or _match2Args[prefix .. 't' .. side .. 'p3'], - ['t' .. side .. 'p3race'] = _match2Args[prefix .. 't' .. side .. 'p3race'], - ['t' .. side .. 'p3flag'] = _match2Args[prefix .. 't' .. side .. 'p3flag'], - } - - MatchMapsTeamLegacy._setPlayersForOpponents(addToMapArgs, side, { - _match2Args[prefix .. 'p' .. side], - _match2Args[prefix .. 't' .. side .. 'p2'], - _match2Args[prefix .. 't' .. side .. 'p3'], - }) - - return Table.mergeInto(mapArgs, addToMapArgs) -end - -function MatchMapsTeamLegacy._setPlayersForOpponents(args, side, displayNames) - local prefix = 't' .. side .. 'p' - - for playerKey, player, playerIndex in Table.iter.pairsByPrefix(args, prefix) do - _opponentPlayers[side][player] = { - race = args[playerKey .. 'race'], - flag = args[playerKey .. 'flag'], - display = displayNames[playerIndex], - } - end -end - -function MatchMapsTeamLegacy._removeProcessedMapInput(prefix) - for key, _ in pairs(_match2Args) do - if String.startsWith(key, prefix) then - _match2Args[key] = nil - end - end -end - -function MatchMapsTeamLegacy._handleOpponents() - local args = _args - - for opponentIndex = 1, _NUMBER_OF_OPPONENTS do - if args['team' .. opponentIndex] and args['team' .. opponentIndex]:lower() == 'bye' then - _match2Args['opponent' .. opponentIndex] = { - ['type'] = 'literal', - name = 'BYE', - } - else - _match2Args['opponent' .. opponentIndex] = { - ['type'] = 'team', - template = args['team' .. opponentIndex], - score = args['score' .. opponentIndex], - } - if args['team' .. opponentIndex] == '' then - _match2Args['opponent' .. opponentIndex]['type'] = 'literal' - else - local players = {} - local playerIndex = 1 - for player, playerData in pairs(_opponentPlayers[opponentIndex]) do - players['p' .. playerIndex .. 'link'] = player - players['p' .. playerIndex] = playerData.display - players['p' .. playerIndex .. 'flag'] = playerData.flag - players['p' .. playerIndex .. 'race'] = playerData.race - playerIndex = playerIndex + 1 - end - _match2Args['opponent' .. opponentIndex].players = players - end - end - - args['team' .. opponentIndex] = nil - args['score' .. opponentIndex] = nil - end -end - -return MatchMapsTeamLegacy diff --git a/lua/wikis/trackmania/MatchGroup/Legacy/MatchList.lua b/lua/wikis/trackmania/MatchGroup/Legacy/MatchList.lua index f6ca4c002d7..cd3ab8862db 100644 --- a/lua/wikis/trackmania/MatchGroup/Legacy/MatchList.lua +++ b/lua/wikis/trackmania/MatchGroup/Legacy/MatchList.lua @@ -13,6 +13,7 @@ local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -68,6 +69,7 @@ function LegacyMatchList.matchMaps(frame) Template.stashReturnValue(processedArgs, 'LegacyMatchlist') return mw.html.create('div') else -- case matchlist version 2 + processedArgs.generate = nil return Json.stringify(processedArgs) end end @@ -95,6 +97,7 @@ end function LegacyMatchList._handleOpponents(processedArgs) for opponentIndex = 1, NUMBER_OF_OPPONENTS do local input = Table.extract(processedArgs, 'team' .. opponentIndex) + local player = Table.extract(processedArgs, 'player' .. opponentIndex) local score = Table.extract(processedArgs, 'games' .. opponentIndex) if (input or ''):lower() == 'bye' then processedArgs['opponent' .. opponentIndex] = { @@ -102,6 +105,14 @@ function LegacyMatchList._handleOpponents(processedArgs) name = 'BYE', score = score, } + elseif Logic.isNotEmpty(player) then + processedArgs['opponent' .. opponentIndex] = { + ['type'] = Opponent.solo, + name = player, + flag = Table.extract(processedArgs, 'p' .. opponentIndex .. 'flag'), + link = Table.extract(processedArgs, 'p' .. opponentIndex .. 'link'), + score = score, + } elseif Logic.isEmpty(input) then processedArgs['opponent' .. opponentIndex] = { ['type'] = Opponent.literal, @@ -167,7 +178,7 @@ end -- handle the second version of matchlists ... -- invoked by Template:LegacyMatchList -function LegacyMatchList.run(frame) +function LegacyMatchList.run(frame, generate) local args = Arguments.getArgs(frame) local store = Logic.nilOr( Logic.readBoolOrNil(args.store), @@ -178,7 +189,13 @@ function LegacyMatchList.run(frame) return args['match' .. matchIndex] end) + ---@type table local matchListArgs = Table.copy(matches) + if generate then + matchListArgs = Table.map(matchListArgs, function(index, value) + return 'M' .. index, Json.parseIfTable(value) or value + end) + end matchListArgs.id = args.id matchListArgs.isLegacy = true matchListArgs.title = args.title or args[1] or 'Match List' @@ -196,8 +213,55 @@ function LegacyMatchList.run(frame) matchListArgs.noDuplicateCheck = true matchListArgs.store = false end + if generate then + matchListArgs.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(matchListArgs) + end return MatchGroup.MatchList(matchListArgs) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchList.generate(frame) + return LegacyMatchList.run(frame, true) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchList.generate2(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + return LegacyMatchList diff --git a/lua/wikis/valorant/MatchMaps/Legacy.lua b/lua/wikis/valorant/MatchMaps/Legacy.lua index 8d7863d028d..44b35c18900 100644 --- a/lua/wikis/valorant/MatchMaps/Legacy.lua +++ b/lua/wikis/valorant/MatchMaps/Legacy.lua @@ -14,6 +14,7 @@ local Array = Lua.import('Module:Array') local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') @@ -251,7 +252,10 @@ end ---@return Html function MatchMapsLegacy.convertMatch(frame) local args = Arguments.getArgs(frame) - local details = Json.parseIfString(args.details or '{}') + + local generate = Logic.readBool(Table.extract(args, 'generate')) + + local details = Json.parseIfString(Table.extract(args, 'details') or '{}') args, details = MatchMapsLegacy._handleDetails(args, details) args = MatchMapsLegacy._handleOpponents(args) @@ -272,6 +276,10 @@ function MatchMapsLegacy.convertMatch(frame) } end + if generate then + return Json.stringify(args) + end + Template.stashReturnValue(args, 'LegacyMatchlist') return mw.html.create('div'):css('display', 'none') end @@ -296,7 +304,7 @@ function MatchMapsLegacy.showmatch(frame) id = args.id, hide = true, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, R1M1 = matches[1] }) @@ -340,7 +348,7 @@ function MatchMapsLegacy.matchListEnd() isLegacy = true, id = bracketId, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = matchlistVars:get('matchListTitle'), @@ -382,4 +390,69 @@ function MatchMapsLegacy.matchListEnd() return MatchGroup.MatchList(args) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + matchsection = args.matchsection, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + local gsl = args.gsl + if Logic.isNotEmpty(gsl) then + if String.endsWith(gsl:lower(), GSL_WINNERS) then + gsl = 'winnersfirst' + elseif String.endsWith(gsl:lower(), GSL_LOSERS) then + gsl = 'losersfirst' + end + if String.startsWith(gsl:lower(), GSL_GF) then + parsedArgs['M6header'] = 'Grand Final' + end + parsedArgs.gsl = gsl + end + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +---@param frame Frame +---@return string +function MatchMapsLegacy.generateSingleMatch(frame) + local args = Arguments.getArgs(frame) + args.generate = true + + assert(args.id, 'Missing id') + + return MatchGroupLegacy.generateWikiCodeForSingleMatch{ + match = MatchMapsLegacy.convertMatch(args), + id = args.id, + width = args.width, + } +end + return MatchMapsLegacy diff --git a/lua/wikis/warcraft/LegacyMatchMaps.lua b/lua/wikis/warcraft/LegacyMatchMaps.lua index 86c7c48c5f9..a7ab3b81419 100644 --- a/lua/wikis/warcraft/LegacyMatchMaps.lua +++ b/lua/wikis/warcraft/LegacyMatchMaps.lua @@ -15,6 +15,7 @@ local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -30,6 +31,66 @@ local BYE = 'BYE' local LegacyMatchMaps = {} +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchMaps.generateSolo(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local parsedArgs = { + id = args.id, + title = args.title, + width = args.width, + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + for _, matchInput, matchIndex in Table.iter.pairsByPrefix(args, 'match') do + parsedArgs['M' .. matchIndex] = LegacyMatchMaps._readSoloMatch(matchInput) + end + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function LegacyMatchMaps.generateTeam(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '350px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + } + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = Match.makeEncodedJson(match) + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + -- invoked by Template:MatchList ---@param frame Frame ---@return string @@ -49,7 +110,7 @@ function LegacyMatchMaps.solo(frame) collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, } for _, matchInput, matchIndex in Table.iter.pairsByPrefix(args, 'match') do @@ -77,6 +138,8 @@ function LegacyMatchMaps._readSoloMatch(matchInput) LegacyMatchMaps._readSoloOpponents(args) LegacyMatchMaps._readMaps(args) + args.details = nil + return Match.makeEncodedJson(args) end @@ -143,9 +206,10 @@ function LegacyMatchMaps._readMaps(args) end) map.vod = args['vodgame' .. mapIndex] args['vodgame' .. mapIndex] = nil - args[prefix .. 'finished'] = true + args[prefix .. 'finished'] = nil if Table.isNotEmpty(map) then + map.finished = true args[prefix] = map end end @@ -171,9 +235,12 @@ end -- invoked by Template:MatchMapsTeams ---@param frame Frame +---@return string? function LegacyMatchMaps.teamMatch(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + args = Table.merge(Json.parseIfString(args.details) or {}, args) args.details = nil @@ -181,6 +248,10 @@ function LegacyMatchMaps.teamMatch(frame) --map data gets preprocessed already due to using the same template as in brackets LegacyMatchMaps._readMaps(args) + if generate then + return Json.stringify(args) + end + Template.stashReturnValue(args, 'LegacyMatchlist') end @@ -197,10 +268,31 @@ function LegacyMatchMaps._readTeamOpponents(args) return end + local players = {} + + local parsePlayer = function(key, playerInput) + local index = string.match(key, '^opponent' .. opponentIndex .. '_p(%d+)$') + if not index then return end + args[key] = nil + local player = Json.parseIfTable(playerInput) + if Logic.isEmpty(player) then return end + ---@cast player -nil + local prefix = 'p' .. index + players[prefix] = player.name + players[prefix .. 'dn'] = player.displayname + players[prefix .. 'flag'] = player.flag + players[prefix .. 'race'] = player.race + end + + for key, item in pairs(args) do + parsePlayer(key, item) + end + args['opponent' .. opponentIndex] = { type = Opponent.team, template = template, score = args['games' .. opponentIndex], + players = Logic.nilIfEmpty(players) } args['games' .. opponentIndex] = nil @@ -222,7 +314,7 @@ function LegacyMatchMaps.teamClose() title = matchlistVars:get('matchListTitle'), width = matchlistVars:get('width'), store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, } diff --git a/lua/wikis/wildrift/MatchMaps/Legacy.lua b/lua/wikis/wildrift/MatchMaps/Legacy.lua index 8c04ecf5ea6..18ac6c27d38 100644 --- a/lua/wikis/wildrift/MatchMaps/Legacy.lua +++ b/lua/wikis/wildrift/MatchMaps/Legacy.lua @@ -14,6 +14,7 @@ local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local Json = Lua.import('Module:Json') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') local Template = Lua.import('Module:Template') @@ -214,6 +215,8 @@ end ---@return Html function MatchMapsLegacy.convertMatch(frame) local args = Arguments.getArgs(frame) + local generate = Logic.readBool(Table.extract(args, 'generate')) + local details = Json.parseIfString(args.details or '{}') args, details = MatchMapsLegacy.handleDetails(args, details) @@ -222,6 +225,9 @@ function MatchMapsLegacy.convertMatch(frame) args = MatchMapsLegacy.setHeaderIfEmpty(args, details) args = MatchMapsLegacy.copyDetailsToArgs(args, details) + if generate then + return Json.stringify(args) + end Template.stashReturnValue(args, 'LegacyMatchlist') return mw.html.create('div'):css('display', 'none') end @@ -262,7 +268,7 @@ function MatchMapsLegacy.matchListEnd() isLegacy = true, id = bracketId, store = store, - noDuplicateCheck = not store, + noDuplicateCheck = not store or nil, collapsed = hide, attached = hide, title = matchlistVars:get('matchListTitle'), @@ -291,4 +297,46 @@ function MatchMapsLegacy.matchListEnd() return MatchGroup.MatchList(args) end +--- for bot conversion to proper match2 matchlists +---@param frame Frame +---@return string +function MatchMapsLegacy.generate(frame) + local args = Arguments.getArgs(frame) + + local store = Logic.readBoolOrNil(args.store) + + local offset = 0 + local title = args.title + if not title and not Json.parseIfTable(args[1]) then + title = args[1] + offset = 1 + end + + local parsedArgs = { + id = args.id, + title = title, + width = args.width or '300px', + collapsed = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + attached = Logic.nilOr(Logic.readBoolOrNil(args.hide), true), + store = store, + patch = args.patch, + } + + local matchsection = Logic.nilOr(args.lpdb_title, args.title) + if Logic.readBoolOrNil(matchsection) ~= false then + parsedArgs.matchsection = matchsection + end + + ---@type table[] + local matches = Array.mapIndexes(function(index) + return Json.parseIfTable(args[index + offset]) + end) + + Array.forEach(matches, function(match, matchIndex) + parsedArgs['M' .. matchIndex] = match + end) + + return MatchGroupLegacy.generateWikiCodeForMatchList(parsedArgs) +end + return MatchMapsLegacy diff --git a/lua/wikis/worldofwarcraft/MatchGroup/Legacy/MatchList.lua b/lua/wikis/worldofwarcraft/MatchGroup/Legacy/MatchList.lua index 514d93d6d2f..c305b049bf9 100644 --- a/lua/wikis/worldofwarcraft/MatchGroup/Legacy/MatchList.lua +++ b/lua/wikis/worldofwarcraft/MatchGroup/Legacy/MatchList.lua @@ -13,6 +13,7 @@ local Json = Lua.import('Module:Json') local Logic = Lua.import('Module:Logic') local Match = Lua.import('Module:Match') local MatchGroup = Lua.import('Module:MatchGroup') +local MatchGroupLegacy = Lua.import('Module:MatchGroup/Legacy') local Opponent = Lua.import('Module:Opponent/Custom') local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') local Table = Lua.import('Module:Table') @@ -23,8 +24,12 @@ local NUMBER_OF_OPPONENTS = 2 local LegacyMatchList = {} +function LegacyMatchList.generate(frame) + return LegacyMatchList.run(frame, true) +end + -- invoked by Template:LegacyMatchList -function LegacyMatchList.run(frame) +function LegacyMatchList.run(frame, generate) local args = Arguments.getArgs(frame) local store = Logic.nilOr( Logic.readBoolOrNil(args.store), @@ -36,6 +41,11 @@ function LegacyMatchList.run(frame) end) local matchListArgs = Table.deepCopy(matches) + if generate then + matchListArgs = Table.map(matchListArgs, function(key, value) + return 'M' .. key, value + end) + end matchListArgs.id = args.id matchListArgs.isLegacy = true matchListArgs.title = args.title or args[1] or 'Match List' @@ -54,6 +64,11 @@ function LegacyMatchList.run(frame) matchListArgs.store = false end + if generate then + matchListArgs.isLegacy = nil + return MatchGroupLegacy.generateWikiCodeForMatchList(matchListArgs) + end + return MatchGroup.MatchList(matchListArgs) end diff --git a/matchConversionRuns.sh b/matchConversionRuns.sh new file mode 100644 index 00000000000..0d8ffeba307 --- /dev/null +++ b/matchConversionRuns.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +cd /home/hjpalpha + +#pwb replace -lang:starcraft -transcludes:"LegacyMatchList" -transcludes:"LegacyBracket" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyMatchList" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp" "\{\{[mM]atchMaps/Legacy" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=preprocess" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=BracketMatchSummary|fn=draw|generate=true" "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" + +#pwb replace -lang:starcraft2 -transcludes:"Legacy Match list start" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacy Match list start(.*?)\}\}\s*\n*\s*\{\{[mM]atch maps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=preprocess|dev=hjp|generate=true" "\{\{[mM]atch maps" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=preprocess|dev=hjp|generate=true" "\{\{[mM]atch list end\|?\}\}" "}}" + +#pwb replace -lang:warcraft -transcludes:"LegacyBracket" -transcludes:"LegacyMatchList" -transcludes:"LegacyMatchListStart" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*(\|?)\{\{" "{{subst:#invoke:Lua|invoke|module=LegacyMatchMaps|fn=generateTeam|dev=hjp\1\n\2{{" "\{\{[bB]racketTeamMatchMulti" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/ConvertMapData|fn=teamMulti|dev=hjp" "\{\{[bB]racketTeamMatch([^M])" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/ConvertMapData|fn=team|dev=hjp\1" "\{\{[gG]roupMatchSummary" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atchMaps([^T])" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs\1" "\{\{[lL]egacyMatchList([^S])" "{{subst:#invoke:Lua|invoke|module=LegacyMatchMaps|fn=generateSolo|dev=hjp\1" "\{\{[mM]atchListEnd\|?\}\}" "}}" "\{\{[mM]atchMapsTeams" "|{{subst:#invoke:Lua|invoke|module=LegacyMatchMaps|fn=teamMatch|dev=hjp|generate=true" "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" + +#pwb replace -lang:leagueoflegends -transcludes:"LegacyMatchListStart" -transcludes:"LegacyBracket" -summary:"Convert LegacyBrackets to Brackets" -pt:60 -regex -always -dotall "\{\{LegacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummaryL?u?a?" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertBracketMatchSummary|dev=hjp" "\{\{[mM]atchLua" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atch/old" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMapsL?u?a?" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|dev=hjp|fn=generate2\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|dev=hjp|fn=convertMatch|generate=true" "\{\{[mM]atchMapsL?u?a?" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|dev=hjp|fn=convertMatch|generate=true" "\{\{MatchListEnd\|?\}\}" "}}" + +#pwb replace -lang:rainbowsix -transcludes:"LegacyMatchListStart" -transcludes:"LegacyBracket" -transcludes:"LegacySingleMatch" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[Mm]apVetoTableSmall" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=LegacyBracketMatchSummary|fn=convert" "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy/Store|dev=hjp|fn=generate2\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=main|dev=hjp|generate=true" "\{\{[Mm]atchMaps" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=main|dev=hjp|generate=true" "\{\{[Mm]atchListEnd\|?\}\}" "}}" "\{\{[lL]egacySingleMatch" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy/Store|fn=generateSingleMatch|dev=hjp" "\{\{LegacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" + +#pwb replace -lang:overwatch -transcludes:"LegacyBracket" -transcludes:"LegacyMatchList" -transcludes:"LegacyMatchListStart" -transcludes:"LegacySingleMatch" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertBracketMatchSummary|dev=hjp" "\{\{[lL]egacyMatchList([^S])" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1" "\{\{[lL]egacySingleMatch" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generateSingleMatch|dev=hjp" "=[\s\n]*\{\{[mM]atchMaps" "={{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate2|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\}\}([\s\n]*)\{\{[mM]atchMaps" "}}\1|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\{\{[mM]atchListEnd\|?\}\}" "}}" + +#pwb replace -lang:valorant -transcludes:"LegacySingleMatch" -transcludes:"LegacyBracket" -transcludes:"LegacyMatchListStart" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[mM]apVetoTableSmall" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMapVeto|dev=hjp" "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[lL]egacySingleMatch" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generateSingleMatch|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertBracketMatchSummary|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\{\{[mM]atchMaps" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp|generate=true" "\{\{MatchListEnd\|?\}\}" "}}" + +#pwb replace -lang:callofduty -transcludes:"LegacyBracket" -transcludes:"LegacyMatchListStart" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=LegacyBracketMatchSummary|fn=run" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=match|generate=true|dev=hjp" "\{\{[mM]atchMaps" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=match|dev=hjp|generate=true" "\{\{MatchListEnd\|?\}\}" "}}" + +#pwb replace -lang:heroes -transcludes:"LegacyMatchList" -transcludes:"LegacyBracket" -summary:"Convert LegacyMatch2 wrappers" -pt:120 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertBracketMatchSummary|dev=hjp" "\{\{[mM]atch/old" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMap|dev=hjp" "\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp" "\{\{[lL]egacyMatchList" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp" + +#pwb replace -lang:arenafps -transcludes:"LegacyBracket" -transcludes:"LegacyMatchList" -transcludes:"LegacySingleMatch" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=LegacyBracketMatchSummary|fn=convert" "\{\{[lL]egacySingleMatch" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generateSingleMatch|dev=hjp" "\{\{[lL]egacyMatchList" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp" + +#pwb replace -lang:hearthstone -transcludes:"LegacyBracket" -transcludes:"LegacyMatchListStart" -transcludes:"LegacyMatchList" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[lL]egacyMatchList([^S])" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1" "\{\{[mM]atchMaps([^N])" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\{\{[mM]atchListEnd\|?\}\}" "}}" "\{\{[bB]racketMatchDetails" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[bB]racketMatchSummaryNew" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atchMapsNew" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMapsNew" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate2|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{subst" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate2|dev=hjp\1\n|{{subst" + +#pwb replace -lang:battalion -transcludes:"LegacyBracket" -transcludes:"LegacyMatchListStart" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[Mm]atchListEnd\|?\}\}" "}}" "\{\{[mM]atchMaps" "|{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=matchMaps|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMapsNew" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=matchMaps|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{subst" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate|dev=hjp\1\n|{{subst" + +#pwb replace -lang:ageofempires -transcludes:MatchSection -summary:"Prep to convert LegacyMatch2 wrappers" -pt:60 -regex -always "\{\{\s*[mM]atchSection\s*\|([^\}]*)\}\}\s*\n*\s*\{\{[mM]atch ?[mM]apsT?e?a?m?" "{{MatchMaps|matchsection=\1" + +#pwb replace -lang:ageofempires -transcludes:LegacySingleMatch -transcludes:LegacyBracket -transcludes:LegacyMatchListStart -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=LegacyBracketMatchSummary|fn=convert" "\{\{[mM]atchTeam" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[lL]egacySingleMatch" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generateSingleMatch|dev=hjp" "\{\{[mM]atchListEnd\|?\}\}" "}}" "\{\{[mM]atch list end\|?\}\}" "}}" "\{\{[mM]atch ?[mM]apsT?e?a?m?" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp|generate=true" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*(<\!\-\-.*?\-\->)?\s*\n*\s*\{\{[mM]atch ?[mM]apsT?e?a?m?" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp|generate=true" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*(<\!\-\-.*?\-\->)?\s*\n*\s*\|\{\{subst" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst" + +#pwb replace -lang:trackmania -transcludes:"LegacyBracket" -transcludes:"LegacyMatchListStart" -transcludes:"LegacyMatchList" -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[Mm]atchListEnd\|?\}\}" "}}" "\{\{[mM]atchMaps" "|{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=matchMaps|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate2|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=matchMaps|generate=true|dev=hjp" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{subst" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate2|dev=hjp\1\n|{{subst" "\|\s*match(\d+)\s*=\s*\|\{\{subst" "|match\1={{subst" "\{\{[lL]egacyMatchList" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate|dev=hjp" "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" + +#pwb replace -lang:wildrift -transcludes:LegacyBracket -transcludes:LegacyMatchListStart -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummaryL?u?a?" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertBracketMatchSummary|dev=hjp" "\{\{[mM]atchLua" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atch2" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atchMapsLua" "|{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp|generate=true" "\{\{[mM]atchListEnd\|?\}\}" "}}" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{subst" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{[mM]atchMapsLua" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp\1\n|{{subst" + +#pwb replace -lang:honorofkings -transcludes:LegacyBracket -transcludes:LegacyMatchList -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummaryL?u?a?" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertBracketMatchSummary|dev=hjp" "\{\{[mM]atchLua" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atchMapsL?u?a?" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=convertMatch|dev=hjp" "\{\{[lL]egacyMatchList" "{{subst:#invoke:Lua|invoke|module=MatchMaps/Legacy|fn=generate|dev=hjp" + +#pwb replace -lang:worldofwarcraft -transcludes:LegacyBracket -transcludes:LegacyMatchList -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atch/old" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[lL]egacyMatchList" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate|dev=hjp" + +#pwb replace -lang:squadrons -transcludes:LegacyBracket -transcludes:LegacyMatchListStart -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall "\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" "\{\{[bB]racketMatchSummary" "{{subst:#invoke:Lua|invoke|module=Json|fn=fromArgs" "\{\{[mM]atchListEnd\|?\s*\}\}" "}}" "\{\{[mM]atchMaps" "|{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=matchMaps|dev=hjp|generate=true" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{subst" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate|dev=hjp\1\n|{{subst" "\{\{[lL]egacyMatchListStart(.*?)\}\}\s*\n*\s*\|\{\{[mM]atchMaps" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=generate|dev=hjp\1\n|{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/MatchList|fn=matchMaps|dev=hjp|generate=true" + + + + + + +"" "" +"" "" +"" "" +"" "" +"" "" +"" "" +"" "" +"" "" +"" "" +"" "" +"" "" + +"\{\{[lL]egacyBracket" "{{subst:#invoke:Lua|invoke|module=MatchGroup/Legacy/Default|fn=runGenerate|dev=hjp" + +pwb replace -lang:.... -page:"...." -summary:"Convert LegacyMatch2 wrappers" -pt:60 -regex -always -dotall