From 93e87ae02326b4431a82705f707cb6ac73b410e5 Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Sat, 14 Oct 2023 18:24:42 +0200 Subject: [PATCH] Fix warcraft match team input reading (#3379) * Fix warcraft match team input reading * merge instead of overwrite --- .../warcraft/match_group_input_custom.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/components/match2/wikis/warcraft/match_group_input_custom.lua b/components/match2/wikis/warcraft/match_group_input_custom.lua index 2d334fbbb74..6726766c78b 100644 --- a/components/match2/wikis/warcraft/match_group_input_custom.lua +++ b/components/match2/wikis/warcraft/match_group_input_custom.lua @@ -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 @@ -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 = {} @@ -367,7 +367,7 @@ function CustomMatchGroupInput._readPlayersOfTeam(match, opponentIndex, teamName opponent.match2players = players - return match + return opponent end ---@param opponent table @@ -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