From e5be9c60ce45f6db080f1de19c8f0d5c22a2709f Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 27 Sep 2023 14:16:31 +0200 Subject: [PATCH 1/9] annos for custom class --- .../wikis/counterstrike/match_summary.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index 91e398f8ca7..7d548456698 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -29,6 +29,12 @@ local EPOCH_TIME_EXTENDED = '1970-01-01T00:00:00+00:00' local TBD = 'TBD' -- Score Class +---@class CounterstrikeScore +---@operator call: CounterstrikeScore +---@field root Html +---@field table Html +---@field top Html +---@field bottom Html local Score = Class.new( function(self, direction) self.root = mw.html.create('div') @@ -41,16 +47,20 @@ local Score = Class.new( end ) +---@return CounterstrikeScore function Score:setLeft() self.table:css('float', 'left') return self end +---@return CounterstrikeScore function Score:setRight() self.table:css('float', 'right') return self end +---@param score string|number|nil +---@return CounterstrikeScore function Score:setMapScore(score) local mapScore = mw.html.create('td') mapScore @@ -64,6 +74,9 @@ function Score:setMapScore(score) return self end +---@param side string +---@param score number +---@return CounterstrikeScore function Score:setFirstHalfScore(score, side) local halfScore = mw.html.create('td') halfScore @@ -75,6 +88,9 @@ function Score:setFirstHalfScore(score, side) return self end +---@param side string +---@param score number +---@return CounterstrikeScore function Score:setSecondHalfScore(score, side) local halfScore = mw.html.create('td') halfScore @@ -86,6 +102,7 @@ function Score:setSecondHalfScore(score, side) return self end +---@return Html function Score:create() self.table:node(self.top):node(self.bottom) return self.root From 6d9baf24d568a3810a17ec79902f8ef7ec609e77 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 27 Sep 2023 14:19:21 +0200 Subject: [PATCH 2/9] annos for 2nd custom class --- .../wikis/counterstrike/match_summary.lua | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index 7d548456698..92eb8c0f5d1 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -16,7 +16,7 @@ local VodLink = require('Module:VodLink') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper', {requireDevIfEnabled = true}) local MatchGroupUtil = Lua.import('Module:MatchGroup/Util', {requireDevIfEnabled = true}) -local MatchSummary = Lua.import('Module:MatchSummary/Base', {requireDevIfEnabled = true}) +local MatchSummary = Lua.import('Module:MatchSummary/Base/temp', {requireDevIfEnabled = true}) local GREEN_CHECK = '[[File:GreenCheck.png|14x14px|link=]]' local NO_CHECK = '[[File:NoCheck.png|link=]]' @@ -109,6 +109,10 @@ function Score:create() end -- Map Veto Class +---@class CounterstrikeMapVeto: MatchSummaryRowInterface +---@operator call: CounterstrikeMapVeto +---@field root Html +---@field table Html local MapVeto = Class.new( function(self) self.root = mw.html.create('div'):addClass('brkts-popup-mapveto') @@ -118,6 +122,7 @@ local MapVeto = Class.new( end ) +---@return CounterstrikeMapVeto function MapVeto:createHeader() self.table:tag('tr') :tag('th'):css('width','33%'):done() @@ -126,6 +131,8 @@ function MapVeto:createHeader() return self end +---@param firstVeto number? +---@return CounterstrikeMapVeto function MapVeto:vetoStart(firstVeto) local textLeft local textCenter @@ -144,6 +151,8 @@ function MapVeto:vetoStart(firstVeto) return self end +---@param map string? +---@return CounterstrikeMapVeto function MapVeto:addDecider(map) map = Logic.emptyOr(map, TBD) @@ -157,6 +166,10 @@ function MapVeto:addDecider(map) return self end +---@param vetotype string? +---@param map1 string? +---@param map2 string? +---@return CounterstrikeMapVeto function MapVeto:addRound(vetotype, map1, map2) map1 = Logic.emptyOr(map1, TBD) map2 = Logic.emptyOr(map2, TBD) @@ -186,6 +199,10 @@ function MapVeto:addRound(vetotype, map1, map2) return self end +---@param row Html +---@param styleClass string +---@param vetoText string +---@return CounterstrikeMapVeto function MapVeto:addColumnVetoType(row, styleClass, vetoText) row:tag('td') :tag('span') @@ -195,11 +212,15 @@ function MapVeto:addColumnVetoType(row, styleClass, vetoText) return self end +---@param row Html +---@param map string? +---@return CounterstrikeMapVeto function MapVeto:addColumnVetoMap(row, map) row:tag('td'):wikitext(map):done() return self end +---@return Html function MapVeto:create() return self.root end From 7044f8dfe82f13007554b8766ebe7811ebf5ba86 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 27 Sep 2023 14:21:33 +0200 Subject: [PATCH 3/9] annos for 3rd custom class --- components/match2/wikis/counterstrike/match_summary.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index 92eb8c0f5d1..3beff639a16 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -225,6 +225,9 @@ function MapVeto:create() return self.root end +---@class CounterstrikeMatchStatus: MatchSummaryRowInterface +---@operator call: CounterstrikeMatchStatus +---@field root Html local MatchStatus = Class.new( function(self) self.root = mw.html.create('div') @@ -235,11 +238,14 @@ local MatchStatus = Class.new( end ) +---@param content string|number|Html|nil +---@return CounterstrikeMatchStatus function MatchStatus:content(content) self.root:node(content):node(MatchSummary.Break():create()) return self end +---@return Html function MatchStatus:create() return self.root end From 8cb49736be708abeb0712ad7c4dc60903e79b01b Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 27 Sep 2023 16:02:04 +0200 Subject: [PATCH 4/9] more annos and adjust for MatchSummary/Base/temp --- .../wikis/counterstrike/match_summary.lua | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index 3beff639a16..495d9b2e41d 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -252,20 +252,41 @@ end local CustomMatchSummary = {} +---@param args table +---@return Html function CustomMatchSummary.getByMatchId(args) - local match = MatchGroupUtil.fetchMatchForBracketDisplay(args.bracketId, args.matchId) + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px'}) +end + +---CreateMatch cs specific overwrite due to altered styles for match comment +---@param matchData table +---@return MatchSummaryMatch? +function CustomMatchSummary.createMatch(matchData) + if not matchData then + return + end - local matchSummary = MatchSummary():init() + local match = MatchSummary.Match() - matchSummary:header(CustomMatchSummary._createHeader(match)) - :body(CustomMatchSummary._createBody(match)) + match + :header(MatchSummary.createDefaultHeader(matchData)) + :body(CustomMatchSummary.createBody(matchData)) - if match.comment then - local comment = MatchSummary.Comment():content(match.comment) + if matchData.comment then + local comment = MatchSummary.Comment():content(matchData.comment) comment.root:css('display', 'block'):css('text-align', 'center') - matchSummary:comment(comment) + match:comment(comment) end + match:footer(CustomMatchSummary.addToFooter(matchData, MatchSummary.Footer())) + + return match +end + +---@param match MatchGroupUtilMatch +---@param footer MatchSummaryFooter +---@return MatchSummaryFooter +function CustomMatchSummary.addToFooter(match, footer) local vods = {} local secondVods = {} if Logic.isNotEmpty(match.links.vod2) then @@ -282,24 +303,15 @@ function CustomMatchSummary.getByMatchId(args) end if not Table.isEmpty(vods) or not Table.isEmpty(match.links) or not Logic.isEmpty(match.vod) then - matchSummary:footer(CustomMatchSummary._createFooter(match, vods, secondVods)) + return CustomMatchSummary._createFooter(match, vods, secondVods) end - return matchSummary:create() -end - -function CustomMatchSummary._createHeader(match) - local header = MatchSummary.Header() - - header:leftOpponent(header:createOpponent(match.opponents[1], 'left')) - :leftScore(header:createScore(match.opponents[1])) - :rightScore(header:createScore(match.opponents[2])) - :rightOpponent(header:createOpponent(match.opponents[2], 'right')) - - return header + return footer end -function CustomMatchSummary._createBody(match) +---@param match MatchGroupUtilMatch +---@return MatchSummaryBody +function CustomMatchSummary.createBody(match) local body = MatchSummary.Body() if match.dateIsExact or (match.date ~= EPOCH_TIME_EXTENDED and match.date ~= EPOCH_TIME) then @@ -353,6 +365,10 @@ function CustomMatchSummary._createBody(match) return body end +---@param match MatchGroupUtilMatch +---@param vods table +---@param secondVods table +---@return MatchSummaryFooter function CustomMatchSummary._createFooter(match, vods, secondVods) local footer = MatchSummary.Footer() @@ -467,6 +483,8 @@ function CustomMatchSummary._createFooter(match, vods, secondVods) return footer end +---@param game MatchGroupUtilGame +---@return MatchSummaryRow function CustomMatchSummary._createMap(game) local row = MatchSummary.Row() local extradata = game.extradata or {} @@ -533,6 +551,8 @@ function CustomMatchSummary._createMap(game) return row end +---@param isWinner boolean? +---@return Html function CustomMatchSummary._createCheckMark(isWinner) local container = mw.html.create('div') container:addClass('brkts-popup-spaced'):css('line-height', '27px') @@ -546,6 +566,9 @@ function CustomMatchSummary._createCheckMark(isWinner) return container end +---@param map string? +---@param game string? +---@return string function CustomMatchSummary._createMapLink(map, game) if Logic.isNotEmpty(map) then if Logic.isNotEmpty(game) then From 9b40b02aee46a998e289236d232c92976bde1f7e Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 27 Sep 2023 16:02:21 +0200 Subject: [PATCH 5/9] shut up wron anno warnings --- components/match2/commons/match_summary_base_temp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/match2/commons/match_summary_base_temp.lua b/components/match2/commons/match_summary_base_temp.lua index 099ce91c944..03b083add46 100644 --- a/components/match2/commons/match_summary_base_temp.lua +++ b/components/match2/commons/match_summary_base_temp.lua @@ -294,7 +294,7 @@ end ---@operator call: MatchSummaryFooter ---@field root Html ---@field inner Html ----@field elements (Html|string)[] +---@field elements (Html|string|number)[] local Footer = Class.new( function(self) self.root = mw.html.create('div') @@ -305,7 +305,7 @@ local Footer = Class.new( end ) ----@param element Html +---@param element Html|string|number|nil ---@return MatchSummaryFooter function Footer:addElement(element) table.insert(self.elements, element) From f597917d42277bcc0eab217ca8f0e66bbf355b42 Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Wed, 27 Sep 2023 16:04:49 +0200 Subject: [PATCH 6/9] kick unused require --- components/match2/wikis/counterstrike/match_summary.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index 495d9b2e41d..b2c107d9c3d 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -15,7 +15,6 @@ local Table = require('Module:Table') local VodLink = require('Module:VodLink') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper', {requireDevIfEnabled = true}) -local MatchGroupUtil = Lua.import('Module:MatchGroup/Util', {requireDevIfEnabled = true}) local MatchSummary = Lua.import('Module:MatchSummary/Base/temp', {requireDevIfEnabled = true}) local GREEN_CHECK = '[[File:GreenCheck.png|14x14px|link=]]' From aafbea2de4b9908603ccd106d0bf827bd3e028cc Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:48:42 +0200 Subject: [PATCH 7/9] fix width --- components/match2/wikis/counterstrike/match_summary.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index b2c107d9c3d..e59f32c7b26 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -254,7 +254,7 @@ local CustomMatchSummary = {} ---@param args table ---@return Html function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px'}) + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args) end ---CreateMatch cs specific overwrite due to altered styles for match comment From ba23d464e76ded57cbbd62202f8c7e2152b06831 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 4 Oct 2023 09:13:49 +0200 Subject: [PATCH 8/9] as per review in #3330 --- .../wikis/counterstrike/match_summary.lua | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index e59f32c7b26..06a5be19586 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -46,20 +46,20 @@ local Score = Class.new( end ) ----@return CounterstrikeScore +---@return self function Score:setLeft() self.table:css('float', 'left') return self end ----@return CounterstrikeScore +---@return self function Score:setRight() self.table:css('float', 'right') return self end ---@param score string|number|nil ----@return CounterstrikeScore +---@return self function Score:setMapScore(score) local mapScore = mw.html.create('td') mapScore @@ -75,7 +75,7 @@ end ---@param side string ---@param score number ----@return CounterstrikeScore +---@return self function Score:setFirstHalfScore(score, side) local halfScore = mw.html.create('td') halfScore @@ -89,7 +89,7 @@ end ---@param side string ---@param score number ----@return CounterstrikeScore +---@return self function Score:setSecondHalfScore(score, side) local halfScore = mw.html.create('td') halfScore @@ -121,7 +121,7 @@ local MapVeto = Class.new( end ) ----@return CounterstrikeMapVeto +---@return self function MapVeto:createHeader() self.table:tag('tr') :tag('th'):css('width','33%'):done() @@ -131,7 +131,7 @@ function MapVeto:createHeader() end ---@param firstVeto number? ----@return CounterstrikeMapVeto +---@return self function MapVeto:vetoStart(firstVeto) local textLeft local textCenter @@ -151,7 +151,7 @@ function MapVeto:vetoStart(firstVeto) end ---@param map string? ----@return CounterstrikeMapVeto +---@return self function MapVeto:addDecider(map) map = Logic.emptyOr(map, TBD) @@ -168,7 +168,7 @@ end ---@param vetotype string? ---@param map1 string? ---@param map2 string? ----@return CounterstrikeMapVeto +---@return self function MapVeto:addRound(vetotype, map1, map2) map1 = Logic.emptyOr(map1, TBD) map2 = Logic.emptyOr(map2, TBD) @@ -201,7 +201,7 @@ end ---@param row Html ---@param styleClass string ---@param vetoText string ----@return CounterstrikeMapVeto +---@return self function MapVeto:addColumnVetoType(row, styleClass, vetoText) row:tag('td') :tag('span') @@ -213,7 +213,7 @@ end ---@param row Html ---@param map string? ----@return CounterstrikeMapVeto +---@return self function MapVeto:addColumnVetoMap(row, map) row:tag('td'):wikitext(map):done() return self @@ -238,7 +238,7 @@ local MatchStatus = Class.new( ) ---@param content string|number|Html|nil ----@return CounterstrikeMatchStatus +---@return self function MatchStatus:content(content) self.root:node(content):node(MatchSummary.Break():create()) return self From 5756ec38d1230dfc6d9f7cccdf8540097b868bf9 Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:12:59 +0200 Subject: [PATCH 9/9] Update components/match2/wikis/counterstrike/match_summary.lua --- components/match2/wikis/counterstrike/match_summary.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/match2/wikis/counterstrike/match_summary.lua b/components/match2/wikis/counterstrike/match_summary.lua index 06a5be19586..fb541c68cbb 100644 --- a/components/match2/wikis/counterstrike/match_summary.lua +++ b/components/match2/wikis/counterstrike/match_summary.lua @@ -258,7 +258,7 @@ function CustomMatchSummary.getByMatchId(args) end ---CreateMatch cs specific overwrite due to altered styles for match comment ----@param matchData table +---@param matchData table? ---@return MatchSummaryMatch? function CustomMatchSummary.createMatch(matchData) if not matchData then