Skip to content

Commit

Permalink
linter & small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hjpalpha committed Dec 15, 2024
1 parent f2fac48 commit 850ea83
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 31 deletions.
8 changes: 4 additions & 4 deletions components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,10 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser)
map.map = Parser.getMapName(map, mapIndex, match)
end

if Parser.getMapBestOf then
map.bestof = Parser.getMapBestOf(map)
end

if Parser.mapIsFinished then
map.finished = Parser.mapIsFinished(map, opponents, finishedInput, winnerInput)
else
Expand All @@ -1220,10 +1224,6 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser)
map.patch = Parser.getPatch(map)
end

if Parser.getMapBestOf then
map.bestof = Parser.getMapBestOf(map)
end

map.opponents = Array.map(opponents, function(opponent, opponentIndex)
local computeOpponentScore = Parser.computeOpponentScore or MatchGroupInputUtil.computeOpponentScore
local score, status = computeOpponentScore({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ function MapFunctions.getMapBestOf(map)
return bestof or DEFAULT_BESTOF_MAP
end

---@param match table
---@param map table
---@param opponentCount integer
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(map, opponentCount)
function MapFunctions.getExtraData(match, map, opponents)
local extradata = {
bestof = map.bestof,
comment = map.comment,
Expand All @@ -113,7 +114,7 @@ function MapFunctions.getExtraData(map, opponentCount)

local bans = {}
local getCharacterName = FnUtil.curry(MatchGroupInputUtil.getCharacterName, BrawlerNames)
for opponentIndex = 1, opponentCount do
for opponentIndex = 1, #opponents do
bans['team' .. opponentIndex] = {}
for _, ban in Table.iter.pairsByPrefix(map, 't' .. opponentIndex .. 'b') do
ban = getCharacterName(ban)
Expand Down
19 changes: 9 additions & 10 deletions components/match2/wikis/clashroyale/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,13 @@ function MatchFunctions.getExtraData(match, games, opponents)
return extradata
end

---@param mapInput table
---@param finished boolean
---@param map table
---@return fun(opponentIndex: integer): integer?
function MapFunctions.calculateMapScore(mapInput, finished)
local winner = tonumber(mapInput.winner)
function MapFunctions.calculateMapScore(map)
local winner = tonumber(map.winner)
return function(opponentIndex)
-- TODO Better to check if map has started, rather than finished, for a more correct handling
if not winner and not finished then
if not winner and not map.finished then
return
end

Expand Down Expand Up @@ -164,15 +163,15 @@ function MapFunctions.getPartyParticipants(mapInput, opponent, opponentIndex)
end

---@param match table
---@param mapInput table
---@param mapOpponents {players: {player: string, played: boolean, cards: table}[]}[]
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, mapInput, mapOpponents)
function MapFunctions.getExtraData(match, map, opponents)
local extradata = {
comment = mapInput.comment,
comment = map.comment,
}

return Table.merge(extradata, MapFunctions.getCardsExtradata(mapOpponents))
return Table.merge(extradata, MapFunctions.getCardsExtradata(map.opponents))
end

--- additionally store cards info in extradata so we can condition on them
Expand Down
9 changes: 4 additions & 5 deletions components/match2/wikis/magic/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,13 @@ function CustomMatchGroupInput._hasTeamOpponent(match)
return match.opponent1.type == Opponent.team or match.opponent2.type == Opponent.team
end

---@param winnerInput string|integer|nil
---@param finished boolean
---@param map table
---@return fun(opponentIndex: integer): integer?
function MapFunctions.calculateMapScore(winnerInput, finished)
local winner = tonumber(winnerInput)
function MapFunctions.calculateMapScore(map)
local winner = tonumber(map.winner)
return function(opponentIndex)
-- TODO Better to check if map has started, rather than finished, for a more correct handling
if not winner and not finished then
if not winner and not map.finished then
return
end
return winner == opponentIndex and 1 or 0
Expand Down
3 changes: 0 additions & 3 deletions components/match2/wikis/smite/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local GodNames = mw.loadData('Module:GodNames')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')
local Variables = require('Module:Variables')

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

local Array = require('Module:Array')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')
local WeaponNames = mw.loadData('Module:WeaponNames')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')
Expand Down
4 changes: 3 additions & 1 deletion components/match2/wikis/tetris/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ function MapFunctions.calculateMapScore(map)
end

---@param map table
---@param mapIndex integer
---@param match table
---@return string?
function MapFunctions.getMapName(map)
function MapFunctions.getMapName(map, mapIndex, match)
return nil
end

Expand Down
2 changes: 0 additions & 2 deletions components/match2/wikis/valorant/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ local AgentNames = require('Module:AgentNames')
local FnUtil = require('Module:FnUtil')
local Json = require('Module:Json')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')

Expand Down

0 comments on commit 850ea83

Please sign in to comment.