-
Notifications
You must be signed in to change notification settings - Fork 101
feat(match2): legacy wrapper for pubg #7030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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', '') | ||
| return MatchGroup.Bracket(Json.stringifySubTables{ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; |
||
| [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 | ||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 onislegacypage 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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
islegacypage var in pubg wiki is right before module invoke in template entrypoint (https://liquipedia.net/pubg/Template:LegacyMatchStandings)