Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
MediaWiki help
Creopedia
Search
Search
Appearance
Log in
Personal tools
Log in
View source for Module:Move/Components/Learnsets
Module
Discussion
English
Read
View source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
View source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
←
Module:Move/Components/Learnsets
require( 'strict' ) local gameTabs = require( 'Module:GameTabs' ) local tableLua = require( 'Module:TableLua' ) local creoLink = require( 'Module:CreoLink' )._main local element = require( 'Module:Element' )._main local level = require( 'Module:Level' )._main local itemLink = require( 'Module:ItemLink' )._main local ecGameData = require( 'Module:GameData/EvoCreo' ) local p = {} --- Helper function to get the icon link for a tome --- --- The EvoCreo 1 learnset data title cases every word ('Tome Of Electricity'), --- which is not how the articles are titled, so those names are normalised. --- --- @param itemName string --- @param gameId string --- @return string local function getTomeWikitext( itemName, gameId ) if gameId == 'evocreo' then itemName = ecGameData.getName( itemName ) end return itemLink( { text = itemName } ) end --- @return TableColumn[] local function getColumns() return { { id = 'creoName', label = 'Creo' }, { id = 'creoElement', label = 'Element' }, { id = 'level', label = 'Level' }, { id = 'tome', label = 'Tome' } } end --- @param data table --- @param gameId string --- @return TableRow[] local function getRows( data, gameId ) local learnsets = {} for _, learnset in ipairs( data.fromLevel ) do table.insert( learnsets, { isLevel = true, data = learnset, } ) end for _, learnset in ipairs( data.fromItem ) do table.insert( learnsets, { isLevel = false, data = learnset, } ) end table.sort( learnsets, function( a, b ) return a.data.creoName < b.data.creoName end ) local rows = {} for i, item in ipairs( learnsets ) do local learnset = item.data if item.isLevel then rows[i] = { creoLink( { name = learnset.creoName } ), element( learnset.creoElement ), level( learnset.level ), '-' } else rows[i] = { creoLink( { name = learnset.creoName } ), element( learnset.creoElement ), '-', getTomeWikitext( learnset.itemName, gameId ) } end end return rows end --- @param data table --- @param gameId string --- @return TableProps local function getTableProps( data, gameId ) return { caption = 'Learnsets', hideCaption = true, columns = getColumns(), data = getRows( data, gameId ), class = table.concat( { 't-move-learnsets-table', 'sortable', -- manually add the sortable class because we don't use the sort prop for sorting 'wikitable--fluid' -- Citizen built-in class for broad tables }, ' ' ) } end --- @param gameData table --- @param gameId string --- @return string local function getGameTabWikitext( gameData, gameId ) local html = mw.html.create( 'div' ):addClass( 't-tabbedCard-table-container' ) html:wikitext( tableLua.render( getTableProps( gameData, gameId ) ) ) return tostring( html ) end --- @param data table --- @return mw.html local function getLearnsetsHtml( data ) local html = mw.html.create( 'div' ):addClass( 't-move-learnsets' ) local gameTabsData = gameTabs.mapGameArgs( data, function ( gameData, game ) return getGameTabWikitext( gameData, game.id ) end ) gameTabsData.noPadding = true html:wikitext( gameTabs._main( gameTabsData ) ) return html end --- @param context ComponentContext --- @return string function p.render( context ) return tostring( getLearnsetsHtml( context.data ) ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:Move/Components/Learnsets/doc
(
view source
)
Return to
Module:Move/Components/Learnsets
.