Skip to content

Commit

Permalink
do some more wikis
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Nov 6, 2024
1 parent ef8d4a0 commit ae7406b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 152 deletions.
41 changes: 5 additions & 36 deletions components/match2/wikis/pokemon/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Array = require('Module:Array')
local ChampionNames = mw.loadData('Module:HeroNames')
local FnUtil = require('Module:FnUtil')
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 Expand Up @@ -46,42 +44,12 @@ end
---@param opponents table[]
---@return table[]
function MatchFunctions.extractMaps(match, opponents)
local maps = {}
for key, map in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
local finishedInput = map.finished --[[@as string?]]
local winnerInput = map.winner --[[@as string?]]

map.extradata = MapFunctions.getExtraData(map, #opponents)

map.finished = MatchGroupInputUtil.mapIsFinished(map)
local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
opponentIndex = opponentIndex,
score = map['score' .. opponentIndex],
}, MapFunctions.calculateMapScore(map.winner, map.finished))
return {score = score, status = status}
end)

map.scores = Array.map(opponentInfo, Operator.property('score'))
if map.finished then
map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo)
map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo)
map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo)
end

table.insert(maps, map)
match[key] = nil
end

return maps
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

--
-- match related functions
--

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function MatchFunctions.calculateMatchScore(maps)
Expand Down Expand Up @@ -110,18 +78,19 @@ end
-- map related functions
--

---@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 = {
comment = map.comment,
team1side = string.lower(map.team1side or ''),
team2side = string.lower(map.team2side or ''),
}

local getCharacterName = FnUtil.curry(MatchGroupInputUtil.getCharacterName, ChampionNames)
for opponentIndex = 1, opponentCount do
for opponentIndex = 1, #opponents do
for _, ban, banIndex in Table.iter.pairsByPrefix(map, 't' .. opponentIndex .. 'b') do
extradata['team' .. opponentIndex .. 'ban' .. banIndex] = getCharacterName(ban)
end
Expand Down
48 changes: 12 additions & 36 deletions components/match2/wikis/sideswipe/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

local Array = require('Module:Array')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')

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

Expand All @@ -32,45 +30,21 @@ end
---@param opponents table[]
---@return table[]
function MatchFunctions.extractMaps(match, opponents)
local maps = {}
for key, map in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
if not map.map then
break
end
local finishedInput = map.finished --[[@as string?]]
local winnerInput = map.winner --[[@as string?]]

map.extradata = MapFunctions.getExtraData(map)
map.finished = MatchGroupInputUtil.mapIsFinished(map)

local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
opponentIndex = opponentIndex,
score = map['score' .. opponentIndex],
})
return {score = score, status = status}
end)

map.scores = Array.map(opponentInfo, Operator.property('score'))
if map.finished then
map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo)
map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo)
map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo)
end

table.insert(maps, map)
match[key] = nil
end

return maps
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

--
-- match related functions
--

---@param games table[]
---@return table[]
function MatchFunctions.removeUnsetMaps(games)
return Array.filter(games, function(map)
return map.map ~= nil
end)
end

---@param match table
---@param opponents table[]
---@return table
Expand All @@ -90,9 +64,11 @@ end
-- map related functions
--

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(map)
function MapFunctions.getExtraData(match, map, opponents)
return {
ot = map.ot,
otlength = map.otlength,
Expand Down
47 changes: 11 additions & 36 deletions components/match2/wikis/splitgate/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

local Array = require('Module:Array')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')
local Variables = require('Module:Variables')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')
Expand All @@ -36,39 +34,15 @@ end
---@param opponents table[]
---@return table[]
function MatchFunctions.extractMaps(match, opponents)
local maps = {}
for key, map in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
if not map.map then
break
end
local finishedInput = map.finished --[[@as string?]]
local winnerInput = map.winner --[[@as string?]]

map.extradata = MapFunctions.getExtraData(map, #opponents)
map.finished = MatchGroupInputUtil.mapIsFinished(map)

local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
opponentIndex = opponentIndex,
score = map['score' .. opponentIndex],
})
return {score = score, status = status}
end)

map.scores = Array.map(opponentInfo, Operator.property('score'))
if map.finished then
map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo)
map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo)
map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo)
end

table.insert(maps, map)
match[key] = nil
end
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

return maps
---@param games table[]
---@return table[]
function MatchFunctions.removeUnsetMaps(games)
return Array.filter(games, function(map)
return map.map ~= nil
end)
end

---@param bestofInput string|integer?
Expand Down Expand Up @@ -104,10 +78,11 @@ end
-- map related functions
--

---@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)
return {
comment = map.comment,
}
Expand Down
49 changes: 12 additions & 37 deletions components/match2/wikis/teamfortress/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

local Array = require('Module:Array')
local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')

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

Expand All @@ -30,45 +28,21 @@ end
---@param opponents table[]
---@return table[]
function MatchFunctions.extractMaps(match, opponents)
local maps = {}
for key, map in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
if not map.map then
break
end
local finishedInput = map.finished --[[@as string?]]
local winnerInput = map.winner --[[@as string?]]

map.extradata = MapFunctions.getExtraData(map)
map.finished = MatchGroupInputUtil.mapIsFinished(map)

local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
opponentIndex = opponentIndex,
score = map['score' .. opponentIndex],
})
return {score = score, status = status}
end)

map.scores = Array.map(opponentInfo, Operator.property('score'))
if map.finished then
map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo)
map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo)
map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo)
end

table.insert(maps, map)
match[key] = nil
end

return maps
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

--
-- match related functions
--

---@param games table[]
---@return table[]
function MatchFunctions.removeUnsetMaps(games)
return Array.filter(games, function(map)
return map.map ~= nil
end)
end

---@param maps table[]
---@return fun(opponentIndex: integer): integer
function MatchFunctions.calculateMatchScore(maps)
Expand Down Expand Up @@ -98,10 +72,11 @@ end
-- map related functions
--

-- Parse extradata information
---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(map)
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
Expand Down
14 changes: 7 additions & 7 deletions components/match2/wikis/tft/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ function CustomMatchGroupInput.processMatch(match, options)
return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions)
end

---@param match table
---@param opponents table[]
---@return table[]
function MatchFunctions.extractMaps(match, opponents)
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

---@param match table
---@return table
function MatchFunctions.getExtraData(match)
Expand Down Expand Up @@ -59,13 +66,6 @@ function MatchFunctions.removeUnsetMaps(games)
end)
end

---@param match table
---@param opponents table[]
---@return table[]
function MatchFunctions.extractMaps(match, opponents)
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

---@param match table
---@param map table
---@param opponents table[]
Expand Down

0 comments on commit ae7406b

Please sign in to comment.