diff --git a/lua/wikis/honorofkings/InGameRoles.lua b/lua/wikis/honorofkings/InGameRoles.lua index f6be20ec8da..d5cd96911aa 100644 --- a/lua/wikis/honorofkings/InGameRoles.lua +++ b/lua/wikis/honorofkings/InGameRoles.lua @@ -8,11 +8,11 @@ ---@type table local inGameRoles = { ['top'] = {category = 'Top Laners', display = 'Top Lane', sortOrder = 1}, - ['bottom'] = {category = 'Bottom Laners', display = 'Bottom Laner', sortOrder = 5}, - ['mid'] = {category = 'Mid Laners', display = 'Mid Laner', sortOrder = 4}, - ['side lane'] = {category = 'Side Laners', display = 'Side Laner', sortOrder = 2}, - ['jungler'] = {category = 'Junglers', display = 'Jungler', sortOrder = 3}, - ['roamer'] = {category = 'Roamers', display = 'Roamer', sortOrder = 6}, + ['jungler'] = {category = 'Junglers', display = 'Jungler', sortOrder = 2}, + ['mid'] = {category = 'Mid Laners', display = 'Middle', sortOrder = 3}, + ['bottom'] = {category = 'Bottom Laners', display = 'Bottom Lane', sortOrder = 4}, + ['roamer'] = {category = 'Roamers', display = 'Roamer', sortOrder = 5}, + ['side lane'] = {category = 'Side Laners', display = 'Side Laner', sortOrder = 6}, ['flex'] = {category = 'Flex', display = 'Flex', sortOrder = 7}, } @@ -29,10 +29,13 @@ inGameRoles['adc'] = inGameRoles.bottom inGameRoles['bot'] = inGameRoles.bottom inGameRoles['carry'] = inGameRoles.bottom inGameRoles['farm'] = inGameRoles.bottom +inGameRoles['bottom lane'] = inGameRoles.bottom inGameRoles['mid laner'] = inGameRoles.mid +inGameRoles['middle'] = inGameRoles.mid inGameRoles['ds lane'] = inGameRoles.top inGameRoles['dsl'] = inGameRoles.top inGameRoles['dark slayer lane'] = inGameRoles.top +inGameRoles['top lane'] = inGameRoles.top inGameRoles['confront'] = inGameRoles.top inGameRoles['clash'] = inGameRoles.top inGameRoles['fill'] = inGameRoles.flex diff --git a/lua/wikis/honorofkings/TeamCard/Legacy/Custom.lua b/lua/wikis/honorofkings/TeamCard/Legacy/Custom.lua new file mode 100644 index 00000000000..69a00b23b04 --- /dev/null +++ b/lua/wikis/honorofkings/TeamCard/Legacy/Custom.lua @@ -0,0 +1,55 @@ +--- +-- @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 DEFAULT_LINEUP_SIZE = 5 +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), + index <= DEFAULT_LINEUP_SIZE and INGAME_ROLES_BY_ORDER[index] or nil + ) + 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