Module:Move
Appearance
This documentation is transcluded from Module:Move/doc.
A meta module for all Move-related templates.
| Page | Description |
|---|---|
| Module:Move/Components/Infobox | Renders the infobox |
| Module:Move/Components/Learnsets | Renders Template:Move/Learnsets |
require( 'strict' )
local gameData = require( 'Module:GameData' )
local p = {}
local moveData = {}
local templateArgs = {}
--- Move names that another kind of subject owns as an article title. EvoCreo 2
--- reused these two for a trait and an ability, so the moves are disambiguated.
local disambiguatedArticles = {
['Agility'] = 'Agility (move)',
['Dive'] = 'Dive (move)'
}
--- Wikitext entry point for the module
---
--- @param frame mw.frame
--- @return string
function p.main( frame )
local getArgs = require( 'Module:Arguments' ).getArgs
return p._main( getArgs( frame ) )
end
--- Lua entry point for the module
---
--- @param args table
--- @return string
function p._main( args )
args = args or {}
local moveName = args.name or mw.title.getCurrentTitle().fullText
moveData = p.getData( moveName )
templateArgs = args
local wikitext = {
p.renderInfobox( moveName ),
p.renderCategories( p.getCategories() )
}
return table.concat( wikitext )
end
--- Get the game data
---
--- @param moveName string
--- @return table
function p.getData( moveName )
return gameData.getMove( moveName )
end
--- Get the article title covering a move
---
--- The move's own name, unless another subject already owns that title, in
--- which case callers link to the disambiguated article while still labelling
--- it with the plain name.
---
--- @param name string
--- @return string
function p.getArticle( name )
return disambiguatedArticles[name] or name
end
--- Return the wikitext for the infobox
---
--- @param moveName string
--- @return string
function p.renderInfobox( moveName )
local data = moveData or p.getData( moveName )
data.name = moveName
return require( 'Module:Move/Components/Infobox' ).render( {
data = data,
args = templateArgs
} )
end
--- Get the page categories
---
--- @return table
function p.getCategories()
local categories = {
'Moves'
}
if moveData.evocreo2 then
table.insert( categories, 'Moves in EvoCreo 2' )
end
if moveData.evocreo then
table.insert( categories, 'Moves in EvoCreo' )
end
return categories
end
--- Return the wikitext for the category
---
--- @param categories table
--- @return string
function p.renderCategories( categories )
local wikitext = {}
for _, category in ipairs( categories ) do
table.insert( wikitext, string.format( '[[Category:%s]]', category ) )
end
return table.concat( wikitext, '' )
end
--- Get the thumbnail for a Move
---
--- Moves are illustrated with the EvoCreo 2 artwork by default. Pass a game ID
--- to use that game's own icon, which is what moves cut before EvoCreo 2 need.
---
--- @param name string
--- @param gameId string|nil
--- @return string
function p.getThumbnail( name, gameId )
local game = gameId == 'evocreo' and 'evocreo' or 'evocreo2'
return string.format( '%s - move - %s.png', string.lower( name ), game )
end
--- Return the wikitext for the learnsets
---
--- @return string
function p.renderLearnsets( frame )
local wikitextArgs = require( 'Module:Arguments' ).getArgs( frame )
local moveName = wikitextArgs[1] or mw.title.getCurrentTitle().fullText
return require( 'Module:Move/Components/Learnsets' ).render( {
data = gameData.getLearnset( moveName )
} )
end
return p