Skip to content
Open
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
2 changes: 1 addition & 1 deletion lua/wikis/deltaforce/GetMatchGroupCopyPaste/wiki.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function WikiCopyPaste.getStandardMatchCode(bestof, mode, index, opponents, args
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=}}'
return INDENT .. '|map' .. mapIndex .. '={{Map|map=|team1side=|team2side=|winner=|vod=}}'
end) or nil,
INDENT .. '}}'
)
Expand Down
63 changes: 57 additions & 6 deletions lua/wikis/deltaforce/MatchGroup/Input/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,32 @@ local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')
local FnUtil = Lua.import('Module:FnUtil')
local Logic = Lua.import('Module:Logic')
local Operator = Lua.import('Module:Operator')
local Variables = Lua.import('Module:Variables')

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

local DEFAULT_BESTOF = 3

local CustomMatchGroupInput = {}

---@class DeltaForceMatchParser: MatchParserInterface
---@class DeltaforceMatchParser: MatchParserInterface
local MatchFunctions = {
DEFAULT_MODE = 'team',
getBestOf = MatchGroupInputUtil.getBestOf,
}

---@class DeltaForceMapParser: MapParserInterface
local MapFunctions = {}
---@class DeltaforceMapParser: MapParserInterface
local MapFunctions = {
BREAK_ON_EMPTY = true,
}

---@class DeltaForceFfaMatchParser: FfaMatchParserInterface
---@class DeltaforceFfaMatchParser: FfaMatchParserInterface
local FfaMatchFunctions = {
DEFAULT_MODE = 'team',
}

---@class DeltaForceFfaMapParser: FfaMapParserInterface
---@class DeltaforceFfaMapParser: FfaMapParserInterface
local FfaMapFunctions = {}

---@param match table
Expand All @@ -47,12 +52,58 @@ function MatchFunctions.extractMaps(match, opponents)
return MatchGroupInputUtil.standardProcessMaps(match, opponents, MapFunctions)
end

---@param bestofInput string|integer?
---@param games table[]
---@return integer?
function MatchFunctions.getBestOf(bestofInput, games)
local bestof = tonumber(bestofInput)

if bestof then
Variables.varDefine('bestof', bestof)
return bestof
end

return tonumber(Variables.varDefault('bestof')) or ((games and #games > 0) and #games) or DEFAULT_BESTOF
end

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

---@param match table
---@param games table[]
---@param opponents MGIParsedOpponent[]
---@return table
function MatchFunctions.getExtraData(match, games, opponents)
return {
mapveto = MatchGroupInputUtil.getMapVeto(match),
mvp = MatchGroupInputUtil.readMvp(match, opponents),
}
end

-- Parse map-side extradata (Attack/Defense) for use in MatchSummary
---@param match table
---@param map table
---@param opponents MGIParsedOpponent[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
if Logic.isEmpty(map.team1side) then
return {}
end

local t1side = map.team1side:upper()

return t1side == 'ATK' and {
t1side = 'ATK',
t2side = 'DEF',
} or t1side == 'DEF' and {
t1side = 'DEF',
t2side = 'ATK',
} or error('Invalid side specified: "' .. map.team1side .. '" (expected ATK or DEF)')
end

--- FFA Match

---@param match table
Expand Down
56 changes: 52 additions & 4 deletions lua/wikis/deltaforce/MatchSummary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,83 @@ local Lua = require('Module:Lua')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchSummary = Lua.import('Module:MatchSummary/Base')

local Html = Lua.import('Module:Widget/Html')
local Image = Lua.import('Module:Widget/Image/Icon/Image')
local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All')
local WidgetUtil = Lua.import('Module:Widget/Util')

local SIDE_ICONS = {
ATK = {
light = 'DF Attacker icon lightmode.png',
dark = 'DF Attacker icon darkmode.png',
},
DEF = {
light = 'DF Defender icon lightmode.png',
dark = 'DF Defender icon darkmode.png',
},
}

local CustomMatchSummary = {}

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

---@param date string
---@param game MatchGroupUtilGame
---@param gameIndex integer
---@return Widget?
---@return Renderable?
function CustomMatchSummary.createGame(date, game, gameIndex)
---@param opponentIndex integer
---@return Renderable[]
local function makeTeamSection(opponentIndex)
return {
MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = opponentIndex},
DisplayHelper.MapScore(game.opponents[opponentIndex], game.status)
}
end

---@param opponentIndex integer
---@return Renderable[]?
local function sideIndicator(opponentIndex)
local iconData = SIDE_ICONS[game.extradata['t' .. opponentIndex .. 'side']]
if not iconData then return end
return {
Html.Span{
classes = {'brkts-popup-spaced'},
children = Image{
imageLight = iconData.light,
imageDark = iconData.dark,
size = '16px',
}
},
Html.Span{
css = {
['font-size'] = '8px',
['font-weight'] = 'bold',
margin = '0 -2px',
['white-space'] = 'nowrap',
},
children = game.extradata['t' .. opponentIndex .. 'side'],
}
}
end

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