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: 0 additions & 2 deletions lua/wikis/chess/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -46,8 +46,6 @@
},
}



---@class ChessMatchSummaryGameRowComponentProps: MatchSummaryGameRowComponentProps
local GameRowComponentProps = {}

Expand Down
1 change: 0 additions & 1 deletion lua/wikis/clashroyale/MatchGroup/Input/Custom.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchGroup/Input/Custom
Expand All @@ -22,7 +22,6 @@
local CustomMatchGroupInput = {}
local MatchFunctions = {}
local MapFunctions = {
ADD_SUB_GROUP = true,
BREAK_ON_EMPTY = true,
}

Expand Down
1 change: 0 additions & 1 deletion lua/wikis/commons/MatchGroup/Input/Starcraft.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchGroup/Input/Starcraft
Expand Down Expand Up @@ -40,7 +40,6 @@

---@class StarcraftMapParser: MapParserInterface
local MapFunctions = {
ADD_SUB_GROUP = true,
BREAK_ON_EMPTY = true,
}

Expand Down
10 changes: 3 additions & 7 deletions lua/wikis/commons/MatchGroup/Input/Util.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchGroup/Input/Util
Expand Down Expand Up @@ -1221,7 +1221,6 @@
---@field getMapBestOf? fun(map: table): integer?
---@field computeOpponentScore? fun(props: table, autoScore?: fun(opponentIndex: integer):integer?): integer?, string?
---@field getGame? fun(match: table, map:table): string?
---@field ADD_SUB_GROUP? boolean
---@field BREAK_ON_EMPTY? boolean
---@field INHERIT_MAP_DATES? boolean

Expand All @@ -1243,15 +1242,14 @@
--- - getGame(match, map): string?
---
--- Additionally, the Parser may have the following properties:
--- - ADD_SUB_GROUP boolean?
--- - BREAK_ON_EMPTY boolean?
---@param match table
---@param opponents MGIParsedOpponent[]
---@param Parser MapParserInterface
---@return table[]
function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser)
local maps = {}
local subGroup = 0
local nextSubGroup = 1
local lastDate = match.date

for key, mapInput, mapIndex in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
Expand All @@ -1270,10 +1268,8 @@

Table.mergeInto(map, MatchGroupInputUtil.readDate(dateToUse))

if Parser.ADD_SUB_GROUP then
subGroup = tonumber(map.subgroup) or (subGroup + 1)
map.subgroup = subGroup
end
map.subgroup = tonumber(map.subgroup) or nextSubGroup
nextSubGroup = map.subgroup + 1

if Parser.getMapName then
map.map, map.mapDisplayName = Parser.getMapName(map, mapIndex, match)
Expand Down
2 changes: 2 additions & 0 deletions lua/wikis/commons/MatchGroup/Util.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchGroup/Util
Expand Down Expand Up @@ -285,6 +285,7 @@
---@field shortname string?
---@field status MatchStatus
---@field stream table
---@field submatches MatchGroupUtilSubgroup[]
---@field tickername string?
---@field tournament string?
---@field type string?
Expand Down Expand Up @@ -611,6 +612,7 @@
}

match.phase = MatchGroupUtil.computeMatchPhase(match)
match.submatches = MatchGroupUtil.groupBySubgroup(match)

return match
end
Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/commons/MatchGroup/Util/Starcraft.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchGroup/Util/Starcraft
Expand Down Expand Up @@ -82,7 +82,7 @@
if match.opponentMode == 'team' then
-- Compute submatches
match.submatches = Array.map(
MatchGroupUtil.groupBySubgroup(match),
match.submatches,
FnUtil.curry(StarcraftMatchGroupUtil.constructSubmatch, match)
)
end
Expand Down
28 changes: 22 additions & 6 deletions lua/wikis/commons/MatchSummary/Base.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary/Base
Expand Down Expand Up @@ -71,14 +71,30 @@

local createGames = CustomMatchSummary.createGames
local createGame = CustomMatchSummary.createGame
local GameRow = CustomMatchSummary.GameRow

