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): use ffa base ms on starcraft(2) #5207

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
efbd975
feat(match2): use ffa base ms on starcraft(2)
hjpalpha Dec 14, 2024
5eb1af0
rename var
hjpalpha Dec 14, 2024
26b0fe8
unused import
hjpalpha Dec 14, 2024
cf7579c
double to single quote
hjpalpha Dec 14, 2024
1ea456b
switch to fix
hjpalpha Dec 14, 2024
914bea5
only show countdown in header if games actually have dates
hjpalpha Dec 14, 2024
bf86c1e
not needed anymore
hjpalpha Dec 14, 2024
02442c6
linter: unused var
hjpalpha Dec 14, 2024
3ef7b95
unused import
hjpalpha Dec 14, 2024
c31c77a
missed to replace that
hjpalpha Dec 14, 2024
6e0f6aa
fix the display for with points
hjpalpha Dec 14, 2024
a931941
nill catches in standard ffa game
hjpalpha Dec 14, 2024
7da23b7
game summary
hjpalpha Dec 14, 2024
8ba58cd
make GameStandingsColumns adjustable
hjpalpha Dec 14, 2024
bd2c0e3
sc(2) adjustGameStandingsColumns
hjpalpha Dec 14, 2024
10159e0
unused import
hjpalpha Dec 14, 2024
5af121c
as per review
hjpalpha Dec 16, 2024
094fdd6
from review
hjpalpha Dec 16, 2024
5de7261
update smoke on apex
hjpalpha Dec 16, 2024
8ec98c3
as per review move function to commons
hjpalpha Dec 16, 2024
9f33433
not needed
hjpalpha Dec 16, 2024
9711340
linter: unused import
hjpalpha Dec 16, 2024
740bd64
fix anno
hjpalpha Dec 16, 2024
83d257f
as per review use MatchSummaryFfa.schedule in all customs
hjpalpha Dec 16, 2024
45c9170
smoke
hjpalpha Dec 16, 2024
851d289
Merge branch 'main' into sc2-ffa-ms-use-base
hjpalpha Dec 19, 2024
46a28af
noscore into settings
hjpalpha Dec 19, 2024
97de033
refacto schedule/countdown stuff as mentioned in screenshot
hjpalpha Dec 19, 2024
0266c64
linter:unused import
hjpalpha Dec 19, 2024
8ce6221
fixerino
hjpalpha Dec 19, 2024
39e5b49
smoke
hjpalpha Dec 19, 2024
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
66 changes: 51 additions & 15 deletions components/match2/commons/match_summary_base_ffa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ local STATUS_ICONS = {
trophy = 'firstplace',
matchpoint = 'matchpoint',
}
MatchSummaryFfa.STATUS_ICONS = STATUS_ICONS
hjpalpha marked this conversation as resolved.
Show resolved Hide resolved

