Module:PoliticalParty

From EarthMC
Jump to navigation Jump to search

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

p = {}
local yesno = require('Module:Yesno')
local data = require("Module:PoliticalParty/data")

function nameConvert(arg)
	if data.partyNames[arg] ~= nil then
		return data.partyNames[arg]
	else
		return arg
	end
end

p.color = function(frame)
    local arg = frame.args[1]
	return data.parties[nameConvert(arg)][1]
end

p.shortname = function(frame)
    local arg = frame.args[1]
	return data.parties[nameConvert(arg)][2]
end

p.altname = function(frame)
    local arg = frame.args[1]
	return data.parties[nameConvert(arg)][3]
end

p.tablecolor = function(frame)
    local arg = frame.args[1]
	return data.parties[nameConvert(arg)][4]
end

p.link = function(frame)
    local arg = frame.args[1]
	return data.parties[nameConvert(arg)][5]
end

p.linkedShort = function(frame)
    local arg = frame.args[1]
	if nameConvert(arg) == "Independent" then
		return frame:preprocess("''Independent''")
	else
		return frame:preprocess("[["..data.parties[nameConvert(arg)][5].."|"..data.parties[nameConvert(arg)][2].."]]")
	end
end

p.won = function(frame)
    local arg = frame.args[1]
	if yesno(arg) == true then
		return "background:#ECFCF4;"
	else
		return ""
	end
end

return p