Skip to content
Merged
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
8 changes: 8 additions & 0 deletions lua/wikis/commons/Role/Util.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:Role/Util
Expand All @@ -12,6 +12,8 @@

local Roles = Lua.import('Module:Roles')

local Html = Lua.import('Module:Widget/Html')

--- TODO: In the future this should be moved to role data entry
local POSITION_ICON_DATA = Lua.requireIfExists('Module:PositionIcon/data', {loadData = true})

Expand All @@ -21,10 +23,12 @@
---@field display string
---@field category string
---@field sortOrder integer?
---@field abbreviation string?

---@class RoleData: RoleBaseData
---@field key string?
---@field type RoleTypes
---@field abbreviation string?
---@field icon string?

---@enum RoleTypes
Expand Down Expand Up @@ -86,6 +90,10 @@
key = key,
type = roleType(),
sortOrder = roleData.sortOrder,
abbreviation = roleData.abbreviation and Html.Abbr{
children = roleData.abbreviation,
title = roleData.display,
} or nil,
icon = POSITION_ICON_DATA and POSITION_ICON_DATA[key] or nil,
}
end
Expand Down
9 changes: 5 additions & 4 deletions lua/wikis/commons/Widget/Participants/Team/Roster.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:Widget/Participants/Team/Roster
Expand Down Expand Up @@ -56,7 +56,7 @@
-- * Returns an array of labels to display (can be multiple)
-- * Left-role:
-- * If the first role has an icon, we use that to render the left-role
-- * If not then we instead display the icon or text of the first ingame role
-- * If not then we instead display the icon of the first ingame role with icon
---@param player table
---@return string?, string[]?
local function getRoleDisplays(player)
Expand All @@ -69,8 +69,8 @@
return firstRole.icon
end
for _, role in ipairs(roles) do
if role.type == RoleUtil.ROLE_TYPE.INGAME then
return role.icon or role.display
if role.type == RoleUtil.ROLE_TYPE.INGAME and role.icon then
return role.icon
end
end
end
Expand All @@ -85,7 +85,7 @@
-- Add non-ingame role if present
for _, role in ipairs(roles) do
if role.type ~= RoleUtil.ROLE_TYPE.INGAME then
table.insert(rightRoles, role.display)
table.insert(rightRoles, role.abbreviation or role.display)
break
end
end
Expand Down Expand Up @@ -138,6 +138,7 @@
end

---@param groups {label: string?, players: table[]}[]
---@return Widget
local makeRostersDisplay = function(groups)
local children = {}
for _, group in ipairs(groups) do
Expand Down
Loading