From b7209ae5329a502a9aeb7c2d760f44cf168fa4cd Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Thu, 10 Oct 2024 11:33:37 +0200 Subject: [PATCH] refactor(match2): make tournamentVars into a non-mutating function (#4839) * refactor(match2): make tournamentVars into a non-mutating function * do tft * cleanup tft a bit --- .../match2/commons/match_group_input.lua | 2 +- .../match2/commons/match_group_input_util.lua | 36 ++++++++++--------- .../match_group_input_starcraft.lua | 2 +- .../match_group_input_starcraft_ffa.lua | 2 +- .../ageofempires/match_group_input_custom.lua | 4 +-- .../apexlegends/match_group_input_custom.lua | 9 ++--- .../arenafps/match_group_input_custom.lua | 10 ++---- .../battlerite/match_group_input_custom.lua | 2 +- .../brawlhalla/match_group_input_custom.lua | 9 ++--- .../brawlstars/match_group_input_custom.lua | 10 ++---- .../callofduty/match_group_input_custom.lua | 10 ++---- .../clashofclans/match_group_input_custom.lua | 10 ++---- .../clashroyale/match_group_input_custom.lua | 10 ++---- .../match_group_input_custom.lua | 14 +++----- .../criticalops/match_group_input_custom.lua | 10 ++---- .../crossfire/match_group_input_custom.lua | 10 ++---- .../deadlock/match_group_input_custom.lua | 2 +- .../wikis/dota2/match_group_input_custom.lua | 13 ++----- .../easportsfc/match_group_input_custom.lua | 9 ++--- .../fighters/match_group_input_custom.lua | 9 ++--- .../geoguessr/match_group_input_custom.lua | 10 ++---- .../wikis/halo/match_group_input_custom.lua | 10 ++---- .../wikis/heroes/match_group_input_custom.lua | 10 ++---- .../honorofkings/match_group_input_custom.lua | 10 ++---- .../match_group_input_custom.lua | 10 ++---- .../wikis/magic/match_group_input_custom.lua | 9 ++--- .../match_group_input_custom.lua | 10 ++---- .../match_group_input_custom.lua | 10 ++---- .../wikis/osu/match_group_input_custom.lua | 10 ++---- .../overwatch/match_group_input_custom.lua | 10 ++---- .../pokemon/match_group_input_custom.lua | 9 ++--- .../rainbowsix/match_group_input_custom.lua | 11 ++---- .../rocketleague/match_group_input_custom.lua | 10 ++---- .../sideswipe/match_group_input_custom.lua | 10 ++---- .../wikis/smite/match_group_input_custom.lua | 10 ++---- .../splatoon/match_group_input_custom.lua | 9 ++--- .../splitgate/match_group_input_custom.lua | 10 ++---- .../stormgate/match_group_input_custom.lua | 2 +- .../teamfortress/match_group_input_custom.lua | 10 ++---- .../wikis/tetris/match_group_input_custom.lua | 9 ++--- .../wikis/tft/match_group_input_custom.lua | 27 +++----------- .../trackmania/match_group_input_custom.lua | 10 ++---- .../valorant/match_group_input_custom.lua | 12 ++----- .../warcraft/match_group_input_custom.lua | 2 +- .../wildrift/match_group_input_custom.lua | 10 ++---- .../worldoftanks/match_group_input_custom.lua | 10 ++---- .../wikis/zula/match_group_input_custom.lua | 10 ++---- 47 files changed, 110 insertions(+), 343 deletions(-) diff --git a/components/match2/commons/match_group_input.lua b/components/match2/commons/match_group_input.lua index ac0656b80bd..f3e5f9476d3 100644 --- a/components/match2/commons/match_group_input.lua +++ b/components/match2/commons/match_group_input.lua @@ -45,7 +45,7 @@ local VALID_GSL_GROUP_STYLES = { ---@param match table function MatchGroupInput._applyTournamentVarsToMaps(match) for _, map in ipairs(MatchGroupUtil.normalizeSubtype(match, 'map')) do - MatchGroupInputUtil.getCommonTournamentVars(map, match) + Table.mergeInto(map, MatchGroupInputUtil.getTournamentContext(map, match)) end end diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index dce458208fe..ddb7ee1f6c6 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -292,36 +292,38 @@ end ---@param obj table ---@param parent table? ---@return table -function MatchGroupInputUtil.getCommonTournamentVars(obj, parent) +---@nodiscard +function MatchGroupInputUtil.getTournamentContext(obj, parent) parent = parent or {} - obj.game = Logic.emptyOr(obj.game, parent.game, globalVars:get('tournament_game')) - obj.icon = Logic.emptyOr(obj.icon, parent.icon, globalVars:get('tournament_icon')) - obj.icondark = Logic.emptyOr(obj.iconDark, parent.icondark, globalVars:get('tournament_icondark')) - obj.liquipediatier = Logic.emptyOr( + local vars = {} + vars.game = Logic.emptyOr(obj.game, parent.game, globalVars:get('tournament_game')) + vars.icon = Logic.emptyOr(obj.icon, parent.icon, globalVars:get('tournament_icon')) + vars.icondark = Logic.emptyOr(obj.iconDark, parent.icondark, globalVars:get('tournament_icondark')) + vars.liquipediatier = Logic.emptyOr( obj.liquipediatier, parent.liquipediatier, globalVars:get('tournament_liquipediatier') ) - obj.liquipediatiertype = Logic.emptyOr( + vars.liquipediatiertype = Logic.emptyOr( obj.liquipediatiertype, parent.liquipediatiertype, globalVars:get('tournament_liquipediatiertype') ) - obj.publishertier = Logic.emptyOr( + vars.publishertier = Logic.emptyOr( obj.publishertier, parent.publishertier, globalVars:get('tournament_publishertier') ) - obj.series = Logic.emptyOr(obj.series, parent.series, globalVars:get('tournament_series')) - obj.shortname = Logic.emptyOr(obj.shortname, parent.shortname, globalVars:get('tournament_shortname')) - obj.tickername = Logic.emptyOr(obj.tickername, parent.tickername, globalVars:get('tournament_tickername')) - obj.tournament = Logic.emptyOr(obj.tournament, parent.tournament, globalVars:get('tournament_name')) - obj.type = Logic.emptyOr(obj.type, parent.type, globalVars:get('tournament_type')) - obj.patch = Logic.emptyOr(obj.patch, parent.patch, globalVars:get('tournament_patch')) - obj.date = Logic.emptyOr(obj.date, parent.date) - obj.mode = Logic.emptyOr(obj.mode, parent.mode) - - return obj + vars.series = Logic.emptyOr(obj.series, parent.series, globalVars:get('tournament_series')) + vars.shortname = Logic.emptyOr(obj.shortname, parent.shortname, globalVars:get('tournament_shortname')) + vars.tickername = Logic.emptyOr(obj.tickername, parent.tickername, globalVars:get('tournament_tickername')) + vars.tournament = Logic.emptyOr(obj.tournament, parent.tournament, globalVars:get('tournament_name')) + vars.type = Logic.emptyOr(obj.type, parent.type, globalVars:get('tournament_type')) + vars.patch = Logic.emptyOr(obj.patch, parent.patch, globalVars:get('tournament_patch')) + vars.date = Logic.emptyOr(obj.date, parent.date) + vars.mode = Logic.emptyOr(obj.mode, parent.mode) + + return vars end ---@param match table diff --git a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua index 63d751a4285..9b66d1b7a61 100644 --- a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua +++ b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua @@ -84,7 +84,7 @@ function StarcraftMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.vod = Logic.nilIfEmpty(match.vod) diff --git a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua index 7748294c364..adbb63257cb 100644 --- a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua +++ b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua @@ -50,7 +50,7 @@ function StarcraftFfaMatchGroupInput.processMatch(match, options) match.vod = Logic.nilIfEmpty(match.vod) match.links = BaseMatchFunctions.getLinks(match) - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) local opponents = BaseMatchFunctions.readOpponents(match) diff --git a/components/match2/wikis/ageofempires/match_group_input_custom.lua b/components/match2/wikis/ageofempires/match_group_input_custom.lua index 3b11d4a8ec2..103a5e0b4bd 100644 --- a/components/match2/wikis/ageofempires/match_group_input_custom.lua +++ b/components/match2/wikis/ageofempires/match_group_input_custom.lua @@ -34,7 +34,7 @@ local OPPONENT_CONFIG = { ---@return table function CustomMatchGroupInput.processMatch(match, options) assert(not Logic.readBool(match.ffa), 'FFA is not yet supported in AoE match2.') - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.game, match.mapsInfo = CustomMatchGroupInput._getMapsAndGame(match) Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date)) @@ -154,7 +154,7 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.map, map.extradata.displayname = CustomMatchGroupInput._getMapName(map, match.mapsInfo) map.extradata.mapmode = Table.extract(map, 'mode') - MatchGroupInputUtil.getCommonTournamentVars(map, match) + Table.mergeInto(map, MatchGroupInputUtil.getTournamentContext(map, match)) map.opponents = CustomMatchGroupInput.processPlayerMapData(map, opponents) diff --git a/components/match2/wikis/apexlegends/match_group_input_custom.lua b/components/match2/wikis/apexlegends/match_group_input_custom.lua index 57ecabff642..999a87cc89a 100644 --- a/components/match2/wikis/apexlegends/match_group_input_custom.lua +++ b/components/match2/wikis/apexlegends/match_group_input_custom.lua @@ -78,7 +78,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchFunctions.setBgForOpponents(opponents, settings.status) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -231,12 +232,6 @@ function MatchFunctions.parseSetting(match) } end ----@param match table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param settings table ---@return table function MatchFunctions.getExtraData(settings) diff --git a/components/match2/wikis/arenafps/match_group_input_custom.lua b/components/match2/wikis/arenafps/match_group_input_custom.lua index bc9b291eea8..8f3df0f363d 100644 --- a/components/match2/wikis/arenafps/match_group_input_custom.lua +++ b/components/match2/wikis/arenafps/match_group_input_custom.lua @@ -65,7 +65,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -131,13 +132,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/battlerite/match_group_input_custom.lua b/components/match2/wikis/battlerite/match_group_input_custom.lua index ea4c039ce2c..1e16b90b04d 100644 --- a/components/match2/wikis/battlerite/match_group_input_custom.lua +++ b/components/match2/wikis/battlerite/match_group_input_custom.lua @@ -67,7 +67,7 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/brawlhalla/match_group_input_custom.lua b/components/match2/wikis/brawlhalla/match_group_input_custom.lua index 14f75d7bd50..dfcd85003c7 100644 --- a/components/match2/wikis/brawlhalla/match_group_input_custom.lua +++ b/components/match2/wikis/brawlhalla/match_group_input_custom.lua @@ -62,7 +62,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - CustomMatchGroupInput.getTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) + match.mode = Variables.varDefault('tournament_mode', 'singles') match.stream = Streams.processStreams(match) @@ -74,12 +75,6 @@ end CustomMatchGroupInput.processMap = FnUtil.identity ----@param match table -function CustomMatchGroupInput.getTournamentVars(match) - match = MatchGroupInputUtil.getCommonTournamentVars(match) - match.mode = Variables.varDefault('tournament_mode', 'singles') -end - ---@param match table ---@param matchOpponents table[] ---@return table[] diff --git a/components/match2/wikis/brawlstars/match_group_input_custom.lua b/components/match2/wikis/brawlstars/match_group_input_custom.lua index 4f9b3b849d8..38ad4470758 100644 --- a/components/match2/wikis/brawlstars/match_group_input_custom.lua +++ b/components/match2/wikis/brawlstars/match_group_input_custom.lua @@ -71,7 +71,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -145,13 +146,6 @@ function MatchFunctions.getBestOf(match) return bestof or DEFAULT_BESTOF_MATCH end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getExtraData(match) diff --git a/components/match2/wikis/callofduty/match_group_input_custom.lua b/components/match2/wikis/callofduty/match_group_input_custom.lua index d2bc98f37c2..52cf8607863 100644 --- a/components/match2/wikis/callofduty/match_group_input_custom.lua +++ b/components/match2/wikis/callofduty/match_group_input_custom.lua @@ -61,7 +61,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -132,13 +133,6 @@ function MatchFunctions.getBestOf(match) return bestof or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/clashofclans/match_group_input_custom.lua b/components/match2/wikis/clashofclans/match_group_input_custom.lua index d8c38229d9c..47ad466e392 100644 --- a/components/match2/wikis/clashofclans/match_group_input_custom.lua +++ b/components/match2/wikis/clashofclans/match_group_input_custom.lua @@ -70,7 +70,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -154,13 +155,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/clashroyale/match_group_input_custom.lua b/components/match2/wikis/clashroyale/match_group_input_custom.lua index 73a038968f1..ed24a5cfe4b 100644 --- a/components/match2/wikis/clashroyale/match_group_input_custom.lua +++ b/components/match2/wikis/clashroyale/match_group_input_custom.lua @@ -70,7 +70,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -91,13 +92,6 @@ function MatchFunctions.getLinks(match) } end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param opponents table[] ---@return table[] diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index 68bb8500ead..da18a3192ef 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -75,7 +75,10 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) + match.publishertier = Logic.emptyOr(match.publishertier, Variables.varDefault('tournament_valve_tier')) + match.status = Logic.emptyOr(match.status, Variables.varDefault('tournament_status')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match, games) @@ -151,15 +154,6 @@ function MatchFunctions.removeUnsetMaps(games) return Array.filter(games, MapFunctions.keepMap) end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) - match.publishertier = Logic.emptyOr(match.publishertier, Variables.varDefault('tournament_valve_tier')) - - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param maps table[] ---@return table diff --git a/components/match2/wikis/criticalops/match_group_input_custom.lua b/components/match2/wikis/criticalops/match_group_input_custom.lua index 62e83d59027..f77961a9576 100644 --- a/components/match2/wikis/criticalops/match_group_input_custom.lua +++ b/components/match2/wikis/criticalops/match_group_input_custom.lua @@ -70,7 +70,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -136,13 +137,6 @@ function MatchFunctions.extractMaps(match, opponentCount) return maps end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/crossfire/match_group_input_custom.lua b/components/match2/wikis/crossfire/match_group_input_custom.lua index 236b0d57978..29d4f5fd54b 100644 --- a/components/match2/wikis/crossfire/match_group_input_custom.lua +++ b/components/match2/wikis/crossfire/match_group_input_custom.lua @@ -70,7 +70,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -138,13 +139,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/deadlock/match_group_input_custom.lua b/components/match2/wikis/deadlock/match_group_input_custom.lua index c23a296bad1..fa1cdc4ad96 100644 --- a/components/match2/wikis/deadlock/match_group_input_custom.lua +++ b/components/match2/wikis/deadlock/match_group_input_custom.lua @@ -63,7 +63,7 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) diff --git a/components/match2/wikis/dota2/match_group_input_custom.lua b/components/match2/wikis/dota2/match_group_input_custom.lua index adcfa4c2e73..1c131c319b4 100644 --- a/components/match2/wikis/dota2/match_group_input_custom.lua +++ b/components/match2/wikis/dota2/match_group_input_custom.lua @@ -104,7 +104,8 @@ function CustomMatchGroupInput.processMatchWithoutStandalone(MatchParser, match) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match, games) @@ -173,14 +174,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.headtohead = Logic.emptyOr(match.headtohead, Variables.varDefault('headtohead')) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param games table[] ---@return table @@ -210,7 +203,7 @@ end function MatchFunctions.getExtraData(match) return { mvp = MatchGroupInputUtil.readMvp(match), - headtohead = match.headtohead, + headtohead = Logic.emptyOr(match.headtohead, Variables.varDefault('headtohead')), casters = MatchGroupInputUtil.readCasters(match, {noSort = true}), } end diff --git a/components/match2/wikis/easportsfc/match_group_input_custom.lua b/components/match2/wikis/easportsfc/match_group_input_custom.lua index 89c57cc4d3e..f99b1e50420 100644 --- a/components/match2/wikis/easportsfc/match_group_input_custom.lua +++ b/components/match2/wikis/easportsfc/match_group_input_custom.lua @@ -66,7 +66,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - CustomMatchGroupInput.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.extradata = CustomMatchGroupInput.getExtraData(match, scoreType == 'mapWins') @@ -155,12 +156,6 @@ function CustomMatchGroupInput.calculateMatchScore(maps, calculateBy) end end ----@param match table -function CustomMatchGroupInput.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo')) - MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param hasSubmatches boolean ---@return table diff --git a/components/match2/wikis/fighters/match_group_input_custom.lua b/components/match2/wikis/fighters/match_group_input_custom.lua index b0fd58158ed..c8ea24e3ee7 100644 --- a/components/match2/wikis/fighters/match_group_input_custom.lua +++ b/components/match2/wikis/fighters/match_group_input_custom.lua @@ -68,7 +68,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - CustomMatchGroupInput.getTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) + match.mode = Variables.varDefault('tournament_mode', 'singles') match.stream = Streams.processStreams(match) @@ -135,12 +136,6 @@ function CustomMatchGroupInput.calculateMatchScore(maps) end end ----@param match table -function CustomMatchGroupInput.getTournamentVars(match) - MatchGroupInputUtil.getCommonTournamentVars(match) - match.mode = Variables.varDefault('tournament_mode', 'singles') -end - ---@param map table ---@param opponent table ---@param opponentIndex integer diff --git a/components/match2/wikis/geoguessr/match_group_input_custom.lua b/components/match2/wikis/geoguessr/match_group_input_custom.lua index 4e77e84a1e5..0bc8661c0d5 100644 --- a/components/match2/wikis/geoguessr/match_group_input_custom.lua +++ b/components/match2/wikis/geoguessr/match_group_input_custom.lua @@ -62,7 +62,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.games = games @@ -121,13 +122,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - -- -- map related functions -- diff --git a/components/match2/wikis/halo/match_group_input_custom.lua b/components/match2/wikis/halo/match_group_input_custom.lua index 4704983e743..aec66a5a30f 100644 --- a/components/match2/wikis/halo/match_group_input_custom.lua +++ b/components/match2/wikis/halo/match_group_input_custom.lua @@ -65,7 +65,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -133,13 +134,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/heroes/match_group_input_custom.lua b/components/match2/wikis/heroes/match_group_input_custom.lua index 250c8dfcd0f..7d0689a6af1 100644 --- a/components/match2/wikis/heroes/match_group_input_custom.lua +++ b/components/match2/wikis/heroes/match_group_input_custom.lua @@ -69,7 +69,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -145,13 +146,6 @@ function MatchFunctions.getBestOf(match) return bestOf or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/honorofkings/match_group_input_custom.lua b/components/match2/wikis/honorofkings/match_group_input_custom.lua index c56ec521396..1694f135769 100644 --- a/components/match2/wikis/honorofkings/match_group_input_custom.lua +++ b/components/match2/wikis/honorofkings/match_group_input_custom.lua @@ -75,7 +75,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -150,13 +151,6 @@ function MatchFunctions.getBestOf(match) return bestOf or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua index e86e79d7660..eefb3333264 100644 --- a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua +++ b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua @@ -104,7 +104,8 @@ function CustomMatchGroupInput.processMatchWithoutStandalone(MatchParser, match) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -172,13 +173,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/magic/match_group_input_custom.lua b/components/match2/wikis/magic/match_group_input_custom.lua index e60b89156c8..5b71e38ce13 100644 --- a/components/match2/wikis/magic/match_group_input_custom.lua +++ b/components/match2/wikis/magic/match_group_input_custom.lua @@ -72,7 +72,8 @@ function CustomMatchGroupInput.processMatch(match) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - CustomMatchGroupInput.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -140,12 +141,6 @@ function CustomMatchGroupInput.getBestOf(match) return bestOf or DEFAULT_BESTOF end ----@param match table -function CustomMatchGroupInput.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo')) - MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return boolean function CustomMatchGroupInput._hasTeamOpponent(match) diff --git a/components/match2/wikis/mobilelegends/match_group_input_custom.lua b/components/match2/wikis/mobilelegends/match_group_input_custom.lua index dd2145f8ddd..bb475894948 100644 --- a/components/match2/wikis/mobilelegends/match_group_input_custom.lua +++ b/components/match2/wikis/mobilelegends/match_group_input_custom.lua @@ -63,7 +63,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -137,13 +138,6 @@ function MatchFunctions.getBestOf(match) return bestof or DEFAULT_BESTOF_MATCH end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getExtraData(match) diff --git a/components/match2/wikis/omegastrikers/match_group_input_custom.lua b/components/match2/wikis/omegastrikers/match_group_input_custom.lua index 672cc4c804d..c798a3f8482 100644 --- a/components/match2/wikis/omegastrikers/match_group_input_custom.lua +++ b/components/match2/wikis/omegastrikers/match_group_input_custom.lua @@ -63,7 +63,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -135,13 +136,6 @@ function MatchFunctions.getBestOf(match) return bestof or DEFAULT_BESTOF_MATCH end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - -- -- map related functions -- diff --git a/components/match2/wikis/osu/match_group_input_custom.lua b/components/match2/wikis/osu/match_group_input_custom.lua index ab93687078b..75e0336ac41 100644 --- a/components/match2/wikis/osu/match_group_input_custom.lua +++ b/components/match2/wikis/osu/match_group_input_custom.lua @@ -66,7 +66,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -139,13 +140,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/overwatch/match_group_input_custom.lua b/components/match2/wikis/overwatch/match_group_input_custom.lua index 72fa21797fd..12c89e82db8 100644 --- a/components/match2/wikis/overwatch/match_group_input_custom.lua +++ b/components/match2/wikis/overwatch/match_group_input_custom.lua @@ -61,7 +61,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -136,13 +137,6 @@ function MatchFunctions.getBestOf(match) return bestof or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/pokemon/match_group_input_custom.lua b/components/match2/wikis/pokemon/match_group_input_custom.lua index 436bb9a2e7b..98e700a5036 100644 --- a/components/match2/wikis/pokemon/match_group_input_custom.lua +++ b/components/match2/wikis/pokemon/match_group_input_custom.lua @@ -73,7 +73,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -145,12 +146,6 @@ function MatchFunctions.getBestOf(match) return bestOf or DEFAULT_BESTOF end ----@param match table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getExtraData(match) diff --git a/components/match2/wikis/rainbowsix/match_group_input_custom.lua b/components/match2/wikis/rainbowsix/match_group_input_custom.lua index b161523ab47..582be452f97 100644 --- a/components/match2/wikis/rainbowsix/match_group_input_custom.lua +++ b/components/match2/wikis/rainbowsix/match_group_input_custom.lua @@ -66,7 +66,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -121,14 +122,6 @@ function MatchFunctions.extractMaps(match, opponentCount) return maps end ---- Fetch information about the tournament ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - -- Template:Map sets a default map name so we can count the number of maps. -- These maps however shouldn't be stored -- The keepMap function will check if a map should be kept diff --git a/components/match2/wikis/rocketleague/match_group_input_custom.lua b/components/match2/wikis/rocketleague/match_group_input_custom.lua index 9008f59d059..a3542280876 100644 --- a/components/match2/wikis/rocketleague/match_group_input_custom.lua +++ b/components/match2/wikis/rocketleague/match_group_input_custom.lua @@ -68,7 +68,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -157,13 +158,6 @@ end -- match related functions -- ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param opponents table[] ---@return table diff --git a/components/match2/wikis/sideswipe/match_group_input_custom.lua b/components/match2/wikis/sideswipe/match_group_input_custom.lua index 0a5c956d4f8..6f75be945fb 100644 --- a/components/match2/wikis/sideswipe/match_group_input_custom.lua +++ b/components/match2/wikis/sideswipe/match_group_input_custom.lua @@ -58,7 +58,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -112,13 +113,6 @@ CustomMatchGroupInput.processMap = FnUtil.identity -- match related functions -- ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param opponents table[] ---@return table diff --git a/components/match2/wikis/smite/match_group_input_custom.lua b/components/match2/wikis/smite/match_group_input_custom.lua index e3e7da0ae8a..aebb6d169c3 100644 --- a/components/match2/wikis/smite/match_group_input_custom.lua +++ b/components/match2/wikis/smite/match_group_input_custom.lua @@ -72,7 +72,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -118,13 +119,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/splatoon/match_group_input_custom.lua b/components/match2/wikis/splatoon/match_group_input_custom.lua index 56d1366ddee..d3f8c22dcd2 100644 --- a/components/match2/wikis/splatoon/match_group_input_custom.lua +++ b/components/match2/wikis/splatoon/match_group_input_custom.lua @@ -64,7 +64,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -135,12 +136,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getExtraData(match) diff --git a/components/match2/wikis/splitgate/match_group_input_custom.lua b/components/match2/wikis/splitgate/match_group_input_custom.lua index 5853fb78fe2..115d51d8e1d 100644 --- a/components/match2/wikis/splitgate/match_group_input_custom.lua +++ b/components/match2/wikis/splitgate/match_group_input_custom.lua @@ -65,7 +65,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -133,13 +134,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/stormgate/match_group_input_custom.lua b/components/match2/wikis/stormgate/match_group_input_custom.lua index 09a77c32bfe..9a9475304f9 100644 --- a/components/match2/wikis/stormgate/match_group_input_custom.lua +++ b/components/match2/wikis/stormgate/match_group_input_custom.lua @@ -99,7 +99,7 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.vod = Logic.nilIfEmpty(match.vod) diff --git a/components/match2/wikis/teamfortress/match_group_input_custom.lua b/components/match2/wikis/teamfortress/match_group_input_custom.lua index 0c3eb99b981..297fbf6e7c1 100644 --- a/components/match2/wikis/teamfortress/match_group_input_custom.lua +++ b/components/match2/wikis/teamfortress/match_group_input_custom.lua @@ -62,7 +62,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match, games) @@ -122,13 +123,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@param games table[] ---@return table diff --git a/components/match2/wikis/tetris/match_group_input_custom.lua b/components/match2/wikis/tetris/match_group_input_custom.lua index c0c3f7cb643..0dd01ba84be 100644 --- a/components/match2/wikis/tetris/match_group_input_custom.lua +++ b/components/match2/wikis/tetris/match_group_input_custom.lua @@ -72,7 +72,8 @@ function CustomMatchGroupInput.processMatch(match) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - CustomMatchGroupInput.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -142,12 +143,6 @@ function CustomMatchGroupInput.getBestOf(match) return bestOf or DEFAULT_BESTOF end ----@param match table -function CustomMatchGroupInput.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo')) - MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function CustomMatchGroupInput.getExtraData(match) diff --git a/components/match2/wikis/tft/match_group_input_custom.lua b/components/match2/wikis/tft/match_group_input_custom.lua index 10785349194..90aef34115b 100644 --- a/components/match2/wikis/tft/match_group_input_custom.lua +++ b/components/match2/wikis/tft/match_group_input_custom.lua @@ -62,10 +62,10 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) + match.mode = Variables.varDefault('tournament_mode', DEFAULT_MODE) match.stream = Streams.processStreams(match) - match.links = MatchFunctions.getLinks(match) match.games = games match.opponents = opponents @@ -75,19 +75,6 @@ function CustomMatchGroupInput.processMatch(match, options) return match end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Variables.varDefault('tournament_mode', DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ----@param match table ----@return table -function MatchFunctions.getLinks(match) - return {} -end - ---@param match table ---@return table function MatchFunctions.getExtraData(match) @@ -106,14 +93,10 @@ function MatchFunctions.calculateMatchScore(maps) end ---@param bestofInput string|integer? ----@return integer? +---@return integer function MatchFunctions.getBestOf(bestofInput) - local bestof = tonumber(bestofInput) or tonumber(Variables.varDefault('match_bestof', DEFAULT_BESTOF)) - - if bestof then - Variables.varDefine('match_bestof', bestof) - end - + local bestof = tonumber(bestofInput) or tonumber(Variables.varDefault('match_bestof')) or DEFAULT_BESTOF + Variables.varDefine('match_bestof', bestof) return bestof end diff --git a/components/match2/wikis/trackmania/match_group_input_custom.lua b/components/match2/wikis/trackmania/match_group_input_custom.lua index f3d27467d07..0ab9dfd4e59 100644 --- a/components/match2/wikis/trackmania/match_group_input_custom.lua +++ b/components/match2/wikis/trackmania/match_group_input_custom.lua @@ -61,7 +61,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', '2v2')) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -138,13 +139,6 @@ function CustomMatchGroupInput._getSetWins(opponent) return setWin(1) + setWin(2) + setWin(3) end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', '2v2')) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return boolean function MatchFunctions.isFeatured(match) diff --git a/components/match2/wikis/valorant/match_group_input_custom.lua b/components/match2/wikis/valorant/match_group_input_custom.lua index 74b863227c4..bce110d7d2b 100644 --- a/components/match2/wikis/valorant/match_group_input_custom.lua +++ b/components/match2/wikis/valorant/match_group_input_custom.lua @@ -65,7 +65,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -142,15 +143,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - match.patch = Logic.emptyOr(match.patch, Variables.varDefault('patch')) - - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/warcraft/match_group_input_custom.lua b/components/match2/wikis/warcraft/match_group_input_custom.lua index 99211ed5167..5574335d52b 100644 --- a/components/match2/wikis/warcraft/match_group_input_custom.lua +++ b/components/match2/wikis/warcraft/match_group_input_custom.lua @@ -103,7 +103,7 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchGroupInputUtil.getCommonTournamentVars(match) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.vod = Logic.nilIfEmpty(match.vod) diff --git a/components/match2/wikis/wildrift/match_group_input_custom.lua b/components/match2/wikis/wildrift/match_group_input_custom.lua index b6c43287b0d..b1a9b311d68 100644 --- a/components/match2/wikis/wildrift/match_group_input_custom.lua +++ b/components/match2/wikis/wildrift/match_group_input_custom.lua @@ -74,7 +74,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -149,13 +150,6 @@ function MatchFunctions.getBestOf(match) return bestOf or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', DEFAULT_MODE)) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param match table ---@return table function MatchFunctions.getLinks(match) diff --git a/components/match2/wikis/worldoftanks/match_group_input_custom.lua b/components/match2/wikis/worldoftanks/match_group_input_custom.lua index 5366fcdcbe4..b3ec8b6bcb5 100644 --- a/components/match2/wikis/worldoftanks/match_group_input_custom.lua +++ b/components/match2/wikis/worldoftanks/match_group_input_custom.lua @@ -66,7 +66,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -134,13 +135,6 @@ function MatchFunctions.getBestOf(bestofInput) return tonumber(Variables.varDefault('bestof')) or DEFAULT_BESTOF end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - ---@param maps table[] ---@return fun(opponentIndex: integer): integer? function MatchFunctions.calculateMatchScore(maps) diff --git a/components/match2/wikis/zula/match_group_input_custom.lua b/components/match2/wikis/zula/match_group_input_custom.lua index f9e3a7a4d1b..84c7ba913e4 100644 --- a/components/match2/wikis/zula/match_group_input_custom.lua +++ b/components/match2/wikis/zula/match_group_input_custom.lua @@ -67,7 +67,8 @@ function CustomMatchGroupInput.processMatch(match, options) MatchGroupInputUtil.setPlacement(opponents, match.winner, 1, 2, match.resulttype) end - MatchFunctions.getTournamentVars(match) + match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) + Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) match.links = MatchFunctions.getLinks(match) @@ -122,13 +123,6 @@ function MatchFunctions.extractMaps(match, opponentCount) return maps end ----@param match table ----@return table -function MatchFunctions.getTournamentVars(match) - match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode'), DEFAULT_MODE) - return MatchGroupInputUtil.getCommonTournamentVars(match) -end - -- Template:Map sets a default map name so we can count the number of maps. -- These maps however shouldn't be stored -- The keepMap function will check if a map should be kept