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..836a838771b --- /dev/null +++ b/lua/wikis/wildrift/TeamCard/Legacy/Custom.lua @@ -0,0 +1,54 @@ +--- +-- @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 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) + 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