From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search
(simplify)
m (fix)
Line 6: Line 6:
local function _shop()
local function _shop()
local title = args.title or 'Poké Mart'
local title = args.title or 'Poké Mart'
local itemList = mw.loadJsonData( 'Module:Pokemon/ShopPricing.json' )  
local itemList = mw.loadJsonData( 'Module:Pokemon/Shop/data.json' )  


root = mw.html.create( 'table' )
root = mw.html.create( 'table' )
Line 18: Line 18:


for k, v in ipairs(args) do
for k, v in ipairs(args) do
if itemList[v] == nil then
if itemList[ "default" ][ v ] == nil then
     root:tag( 'tr' )
     root:tag( 'tr' )
:tag( 'td' )
:tag( 'td' )
Line 27: Line 27:
root:tag( 'tr' )
root:tag( 'tr' )
:tag( 'td' ):wikitext( v )
:tag( 'td' ):wikitext( v )
:tag( 'td' ):wikitext( '[[File:Pokebuck.png]]', itemList[v] )
:tag( 'td' ):wikitext( '[[File:Pokebuck.png]]', itemList[ "default" ][ v ] )
end
end
end
end

Revision as of 02:06, 13 February 2024

Documentation for this module may be created at Module:Pokemon/Shop/Documentation

local getArgs = require('Module:Arguments').getArgs

local p = {}
local root

local function _shop()
	local title = args.title or 'Poké Mart'
	local itemList = mw.loadJsonData( 'Module:Pokemon/Shop/data.json' ) 

	root = mw.html.create( 'table' )
	root
		:addClass( 'wikitable' )
			:tag( 'tr' )
				:tag( 'th' )
					:attr( 'colspan', 2 )				 
					:css( { ['background-color'] = '#0000BD', color = 'white' } )
					:wikitext( title )

	for k, v in ipairs(args) do
		if itemList[ "default" ][ v ] == nil then
    		root:tag( 'tr' )
				:tag( 'td' )
					:attr( 'colspan', 2 )
					:css( 'text-align', 'center' )    
					:wikitext( v )
        else
			root:tag( 'tr' )
				:tag( 'td' ):wikitext( v )
				:tag( 'td' ):wikitext( '[[File:Pokebuck.png]]', itemList[ "default" ][ v ] )
		end
	end

	return tostring( root )
end

function p.shop( frame )
	args = getArgs( frame, { wrappers = 'Template:Pokemon/Shop' } )

	return _shop()
end

return p