local nodes
if CustomMatchSummary.GameRow then
nodes = MatchSummaryWidgets.GamesContainer{
children = Array.map(match.games, function(game, gameIndex)
return CustomMatchSummary.GameRow{game = game, gameIndex = gameIndex}
if GameRow then
local sets = match.submatches or {}

-- With one set for all matches, or one game per set, it's redundant to show set level info.
Comment thread
Rathoz marked this conversation as resolved.
if #sets > 1 and #sets < #match.games then
nodes = Array.map(sets, function(set)
return MatchSummaryWidgets.GamesContainer{
gamesSectionName = set.header or ('Set ' .. set.subgroup),
gamesSectionResult = MatchSummaryWidgets.SetHeader{set = set},
children = Array.map(set.games, function(game, gameIndex)
return GameRow{game = game, gameIndex = gameIndex}
end)
}
end)
}
else
nodes = MatchSummaryWidgets.GamesContainer{
children = Array.map(match.games, function(game, gameIndex)
return GameRow{game = game, gameIndex = gameIndex}
end)
}
end
elseif createGames then
nodes = createGames(match)
else
Expand Down Expand Up @@ -239,7 +255,7 @@
type(CustomMatchSummary.createGames) == 'function' or
CustomMatchSummary.GameRow
),
'One of createBody or createGame or createGames must be implemented in Module:MatchSummary'
'One of createBody or createGame or createGames or GameRow must be implemented in Module:MatchSummary'
)

options = options or {}
Expand Down
13 changes: 4 additions & 9 deletions lua/wikis/commons/MatchSummary/Starcraft.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@ end
function StarcraftMatchSummary.createBody(match)
StarcraftMatchSummary.computeOffFactions(match)

local subMatches
if match.opponentMode ~= UNIFORM_MATCH then
subMatches = match.submatches or {}
end

