From f23dc1ca84eb821d2ac0f58aae422c51911f3536 Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:46:10 +0100 Subject: [PATCH] feat: enable headtohead storage and wiki variable on dota2 (#5212) 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 '')