Skip to content

Commit

Permalink
Merge branch 'main' into mgi-cr-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz authored Nov 6, 2024
2 parents b4d69e7 + 8471582 commit a6286fd
Show file tree
Hide file tree
Showing 17 changed files with 353 additions and 349 deletions.
3 changes: 2 additions & 1 deletion components/infobox/commons/infobox_league.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local Variables = require('Module:Variables')

local BasicInfobox = Lua.import('Module:Infobox/Basic')
local Flags = Lua.import('Module:Flags')
local HighlightConditions = Lua.import('Module:HighlightConditions')
local InfoboxPrizePool = Lua.import('Module:Infobox/Extensions/PrizePool')
local LeagueIcon = Lua.import('Module:LeagueIcon')
local Links = Lua.import('Module:Links')
Expand Down Expand Up @@ -504,7 +505,7 @@ end
---@param args table
---@return boolean
function League:liquipediaTierHighlighted(args)
return self.data.publishertier
return HighlightConditions.tournament(self.data)
end

--- Allows for overriding this functionality
Expand Down
6 changes: 0 additions & 6 deletions components/infobox/wikis/callofduty/infobox_league_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ function CustomLeague:defineCustomPageVariables(args)
Variables.varDefine('tournament_edate', self.data.endDate)
end

---@param args table
---@return boolean
function CustomLeague:liquipediaTierHighlighted(args)
return Logic.readBool(args['atvi-sponsored'])
end

---@param content Html|string|number|nil
---@return Html
function CustomLeague:_createNoWrappingSpan(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,27 @@ end
---@param args table
---@return string
function CustomLeague:appendLiquipediatierDisplay(args)
if Logic.readBool(args.riotpremier) then
if self.data.publishertier then
return ' ' .. RIOT_ICON
end
return ''
end

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

---@param lpdbData table
---@param args table
---@return table
function CustomLeague:addToLpdb(lpdbData, args)
lpdbData.extradata.individual = String.isNotEmpty(args.participants_number) or
String.isNotEmpty(args.individual) and 'true' or ''

lpdbData.extradata['is riot premier'] = String.isNotEmpty(args.riotpremier) and 'true' or ''
lpdbData.extradata['is riot premier'] = lpdbData.publishertier and 'true' or ''

return lpdbData
end

---@param args table
function CustomLeague:customParseArguments(args)
self.data.publishertier = Logic.readBool(args.riotpremier) and '1' or nil
self.data.publishertier = Logic.readBoolOrNil(args.riotpremier) or nil
end

---@param args table
Expand Down
9 changes: 2 additions & 7 deletions components/infobox/wikis/tft/infobox_league_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,10 @@ function CustomInjector:parse(id, widgets)
return widgets
end

---@param args table
---@return boolean
function CustomLeague:liquipediaTierHighlighted(args)
return Logic.readBool(args['riot-sponsored'])
end

---@param args table
---@return string
function CustomLeague:appendLiquipediatierDisplay(args)
if Logic.readBool(args['riot-sponsored']) then
if self.data.publishertier then
return ' ' .. RIOT_ICON
end
return ''
Expand All @@ -83,6 +77,7 @@ function CustomLeague:customParseArguments(args)
args.mode = args.mode and GAME_MODES[string.lower(args.mode):gsub('s$', '')] or DEFAULT_MODE

self.data.mode = string.lower(args.mode)
self.data.publishertier = Logic.readBool(args['riot-sponsored']) and 'sponsored' or nil
end

---@param args table
Expand Down
15 changes: 5 additions & 10 deletions components/infobox/wikis/trackmania/infobox_league_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,17 @@ function CustomInjector:parse(id, widgets)
return widgets
end

---@param args table
---@return boolean
function CustomLeague:liquipediaTierHighlighted(args)
return Array.any(self:getAllArgsForBase(args, 'organizer'),
function(organizer)
return organizer:find('Nadeo', 1, true) or organizer:find('Ubisoft', 1, true)
end)
end

---@param args table
function CustomLeague:customParseArguments(args)
self.data.mode = Logic.emptyOr(
args.mode,
(String.isNotEmpty(args.team_number) and 'team' or nil),
DEFAULT_MODE
)
self.data.publishertier = Array.any(self:getAllArgsForBase(args, 'organizer'),
function(organizer)
return organizer:find('Nadeo', 1, true) or organizer:find('Ubisoft', 1, true)
end)
end

---@param args table
Expand All @@ -133,7 +128,7 @@ function CustomLeague:getWikiCategories(args)
return info and (info.link .. ' Competitions') or nil
end)

