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:GameData
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:GameData
require( 'strict' ) local games = mw.loadJsonData( 'Module:GameData/Games.json' ) local p = {} --- Get the MediaWiki module page name for a game --- --- @param gameId string --- @return string local function loadModule( gameId ) return require( 'Module:GameData/' .. p.getGame( gameId ).name:gsub( ' ', '' ) ) end --- Helper function to access the data for a game --- --- @param funcName string --- @param name string --- @param gameId string|nil --- @return table local function getData( funcName, name, gameId ) if type( gameId ) == 'string' then return loadModule( gameId )[funcName]( name ) end local data = {} for _, game in pairs( games ) do data[game.id] = loadModule( game.id )[funcName]( name ) end return data end --- Get the games definition --- --- @return table function p.getGames() return games end --- Get the game definition --- --- @param gameId string --- @return table function p.getGame( gameId ) for _, game in pairs( games ) do if game.id == gameId then return game end end error( string.format( 'Game not found: %s', gameId ) ) end --------------------------------------------- --- Interface for submodules to use --- Submodules must implement these functions --------------------------------------------- --- Get the Creo data for a game --- --- @param name string --- @param gameId string|nil --- @return table function p.getCreo( name, gameId ) return getData( 'getCreo', name, gameId ) end --- Get the Move data for a game --- --- @param name string --- @param gameId string|nil --- @return table function p.getMove( name, gameId ) return getData( 'getMove', name, gameId ) end --- Get the Learnset data for a game --- --- @param name string --- @param gameId string|nil --- @return table function p.getLearnset( name, gameId ) return getData( 'getLearnset', name, gameId ) end --- Get the Item data for a game --- --- @param name string --- @param gameId string|nil --- @return table function p.getItem( name, gameId ) return getData( 'getItem', name, gameId ) end --- Get the Ability data for a game --- --- @param name string --- @param gameId string|nil --- @return table function p.getAbility( name, gameId ) return getData( 'getAbility', name, gameId ) end --- Get the Trait data for a game --- --- @param name string --- @param gameId string|nil --- @return table function p.getTrait( name, gameId ) return getData( 'getTrait', name, gameId ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:GameData/doc
(
view source
)
Return to
Module:GameData
.