return WidgetUtil.collect(
Array.map(match.opponents, StarcraftMatchSummary.advantageOrPenalty),
subMatches and Array.map(subMatches, StarcraftMatchSummary.TeamSubmatch)
match.opponentMode ~= UNIFORM_MATCH and Array.map(match.submatches or {}, StarcraftMatchSummary.TeamSubmatch)
or Array.map(match.games, FnUtil.curry(StarcraftMatchSummary.Game, {})),
Logic.isNotEmpty(match.vetoes) and MatchSummaryWidgets.Row{
css = {['text-align'] = 'center'},
Expand Down Expand Up @@ -110,7 +105,7 @@ end

---@param options {noLink: boolean?, isPartOfSubMatch: boolean?}
---@param game StarcraftMatchGroupUtilGame
---@return MatchSummaryRow
---@return Renderable
function StarcraftMatchSummary.Game(options, game)
local noLink = options.noLink or (game.map or ''):upper() == TBD

Expand Down Expand Up @@ -207,7 +202,7 @@ function StarcraftMatchSummary.TeamSubMatchOpponnetRow(submatch)

---@param opponentIndex integer
---@param additionalClasses string[]?
---@return Widget
---@return Renderable
local createScore = function(opponentIndex, additionalClasses)
return OpponentDisplay.BlockScore{
additionalClasses = additionalClasses,
Expand Down Expand Up @@ -239,7 +234,7 @@ function StarcraftMatchSummary.TeamSubMatchOpponnetRow(submatch)
end

---@param veto StarcraftMatchGroupUtilVeto
---@return MatchSummaryRow
---@return Renderable
function StarcraftMatchSummary.Veto(veto)
local statusIcon = function(opponentIndex)
return opponentIndex == veto.by and MAP_VETO_LABEL or nil
Expand Down
1 change: 1 addition & 0 deletions lua/wikis/commons/Widget/Match/Summary/All.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ Widgets.MapVeto = Lua.import('Module:Widget/Match/Summary/MapVeto')
Widgets.MatchComment = Lua.import('Module:Widget/Match/Summary/MatchComment')
Widgets.Mvp = Lua.import('Module:Widget/Match/Summary/Mvp')
Widgets.Row = Lua.import('Module:Widget/Match/Summary/Row')
Widgets.SetHeader = Lua.import('Module:Widget/Match/Summary/SetHeader')

return Widgets
99 changes: 99 additions & 0 deletions lua/wikis/commons/Widget/Match/Summary/SetHeader.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
-- @Liquipedia
-- page=Module:Widget/Match/Summary/SetHeader
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')

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

local Component = Lua.import('Module:Widget/Component')
local Html = Lua.import('Module:Widget/Html')
local Span = Html.Span
local Div = Html.Div

local WinLossIndicator = Lua.import('Module:Widget/Match/Summary/GameWinLossIndicator')

---@param props {set: MatchGroupUtilSubgroup}
---@return VNode?
local function MatchSetHeader(props)
-- TODO: Move logic elsewhere in the future
local set = props.set
if not set then
return nil
end

local isStarted = Array.any(set.games, function (game)
return MatchGroupUtil.computeMatchPhase(game) ~= 'upcoming'
end)
local isFinished = Array.all(set.games, function (game)
return MatchGroupUtil.computeMatchPhase(game) == 'finished'
end)

local scoreLeft, scoreRight = 0, 0
if isStarted then
Array.forEach(set.games, function(game)
if game.winner == 1 then
scoreLeft = scoreLeft + 1
elseif game.winner == 2 then
scoreRight = scoreRight + 1
end
end)
end

local winner
if isFinished then
if scoreLeft == scoreRight then
winner = 0
elseif scoreLeft > scoreRight then
winner = 1
elseif scoreRight > scoreLeft then
winner = 2
end
end

return Div{
classes = {'brkts-popup-body-grid-header-center'},
children = {
Div{
children = {
WinLossIndicator{winner = winner, opponentIndex = 1}
}
},
Div{
classes = {'match-info-header-scoreholder'},
children = isStarted and {
Span{
classes = {
'match-info-header-scoreholder-score',
(winner == 0 or winner == 1) and 'match-info-header-winner' or nil
},
children = scoreLeft,
},
Span{
classes = {'match-info-header-scoreholder-divider'},
children = ':'
},
Span{
classes = {
'match-info-header-scoreholder-score',
(winner == 0 or winner == 2) and 'match-info-header-winner' or nil
},
children = scoreRight,
}
} or nil,
},
Div{
children = {
WinLossIndicator{winner = winner, opponentIndex = 2}
}
},
}
}
end

return Component.component(MatchSetHeader)
4 changes: 1 addition & 3 deletions lua/wikis/hearthstone/MatchGroup/Input/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ local MatchFunctions = {
}

---@class HearthstoneMapParser: MapParserInterface
local MapFunctions = {
ADD_SUB_GROUP = true,
}
local MapFunctions = {}

---@class HearthstoneFfaMatchParser: FfaMatchParserInterface
local FfaMatchFunctions = {
Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/hearthstone/MatchGroup/Util/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function CustomMatchGroupUtil.matchFromRecord(record)

-- Compute submatches
match.submatches = Array.map(
MatchGroupUtil.groupBySubgroup(match),
match.submatches,
FnUtil.curry(CustomMatchGroupUtil.constructSubmatch, match)
)

Expand Down Expand Up @@ -82,6 +82,7 @@ end
function CustomMatchGroupUtil.constructSubmatch(match, subgroup)
local games = subgroup.games
local firstGame = games[1]
---@type HearthstoneMatchGroupUtilGameOpponent[]
local opponents = Table.deepCopy(firstGame.opponents)
local isSubmatch = string.find(firstGame.map or '', '^[sS]ubmatch %d+$')
if isSubmatch then
Expand Down
7 changes: 1 addition & 6 deletions lua/wikis/hearthstone/MatchSummary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ end
---@param match HearthstoneMatchGroupUtilMatch
---@return Renderable[]
function CustomMatchSummary.createBody(match)
local submatches
if match.isTeamMatch then
submatches = match.submatches or {}
end

return WidgetUtil.collect(
submatches and Array.map(submatches, CustomMatchSummary.TeamSubmatch)
match.isTeamMatch and Array.map(match.submatches or {}, CustomMatchSummary.TeamSubmatch)
or Array.map(match.games, FnUtil.curry(CustomMatchSummary.Game, {isPartOfSubMatch = false}))
)
end
Expand Down
1 change: 0 additions & 1 deletion lua/wikis/stormgate/MatchGroup/Input/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ local MatchFunctions = {
},
}
local MapFunctions = {
ADD_SUB_GROUP = true,
BREAK_ON_EMPTY = true,
}

Expand Down
3 changes: 2 additions & 1 deletion lua/wikis/stormgate/MatchGroup/Util/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function CustomMatchGroupUtil.matchFromRecord(record)
if not match.isUniformMode then
-- Compute submatches
match.submatches = Array.map(
MatchGroupUtil.groupBySubgroup(match),
match.submatches,
FnUtil.curry(CustomMatchGroupUtil.constructSubmatch, match)
)
end
Expand Down Expand Up @@ -160,6 +160,7 @@ end
function CustomMatchGroupUtil.constructSubmatch(match, subgroup)
local games = subgroup.games
local firstGame = games[1]
---@type StormgateMatchGroupUtilGameOpponent[]
local opponents = Table.deepCopy(firstGame.opponents)
local isSubmatch = String.startsWith(firstGame.map or '', 'Submatch')
if isSubmatch then
Expand Down
Loading
Loading