diff --git a/lua/wikis/commons/TeamCard/Legacy.lua b/lua/wikis/commons/TeamCard/Legacy.lua index ac78e88495b..d42437a5dcf 100644 --- a/lua/wikis/commons/TeamCard/Legacy.lua +++ b/lua/wikis/commons/TeamCard/Legacy.lua @@ -348,6 +348,9 @@ end function LegacyTeamCard.mapCoaches(tcArgs) local coaches = {} + if Logic.isNotEmpty(tcArgs.c) then + table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'c', nil)) + end Array.forEach(indicesPresent(tcArgs, 'c', MAX_COACH_INDEX), function(i) table.insert(coaches, LegacyTeamCard.mapCoach(tcArgs, 'c' .. i, nil)) end) diff --git a/lua/wikis/identityv/TeamCard/Legacy/Custom.lua b/lua/wikis/identityv/TeamCard/Legacy/Custom.lua new file mode 100644 index 00000000000..daf95267804 --- /dev/null +++ b/lua/wikis/identityv/TeamCard/Legacy/Custom.lua @@ -0,0 +1,43 @@ +--- +-- @Liquipedia +-- page=Module:TeamCard/Legacy/Custom +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local Logic = Lua.import('Module:Logic') + +local LegacyTeamCard = Lua.import('Module:TeamCard/Legacy') + +local MAX_PLAYER_INDEX = 10 + +local POSITION_ALIASES = { + s = 'survivor', + h = 'hunter', +} + +local CustomLegacyTeamCard = {} + +-- Template entry point +---@return Widget +function CustomLegacyTeamCard.run() + return LegacyTeamCard.run(CustomLegacyTeamCard) +end + +---@param tcArgs table +---@return table +function CustomLegacyTeamCard.preprocessCard(tcArgs) + for n = 1, MAX_PLAYER_INDEX do + local oldKey = 'pos' .. n + local value = tcArgs[oldKey] + if Logic.isNotEmpty(value) then + tcArgs['p' .. n .. 'pos'] = POSITION_ALIASES[value:lower()] or value + tcArgs[oldKey] = nil + end + end + return tcArgs +end + +return CustomLegacyTeamCard