From 563b58b3455da81c5f55f4250daa8138e7502c19 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Mon, 16 Dec 2024 08:46:14 +0100 Subject: [PATCH] feat(infobox, HDB): enable headtohead storage and wiki variable --- .../hidden_data_box/wikis/dota2/hidden_data_box_custom.lua | 7 +++++++ components/infobox/wikis/dota2/infobox_league_custom.lua | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/components/hidden_data_box/wikis/dota2/hidden_data_box_custom.lua b/components/hidden_data_box/wikis/dota2/hidden_data_box_custom.lua index 313ff64dda4..4ba896ace3d 100644 --- a/components/hidden_data_box/wikis/dota2/hidden_data_box_custom.lua +++ b/components/hidden_data_box/wikis/dota2/hidden_data_box_custom.lua @@ -7,6 +7,7 @@ -- local Class = require('Module:Class') +local Logic = require('Module:Logic') local Lua = require('Module:Lua') local Variables = require('Module:Variables') @@ -38,6 +39,12 @@ function CustomHiddenDataBox.addCustomVariables(args, queryResult) Variables.varDefine('tournament_icon_dark', Variables.varDefault('tournament_icondark')) Variables.varDefine('tournament_parent_page', Variables.varDefault('tournament_parent')) + Variables.varDefine('headtohead', tostring(Logic.readBool(Logic.emptyOr( + args.headtohead, + Variables.varDefault('headtohead'), + (queryResult.extradata or {}).headtohead + )))) + BasicHiddenDataBox.checkAndAssign('tournament_patch', args.patch, queryResult.patch) end diff --git a/components/infobox/wikis/dota2/infobox_league_custom.lua b/components/infobox/wikis/dota2/infobox_league_custom.lua index 54e3791c280..781125ad3a5 100644 --- a/components/infobox/wikis/dota2/infobox_league_custom.lua +++ b/components/infobox/wikis/dota2/infobox_league_custom.lua @@ -9,6 +9,7 @@ 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') @@ -86,6 +87,7 @@ end function CustomLeague:addToLpdb(lpdbData, args) lpdbData.extradata.individual = String.isNotEmpty(args.player_number) and 'true' or '' lpdbData.extradata.dpcpoints = String.isNotEmpty(args.points) or '' + lpdbData.extradata.headtohead = self.data.headtohead return lpdbData end @@ -93,11 +95,13 @@ end ---@param args table function CustomLeague:customParseArguments(args) self.data.publishertier = (self.publisherTier or {}).name + self.data.headtohead = tostring(Logic.readBool(args.headtohead)) end ---@param args table function CustomLeague:defineCustomPageVariables(args) -- Custom Vars + Variables.varDefine('headtohead', self.data.headtohead) 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 '')