Skip to content

Commit

Permalink
do another 8 wikis
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Nov 5, 2024
1 parent 3b1fee7 commit 6108e79
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 440 deletions.
59 changes: 7 additions & 52 deletions components/match2/wikis/hearthstone/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,72 +14,27 @@ local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local String = require('Module:StringUtils')
local Table = require('Module:Table')
local Variables = require('Module:Variables')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')
local OpponentLibraries = require('Module:OpponentLibraries')
local Opponent = OpponentLibraries.Opponent
local Streams = Lua.import('Module:Links/Stream')

local OPPONENT_CONFIG = {

local CustomMatchGroupInput = {}
local MatchFunctions = {}
local MapFunctions = {}
MatchFunctions.OPPONENT_CONFIG = {
resolveRedirect = true,
pagifyTeamNames = true,
pagifyPlayerNames = true,
}
local TBD = 'TBD'

local CustomMatchGroupInput = {}
local MatchFunctions = {}
local MapFunctions = {}

---@param match table
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
local finishedInput = match.finished --[[@as string?]]
local winnerInput = match.winner --[[@as string?]]

Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date))

local opponents = Array.mapIndexes(function(opponentIndex)
return MatchGroupInputUtil.readOpponent(match, opponentIndex, OPPONENT_CONFIG)
end)

local games = MatchFunctions.extractMaps(match, opponents)

local autoScoreFunction = MatchGroupInputUtil.canUseAutoScore(match, games)
and MatchFunctions.calculateMatchScore(games)
or nil

Array.forEach(opponents, function(opponent, opponentIndex)
opponent.score, opponent.status = MatchGroupInputUtil.computeOpponentScore({
walkover = match.walkover,
winner = match.winner,
opponentIndex = opponentIndex,
score = opponent.score,
}, autoScoreFunction)
end)

match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents)

if match.finished then
match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents)
match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents)
match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents)
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex)
end)
end

match.mode = Variables.varDefault('tournament_mode', 'singles')
Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))

match.stream = Streams.processStreams(match)

match.games = games
match.opponents = opponents

return match
return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions)
end

---@param maps table[]
Expand Down Expand Up @@ -111,7 +66,7 @@ function MatchFunctions.extractMaps(match, opponents)

map.finished = MatchGroupInputUtil.mapIsFinished(map)

local opponentInfo = Array.map(Array.range(1, #opponents), function(opponentIndex)
local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
Expand Down
75 changes: 13 additions & 62 deletions components/match2/wikis/heroes/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,89 +14,41 @@ local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')
local Variables = require('Module:Variables')
local Streams = require('Module:Links/Stream')

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

local DEFAULT_BESTOF = 3
local DEFAULT_MODE = 'team'

local OPPONENT_CONFIG = {}

-- containers for process helper functions
local CustomMatchGroupInput = {}
local MatchFunctions = {}
local MapFunctions = {}

local CustomMatchGroupInput = {}
local DEFAULT_BESTOF = 3
MatchFunctions.DEFAULT_MODE = 'team'
MatchFunctions.OPPONENT_CONFIG = {}
MatchFunctions.DATE_FALLBACKS = {
'tournament_enddate',
'tournament_startdate',
}

---@param match table
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
local finishedInput = match.finished --[[@as string?]]
local winnerInput = match.winner --[[@as string?]]
Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date, {
'tournament_enddate',
'tournament_startdate',
}))

local opponents = Array.mapIndexes(function(opponentIndex)
return MatchGroupInputUtil.readOpponent(match, opponentIndex, OPPONENT_CONFIG)
end)
local games = CustomMatchGroupInput.extractMaps(match, #opponents)
match.bestof = MatchFunctions.getBestOf(match)
match.links = MatchGroupInputUtil.getLinks(match)

local autoScoreFunction = MatchGroupInputUtil.canUseAutoScore(match, games)
and MatchFunctions.calculateMatchScore(games)
or nil

Array.forEach(opponents, function(opponent, opponentIndex)
opponent.score, opponent.status = MatchGroupInputUtil.computeOpponentScore({
walkover = match.walkover,
winner = match.winner,
opponentIndex = opponentIndex,
score = opponent.score,
}, autoScoreFunction)
end)

match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents)

if match.finished then
match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents)
match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents)
match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents)
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex)
end)
end

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
match.opponents = opponents

match.extradata = MatchFunctions.getExtraData(match)

return match
return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions)
end

---@param match table
---@param opponentCount integer
---@param opponents table[]
---@return table[]
function CustomMatchGroupInput.extractMaps(match, opponentCount)
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, opponentCount)
map.extradata = MapFunctions.getExtraData(map, #opponents)

map.finished = MatchGroupInputUtil.mapIsFinished(map)
local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex)
local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
Expand All @@ -120,7 +72,6 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount)
return maps
end


--
-- match related functions
---
Expand Down
82 changes: 17 additions & 65 deletions components/match2/wikis/honorofkings/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,39 @@ local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')
local Variables = require('Module:Variables')
local Streams = require('Module:Links/Stream')

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

