-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathGameRow.lua
More file actions
107 lines (93 loc) · 2.89 KB
/
GameRow.lua
File metadata and controls
107 lines (93 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
-- @Liquipedia
-- page=Module:Widget/Match/Summary/GameRow
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--
local Lua = require('Module:Lua')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local Widget = Lua.import('Module:Widget')
local HtmlWidgets = Lua.import('Module:Widget/Html/All')
local GameCenter = Lua.import('Module:Widget/Match/Summary/GameCenter')
local GameWinLossIndicator = Lua.import('Module:Widget/Match/Summary/GameWinLossIndicator')
---@class MatchSummaryGameRowProps
---@field css table<string, string|number>?
---@field game MatchGroupUtilGame
---@field gameIndex integer
---@class MatchSummaryGameRow: Widget
---@operator call(MatchSummaryGameRowProps): MatchSummaryGameRow
---@field props MatchSummaryGameRowProps
local MatchSummaryGameRow = Class.new(Widget)
---@return Widget?
function MatchSummaryGameRow:render()
local props = self.props
return HtmlWidgets.Div{
classes = {'brkts-popup-body-grid-row'},
css = props.css,
children = {
GameWinLossIndicator{
opponentIndex = 1,
winner = props.game.winner,
},
HtmlWidgets.Div{
classes = {'brkts-popup-body-grid-row-detail'},
children = {
GameCenter{children = self:createGameOpponentView(1)},
GameCenter{children = self:createGameOverview()},
GameCenter{children = self:createGameOpponentView(2)}
},
},
GameWinLossIndicator{
opponentIndex = 2,
winner = props.game.winner,
},
self:_renderGameComment()
},
}
end
---@protected
---@param opponentIndex integer
---@return Renderable|Renderable[]
function MatchSummaryGameRow:createGameOpponentView(opponentIndex)
error('MatchSummaryGameRow:createGameOpponentView() cannot be called directly and must be overridden.')
end
---@protected
---@return Renderable|Renderable[]
function MatchSummaryGameRow:createGameOverview()
error('MatchSummaryGameRow:createGameOverview() cannot be called directly and must be overridden.')
end
---@protected
---@return Renderable?
function MatchSummaryGameRow:lengthDisplay()
local game = self.props.game
return Logic.emptyOr(game.length, 'Game ' .. self.props.gameIndex)
end
---@protected
---@param config {noLink: boolean?}?
---@return string
function MatchSummaryGameRow:mapDisplay(config)
local game = self.props.game
return DisplayHelper.Map(game, config)
end
---@protected
---@param opponentIndex integer
---@return string
function MatchSummaryGameRow:scoreDisplay(opponentIndex)
local game = self.props.game
return DisplayHelper.MapScore(game.opponents[opponentIndex], game.status)
end
---@private
---@return Widget?
function MatchSummaryGameRow:_renderGameComment()
local game = self.props.game
if Logic.isEmpty(game.comment) then
return
end
return HtmlWidgets.Div{
classes = {'brkts-popup-comment'},
children = game.comment,
}
end
return MatchSummaryGameRow