Module:Properties

From Artifact Wiki
Jump to: navigation, search

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

local util = require('Module:Util')

p = {}

-- Default Card width
function p.getCardWidth()
	return 200
end

-- Default Card margin
function p.getCardMargin()
	return 2
end

function p.getCardColor(color)
	if(color == nil or color == '') then
		-- No color provided
		return 'purple'		
	end
	
	-- Ignore casing
	color = string.lower(color)
	
	-- Red
	if(color == 'red') then
		return '#982e38'
	-- Blue
	elseif(color == 'blue') then
		return '#184b6e'
	-- Green
	elseif(color == 'green') then
		return '#4f6a40'
	-- Black
	elseif(color == 'black') then
		return '#1f171b'
	-- Gray
	elseif(color == 'gray' or color == 'grey') then
		return 'gray'
	-- Gold
	elseif(color == 'gold') then
		return '#d79525'
	else
		return color
	end	
end

function p.getNoDatabaseDescription(name, type)
	if(util.isempty(type)) then
		type = "card"
	end
	
	local databaseError = string.format("This %s is not in the [[Special:CargoTables/cards|database]] yet.", type)
	
	if(util.isempty(name)) then
		return databaseError
	else
		return string.format("%s<br/>You can view or create the page [[%s|here]].", databaseError, name)
	end
end
	
function p.isempty(s)
	return s == nil or s == ''
end

return p