BirbAngry emoji.png
Open Beta is out on IOS/Android, PC & Mac! Play Now for Free!

Module:ItemInfobox

From Castaways Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:ItemInfobox/doc

local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local headerStyle
	if args.headerstyle and args.headerstyle ~= '' then
		headerStyle = string.format('background-color:%s;', args.headerstyle)
	else
		headerStyle = 'background-color:grey;'
	end
	local retval = capiunto.create( {
		title = tostring(mw.title.getCurrentTitle()),
		headerStyle = headerStyle
	} )
	:addImage( args.image, args.caption )
	:addHeader ( 'Properties' )
	:addRow ( 'Display Name', args.displayName )
	:addRow ( 'Stackable?', args.stackable )
	
	if not args.consumable then
		args.consumable = 'N/A'
	end
	
	retval:addRow ( 'Consumable?', args.consumable )
	
	if args.recipeInput and args.recipeInput ~= '' then
		retval:addHeader( 'Crafting Recipe' )
		retval:addRow( 'Ingredients', args.recipeInput )
		retval:addRow( 'Output Quantity', args.recipeOutput )
	end
	
	if args.tool and args.tool ~= '' then
		retval:addHeader( 'Tool Properties' )
		retval:addRow ( 'Tool Type', args.tool)
		
		if args.toolEffectiveOn and args.toolEffectiveOn ~= '' then
			retval:addRow ( 'Effective On', args.toolEffectiveOn )
		end
		
		retval:addRow( 'Durability', args.durability )
		retval:addRow( 'Tool Multiplier', args.toolMultiplier )
	end
	
	if args.weapon and args.weapon ~= '' then -- will be useful when weapons are useful
		retval:addHeader( 'Weapon Properties' )
		retval:addRow ( 'Weapon Type', args.weapon)
		retval:addRow( 'Durability', args.durability )
		retval:addRow( 'Damage', args.damage )
	end
	
	if args.poolType and args.poolType ~= '' then
		retval:addHeader( 'Fishing Properties' )
		retval:addRow ( 'Pool Type', args.poolType )
		retval:addRow ( 'Catch Chance', args.catchChance )
	end
	
	if args.food and args.food ~= '' then
		retval:addHeader( 'Food Properties' )
		retval:addRow ( 'Food Type', args.food)
		retval:addRow ( 'Hunger Restored', args.hungerRestored)
	end

	return retval
end

return p