Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 10 additions & 19 deletions lua/wikis/commons/PrizePool/Base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ local Lua = require('Module:Lua')
local Abbreviation = Lua.import('Module:Abbreviation')
local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local DateExt = Lua.import('Module:Date/Ext')
local Json = Lua.import('Module:Json')
local LeagueIcon = Lua.import('Module:LeagueIcon')
local Logic = Lua.import('Module:Logic')
local Lpdb = Lua.import('Module:Lpdb')
local MathUtil = Lua.import('Module:MathUtil')
local PageVariableNamespace = Lua.import('Module:PageVariableNamespace')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
Expand Down Expand Up @@ -49,8 +51,6 @@ local BasePrizePool = Class.new(function(self, ...) self:init(...) end)
---@field index integer
---@field data table

local TODAY = os.date('%Y-%m-%d') --[[@as string]]

local LANG = mw.language.getContentLanguage()
local DASH = '-'
local NON_BREAKING_SPACE = ' '
Expand Down Expand Up @@ -89,14 +89,14 @@ BasePrizePool.config = {
cutafter = {
default = 4,
read = function(args)
return tonumber(args.cutafter)
return MathUtil.toInteger(args.cutafter)
end
},
hideafter = {
default = math.huge,
read = function(args)
local hideAfter = tonumber(args.hideafter)
local cutAfter = tonumber(args.cutafter) or 4
local hideAfter = MathUtil.toInteger(args.hideafter)
local cutAfter = MathUtil.toInteger(args.cutafter) or 4
if not hideAfter then
return
end
Expand Down Expand Up @@ -386,7 +386,7 @@ function BasePrizePool:init(args)
self.args = self:_parseArgs(args)

self.pagename = mw.title.getCurrentTitle().text
self.date = BasePrizePool._getTournamentDate()
self.date = DateExt.getContextualDateOrNow()
self.opponentType = self.args.type

self.options = {}
Expand Down Expand Up @@ -773,12 +773,9 @@ function BasePrizePool:_currencyExchangeInfo()
end

-- The exchange date display should not be in the future, as the extension uses current date for those.
local exchangeDate = self.date
if exchangeDate > TODAY then
exchangeDate = TODAY
end

local exchangeDateText = LANG:formatDate('M j, Y', exchangeDate)
local exchangeDateText = DateExt.formatTimestamp(
'M j, Y', math.min(DateExt.getCurrentTimestamp(), DateExt.readTimestamp(self.date))
)

local wrapper = mw.html.create('small')

Expand All @@ -798,7 +795,7 @@ end
---@return string
function BasePrizePool._CurrencyConvertionText(prize)
local exchangeRate = BasePrizePool.prizeTypes[PRIZE_TYPE_LOCAL_CURRENCY].convertToBaseCurrency(
prize.data, 1, BasePrizePool._getTournamentDate()
prize.data, 1, DateExt.getContextualDateOrNow()
)

return Currency.display(prize.data.currency, 1) .. ' ≃ ' ..
Expand Down Expand Up @@ -846,12 +843,6 @@ function BasePrizePool:assertOpponentStructType(typeStruct)
end
end

--- Returns the default date based on wiki-variables set in the Infobox League
---@return string
function BasePrizePool._getTournamentDate()
return Variables.varDefault('tournament_enddate', TODAY)
end

---@return self
function BasePrizePool:storeData()
local prizePoolIndex = (tonumber(Variables.varDefault('prizepool_index')) or 0) + 1
Expand Down
49 changes: 38 additions & 11 deletions lua/wikis/counterstrike/Infobox/League/Custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ local Lua = require('Module:Lua')

local Array = Lua.import('Module:Array')
local Class = Lua.import('Module:Class')
local Logic = Lua.import('Module:Logic')
local FnUtil = Lua.import('Module:FnUtil')
local Json = Lua.import('Module:Json')
local Logic = Lua.import('Module:Logic')
local Operator = Lua.import('Module:Operator')
local Page = Lua.import('Module:Page')
local String = Lua.import('Module:StringUtils')
local Table = Lua.import('Module:Table')
Expand All @@ -30,6 +32,9 @@ local Widgets = Lua.import('Module:Widget/All')
local Cell = Widgets.Cell
local Title = Widgets.Title
local Center = Widgets.Center
local IconFontawesome = Lua.import('Module:Widget/Image/Icon/Fontawesome')
local Link = Lua.import('Module:Widget/Basic/Link')
local WidgetUtil = Lua.import('Module:Widget/Util')

---@class CounterstrikeLeagueInfobox: InfoboxLeague
---@field gameData table
Expand Down Expand Up @@ -85,11 +90,21 @@ local VALVE_TIERS = {
['rmr event'] = {meta = 'Regional Major Rankings event', name = 'RMR Event', link = 'Regional Major Rankings'},
['tier 1'] = {meta = 'Valve Tier 1 event', name = 'Tier 1', link = 'Valve Tier 1 Events'},
['tier 1 qualifier'] = {meta = 'Valve Tier 1 qualifier', name = 'Tier 1 Qualifier', link = 'Valve Tier 1 Events'},
['tier 1 wildcard'] = {meta = 'Valve Tier 1 Wildcard event', name = 'Tier 1 Wildcard', link = 'Valve Wildcard Events'},
['tier 2'] = {meta = 'Valve Tier 2 event', name = 'Tier 2', link = 'Valve Tier 2 Events'},
['tier 2 qualifier'] = {meta = 'Valve Tier 2 qualifier', name = 'Tier 2 Qualifier', link = 'Valve Tier 2 Events'},
['tier 2 wildcard'] = {meta = 'Valve Tier 2 Wildcard event', name = 'Tier 2 Wildcard', link = 'Valve Wildcard Events'},
['wildcard'] = {meta = 'Valve Wildcard event', name = 'Wildcard', link = 'Valve Wildcard Events'},
}

local VALVE_TOR_START_DATE = '2025-01-01'
local VALVE_TOR_ENABLED_TIERS = {
VALVE_TIERS.major,
VALVE_TIERS['tier 1'],
VALVE_TIERS['tier 1 qualifier'],
VALVE_TIERS['tier 1 wildcard']
}

local RESTRICTIONS = {
female = {
name = 'Female Players Only',
Expand Down Expand Up @@ -170,20 +185,17 @@ function CustomInjector:parse(id, widgets)
table.insert(widgets, Center{children = {table.concat(maps, ' • ')}})
end
elseif id == 'liquipediatier' then
table.insert(
widgets,
Array.appendWith(widgets,
Cell{
name = '[[File:ESL 2019 icon.png|20x20px|link=|ESL|alt=ESL]] Pro Tour Tier',
children = {self.caller:_createEslProTierCell(args.eslprotier)},
classes = {'infobox-icon-small'}
}
)
table.insert(
widgets,
},
Cell{
name = Template.safeExpand(mw.getCurrentFrame(), 'Valve/infobox') .. ' Tier',
children = {self.caller:_createValveTierCell()},
classes = {'valvepremier-highlighted'}
content = self.caller:_createValveTierCell(),
classes = {'valvepremier-highlighted'},
options = {separator = ' '}
}
)
elseif id == 'gamesettings' then
Expand Down Expand Up @@ -377,10 +389,25 @@ function CustomLeague:_createEslProTierCell(eslProTier)
end
end

---@return string?
---@return Widget[]?
function CustomLeague:_createValveTierCell()
if self.valveTier then
return '[[' .. self.valveTier.link .. '|' .. self.valveTier.name .. ']]'
local showInfoIcon = self.data.endDate
and self.data.endDate >= VALVE_TOR_START_DATE
and Array.find(VALVE_TOR_ENABLED_TIERS, FnUtil.curry(Operator.eq, self.valveTier))
return WidgetUtil.collect(
Link{
children = {self.valveTier.name},
link = self.valveTier.link
},
showInfoIcon and Link{
children = {IconFontawesome{
iconName = 'general-info',
hover = 'Click for further details',
}},
link = '#Valve Operational Requirements'
} or nil
)
end
end

Expand Down
19 changes: 17 additions & 2 deletions lua/wikis/counterstrike/MainPageLayout/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local FilterButtonsWidget = Lua.import('Module:Widget/FilterButtons')
local ThisDayWidgets = Lua.import('Module:Widget/MainPage/ThisDay')
local TransfersList = Lua.import('Module:Widget/MainPage/TransfersList')
local WantToHelp = Lua.import('Module:Widget/MainPage/WantToHelp')
local VRSStandings = Lua.import('Module:Widget/VRSStandings')


local CONTENT = {
Expand Down Expand Up @@ -74,6 +75,16 @@ local CONTENT = {
padding = true,
boxid = MainPageLayoutUtil.BoxId.TOURNAMENTS_TICKER,
},
vrsStandings = {
heading = 'Valve Regional Standings',
body = VRSStandings{
shouldFetch = 1,
fetchLimit = 5,
mainpage = 1,
},
padding = false,
boxid = 1521,
}
}

return {
Expand Down Expand Up @@ -151,13 +162,17 @@ return {
mobileOrder = 1,
content = CONTENT.specialEvents,
},
{
mobileOrder = 3,
content = CONTENT.vrsStandings,
},
{
mobileOrder = 4,
content = CONTENT.thisDay,
content = CONTENT.transfers,
},
{
mobileOrder = 5,
content = CONTENT.transfers,
content = CONTENT.thisDay,
},
{
mobileOrder = 7,
Expand Down
Loading
Loading