Skip to content

Commit

Permalink
do osu too
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Oct 30, 2024
1 parent 3695b0b commit 9f7b980
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
10 changes: 1 addition & 9 deletions components/match2/wikis/osu/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ local Icon = require('Module:Icon')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local Page = require('Module:Page')
local Table = require('Module:Table')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchSummary = Lua.import('Module:MatchSummary/Base')
Expand All @@ -27,9 +26,6 @@ local Icons = {
EMPTY = '[[File:NoCheck.png|link=]]',
}

local VETO_TYPE_TO_TEXT = Table.copy(MatchSummary.DEFAULT_VETO_TYPE_TO_TEXT)
VETO_TYPE_TO_TEXT.protect = 'PROTECT'

local CustomMatchSummary = {}

---@param args table
Expand All @@ -42,17 +38,13 @@ end
---@return MatchSummaryBody
function CustomMatchSummary.createBody(match)
local showCountdown = match.timestamp ~= DateExt.defaultTimestamp
local mapVeto = MatchSummary.defaultMapVetoDisplay(match.extradata.mapveto, {
vetoTypeToText = VETO_TYPE_TO_TEXT,
emptyMapDisplay = NONE}
)

return MatchSummaryWidgets.Body{children = WidgetUtil.collect(
showCountdown and MatchSummaryWidgets.Row{children = DisplayHelper.MatchCountdownBlock(match)} or nil,
Array.map(match.games, CustomMatchSummary._createMapRow),
MatchSummaryWidgets.Mvp(match.extradata.mvp),
MatchSummaryWidgets.Casters{casters = match.extradata.casters},
mapVeto and mapVeto:create() or nil
MatchSummaryWidgets.MapVeto(MatchSummary.preProcessMapVeto(match.extradata.mapveto, {emptyMapDisplay = NONE}))
)}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local DEFAULT_VETO_TYPE_TO_TEXT = {
pick = 'PICK',
decider = 'DECIDER',
defaultban = 'DEFAULT BAN',
protect = 'PROTECT',
}
local VETO_DECIDER = 'decider'

Expand All @@ -27,32 +28,33 @@ local MatchSummaryMapVetoRound = Class.new(Widget)

---@return Widget?
function MatchSummaryMapVetoRound:render()
if not self.props.vetoType then
local vetoType = self.props.vetoType
if not vetoType then
return
end
-- TODO Support Osu's "protect" type
local vetoText = DEFAULT_VETO_TYPE_TO_TEXT[self.props.vetoType]

local vetoText = DEFAULT_VETO_TYPE_TO_TEXT[vetoType]
if not vetoText then
return
end

local function displayMap(map)
if not map.page then
return map
return map.name
end
return Link{
children = map.name,
link = map.page,
}
end

local typeClass = 'brkts-popup-mapveto-' .. self.props.vetoType
local typeClass = 'brkts-popup-mapveto-' .. vetoType
local function createVetoTypeElement()
return HtmlWidgets.Span{classes = {typeClass, 'brkts-popup-mapveto-vetotype'}, text = vetoText}
end

local children
if self.props.vetoType == VETO_DECIDER then
if vetoType == VETO_DECIDER then
children = {
HtmlWidgets.Td{children = createVetoTypeElement()},
HtmlWidgets.Td{children = displayMap(self.props.map1)},
Expand Down

0 comments on commit 9f7b980

Please sign in to comment.