Skip to content

Commit

Permalink
swap parsing function
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Jan 13, 2025
1 parent ac0435a commit f9b042c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 4 additions & 3 deletions components/match_ticker/commons/match_ticker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local Tier = require('Module:Tier/Utils')
local OpponentLibrary = require('Module:OpponentLibraries')
local Opponent = OpponentLibrary.Opponent
local MatchUtil = Lua.import('Module:Match/Util')
local MatchGroupUtil = Lua.import('Module:MatchGroup/Util')

local Condition = require('Module:Condition')
local ConditionTree = Condition.Tree
Expand Down Expand Up @@ -320,7 +321,7 @@ end
---@return table[]
function MatchTicker:parseMatches(matches)
return Array.map(matches, function (match)
match.opponents = Array.map(match.match2opponents, Opponent.fromMatch2Record)
match.opponents = Array.map(match.match2opponents, MatchGroupUtil.opponentFromRecord)
return match
end)
end
Expand Down Expand Up @@ -433,9 +434,9 @@ function MatchTicker:adjustMatch(match)
local opponentNames = Array.extend({self.config.player}, self.config.teamPages)
if
--check for the name value
Table.includes(opponentNames, (match.match2opponents[2].name:gsub(' ', '_')))
Table.includes(opponentNames, (match.opponents[2].name:gsub(' ', '_')))
--check inside match2players too for the player value
or self.config.player and Table.any(match.match2opponents[2].match2players, function(_, playerData)
or self.config.player and Table.any(match.opponents[2].players, function(_, playerData)
return (playerData.name or ''):gsub(' ', '_') == self.config.player end)
then
return MatchTicker.switchOpponents(match)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,11 @@ function ScoreBoard:create()
:node(self:opponent(match.opponents[2], winner == 2):addClass('team-right'))
end

---@param opponentData table
---@param opponent table
---@param isWinner boolean
---@param flip boolean?
---@return Html
function ScoreBoard:opponent(opponentData, isWinner, flip)
local opponent = Opponent.fromMatch2Record(opponentData)
---@cast opponent -nil
function ScoreBoard:opponent(opponent, isWinner, flip)
if Opponent.isEmpty(opponent) or Opponent.isTbd(opponent) and opponent.type ~= Opponent.literal then
opponent = Opponent.tbd(Opponent.literal)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ local ScoreBoard = Class.new(
function ScoreBoard:create()
local match = self.match
local winner = tonumber(match.winner)
local opponents = #match.opponents

if opponents > 2 then
if #match.opponents > 2 then
--- When "FFA/BR" we don't want to display the opponents, as there are more than 2.
return self.root:node(self:versus())
end
Expand Down

0 comments on commit f9b042c

Please sign in to comment.