From 2210fad71f68cb5c2ee09ca9a5db369aa850d19d Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Thu, 12 Dec 2024 17:13:43 +0100 Subject: [PATCH 1/2] fix(match2): error when using ShowBracket --- components/match2/commons/match_group_input.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/match2/commons/match_group_input.lua b/components/match2/commons/match_group_input.lua index 5014fab67d..46442126f4 100644 --- a/components/match2/commons/match_group_input.lua +++ b/components/match2/commons/match_group_input.lua @@ -348,11 +348,11 @@ function MatchGroupInput.applyOverrideArgs(matches, args) end end ----@param matches {match2opponents: table[]}[] +---@param matches {match2opponents: table[]?, opponents: table[]?}[] ---@return integer function MatchGroupInput.getMaxOpponentCount(matches) return Array.reduce(matches, function(cur, match) - return math.max(#match.match2opponents, cur) + return math.max(#(match.match2opponents or match.opponents or {}), cur) end, 0) end From 9f043892846ced8595043a55a916ac35c5346ac0 Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Thu, 12 Dec 2024 17:14:25 +0100 Subject: [PATCH 2/2] add comment --- components/match2/commons/match_group_input.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/match2/commons/match_group_input.lua b/components/match2/commons/match_group_input.lua index 46442126f4..d29d274219 100644 --- a/components/match2/commons/match_group_input.lua +++ b/components/match2/commons/match_group_input.lua @@ -352,6 +352,8 @@ end ---@return integer function MatchGroupInput.getMaxOpponentCount(matches) return Array.reduce(matches, function(cur, match) + -- If the match comes from ShowBracket then it's opponents, otherwise it's match2opponents + -- Which is stupid, and needs to be fixed return math.max(#(match.match2opponents or match.opponents or {}), cur) end, 0) end