return Array.append(categories, self:liquipediaTierHighlighted(args) and 'Ubisoft Tournaments' or nil)
return Array.append(categories, self.data.publishertier and 'Ubisoft Tournaments' or nil)
end

---@param lpdbData table
Expand Down
8 changes: 1 addition & 7 deletions components/infobox/wikis/valorant/infobox_league_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,10 @@ function CustomLeague:addToLpdb(lpdbData, args)
return lpdbData
end

---@param args table
---@return boolean
function CustomLeague:liquipediaTierHighlighted(args)
return Logic.readBool(args['riot-highlighted'])
end

---@param args table
---@return string
function CustomLeague:appendLiquipediatierDisplay(args)
if Logic.readBool(args['riot-highlighted']) or Logic.readBool(args['riot-sponsored']) then
if self.data.publishertier then
return ' ' .. RIOT_ICON
end
return ''
Expand Down
19 changes: 11 additions & 8 deletions components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1078,34 +1078,37 @@ function MatchGroupInputUtil.mergeStandaloneIntoMatch(match, standaloneMatch)
end

---@class MatchParserInterface
---@field extractMaps fun(match: table, opponents: table[]): table[]
---@field extractMaps fun(match: table, opponents: table[], mapProps: any?): table[]
---@field getBestOf fun(bestOfInput: string|integer, maps: table[]): integer
---@field calculateMatchScore fun(maps: table[], opponents: table[]): fun(opponentIndex: integer): integer
---@field calculateMatchScore? fun(maps: table[], opponents: table[]): fun(opponentIndex: integer): integer
---@field removeUnsetMaps? fun(maps: table[]): table[]
---@field getExtraData? fun(match: table, games: table[], opponents: table[]): table
---@field getLinks? fun(match: table, games: table[]): table
---@field DEFAULT_MODE? string
---@field DATE_FALLBACKS? string[]
---@field OPPONENT_CONFIG? readOpponentOptions

--- The standard way to process a match input.
---
--- The Parser injection must have the following functions:
--- - extractMaps(match, opponents): table[]
--- - extractMaps(match, opponents, mapProps): table[]
--- - getBestOf(bestOfInput, maps): integer
--- - calculateMatchScore(maps, opponents): fun(opponentIndex): integer
---
--- It may optionally have the following functions:
--- - calculateMatchScore(maps, opponents): fun(opponentIndex): integer
--- - removeUnsetMaps(maps): table[]
--- - getExtraData(match, games, opponents): table
--- - getLinks
---
--- Additionally, the Parser may have the following properties:
--- - DEFAULT_MODE: string
--- - DATE_FALLBACKS: string[]
--- - OPPONENT_CONFIG: table
---@param match table
---@param Parser MatchParserInterface
---@param mapProps any?
---@return table
function MatchGroupInputUtil.standardProcessMatch(match, Parser)
function MatchGroupInputUtil.standardProcessMatch(match, Parser, mapProps)
local finishedInput = match.finished --[[@as string?]]
local winnerInput = match.winner --[[@as string?]]

Expand All @@ -1115,13 +1118,13 @@ function MatchGroupInputUtil.standardProcessMatch(match, Parser)
return MatchGroupInputUtil.readOpponent(match, opponentIndex, Parser.OPPONENT_CONFIG)
end)

local games = Parser.extractMaps(match, opponents)
local games = Parser.extractMaps(match, opponents, mapProps)
match.bestof = Parser.getBestOf(match.bestof, games)
games = Parser.removeUnsetMaps and Parser.removeUnsetMaps(games) or games

match.links = MatchGroupInputUtil.getLinks(match)
match.links = Parser.getLinks and Parser.getLinks(match, games) or MatchGroupInputUtil.getLinks(match)

local autoScoreFunction = MatchGroupInputUtil.canUseAutoScore(match, games)
local autoScoreFunction = (Parser.calculateMatchScore and MatchGroupInputUtil.canUseAutoScore(match, games))
and Parser.calculateMatchScore(games, opponents)
or nil
Array.forEach(opponents, function(opponent, opponentIndex)
Expand Down
Loading

0 comments on commit a6286fd

Please sign in to comment.