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

feat(match2): Support for Marvel Rivals #5184

Merged
merged 13 commits into from
Dec 17, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
-- @Liquipedia
-- wiki=marvelrivals
-- page=Module:GetMatchGroupCopyPaste/wiki
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Array = require('Module:Array')
local Class = require('Module:Class')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')

local BaseCopyPaste = Lua.import('Module:GetMatchGroupCopyPaste/wiki/Base')

---@class MarvelRivalsMatch2CopyPaste: Match2CopyPasteBase
local WikiCopyPaste = Class.new(BaseCopyPaste)

local INDENT = WikiCopyPaste.Indent

--returns the Code for a Match, depending on the input
---@param bestof integer
---@param mode string
---@param index integer
---@param opponents integer
---@param args table
---@return string
function WikiCopyPaste.getMatchCode(bestof, mode, index, opponents, args)
local showScore = Logic.nilOr(Logic.readBool(args.score), bestof == 0)
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
local opponent = WikiCopyPaste.getOpponent(mode, showScore)

local lines = Array.extendWith({},
'{{Match',
Logic.readBool(args.needsWinner) and (INDENT .. '|winner=') or nil,
Hesketh2 marked this conversation as resolved.
Show resolved Hide resolved
INDENT .. '|date=',
Logic.readBool(args.streams) and (INDENT .. '|twitch=|youtube=|vod=') or nil,
Array.map(Array.range(1, opponents), function(opponentIndex)
return INDENT .. '|opponent' .. opponentIndex .. '=' .. opponent
end),
bestof ~= 0 and Array.map(Array.range(1, bestof), function(mapIndex)
return INDENT .. '|map' .. mapIndex .. '={{Map|map=|score1=|score2=|winner=}}'
end) or nil,
Hesketh2 marked this conversation as resolved.
Show resolved Hide resolved
INDENT .. '}}'
)

return table.concat(lines, '\n')
end

return WikiCopyPaste
59 changes: 59 additions & 0 deletions components/match2/wikis/marvelrivals/match_group_input_custom.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
-- @Liquipedia
-- wiki=marvelrivals
-- page=Module:MatchGroup/Input/Custom
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')

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

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

MatchFunctions.DEFAULT_MODE = 'team'
MatchFunctions.getBestOf = MatchGroupInputUtil.getBestOf
Hesketh2 marked this conversation as resolved.
Show resolved Hide resolved

---@param match table
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions)
end

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

---@param maps table[]
---@return fun(opponentIndex: integer): integer?
function MatchFunctions.calculateMatchScore(maps)
return function(opponentIndex)
return MatchGroupInputUtil.computeMatchScoreFromMapWinners(maps, opponentIndex)
end
end

--
-- map related functions
--

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

return CustomMatchGroupInput
51 changes: 51 additions & 0 deletions components/match2/wikis/marvelrivals/match_summary.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
-- @Liquipedia
-- wiki=marvelrivals
-- page=Module:MatchSummary
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchSummary = Lua.import('Module:MatchSummary/Base')
local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All')
local WidgetUtil = Lua.import('Module:Widget/Util')

local CustomMatchSummary = {}

---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args)
end

---@param date string
---@param game MatchGroupUtilGame
---@param gameIndex integer
---@return Widget?
function CustomMatchSummary.createGame(date, game, gameIndex)
if not game.map then
return
end

local function makeTeamSection(opponentIndex)
return {
MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = opponentIndex},
DisplayHelper.MapScore(game.scores[opponentIndex], opponentIndex, game.resultType, game.walkover, game.winner)
}
end

return MatchSummaryWidgets.Row{
classes = {'brkts-popup-body-game'},
children = WidgetUtil.collect(
MatchSummaryWidgets.GameTeamWrapper{children = makeTeamSection(1)},
MatchSummaryWidgets.GameCenter{children = DisplayHelper.Map(game)},
MatchSummaryWidgets.GameTeamWrapper{children = makeTeamSection(2), flipped = true},
MatchSummaryWidgets.GameComment{children = game.comment}
)
}
end

return CustomMatchSummary
41 changes: 41 additions & 0 deletions standard/info/wikis/marvelrivals/info.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
-- @Liquipedia
-- wiki=marvelrivals
-- page=Module:Info
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

return {
startYear = 2024,
wikiName = 'marvelrivals',
name = 'Marvel Rivals',
defaultGame = 'Marvel Rivals',
games = {
marvelrivals = {
abbreviation = 'Marvel Rivals',
name = 'Marvel Rivals',
link = 'Marvel Rivals',
logo = {
darkMode = 'Marvel Rivals darkmode.png',
lightMode = 'Marvel Rivals lightmode.png',
},
defaultTeamLogo = {
darkMode = 'Marvel Rivals darkmode.png',
lightMode = 'Marvel Rivals lightmode.png',
},
},
},
config = {
squads = {
hasPosition = true,
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
hasSpecialTeam = false,
allowManual = false,
},
match2 = {
status = 2,
matchWidth = 180,
},
},
defaultRoundPrecision = 0,
}
Loading