Module:BonusMalus

From Ways of Darkness
Jump to navigation Jump to search

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

function BonusMalus(number,mode)
	local temp = ""
	if number == 0 then
		if mode == "TEXT" or mode == "TEXT_PERC" then
		temp = "\'\'No bonus\'\'"
	end
	elseif number < 0 then
		if mode == "PERC" or mode == "TEXT_PERC" then
		temp = "\'\'\'<span style=\"color: red;\">" .. number .. "%</span>\'\'\'"
		else
		temp = "\'\'\'<span style=\"color: red;\">" .. number .. "</span>\'\'\'"
	end
	else
		if mode == "PERC" or mode == "TEXT_PERC" then
		temp = "\'\'\'<span style=\"color: rgb(0, 153, 0);\">+" .. number .. "%</span>\'\'\'"
		else
		temp = "\'\'\'<span style=\"color: rgb(0, 153, 0);\">+" .. number .. "</span>\'\'\'"
	end
	end
	return temp
end
function BonusMalus2(number)
	local temp = ""
	if number == 0 then
		temp = "\'\'0\'\'"
	elseif number < 0 then
		temp = "\'\'\'<span style=\"color: red;\">" .. number .. "</span>\'\'\'"
	else
		temp = "\'\'\'<span style=\"color: rgb(0, 153, 0);\">+" .. number .. "</span>\'\'\'"
	end
	return temp
end

local p = {}
function p.main(frame)
	return BonusMalus(tonumber(frame.args[1]),frame.args[2])
end
function p.sheet(frame)
	return BonusMalus2(tonumber(frame.args[1]))
end
return p