Skip to content

Commit

Permalink
Add Player as optional role for player card.
Browse files Browse the repository at this point in the history
- Also added 3 roles if rare case happen (both player, staff and talent.)
ref discussion: https://discord.com/channels/93055209017729024/1164213669324927096/1277282662947623036
  • Loading branch information
RushFTK committed Aug 25, 2024
1 parent a8e461f commit 096c289
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local Cell = Widgets.Cell
local ROLES = {
-- Players
['igl'] = {category = 'In-game leaders', variable = 'In-game leader'},
['player'] = {category = 'Players', variable = 'Player'},

-- Staff and Talents
['analyst'] = {category = 'Analysts', variable = 'Analyst', staff = true},
Expand All @@ -39,6 +40,7 @@ local ROLES = {
---@class OsuInfoboxPlayer: Person
---@field role {category: string, variable: string, staff: boolean?, talent: boolean?}?
---@field role2 {category: string, variable: string, staff: boolean?, talent: boolean?}?
---@field role3 {category: string, variable: string, staff: boolean?, talent: boolean?}?
local CustomPlayer = Class.new(Player)
local CustomInjector = Class.new(Injector)

Expand All @@ -51,6 +53,7 @@ function CustomPlayer.run(frame)
player.args.history = TeamHistoryAuto.results{convertrole = true}
player.role = player:_getRoleData(player.args.role)
player.role2 = player:_getRoleData(player.args.role2)
player.role3 = player:_getRoleData(player.args.role3)

return player:createInfobox()
end
Expand All @@ -69,6 +72,7 @@ function CustomInjector:parse(id, widgets)
Cell{name = 'Role', content = {
caller:_displayRole(caller.role),
caller:_displayRole(caller.role2),
caller:_displayRole(caller.role3),
}},
}
elseif id == 'history' then
Expand Down Expand Up @@ -102,14 +106,16 @@ end
function CustomPlayer:defineCustomPageVariables(args)
Variables.varDefine('role', (self.role or {}).variable)
Variables.varDefine('role2', (self.role2 or {}).variable)
Variables.varDefine('role3', (self.role3 or {}).variable)
end

---@param categories string[]
---@return string[]
function CustomPlayer:getWikiCategories(categories)
return Array.append(categories,
(self.role or {}).category,
(self.role2 or {}).category
(self.role2 or {}).category,
(self.role3 or {}).category
)
end

Expand Down

0 comments on commit 096c289

Please sign in to comment.