Skip to content

Commit

Permalink
feat(match2): support for hero bans on deadlock (#4879)
Browse files Browse the repository at this point in the history
* Adding support for Hero Bans in Deadlock

* Update match_summary.lua

* Update match_summary.lua

* Update components/match2/wikis/deadlock/match_summary.lua

Co-authored-by: Rikard Blixt <[email protected]>

* Update components/match2/wikis/deadlock/match_summary.lua

Co-authored-by: Rikard Blixt <[email protected]>

* Update components/match2/wikis/deadlock/match_summary.lua

Co-authored-by: Rikard Blixt <[email protected]>

* Update match_summary.lua

* Update match_summary.lua

* Update Match Copy Paste

* Update get_match_group_copy_paste_wiki.lua

* Update get_match_group_copy_paste_wiki.lua

* Update get_match_group_copy_paste_wiki.lua

* Update match_summary.lua

* Update get_match_group_copy_paste_wiki.lua

* Update match_summary.lua

* #4878

* Update components/match2/wikis/deadlock/match_summary.lua

---------

Co-authored-by: Rikard Blixt <[email protected]>
  • Loading branch information
Kanopedia and Rathoz authored Oct 17, 2024
1 parent dc117c3 commit 9567a20
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
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=',
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
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

0 comments on commit 9567a20

Please sign in to comment.