Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/wikis/commons/TeamCard/Legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 43 additions & 0 deletions lua/wikis/identityv/TeamCard/Legacy/Custom.lua
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +34 to +38
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local value = tcArgs[oldKey]
if Logic.isNotEmpty(value) then
tcArgs['p' .. n .. 'pos'] = POSITION_ALIASES[value:lower()] or value
tcArgs[oldKey] = nil
end
local value = Table.extract(tcArgs, oldKey)
tcArgs['p' .. n .. 'pos'] = Logic.emptyOr(tcArgs['p' .. n .. 'pos'], POSITION_ALIASES[value:lower()], value)

end
return tcArgs
end

return CustomLegacyTeamCard
Loading