Skip to content
Open
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
94 changes: 94 additions & 0 deletions lua/wikis/pubg/MatchStandings/Legacy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
-- @Liquipedia
-- page=Module:MatchStandings/Legacy
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')

local Arguments = Lua.import('Module:Arguments')
local Array = Lua.import('Module:Array')
local Json = Lua.import('Module:Json')
local MatchGroup = Lua.import('Module:MatchGroup')
local Opponent = Lua.import('Module:Opponent/Custom')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
local Variables = Lua.import('Module:Variables')

local MatchStandingsLegacy = {}

---@param frame Frame
function MatchStandingsLegacy.run(frame)
local args = Arguments.getArgs(frame)

MatchStandingsLegacy.readMaps(args)
MatchStandingsLegacy.readOpponents(args)
MatchStandingsLegacy.readBackground(args)

Variables.varDefine('islegacy', '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we unset this var here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|detailsX= params are conditionally json strings depending on islegacy page var (ref:https://liquipedia.net/pubg/index.php?title=Template:MatchSummary&diff=556745&oldid=556058)
so it's to prevent uses outside of legacy wrapper from (theoretically) breaking

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case: do we need to reset it to its former value after the processing done in this module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have to
the only place we define islegacy page var in pubg wiki is right before module invoke in template entrypoint (https://liquipedia.net/pubg/Template:LegacyMatchStandings)

return MatchGroup.Bracket(Json.stringifySubTables{
Copy link
Collaborator

@Rathoz Rathoz Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible.to say that it should always be a Bracket/2 though.

Eg here it is clearly a matchlist https://liquipedia.net/pubg/PUBG_Development_League/2019/Spring/Division_A#Results

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that is an inherent problem with pubg's match1 setup; it treated every match as single match (i.e., it had no notion of bracket/matchlist)
since match2 requires all matchgroups to be either one of brackets or matchlists, we would have to make compromise somewhere

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat the issue I ran into with Apex when I was doing conversions;
If we want to ensure it's all done correctly; you kind of just need to manually sort through conversions generally to see what needs to be applied. (And to be fair; I also ended up merging a lot more pages, Where in the past for Apex' Challenger circuit, it was set as subpages for Quarters/Semis/Finals I then merged it unto a single bracket page)

[1] = 'Bracket/2',
isLegacy = true,
id = Table.extract(args, 'id'),
R1M1header = Table.extract(args, 'title'),
R1M1 = args
})
end

---@param args table
function MatchStandingsLegacy.readMaps(args)
for key, _, index in Table.iter.pairsByPrefix(args, 'details') do
args['map' .. index] = Json.parseIfString(Table.extract(args, key))
end
end

---@param args table
function MatchStandingsLegacy.readOpponents(args)
local opponents = Array.mapIndexes(function (opponentIndex)
local prefix = 'p' .. opponentIndex
local team = String.trim(Table.extract(args, prefix .. 'team') or '')
if String.isEmpty(team) then
return
end

---@type string[][]
local teamResults = Array.map(
Array.parseCommaSeparatedString(Table.extract(args, prefix .. 'results')),
function (teamResult)
return Array.parseCommaSeparatedString(teamResult, '-')
end
)

local teamOffset = Table.extract(args, prefix .. 'changes')

---@type table<string, any>
local parsedOpponent = {
type = Opponent.team,
template = team,
startingpoints = tonumber(teamOffset),
}

Array.forEach(teamResults, function (result, resultIndex)
parsedOpponent['m' .. resultIndex] = result
end)

return parsedOpponent
end)

Array.forEach(opponents, function (opponent, opponentIndex)
args['opponent' .. opponentIndex] = opponent
end)
end

---@param args table
function MatchStandingsLegacy.readBackground(args)
local backgrounds = Table.mapArgumentsByPrefix(args, {'bg'}, function (key, index, prefix)
return Table.extract(args, key)
end, true)
args.bg = table.concat(Array.map(backgrounds, function (background, index)
return index .. '=' .. background
end), ',')
end

return MatchStandingsLegacy
Loading