Skip to content

Commit

Permalink
Fix warcraft match team input reading (#3379)
Browse files Browse the repository at this point in the history
* Fix warcraft match team input reading

* merge instead of overwrite
  • Loading branch information
hjpalpha authored Oct 14, 2023
1 parent e20f596 commit 93e87ae
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions components/match2/wikis/warcraft/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function CustomMatchGroupInput._opponentInput(match)
opponent = CustomMatchGroupInput.processPartyOpponentInput(opponent, partySize)
elseif opponent.type == Opponent.team then
opponent = CustomMatchGroupInput.ProcessTeamOpponentInput(opponent, match.date)
CustomMatchGroupInput._readPlayersOfTeam(match, opponentIndex, opponent.name)
opponent = CustomMatchGroupInput._readPlayersOfTeam(match, opponentIndex, opponent)
elseif opponent.type == Opponent.literal then
opponent = CustomMatchGroupInput.ProcessLiteralOpponentInput(opponent)
else
Expand Down Expand Up @@ -334,10 +334,10 @@ end
---reads the players of a team from input and wiki variables
---@param match table
---@param opponentIndex integer
---@param teamName string
---@param opponent table
---@return table
function CustomMatchGroupInput._readPlayersOfTeam(match, opponentIndex, teamName)
local opponent = match['opponent' .. opponentIndex]
function CustomMatchGroupInput._readPlayersOfTeam(match, opponentIndex, opponent)
local teamName = opponent.name
local playersData = Json.parseIfString(opponent.players) or {}

local players = {}
Expand Down Expand Up @@ -367,7 +367,7 @@ function CustomMatchGroupInput._readPlayersOfTeam(match, opponentIndex, teamName

opponent.match2players = players

return match
return opponent
end

---@param opponent table
Expand Down Expand Up @@ -446,13 +446,13 @@ function CustomMatchGroupInput.ProcessTeamOpponentInput(opponent, date)
local template = string.lower(Logic.emptyOr(opponent.template, opponent[1], '')--[[@as string]]):gsub('_', ' ')

if String.isEmpty(template) or template == 'noteam' then
return Opponent.blank(Opponent.team)
end

if not mw.ext.TeamTemplate.teamexists(template) then
opponent = Table.merge(opponent, Opponent.blank(Opponent.team))
opponent.name = Opponent.toName(opponent)
return opponent
end

assert(mw.ext.TeamTemplate.teamexists(template), 'Missing team template "' .. template .. '"')

local templateData = mw.ext.TeamTemplate.raw(template, date)

opponent.icon = templateData.image
Expand Down

0 comments on commit 93e87ae

Please sign in to comment.