From efa34b7133f3163022634e6c0bdd3e45f70d6e30 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Thu, 14 May 2026 15:09:56 +0900 Subject: [PATCH 1/3] add legacy teamcard for lol --- .../TeamCard/Legacy/Custom.lua | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua diff --git a/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua b/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua new file mode 100644 index 00000000000..f3aa7868fd0 --- /dev/null +++ b/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua @@ -0,0 +1,60 @@ +--- +-- @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 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) + -- Add local template overrides + card.defaultRowNumber = MathUtil.toInteger(card.defaultRowNumber) or 5 + card.t2title = Logic.emptyOr(card.t2title, 'Substitutes') + card.t3title = Logic.emptyOr(card.t3title, 'Staff') + + -- Adjust position arguments and add default + Array.forEach(Array.range(1, 10), 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, 10), 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 ff6dc6dd963b60fee6d9f284b247ced444b4b310 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Thu, 14 May 2026 15:11:11 +0900 Subject: [PATCH 2/3] share constant --- lua/wikis/commons/TeamCard/Legacy.lua | 14 +++++++------- .../leagueoflegends/TeamCard/Legacy/Custom.lua | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/wikis/commons/TeamCard/Legacy.lua b/lua/wikis/commons/TeamCard/Legacy.lua index 164b2876257..f831814a01d 100644 --- a/lua/wikis/commons/TeamCard/Legacy.lua +++ b/lua/wikis/commons/TeamCard/Legacy.lua @@ -245,8 +245,8 @@ function LegacyTeamCard.mapCoach(tcArgs, prefix, sourceGroup) } end -local DEFAULT_MAX_PLAYER_INDEX = 10 -local MAX_COACH_INDEX = 10 +LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX = 10 +LegacyTeamCard.MAX_COACH_INDEX = 10 local TN_TYPE_DEFAULTS = {t2 = 'sub', t3 = 'former'} @@ -294,7 +294,7 @@ end function LegacyTeamCard.mapPlayers(tcArgs) local players = {} local indexByKey = {} - local maxPlayerIndex = tonumber(tcArgs.maxPlayers) or DEFAULT_MAX_PLAYER_INDEX + local maxPlayerIndex = tonumber(tcArgs.maxPlayers) or LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX local function add(person, allowOverwrite) local key = normalizeKey(person.link or person[1]) @@ -344,13 +344,13 @@ end function LegacyTeamCard.mapCoaches(tcArgs) local coaches = {} - Array.forEach(indicesPresent(tcArgs, 'c', MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, 'c', LegacyTeamCard.MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'c' .. i, nil)) end) - Array.forEach(indicesPresent(tcArgs, 'sc', MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, 'sc', LegacyTeamCard.MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'sc' .. i, 'sc')) end) - Array.forEach(indicesPresent(tcArgs, 'fc', MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, 'fc', LegacyTeamCard.MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'fc' .. i, 'fc')) end) @@ -361,7 +361,7 @@ function LegacyTeamCard.mapCoaches(tcArgs) elseif tabType == 'former' then sourceGroup = 'fc' else sourceGroup = nil end - Array.forEach(indicesPresent(tcArgs, tab .. 'c', MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, tab .. 'c', LegacyTeamCard.MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, tab .. 'c' .. i, sourceGroup)) end) end) diff --git a/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua b/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua index f3aa7868fd0..82f91f448b5 100644 --- a/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua +++ b/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua @@ -35,7 +35,7 @@ function CustomLegacyTeamCard.preprocessCard(card) card.t3title = Logic.emptyOr(card.t3title, 'Staff') -- Adjust position arguments and add default - Array.forEach(Array.range(1, 10), function(index) + Array.forEach(Array.range(1, LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX), function(index) local key = 'p' .. index card[key .. 'pos'] = Logic.emptyOr( card[key .. 'pos'], @@ -45,7 +45,7 @@ function CustomLegacyTeamCard.preprocessCard(card) end) for tabIndex = 2, 3 do - Array.forEach(Array.range(1, 10), function(index) + Array.forEach(Array.range(1, LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX), function(index) local key = 't' .. tabIndex .. 'p' .. index card[key .. 'pos'] = Logic.emptyOr( card[key .. 'pos'], From 7454165a620c7b1b7ac90f9250996127e2612df2 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Thu, 14 May 2026 16:28:09 +0900 Subject: [PATCH 3/3] apply suggestion from feedback --- lua/wikis/commons/TeamCard/Legacy.lua | 14 +++++++------- .../leagueoflegends/TeamCard/Legacy/Custom.lua | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lua/wikis/commons/TeamCard/Legacy.lua b/lua/wikis/commons/TeamCard/Legacy.lua index f831814a01d..164b2876257 100644 --- a/lua/wikis/commons/TeamCard/Legacy.lua +++ b/lua/wikis/commons/TeamCard/Legacy.lua @@ -245,8 +245,8 @@ function LegacyTeamCard.mapCoach(tcArgs, prefix, sourceGroup) } end -LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX = 10 -LegacyTeamCard.MAX_COACH_INDEX = 10 +local DEFAULT_MAX_PLAYER_INDEX = 10 +local MAX_COACH_INDEX = 10 local TN_TYPE_DEFAULTS = {t2 = 'sub', t3 = 'former'} @@ -294,7 +294,7 @@ end function LegacyTeamCard.mapPlayers(tcArgs) local players = {} local indexByKey = {} - local maxPlayerIndex = tonumber(tcArgs.maxPlayers) or LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX + local maxPlayerIndex = tonumber(tcArgs.maxPlayers) or DEFAULT_MAX_PLAYER_INDEX local function add(person, allowOverwrite) local key = normalizeKey(person.link or person[1]) @@ -344,13 +344,13 @@ end function LegacyTeamCard.mapCoaches(tcArgs) local coaches = {} - Array.forEach(indicesPresent(tcArgs, 'c', LegacyTeamCard.MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, 'c', MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'c' .. i, nil)) end) - Array.forEach(indicesPresent(tcArgs, 'sc', LegacyTeamCard.MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, 'sc', MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'sc' .. i, 'sc')) end) - Array.forEach(indicesPresent(tcArgs, 'fc', LegacyTeamCard.MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, 'fc', MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'fc' .. i, 'fc')) end) @@ -361,7 +361,7 @@ function LegacyTeamCard.mapCoaches(tcArgs) elseif tabType == 'former' then sourceGroup = 'fc' else sourceGroup = nil end - Array.forEach(indicesPresent(tcArgs, tab .. 'c', LegacyTeamCard.MAX_COACH_INDEX), function(i) + Array.forEach(indicesPresent(tcArgs, tab .. 'c', MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, tab .. 'c' .. i, sourceGroup)) end) end) diff --git a/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua b/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua index 82f91f448b5..ce4ca372fd0 100644 --- a/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua +++ b/lua/wikis/leagueoflegends/TeamCard/Legacy/Custom.lua @@ -14,6 +14,7 @@ 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) @@ -35,7 +36,7 @@ function CustomLegacyTeamCard.preprocessCard(card) card.t3title = Logic.emptyOr(card.t3title, 'Staff') -- Adjust position arguments and add default - Array.forEach(Array.range(1, LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX), function(index) + Array.forEach(Array.range(1, DEFAULT_MAX_PLAYER_INDEX), function(index) local key = 'p' .. index card[key .. 'pos'] = Logic.emptyOr( card[key .. 'pos'], @@ -45,7 +46,7 @@ function CustomLegacyTeamCard.preprocessCard(card) end) for tabIndex = 2, 3 do - Array.forEach(Array.range(1, LegacyTeamCard.DEFAULT_MAX_PLAYER_INDEX), function(index) + 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'],