-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathMatchSummary.lua
More file actions
85 lines (71 loc) · 2.71 KB
/
MatchSummary.lua
File metadata and controls
85 lines (71 loc) · 2.71 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
---
-- @Liquipedia
-- page=Module:MatchSummary
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--
local Lua = require('Module:Lua')
local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local MatchSummary = Lua.import('Module:MatchSummary/Base')
local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All')
local WidgetUtil = Lua.import('Module:Widget/Util')
local MAX_NUM_BANS = 5
local NUM_CHAMPIONS_PICK = 5
---@class MobileLegendsCustomMatchSummary: CustomMatchSummaryInterface
local CustomMatchSummary = {}
---@class MobileLegendsMatchSummaryGameRow: MatchSummaryGameRow
---@operator call(MatchSummaryGameRowProps): MobileLegendsMatchSummaryGameRow
local MobileLegendsMatchSummaryGameRow = Class.new(MatchSummaryWidgets.GameRow)
---@param args table
---@return Widget
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'hybrid'})
end
---@param match MatchGroupUtilMatch
---@return Widget[]
function CustomMatchSummary.createBody(match)
local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS)
---@param game MatchGroupUtilGame
---@return boolean
local function hasCharacterData(game)
local extradata = game.extradata or {}
return Array.any(Array.range(1, NUM_CHAMPIONS_PICK), function (index)
return Logic.isNotEmpty(extradata['team1champion' .. index])
or Logic.isNotEmpty(extradata['team2champion' .. index])
end)
end
return WidgetUtil.collect(
MatchSummaryWidgets.GamesContainer{
children = Array.map(match.games, function (game, gameIndex)
if Logic.isEmpty(game.length) and Logic.isEmpty(game.winner) and not hasCharacterData(game) then
return
end
return MobileLegendsMatchSummaryGameRow{game = game, gameIndex = gameIndex}
end)
},
MatchSummaryWidgets.Mvp(match.extradata.mvp),
MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date}
)
end
---@return Renderable?
function MobileLegendsMatchSummaryGameRow:createGameOverview()
return self:lengthDisplay()
end
---@param opponentIndex integer
---@return Widget
function MobileLegendsMatchSummaryGameRow:createGameOpponentView(opponentIndex)
local props = self.props
local game = props.game
local extradata = game.extradata or {}
return MatchSummaryWidgets.Characters{
flipped = opponentIndex == 2,
characters = MatchSummary.buildCharacterList(
extradata, 'team' .. opponentIndex .. 'champion', NUM_CHAMPIONS_PICK
),
bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata['team' .. opponentIndex .. 'side'] or ''),
date = game.date,
}
end
return CustomMatchSummary