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 hero bans on deadlock #4879

Merged
merged 17 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,38 @@ local INDENT = WikiCopyPaste.Indent

function WikiCopyPaste.getMatchCode(bestof, mode, index, opponents, args)
local showScore = Logic.nilOr(Logic.readBoolOrNil, bestof == 0)
local bans = Logic.readBool(args.bans)

local lines = Array.extend(
'{{Match|bestof=' .. (bestof ~= 0 and bestof or ''),
Logic.readBool(args.needsWinner) and INDENT .. '|winner=' or nil,
Array.map(Array.range(1, opponents), function(opponentIndex)
return INDENT .. '|opponent' .. opponentIndex .. '=' .. WikiCopyPaste.getOpponent(mode, showScore)
end),
INDENT .. '|date=|finished=',
INDENT .. '|date=',
INDENT .. '|twitch=|youtube=|vod=',
Array.map(Array.range(1, bestof), WikiCopyPaste._getMapCode),
Array.map(Array.range(1, bestof), function(mapIndex)
return WikiCopyPaste._getMapCode(mapIndex, bans)
end),
'}}'
)

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

---@param mapIndex integer
---@param bans boolean
---@return string
function WikiCopyPaste._getMapCode(mapIndex)
function WikiCopyPaste._getMapCode(mapIndex, bans)
return table.concat(Array.extend(
INDENT .. '|map' .. mapIndex .. '={{Map|length=|winner=|vod=',
INDENT .. INDENT .. '|team1side=|team2side=',
INDENT .. '|map' .. mapIndex .. '={{Map',
INDENT .. INDENT .. '|team1side=',
INDENT .. INDENT .. '|t1h1=|t1h2=|t1h3=|t1h4=|t1h5=|t1h6=',
bans and (INDENT .. INDENT .. '|t1b1=|t1b2=|t1b3=|t1b4=|t1b5=|t1b6=') or nil,
INDENT .. INDENT .. '|team2side=',
INDENT .. INDENT .. '|t2h1=|t2h2=|t2h3=|t2h4=|t2h5=|t2h6=',
bans and (INDENT .. INDENT .. '|t2b1=|t2b2=|t2b3=|t2b4=|t2b5=|t2b6=') or nil,
INDENT .. INDENT .. '|length=|winner=|matchid=|vod=',
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
INDENT .. '}}'
), '\n')
end
Expand Down
19 changes: 15 additions & 4 deletions components/match2/wikis/deadlock/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function MatchFunctions.extractMaps(match, opponents)

map.map = nil
map.participants = MapFunctions.getParticipants(map, opponents)
map.extradata = MapFunctions.getExtraData(map)
map.extradata = MapFunctions.getExtraData(map, #opponents)

map.finished = MatchGroupInputUtil.mapIsFinished(map)
local opponentInfo = Array.map(opponents, function(_, opponentIndex)
Expand Down Expand Up @@ -132,15 +132,26 @@ function MatchFunctions.getExtraData(match)
end

---@param map table
---@param opponentCount integer
---@return table
function MapFunctions.getExtraData(map)
local extraData = {
function MapFunctions.getExtraData(map, opponentCount)
local extradata = {
comment = map.comment,
team1side = map.team1side,
team2side = map.team2side,
}

return extraData
local getCharacterName = FnUtil.curry(MatchGroupInputUtil.getCharacterName, HeroNames)
for opponentIndex = 1, opponentCount do
for _, ban, banIndex in Table.iter.pairsByPrefix(map, 't' .. opponentIndex .. 'b') do
extradata['team' .. opponentIndex .. 'ban' .. banIndex] = getCharacterName(ban)
end
for _, pick, pickIndex in Table.iter.pairsByPrefix(map, 't' .. opponentIndex .. 'h') do
extradata['team' .. opponentIndex .. 'hero' .. pickIndex] = getCharacterName(pick)
end
end

return extradata
end

---@param map table
Expand Down
11 changes: 11 additions & 0 deletions components/match2/wikis/deadlock/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ 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 MAX_NUM_BANS = 6
Rathoz marked this conversation as resolved.
Show resolved Hide resolved
local ICONS = {
winner = Icon.makeIcon{iconName = 'winner', color = 'forest-green-text', size = 'initial'},
loss = Icon.makeIcon{iconName = 'loss', color = 'cinnabar-text', size = 'initial'},
Expand Down Expand Up @@ -46,8 +47,18 @@ function CustomMatchSummary.createBody(match)
))
end

-- Iterate each map
Array.forEach(Array.map(match.games, CustomMatchSummary._createGame), FnUtil.curry(body.addRow, body))

-- Add the Hero Bans
local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS)
if characterBansData then
body.root:node(MatchSummaryWidgets.CharacterBanTable{
bans = characterBansData,
date = match.date,
})
end

return body
end

Expand Down
Loading