From 135492b5b0f8506376a4c700d53cda77c7dd1fa1 Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Mon, 1 Jun 2026 12:59:57 +0300 Subject: [PATCH 1/2] add custom to wildrift --- lua/wikis/wildrift/InGameRoles.lua | 10 ++-- lua/wikis/wildrift/TeamCard/Legacy/Custom.lua | 59 +++++++++++++++++++ 2 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 lua/wikis/wildrift/TeamCard/Legacy/Custom.lua diff --git a/lua/wikis/wildrift/InGameRoles.lua b/lua/wikis/wildrift/InGameRoles.lua index 4e7b2663774..a9bdbb9eac9 100644 --- a/lua/wikis/wildrift/InGameRoles.lua +++ b/lua/wikis/wildrift/InGameRoles.lua @@ -7,11 +7,11 @@ ---@type table local inGameRoles = { - ['baron'] = {category = 'Baron Lane players', display = 'Baron'}, - ['support'] = {category = 'Support players', display = 'Support'}, - ['jungle'] = {category = 'Jungle players', display = 'Jungle'}, - ['mid'] = {category = 'Mid Lane players', display = 'Mid'}, - ['dragon'] = {category = 'Dragon Lane players', display = 'Dragon'}, + ['baron'] = {category = 'Baron Lane players', display = 'Baron', sortOrder = 1}, + ['jungle'] = {category = 'Jungle players', display = 'Jungle', sortOrder = 2}, + ['mid'] = {category = 'Mid Lane players', display = 'Mid', sortOrder = 3}, + ['dragon'] = {category = 'Dragon Lane players', display = 'Dragon', sortOrder = 4}, + ['support'] = {category = 'Support players', display = 'Support', sortOrder = 5}, } inGameRoles['jgl'] = inGameRoles.jungle diff --git a/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua b/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua new file mode 100644 index 00000000000..fc03424d700 --- /dev/null +++ b/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua @@ -0,0 +1,59 @@ +--- +-- @Liquipedia +-- page=Module:TeamCard/Legacy/Custom +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local Array = Lua.import('Module:Array') +local InGameRoles = Lua.import('Module:InGameRoles', {loadData = true}) +local LegacyTeamCard = Lua.import('Module:TeamCard/Legacy') +local Logic = Lua.import('Module:Logic') +local MathUtil = Lua.import('Module:MathUtil') +local Table = Lua.import('Module:Table') + +local DEFAULT_MAX_PLAYER_INDEX = 10 +local INGAME_ROLES_BY_ORDER = Table.map(InGameRoles, function(_, roleData) + return roleData.sortOrder, roleData.display +end) + +local CustomLegacyTeamCard = {} + +-- Template entry point +---@return Widget +function CustomLegacyTeamCard.run() + return LegacyTeamCard.run(CustomLegacyTeamCard) +end + +---@param card table +---@return table +function CustomLegacyTeamCard.preprocessCard(card) + card.defaultRowNumber = MathUtil.toInteger(card.defaultRowNumber) or 5 + card.t2title = Logic.emptyOr(card.t2title, 'Substitutes') + card.t3title = Logic.emptyOr(card.t3title, 'Staff') + + Array.forEach(Array.range(1, DEFAULT_MAX_PLAYER_INDEX), function(index) + local key = 'p' .. index + card[key .. 'pos'] = Logic.emptyOr( + card[key .. 'pos'], + Table.extract(card, 'pos' .. index), + INGAME_ROLES_BY_ORDER[index] + ) + end) + + for tabIndex = 2, 3 do + Array.forEach(Array.range(1, DEFAULT_MAX_PLAYER_INDEX), function(index) + local key = 't' .. tabIndex .. 'p' .. index + card[key .. 'pos'] = Logic.emptyOr( + card[key .. 'pos'], + Table.extract(card, 't' .. tabIndex .. 'pos' .. index) + ) + end) + end + + return card +end + +return CustomLegacyTeamCard From a923733465ab7cff76ab29f5bd5b0cedbde49d4b Mon Sep 17 00:00:00 2001 From: Eetu Rantanen Date: Mon, 1 Jun 2026 15:17:46 +0300 Subject: [PATCH 2/2] remove unneeded overrides --- lua/wikis/wildrift/TeamCard/Legacy/Custom.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua b/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua index fc03424d700..836a838771b 100644 --- a/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua +++ b/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua @@ -11,7 +11,6 @@ local Array = Lua.import('Module:Array') local InGameRoles = Lua.import('Module:InGameRoles', {loadData = true}) local LegacyTeamCard = Lua.import('Module:TeamCard/Legacy') local Logic = Lua.import('Module:Logic') -local MathUtil = Lua.import('Module:MathUtil') local Table = Lua.import('Module:Table') local DEFAULT_MAX_PLAYER_INDEX = 10 @@ -30,10 +29,6 @@ end ---@param card table ---@return table function CustomLegacyTeamCard.preprocessCard(card) - card.defaultRowNumber = MathUtil.toInteger(card.defaultRowNumber) or 5 - card.t2title = Logic.emptyOr(card.t2title, 'Substitutes') - card.t3title = Logic.emptyOr(card.t3title, 'Staff') - Array.forEach(Array.range(1, DEFAULT_MAX_PLAYER_INDEX), function(index) local key = 'p' .. index card[key .. 'pos'] = Logic.emptyOr(