Skip to content

Commit

Permalink
feat(infobox): implement valve tier for dota2 wiki (#5035)
Browse files Browse the repository at this point in the history
* Update infobox_league_custom.lua

* Update hidden_data_box_custom.lua

* Update prize_pool_custom.lua

* Delete standard/highlight_conditions/wikis/dota2 directory

* Update infobox_league_custom.lua

* Update infobox_league_custom.lua

* Update infobox_league_custom.lua

* code style

* `valvetier` -> `publishertier`
  • Loading branch information
iMarbot authored Nov 7, 2024
1 parent b41da9d commit 8d2130e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ function CustomHiddenDataBox.addCustomVariables(args, queryResult)
Variables.varDefine('tournament_parent_page', Variables.varDefault('tournament_parent'))

BasicHiddenDataBox.checkAndAssign('tournament_patch', args.patch, queryResult.patch)
BasicHiddenDataBox.checkAndAssign('tournament_valve_premier', args.valvepremier, queryResult.extradata.valvepremier)
BasicHiddenDataBox.checkAndAssign('tournament_publishertier', args.pctier, queryResult.publishertier)
BasicHiddenDataBox.checkAndAssign('tournament_pro_circuit_tier', args.pctier, queryResult.publishertier)
end

return Class.export(CustomHiddenDataBox)
57 changes: 28 additions & 29 deletions components/infobox/wikis/dota2/infobox_league_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
local Array = require('Module:Array')
local Class = require('Module:Class')
local Game = require('Module:Game')
local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local String = require('Module:StringUtils')
local Variables = require('Module:Variables')
Expand All @@ -25,6 +24,14 @@ local Cell = Widgets.Cell
local CustomLeague = Class.new(League)
local CustomInjector = Class.new(Injector)

local VALVE_TIERS = {
['international'] = {meta = '', name = 'The International', link = 'The International'},
['major'] = {meta = 'Dota Major Championship', name = 'Dota Major Championship', link = 'Dota Major Championships'},
['dpc major'] = {meta = 'DPC Major', name = 'DPC Major', link = 'Dota Major Championships'},
['dpc minor'] = {meta = 'DPC Minor', name = 'DPC Major', link = 'Dota Minor Championships'},
['dpc league'] = {meta = 'DPC Regional League', name = 'DPC Regional League', link = 'Regional League'}
}

---@param frame Frame
---@return Html
function CustomLeague.run(frame)
Expand All @@ -36,6 +43,10 @@ function CustomLeague.run(frame)
league.args.dotabuff = league.args.leagueid
league.args.stratz = league.args.leagueid

-- Valve Tier stuff
league.args.publisherdescription = 'metadesc-valve'
league.publisherTier = VALVE_TIERS[(league.args.publishertier or ''):lower()]

return league:createInfobox()
end

Expand All @@ -56,15 +67,12 @@ function CustomInjector:parse(id, widgets)
Cell{name = 'Dota TV Ticket', content = {args.dotatv}},
Cell{name = 'Pro Circuit Points', content = {points and mw.getContentLanguage():formatNum(points)}}
)
elseif id == 'liquipediatier' and args.pctier and args.liquipediatiertype ~= 'Qualifier' then
local valveIcon = ''
if Logic.readBool(args.valvepremier) then
valveIcon = Template.safeExpand(mw.getCurrentFrame(), 'Valve/infobox')
end
table.insert(widgets,
elseif id == 'liquipediatier' and self.caller.publisherTier then
table.insert(
widgets,
Cell{
name = 'Pro Circuit Tier',
content = {'[[Dota Pro Circuit|' .. args.pctier .. ']] ' .. valveIcon},
name = Template.safeExpand(mw.getCurrentFrame(), 'Valve/infobox') .. ' Tier',
content = {self.caller:_createPublisherTierCell()},
classes = {'valvepremier-highlighted'}
}
)
Expand All @@ -73,23 +81,7 @@ function CustomInjector:parse(id, widgets)
return widgets
end

---@param args table
---@return string
function CustomLeague:appendLiquipediatierDisplay(args)
if String.isEmpty(args.pctier) and Logic.readBool(args.valvepremier) then
return ' ' .. Template.safeExpand(mw.getCurrentFrame(), 'Valve/infobox')
end
return ''
end

---@param args table
---@return boolean
function CustomLeague:liquipediaTierHighlighted(args)
return Logic.readBool(args.valvepremier)
end

function CustomLeague:addToLpdb(lpdbData, args)
lpdbData.extradata.valvepremier = String.isNotEmpty(args.valvepremier) and '1' or '0'
lpdbData.extradata.individual = String.isNotEmpty(args.player_number) and 'true' or ''
lpdbData.extradata.dpcpoints = String.isNotEmpty(args.points) or ''

Expand All @@ -98,7 +90,7 @@ end

---@param args table
function CustomLeague:customParseArguments(args)
self.data.publishertier = args.pctier
self.data.publishertier = (self.publisherTier or {}).name
end

---@param args table
Expand All @@ -107,9 +99,9 @@ function CustomLeague:defineCustomPageVariables(args)
Variables.varDefine('tournament_pro_circuit_points', args.points or '')
local isIndividual = String.isNotEmpty(args.individual) or String.isNotEmpty(args.player_number)
Variables.varDefine('tournament_individual', isIndividual and 'true' or '')
Variables.varDefine('tournament_valve_premier', args.valvepremier)
Variables.varDefine('tournament_publisher_major', args.valvepremier)
Variables.varDefine('tournament_pro_circuit_tier', args.pctier)
if self.publisherTier then
Variables.varDefine('metadesc-valve', self.publisherTier.meta)
end

--Legacy vars
Variables.varDefine('tournament_ticker_name', args.tickername or '')
Expand Down Expand Up @@ -140,4 +132,11 @@ function CustomLeague:_createPatchCell(args)
return displayText
end

---@return string?
function CustomLeague:_createPublisherTierCell()
if self.publisherTier then
return '[[' .. self.publisherTier.link .. '|' .. self.publisherTier.name .. ']]'
end
end

return CustomLeague
2 changes: 0 additions & 2 deletions components/prize_pool/wikis/dota2/prize_pool_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ function CustomLpdbInjector:adjust(lpdbData, placement, opponent)
placement.placeStart
)

lpdbData.publishertier = Variables.varDefault('tournament_pro_circuit_tier', '')
lpdbData.extradata.publisherpremier = Variables.varDefault('tournament_valve_premier', '')
lpdbData.extradata.lis = Variables.varDefault('tournament_lis', '')
lpdbData.extradata.series2 = Variables.varDefault('tournament_series2', '')

Expand Down
33 changes: 0 additions & 33 deletions standard/highlight_conditions/wikis/dota2/highlight_conditions.lua

This file was deleted.

0 comments on commit 8d2130e

Please sign in to comment.