Skip to content

Commit

Permalink
fix(match2): valorant legacy storgae does not store enough players so…
Browse files Browse the repository at this point in the history
…metimes (#4847)

* fix(match2): valorant legacy storgae does not store enough players sometimes

* import array
  • Loading branch information
hjpalpha authored Oct 11, 2024
1 parent 002cf1a commit aaecbd4
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions components/match2/wikis/valorant/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

local MatchLegacy = {}

local Array = require('Module:Array')
local Json = require('Module:Json')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
Expand Down Expand Up @@ -182,30 +183,28 @@ function MatchLegacy._convertParameters(match2)
local handleOpponent = function (index)
local prefix = 'opponent'..index
local opponent = match2.match2opponents[index] or {}
local opponentmatch2players = opponent.match2players or {}
if opponent.type == 'team' then
match[prefix] = opponent.name
if match2.bestof == 1 then
if ((match2.match2games or {})[1] or {}).scores then
match[prefix..'score'] = Json.parseIfString(match2.match2games[1].scores)[index]
match[prefix .. 'score'] = Json.parseIfString(match2.match2games[1].scores)[index]
end
end
if not match[prefix..'score'] then
match[prefix..'score'] = (tonumber(opponent.score) or 0) > 0 and opponent.score or 0
end
local opponentplayers = {}
for i = 1, 5 do
local player = opponentmatch2players[i] or {}
opponentplayers['p' .. i] = player.name or ''
opponentplayers['p' .. i .. 'flag'] = player.flag or ''
opponentplayers['p' .. i .. 'dn'] = player.displayname or ''
end
match[prefix..'players'] = opponentplayers
local players = {}
Array.forEach(opponent.match2players or {}, function(player, playerIndex)
players['p' .. playerIndex] = player.name or ''
players['p' .. playerIndex .. 'flag'] = player.flag or ''
players['p' .. playerIndex .. 'dn'] = player.displayname or ''
end)
match[prefix .. 'players'] = players
elseif opponent.type == 'solo' then
local player = opponentmatch2players[1] or {}
local player = (opponent.match2players or {})[1] or {}
match[prefix] = player.name
match[prefix..'score'] = tonumber(opponent.score) or 0 >= 0 and opponent.score or 0
match[prefix..'flag'] = player.flag
match[prefix .. 'score'] = tonumber(opponent.score) or 0 >= 0 and opponent.score or 0
match[prefix .. 'flag'] = player.flag
elseif opponent.type == 'literal' then
match[prefix] = 'TBD'
end
Expand Down

0 comments on commit aaecbd4

Please sign in to comment.