local MAX_NUM_PLAYERS = 5
local DEFAULT_BESTOF = 3
local DEFAULT_MODE = 'team'
local DUMMY_MAP = 'default'
local CustomMatchGroupInput = {}
local MatchFunctions = {}
local MapFunctions = {}

local OPPONENT_CONFIG = {
MatchFunctions.DEFAULT_MODE = 'team'
MatchFunctions.OPPONENT_CONFIG = {
resolveRedirect = true,
pagifyTeamNames = false,
maxNumPlayers = 5,
}
MatchFunctions.DATE_FALLBACKS = {
'tournament_enddate',
'tournament_startdate',
}

-- containers for process helper functions
local MatchFunctions = {}
local MapFunctions = {}

local CustomMatchGroupInput = {}
local MAX_NUM_PLAYERS = 5
local DEFAULT_BESTOF = 3
local DUMMY_MAP = 'default'

-- called from Module:MatchGroup
---@param match table
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
local finishedInput = match.finished --[[@as string?]]
local winnerInput = match.winner --[[@as string?]]
Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date, {
'tournament_enddate',
'tournament_startdate',
}))

local opponents = Array.mapIndexes(function(opponentIndex)
return MatchGroupInputUtil.readOpponent(match, opponentIndex, OPPONENT_CONFIG)
end)
local games = CustomMatchGroupInput.extractMaps(match, #opponents)
match.bestof = MatchFunctions.getBestOf(match)
match.links = MatchGroupInputUtil.getLinks(match)

local autoScoreFunction = MatchGroupInputUtil.canUseAutoScore(match, games)
and MatchFunctions.calculateMatchScore(games)
or nil

Array.forEach(opponents, function(opponent, opponentIndex)
opponent.score, opponent.status = MatchGroupInputUtil.computeOpponentScore({
walkover = match.walkover,
winner = match.winner,
opponentIndex = opponentIndex,
score = opponent.score,
}, autoScoreFunction)
end)

match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents)

if match.finished then
match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents)
match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents)
match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents)
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex)
end)
end

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
match.opponents = opponents

match.extradata = MatchFunctions.getExtraData(match)

return match
return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions)
end

---@param match table
---@param opponentCount integer
---@param opponents table[]
---@return table[]
function CustomMatchGroupInput.extractMaps(match, opponentCount)
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?]]
Expand All @@ -104,10 +56,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount)
map.map = nil
end

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

map.finished = MatchGroupInputUtil.mapIsFinished(map)
local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex)
local opponentInfo = Array.map(opponents, function(_, opponentIndex)
local score, status = MatchGroupInputUtil.computeOpponentScore({
walkover = map.walkover,
winner = map.winner,
Expand Down
51 changes: 5 additions & 46 deletions components/match2/wikis/magic/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ local Lua = require('Module:Lua')
local Operator = require('Module:Operator')
local Table = require('Module:Table')
local Variables = require('Module:Variables')
local Streams = require('Module:Links/Stream')

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

local OpponentLibrary = require('Module:OpponentLibraries')
local Opponent = OpponentLibrary.Opponent

local CustomMatchGroupInput = {}

local DEFAULT_BESTOF = 99

local OPPONENT_CONFIG = {
CustomMatchGroupInput.OPPONENT_CONFIG = {
resolveRedirect = true,
pagifyTeamNames = true,
}
CustomMatchGroupInput.DEFAULT_MODE = 'solo'

local CustomMatchGroupInput = {}

-- called from Module:MatchGroup
---@param match table
Expand All @@ -39,49 +40,7 @@ function CustomMatchGroupInput.processMatch(match)
error('Team opponents are currently not yet supported on magic wiki')
end

local finishedInput = match.finished --[[@as string?]]
local winnerInput = match.winner --[[@as string?]]
Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date))

local opponents = Array.mapIndexes(function(opponentIndex)
return MatchGroupInputUtil.readOpponent(match, opponentIndex, OPPONENT_CONFIG)
end)
local games = CustomMatchGroupInput.extractMaps(match, opponents)
match.bestof = CustomMatchGroupInput.getBestOf(match)

local autoScoreFunction = MatchGroupInputUtil.canUseAutoScore(match, games)
and CustomMatchGroupInput.calculateMatchScore(games)
or nil

Array.forEach(opponents, function(opponent, opponentIndex)
opponent.score, opponent.status = MatchGroupInputUtil.computeOpponentScore({
walkover = match.walkover,
winner = match.winner,
opponentIndex = opponentIndex,
score = opponent.score,
}, autoScoreFunction)
end)

match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents)

if match.finished then
match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents)
match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents)
match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents)
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex)
end)
end

match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo'))
Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))

match.stream = Streams.processStreams(match)

match.games = games
match.opponents = opponents

return match
return MatchGroupInputUtil.standardProcessMatch(match, CustomMatchGroupInput)
end

---@param match table
Expand Down
Loading

0 comments on commit 6108e79

Please sign in to comment.