Skip to content

Commit

Permalink
feat(match2): create m2->m1 mapping for tft (#5272)
Browse files Browse the repository at this point in the history
feat(match2): create m2->m1 mapping for ftf
  • Loading branch information
Rathoz authored Jan 3, 2025
1 parent 54af44b commit 9c0f167
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions components/match2/wikis/tft/match_legacy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
-- @Liquipedia
-- wiki=tft
-- page=Module:Match/Legacy
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local MatchLegacy = {}

local DisplayHelper = require('Module:MatchGroup/Display/Helper')
local Json = require('Module:Json')
local String = require('Module:StringUtils')
local Table = require('Module:Table')


function MatchLegacy.storeMatch(match2)
MatchLegacy._storeMatch1(match2)
end

function MatchLegacy._storeMatch1(match2)
for gameIndex, game2 in ipairs(match2.match2games or {}) do
local match = Table.deepCopy(match2)
local g2extradata = Json.parseIfString(game2.extradata) or {}

match.date = game2.date
match.vod = game2.vod
match.dateexact = g2extradata.dateexact
match.finished = String.isNotEmpty(game2.winner)
match.staticid = match2.match2id .. '_' .. gameIndex

-- Handle extradata fields
local bracketData = Json.parseIfString(match2.match2bracketdata)
if type(bracketData) == 'table' and bracketData.inheritedheader then
match.header = (DisplayHelper.expandHeader(bracketData.inheritedheader) or {})[1]
end
local m1extradata = {}

m1extradata.map = game2.map
m1extradata.round = tostring(gameIndex)

match.extradata = mw.ext.LiquipediaDB.lpdb_create_json(m1extradata)

mw.ext.LiquipediaDB.lpdb_match('legacymatch_' .. match2.match2id .. '_' .. gameIndex, match)
end
end

return MatchLegacy

0 comments on commit 9c0f167

Please sign in to comment.