Skip to content
Draft
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
13 changes: 8 additions & 5 deletions lua/wikis/honorofkings/InGameRoles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
---@type table<string, RoleBaseData>
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},
}

Expand All @@ -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
Expand Down
55 changes: 55 additions & 0 deletions lua/wikis/honorofkings/TeamCard/Legacy/Custom.lua
Original file line number Diff line number Diff line change
@@ -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)
Comment thread
Eetwalt marked this conversation as resolved.

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
Loading