Module:Stats/SCHEMA

From Halopedia, the Halo wiki

Documentation for this module may be created at ModuleDoc:Stats/SCHEMA

local strings = require( 'Module:Stats/Cosmetic/MCC/STRINGS' )
local currency = require( 'Module:Currency' )

local p = {}

function p.name( object, options )
	return object[ 'fullname' ] or '-'
end

function p.image( object, options )
	if object[ 'img' ] == nil then
		return nil
	end
	local imgsize = options[ 'imgsize' ] or 128
	return '[[File:' .. object[ 'img' ] .. '|' .. imgsize .. 'px]]'
end

function p.description( object, options )
	return object[ 'desc' ] or '\'\'N/A\'\''
end

function p.unlock( object, options )
	if object[ 'unlock' ] == 'bydefault' then
		return 'Unlocked by default'
	end
	return object[ 'unlock' ] or '\'\'N/A\'\''
end

function p.mccunlock( object, options )
	if object[ 'mccunlock' ] == 'bydefault' then
		return 'Unlocked by default'
	end
	local text = ''
	if object[ 'mccseason' ] ~= nil then
		text = text .. strings.seasonShortLink( object[ 'mccseason' ] )
		.. ', Tier ' .. ( object[ 'mccseasontier' ] or '?' ) .. '('
		.. currency.seasonPoint( object[ 'mccseasoncost' ] ) .. ')\n'
	end
	if object[ 'mccexchange' ] ~= nil then
		text = text .. '[[The Exchange]] ('
		.. currency.seasonPoint( object[ 'mccexchangecost' ] ) .. ')\n'
	end
	if object[ 'mccchallengeseason' ] ~= nil then
		challenge = strings.seasonShortLink( object[ 'mccseason' ] )
		.. '[[Challenges/Halo: The Master Chief Collection|challenge]]: '
		.. ( object[ 'mccchallengename' ] or 'Unknown challenge' ) .. '\n'
	end
	return text
end

return p