Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(match2): remove deprecated processMap, simplify subobjects #4842

Merged
merged 5 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions components/match2/commons/brkts_wiki_specific_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ WikiSpecificBase.processMatch = FnUtil.lazilyDefineFunction(function()
or error('Function "processMatch" not implemented on wiki in "Module:MatchGroup/Input/Custom"')
end)

-- called from Module:Match/Subobjects
-- used to transform wiki-specific input of templates to the generalized
-- format that is required by Module:MatchGroup
-- @parameter map - a map
-- @returns the map after changes have been applied
WikiSpecificBase.processMap = FnUtil.lazilyDefineFunction(function()
local InputModule = Lua.import('Module:MatchGroup/Input/Custom')
return InputModule and InputModule.processMap
or error('Function "processMap" not implemented on wiki in "Module:MatchGroup/Input/Custom"')
end)

--[[
Converts a match record to a structurally typed table with the appropriate data
types for field values. The match record is either a match created in the store
Expand Down
4 changes: 2 additions & 2 deletions components/match2/commons/match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ end
function Match._prepareGameRecordForStore(matchRecord, gameRecord)
gameRecord.parent = matchRecord.parent
gameRecord.tournament = matchRecord.tournament
if not gameRecord.participants and gameRecord.opponents then
if not gameRecord.participants then
gameRecord.participants = {}
for opponentId, opponent in ipairs(gameRecord.opponents) do
for opponentId, opponent in ipairs(gameRecord.opponents or {}) do
for playerId, player in pairs(opponent.players) do
-- Deep copy have to be used here, otherwise a json.stringify complains about circular references
-- between participants and opponents
Expand Down
16 changes: 1 addition & 15 deletions components/match2/commons/match_subobjects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ local Json = require('Module:Json')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')

local WikiSpecific = Lua.import('Module:Brkts/WikiSpecific')

local ENTRY_POINT_NAMES = {'getMap'}

local MatchSubobjects = {}
Expand All @@ -31,20 +29,8 @@ function MatchSubobjects.luaGetMap(args)
-- dont save map if 'map' is not filled in
if Logic.isEmpty(args.map) then
return nil
else
args = WikiSpecific.processMap(args)

args.participants = args.participants or {}
for key, item in pairs(args.participants) do
if not key:match('%d_%d') then
error('Key \'' .. key .. '\' in match2game.participants has invalid format: \'<number>_<number>\' expected')
elseif type(item) ~= 'table' then
error('Item \'' .. tostring(item) .. '\' in match2game.participants has invalid format: table expected')
end
end

return args
end
return args
end

if FeatureFlag.get('perf') then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Json = require('Module:Json')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
Expand Down Expand Up @@ -91,8 +90,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param match table
---@param opponents table[]
---@param scoreSettings table
Expand Down
3 changes: 0 additions & 3 deletions components/match2/wikis/arenafps/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -77,8 +76,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Streams = require('Module:Links/Stream')
Expand Down Expand Up @@ -80,8 +79,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

local Array = require('Module:Array')
local CharacterStandardization = mw.loadData('Module:CharacterStandardization')
local FnUtil = require('Module:FnUtil')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local String = require('Module:StringUtils')
Expand Down Expand Up @@ -73,8 +72,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param match table
---@param matchOpponents table[]
---@return table[]
Expand All @@ -95,9 +92,6 @@ function CustomMatchGroupInput.extractMaps(match, matchOpponents)
map.opponents = Array.map(matchOpponents, function(opponent, opponentIndex)
return CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex)
end)
-- Match/Subobjects:luaGetMap sets a empty table as default value for participants.
-- Once subobjects have been refactored away this can be removed.
map.participants = nil

local opponentInfo = Array.map(matchOpponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ function CustomMatchGroupInput.extractMaps(match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -111,8 +110,6 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local MathUtil = require('Module:MathUtil')
Expand Down Expand Up @@ -86,8 +85,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
local Array = require('Module:Array')
local DateExt = require('Module:Date/Ext')
local EarningsOf = require('Module:Earnings of')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -91,8 +90,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local MathUtil = require('Module:MathUtil')
Expand Down Expand Up @@ -86,8 +85,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -84,8 +83,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
2 changes: 0 additions & 2 deletions components/match2/wikis/deadlock/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ function MatchFunctions.extractMaps(match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function MatchFunctions.calculateMatchScore(maps)
Expand Down
2 changes: 0 additions & 2 deletions components/match2/wikis/dota2/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ function MatchFunctions.extractMaps(MatchParser, match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function MatchFunctions.calculateMatchScore(maps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Ordinal = require('Module:Ordinal')
Expand Down Expand Up @@ -131,7 +130,6 @@ function CustomMatchGroupInput.extractMaps(match, opponents)

return maps
end
CustomMatchGroupInput.processMap = FnUtil.identity

--- TODO: Investigate if some parts of this should be a display rather than storage.
--- If penalties is supplied, than one map MUST have the penalty flag set to true.
Expand Down
6 changes: 0 additions & 6 deletions components/match2/wikis/fighters/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Game = require('Module:Game')
local Json = require('Module:Json')
local Lua = require('Module:Lua')
Expand Down Expand Up @@ -98,9 +97,6 @@ function CustomMatchGroupInput.extractMaps(match, matchOpponents)
map.opponents = Array.map(matchOpponents, function(opponent, opponentIndex)
return CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex)
end)
-- Match/Subobjects:luaGetMap sets a empty table as default value for participants.
-- Once subobjects have been refactored away this can be removed.
map.participants = nil

local opponentInfo = Array.map(matchOpponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
Expand All @@ -126,8 +122,6 @@ function CustomMatchGroupInput.extractMaps(match, matchOpponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function CustomMatchGroupInput.calculateMatchScore(maps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -108,8 +107,6 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
3 changes: 0 additions & 3 deletions components/match2/wikis/halo/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -79,8 +78,6 @@ function CustomMatchGroupInput.processMatch(match, options)
return match
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
2 changes: 0 additions & 2 deletions components/match2/wikis/heroes/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity


--
-- match related functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ function MatchFunctions.extractMaps(MatchParser, match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function MatchFunctions.calculateMatchScore(maps)
Expand Down
3 changes: 0 additions & 3 deletions components/match2/wikis/magic/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
Expand Down Expand Up @@ -123,8 +122,6 @@ function CustomMatchGroupInput.extractMaps(match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function CustomMatchGroupInput.calculateMatchScore(maps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ function CustomMatchGroupInput.extractMaps(match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ function CustomMatchGroupInput.extractMaps(match, opponents)
return maps
end

CustomMatchGroupInput.processMap = FnUtil.identity

--
-- match related functions
--
Expand Down
Loading
Loading