-
Notifications
You must be signed in to change notification settings - Fork 96
feat(infobox): Add rematch Infobox player #6112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mehdi9120310391
wants to merge
13
commits into
Liquipedia:main
Choose a base branch
from
Mehdi9120310391:patch-6
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
36249d1
Create Custom.lua
Mehdi9120310391 edf2fe0
Update Custom.lua
Mehdi9120310391 dea6c07
Update Custom.lua
Mehdi9120310391 9ff1ccb
Update lua/wikis/rematch/Infobox/Person/Player/Custom.lua
Mehdi9120310391 6d21e05
Update lua/wikis/rematch/Infobox/Person/Player/Custom.lua
Mehdi9120310391 6a214de
Update lua/wikis/rematch/Infobox/Person/Player/Custom.lua
Mehdi9120310391 7870057
Update lua/wikis/rematch/Infobox/Person/Player/Custom.lua
Mehdi9120310391 b051e16
Update lua/wikis/rematch/Infobox/Person/Player/Custom.lua
Mehdi9120310391 3f61303
Update Custom.lua
Mehdi9120310391 ad92515
Update lua/wikis/rematch/Infobox/Person/Player/Custom.lua
Mehdi9120310391 c08cb34
Update Custom.lua
Mehdi9120310391 9dfa263
Merge branch 'main' into patch-6
Mehdi9120310391 fa5f2f8
Merge branch 'main' into patch-6
Mehdi9120310391 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| --- | ||
| -- @Liquipedia | ||
| -- page=Module:Infobox/Person/Player/Custom | ||
| -- | ||
| -- Please see https://github.com/Liquipedia/Lua-Modules to contribute | ||
| -- | ||
|
|
||
| local Lua = require('Module:Lua') | ||
| local Array = Lua.import('Module:Array') | ||
| local Class = Lua.import('Module:Class') | ||
| local Flags = Lua.import('Module:Flags') | ||
| local Namespace = Lua.import('Module:Namespace') | ||
| local String = Lua.import('Module:StringUtils') | ||
|
|
||
| local Injector = Lua.import('Module:Widget/Injector') | ||
| local Player = Lua.import('Module:Infobox/Person') | ||
|
|
||
| local PlayerAchievements = Lua.import('Module:Infobox/Extension/Achievements') | ||
|
|
||
| local Widgets = Lua.import('Module:Widget/All') | ||
| local Cell = Widgets.Cell | ||
|
|
||
| ---@class RematchInfoboxPlayer: Person | ||
| local CustomPlayer = Class.new(Player) | ||
| ---@class RematchInfoboxPlayerWidgetInjector: WidgetInjector | ||
| ---@field caller RematchInfoboxPlayer | ||
| local CustomInjector = Class.new(Injector) | ||
|
|
||
| ---@param frame Frame | ||
| ---@return Html | ||
| function CustomPlayer.run(frame) | ||
| local player = CustomPlayer(frame) | ||
| player:setWidgetInjector(CustomInjector(player)) | ||
|
|
||
| player.args.autoTeam = true | ||
| player.args.achievements = PlayerAchievements.player{} | ||
|
|
||
| return player:createInfobox() | ||
| end | ||
|
|
||
| ---@param id string | ||
| ---@param widgets Widget[] | ||
| ---@return Widget[] | ||
| function CustomInjector:parse(id, widgets) | ||
| local caller = self.caller | ||
| local args = caller.args | ||
|
|
||
| if id == 'status' then | ||
| local positions = Array.parseCommaSeparatedString(args.positions, ',') | ||
| local validPositions = Array.map(positions, String.nilIfEmpty) | ||
| local label = #validPositions > 1 and 'Positions' or 'Position' | ||
| return { | ||
| Cell{name = label, content = Array.map(validPositions, function(pos) | ||
| local capitalizedPos = String.upperCaseFirst(pos) | ||
| return '[[:Category:' .. capitalizedPos .. 's|' .. capitalizedPos .. ']]' | ||
| end)} | ||
| } | ||
| end | ||
| return widgets | ||
| end | ||
|
|
||
| ---@param args table | ||
| ---@param birthDisplay string | ||
| ---@param personType string | ||
| ---@param status PlayerStatus | ||
| ---@return string[] | ||
| function CustomPlayer:getCategories(args, birthDisplay, personType, status) | ||
| if not Namespace.isMain() then return {} end | ||
|
|
||
| local categories = {} | ||
| local roles = String.isNotEmpty(args.roles) and Array.parseCommaSeparatedString(args.roles, ',') or {} | ||
|
|
||
| Array.forEach(roles, function(role) | ||
| local roleCategory = role .. 's' | ||
| table.insert(categories, roleCategory) | ||
| end) | ||
|
|
||
| Array.forEach(self:getLocations(), function(country) | ||
| local demonym = Flags.getLocalisation(country) | ||
| if demonym then | ||
| Array.forEach(roles, function(role) | ||
| local roleCategory = demonym .. ' ' .. role .. 's' | ||
| table.insert(categories, roleCategory) | ||
| end) | ||
| end | ||
| end) | ||
|
|
||
| if String.isNotEmpty(args.positions) then | ||
| local positions = Array.parseCommaSeparatedString(args.positions, ',') | ||
| local validPositions = Array.map(positions, String.nilIfEmpty) | ||
| Array.forEach(validPositions, function(pos) | ||
| local category = String.upperCaseFirst(pos) .. 's' | ||
| table.insert(categories, category) | ||
| end) | ||
| end | ||
|
|
||
| return categories | ||
| end | ||
|
|
||
| return CustomPlayer | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as already mentioned before
do not overwrite the commons function!
if you actually need to append the list of categories with wiki specific ones use
CustomPlayer:getWikiCategories(categories)instead!