Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions lua/wikis/fighters/MatchMaps/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 Opponent = Lua.import('Module:Opponent/Custom')
local PageVariableNamespace = Lua.import('Module:PageVariableNamespace')
local Table = Lua.import('Module:Table')
Expand Down Expand Up @@ -175,6 +176,7 @@ 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)
Expand All @@ -183,7 +185,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')
Expand Down Expand Up @@ -227,7 +229,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'),
Expand Down Expand Up @@ -256,4 +258,45 @@ 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

return MatchMapsLegacy
Loading