local MATCH_OVERVIEW_COLUMNS = {
{
id = 'status',
class = 'cell--status',
show = function(match)
return Table.any(match.extradata.placementinfo or {}, function(_, value)
Expand All @@ -66,6 +68,7 @@ local MATCH_OVERVIEW_COLUMNS = {
},
},
{
id = 'rank',
sortable = true,
sortType = 'rank',
class = 'cell--rank',
Expand All @@ -90,6 +93,7 @@ local MATCH_OVERVIEW_COLUMNS = {
},
},
{
id = 'opponent',
sortable = true,
sortType = 'team',
class = 'cell--team',
Expand All @@ -115,6 +119,7 @@ local MATCH_OVERVIEW_COLUMNS = {
},
},
{
id = 'totalPoints',
sortable = true,
sortType = 'total-points',
class = 'cell--total-points',
Expand All @@ -135,6 +140,7 @@ local MATCH_OVERVIEW_COLUMNS = {
},
},
{
id = 'matchPoints',
sortable = true,
sortType = 'match-points',
class = 'cell--match-points',
Expand All @@ -153,13 +159,14 @@ local MATCH_OVERVIEW_COLUMNS = {
},
row = {
value = function (opponent, idx)
return opponent.matchPointReachedIn and "Game " .. opponent.matchPointReachedIn or nil
return opponent.matchPointReachedIn and 'Game ' .. opponent.matchPointReachedIn or nil
end,
},
},
}
local GAME_OVERVIEW_COLUMNS = {
{
id = 'placement',
show = function(match)
return (match.extradata.settings or {}).showGameDetails
end,
Expand Down Expand Up @@ -190,6 +197,7 @@ local GAME_OVERVIEW_COLUMNS = {
},
},
{
id = 'kills',
show = function(match)
if (match.extradata.settings or {}).showGameDetails == false then
return false
Expand All @@ -205,11 +213,12 @@ local GAME_OVERVIEW_COLUMNS = {
},
row = {
value = function (opponent)
return opponent.scoreBreakdown.kills
return (opponent.scoreBreakdown or {}).kills
end,
},
},
{
id = 'points',
show = function(match)
return not (match.extradata.settings or {}).showGameDetails
end,
Expand All @@ -227,6 +236,7 @@ local GAME_OVERVIEW_COLUMNS = {
}
local GAME_STANDINGS_COLUMNS = {
{
id = 'rank',
sortable = true,
sortType = 'rank',
class = 'cell--rank',
Expand Down Expand Up @@ -259,6 +269,7 @@ local GAME_STANDINGS_COLUMNS = {
},
},
{
id = 'opponent',
sortable = true,
sortType = 'team',
class = 'cell--team',
Expand All @@ -284,6 +295,7 @@ local GAME_STANDINGS_COLUMNS = {
},
},
{
id = 'totalPoints',
sortable = true,
sortType = 'total-points',
class = 'cell--total-points',
Expand All @@ -304,6 +316,7 @@ local GAME_STANDINGS_COLUMNS = {
},
},
{
id = 'placements',
sortable = true,
sortType = 'placements',
class = 'cell--placements',
Expand All @@ -313,16 +326,17 @@ local GAME_STANDINGS_COLUMNS = {
},
sortVal = {
value = function (opponent, idx)
return opponent.scoreBreakdown.placePoints
return (opponent.scoreBreakdown or {}).placePoints
end,
},
row = {
value = function (opponent, idx)
return opponent.scoreBreakdown.placePoints
return (opponent.scoreBreakdown or {}).placePoints
end,
},
},
{
id = 'kills',
sortable = true,
sortType = 'kills',
class = 'cell--kills',
Expand All @@ -332,12 +346,12 @@ local GAME_STANDINGS_COLUMNS = {
},
sortVal = {
value = function (opponent, idx)
return opponent.scoreBreakdown.killPoints
return (opponent.scoreBreakdown or {}).killPoints
end,
},
row = {
value = function (opponent, idx)
return opponent.scoreBreakdown.killPoints
return (opponent.scoreBreakdown or {}).killPoints
end,
},
},
Expand Down Expand Up @@ -389,11 +403,25 @@ function MatchSummaryFfa.createScoringData(match)
return newScores
end

---@class FfaMatchSummaryParser
---@field adjustMatchColumns? fun(defaultColumns: table[]): table[]
---@field adjustGameOverviewColumns? fun(defaultColumns: table[]): table[]
---@field gameHeader? fun(match: table, game: table, gameIndex: integer): Widget[]

---@param match table
---@param Parser FfaMatchSummaryParser?
---@return MatchSummaryFfaTable
function MatchSummaryFfa.standardMatch(match)
function MatchSummaryFfa.standardMatch(match, Parser)
Parser = Parser or {}
local matchColumns = Parser.adjustMatchColumns
and Parser.adjustMatchColumns(MATCH_OVERVIEW_COLUMNS)
or MATCH_OVERVIEW_COLUMNS
local gameOverviewColumns = Parser.adjustGameOverviewColumns
and Parser.adjustGameOverviewColumns(GAME_OVERVIEW_COLUMNS)
or GAME_OVERVIEW_COLUMNS

local rows = Array.map(match.opponents, function (opponent, index)
local children = Array.map(MATCH_OVERVIEW_COLUMNS, function(column)
local children = Array.map(matchColumns, function(column)
if column.show and not column.show(match) then
return
end
Expand All @@ -414,7 +442,7 @@ function MatchSummaryFfa.standardMatch(match)
children = Array.map(opponent.games, function(gameOpponent)
local gameRow = HtmlWidgets.Div{
classes = {'panel-table__cell', 'cell--game'},
children = Array.map(GAME_OVERVIEW_COLUMNS, function(column)
children = Array.map(gameOverviewColumns, function(column)
if column.show and not column.show(match) then
return
end
Expand All @@ -431,7 +459,7 @@ function MatchSummaryFfa.standardMatch(match)
return MatchSummaryWidgets.TableRow{children = children}
end)

local cells = Array.map(MATCH_OVERVIEW_COLUMNS, function(column)
local cells = Array.map(matchColumns, function(column)
if column.show and not column.show(match) then
return
end
Expand Down Expand Up @@ -463,7 +491,7 @@ function MatchSummaryFfa.standardMatch(match)
children = {
HtmlWidgets.Div{
classes = {'panel-table__cell__game-head'},
children = {
children = Parser.gameHeader and Parser.gameHeader(match, game, idx) or {
HtmlWidgets.Div{
classes = {'panel-table__cell__game-title'},
children = {
Expand All @@ -479,7 +507,7 @@ function MatchSummaryFfa.standardMatch(match)
},
HtmlWidgets.Div{
classes = {'panel-table__cell__game-details'},
children = Array.map(GAME_OVERVIEW_COLUMNS, function(column)
children = Array.map(gameOverviewColumns, function(column)
if column.show and not column.show(match) then
return
end
Expand All @@ -505,11 +533,19 @@ function MatchSummaryFfa.standardMatch(match)
}}
end

---@class FfaGameSummaryParser
---@field adjustGameStandingsColumns? fun(defaultColumns: table[], game: table): table[]

---@param game table
---@param Parser FfaGameSummaryParser?
---@return MatchSummaryFfaTable
function MatchSummaryFfa.standardGame(game)
function MatchSummaryFfa.standardGame(game, Parser)
Parser = Parser or {}
local gameStandingsColumns = Parser.adjustGameStandingsColumns
and Parser.adjustGameStandingsColumns(GAME_STANDINGS_COLUMNS, game)
or GAME_STANDINGS_COLUMNS
local rows = Array.map(game.opponents, function (opponent, index)
local children = Array.map(GAME_STANDINGS_COLUMNS, function(column)
local children = Array.map(gameStandingsColumns, function(column)
if column.show and not column.show(game) then
return
end
Expand All @@ -525,7 +561,7 @@ function MatchSummaryFfa.standardGame(game)
end)

return MatchSummaryWidgets.Table{children = {
MatchSummaryWidgets.TableHeader{children = Array.map(GAME_STANDINGS_COLUMNS, function(column)
MatchSummaryWidgets.TableHeader{children = Array.map(gameStandingsColumns, function(column)
if column.show and not column.show(game) then
return
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
-- @Liquipedia
-- wiki=commons
-- page=Module:GameSummary/Starcraft/FFa
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local CustomGameSummary = {}

local Array = require('Module:Array')
local Lua = require('Module:Lua')

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

local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa')
local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All')

---@param props {bracketId: string, matchId: string, gameIdx: integer}
---@return Html
function CustomGameSummary.getGameByMatchId(props)
local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId)

local game = match.games[props.gameIdx]
assert(game, 'Error Game ID ' .. tostring(props.gameIdx) .. ' not found')

game.stream = match.stream
game.noScore = match.noScore

SummaryHelper.updateGameOpponents(game, match.opponents)

return MatchSummaryWidgets.Tab{
matchId = match.matchId,
idx = props.gameIdx,
children = {
MatchSummaryWidgets.GameDetails{game = game},
SummaryHelper.standardGame(game, CustomGameSummary)
}
}
end

---@param columns table[]
---@param game table
---@return table[]
function CustomGameSummary.adjustGameStandingsColumns(columns, game)
return Array.map(columns, function(column)
if column.id == 'totalPoints' and game.noScore then
return
elseif column.id == 'placements' or column.id == 'kills' then
return
hjpalpha marked this conversation as resolved.
Show resolved Hide resolved
end

return column
end)
end

return CustomGameSummary

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function MapFunctions.readMap(mapInput, opponentCount, hasScores)

if mapInput.date then
Table.mergeInto(map, MatchGroupInputUtil.readDate(map.date))
map.extradata = map.dateexact
end

if MatchGroupInputUtil.isNotPlayed(mapInput.winner, mapInput.finished) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local MatchSummary = Lua.import('Module:MatchSummary/Base')
local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All')
local MatchGroupUtil = Lua.import('Module:MatchGroup/Util')
local MatchGroupUtilStarcraft = Lua.import('Module:MatchGroup/Util/Starcraft')
local WidgetUtil = Lua.import('Module:Widget/Util')

Expand All @@ -39,16 +38,6 @@ local StarcraftMatchSummary = {}
---@param args {bracketId: string, matchId: string, config: table?}
---@return Html
function StarcraftMatchSummary.getByMatchId(args)
local match = MatchGroupUtil.fetchMatchForBracketDisplay(args.bracketId, args.matchId)
---@cast match StarcraftMatchGroupUtilMatch

if match.isFfa then
return Lua.import('Module:MatchSummary/Starcraft/Ffa').getByMatchId{
match = match,
config = args.config
}
end

return MatchSummary.defaultGetByMatchId(StarcraftMatchSummary, args):addClass('brkts-popup-sc')
end

Expand Down
Loading
Loading