diff --git a/lua/wikis/eva/GetMatchGroupCopyPaste/wiki.lua b/lua/wikis/eva/GetMatchGroupCopyPaste/wiki.lua new file mode 100644 index 00000000000..17a91efb93d --- /dev/null +++ b/lua/wikis/eva/GetMatchGroupCopyPaste/wiki.lua @@ -0,0 +1,49 @@ +--- +-- @Liquipedia +-- page=Module:GetMatchGroupCopyPaste/wiki +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local Array = Lua.import('Module:Array') +local Class = Lua.import('Module:Class') +local Logic = Lua.import('Module:Logic') + +local BaseCopyPaste = Lua.import('Module:GetMatchGroupCopyPaste/wiki/Base') + +---@class EvaMatch2CopyPaste: 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 = bestof == 0 + local opponent = WikiCopyPaste.getOpponent(mode, showScore) + + local lines = Array.extendWith({}, + '{{Match', + showScore and (INDENT .. '|finished=') or nil, + 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, + INDENT .. '}}' + ) + + return table.concat(lines, '\n') +end + +return WikiCopyPaste diff --git a/lua/wikis/eva/MatchGroup/Input/Custom.lua b/lua/wikis/eva/MatchGroup/Input/Custom.lua new file mode 100644 index 00000000000..613739bb7d1 --- /dev/null +++ b/lua/wikis/eva/MatchGroup/Input/Custom.lua @@ -0,0 +1,51 @@ +--- +-- @Liquipedia +-- page=Module:MatchGroup/Input/Custom +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') +local FnUtil = Lua.import('Module:FnUtil') +local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util') +local CustomMatchGroupInput = {} + +---@class EvaMatchParser: MatchParserInterface +local MatchFunctions = { + DEFAULT_MODE = 'team', + getBestOf = MatchGroupInputUtil.getBestOf, +} + +---@class EvaMapParser: MapParserInterface +local MapFunctions = {} + +---@param match table +---@param options table? +---@return table +function CustomMatchGroupInput.processMatch(match, options) + return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions) +end + +-- "Normal" match +---@param match table +---@param opponents MGIParsedOpponent[] +---@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 FnUtil.curry(MatchGroupInputUtil.computeMatchScoreFromMapWinners, maps) +end + +---@param match table +---@return table +function MatchFunctions.getExtraData(match) + return { + mapveto = MatchGroupInputUtil.getMapVeto(match), + } +end + +return CustomMatchGroupInput diff --git a/lua/wikis/eva/MatchSummary.lua b/lua/wikis/eva/MatchSummary.lua new file mode 100644 index 00000000000..60911d3df58 --- /dev/null +++ b/lua/wikis/eva/MatchSummary.lua @@ -0,0 +1,46 @@ +--- +-- @Liquipedia +-- 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 Widget +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) + local function makeTeamSection(opponentIndex) + return { + MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = opponentIndex}, + DisplayHelper.MapScore(game.opponents[opponentIndex], game.status) + } + 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