
if (not Nurfed_Units) then

	Nurfed_Units = {};

	Nurfed_Units.Class = {
		[NURFEDWARRIOR] = { right = 0, left = 0.25, top = 0, bottom = 0.25, color = "b39442" },
		[NURFEDMAGE] = { right = 0.25, left = 0.5, top = 0, bottom = 0.25, color = "00ffff" },
		[NURFEDROGUE] = { right = 0.5, left = 0.75, top = 0, bottom = 0.25, color = "ffff00" },
		[NURFEDDRUID] = { right = 0.75, left = 1, top = 0, bottom = 0.25, color = "ff8a00" },
		[NURFEDHUNTER] = { right = 0, left = 0.25, top = 0.25, bottom = 0.5, color = "00ff00" },
		[NURFEDSHAMAN] = { right = 0.25, left = 0.5, top = 0.25, bottom = 0.5, color = "ff71a8" },
		[NURFEDPRIEST] = { right = 0.5, left = 0.75, top = 0.25, bottom = 0.5, color = "ffffff" },
		[NURFEDWARLOCK] = { right = 0.75, left = 1, top = 0.25, bottom = 0.5, color = "8d54fb" },
		[NURFEDPALADIN] = { right = 0, left = 0.25, top = 0.5, bottom = 0.75, color = "ff71a8" },
	};

	Nurfed_Units.UnitNames = {
		"player",
		"pet",
		"target",
		"party1",
		"party2",
		"party3",
		"party4",
	};
	
	function Nurfed_Units:New ()
		local object = {};
		setmetatable(object, self);
		self.__index = self;
		return object;
	end

	function Nurfed_Units:Health(unit)
		local currhp, maxhp;
		maxhp = UnitHealthMax(unit);
		currhp = UnitHealth(unit);
		if (maxhp == 100 and (IsAddOnLoaded("MobHealth") or IsAddOnLoaded("MobInfo2"))) then
			local check = MobHealth_GetTargetMaxHP();
			if (check and check > 0) then
				maxhp = check;
				currhp = MobHealth_GetTargetCurHP();
			end
		end

		local perc = currhp / maxhp;

		local info = {};
		if(perc > 0.5) then
			info.r = (1.0 - perc) * 2;
			info.g = 1.0;
		else
			info.r = 1.0;
			info.g = perc * 2;
		end
		info.b = 0.0;

		perc = perc * 100;

		return currhp, maxhp, perc, info;
	end

	function Nurfed_Units:Mana(unit)
		local currmp = UnitMana(unit);
		local maxmp = UnitManaMax(unit);
		local perc = (currmp / maxmp) * 100;

		return currmp, maxmp, perc;
	end

	function Nurfed_Units:Raid(unitname)
		local num = GetNumRaidMembers();
		local name, subgroup, class;
		for i=1, num do
			name, _, subgroup, _, class, _, _, _, _ = GetRaidRosterInfo(i);
			if (name == unitname) then
				return subgroup, class;
			end
		end
		return nil;
	end

	function Nurfed_Units:DebuffInfo(unit, i)
		NurfedTooltipTextLeft1:SetText(nil);
		NurfedTooltipTextRight1:SetText(nil);
		NurfedTooltip:SetUnitDebuff(unit, i);
		if (NurfedCureTooltipTextRight1:GetText()) then
			local name = NurfedTooltipTextLeft1:GetText();
			local type = NurfedTooltipTextRight1:GetText();
			return name, type;
		end
		return nil;
	end

	function Nurfed_Units:Reaction(unit)
		local info = {};
		if (UnitPlayerControlled(unit)) then
			if (UnitCanAttack(unit, "player")) then
				-- Hostile players are red
				if (not UnitCanAttack("player", unit)) then
					info.r = 0.0;
					info.g = 0.0;
					info.b = 1.0;
				else
					info.r = UnitReactionColor[2].r;
					info.g = UnitReactionColor[2].g;
					info.b = UnitReactionColor[2].b;
				end
			elseif (UnitCanAttack("player", unit)) then
				-- Players we can attack but which are not hostile are yellow
				info.r = UnitReactionColor[4].r;
				info.g = UnitReactionColor[4].g;
				info.b = UnitReactionColor[4].b;
			elseif (UnitIsPVP(unit)) then
				-- Players we can assist but are PvP flagged are green
				info.r = UnitReactionColor[6].r;
				info.g = UnitReactionColor[6].g;
				info.b = UnitReactionColor[6].b;
			else
				-- All other players are blue (the usual state on the "blue" server)
				info.r = 0.0;
				info.g = 1.0;
				info.b = 1.0;
			end
		elseif (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
			info.r = 0.5;
			info.g = 0.5;
			info.b = 0.5;
		else
			local reaction = UnitReaction(unit, "player");
			if (reaction) then
				info.r = UnitReactionColor[reaction].r;
				info.g = UnitReactionColor[reaction].g;
				info.b = UnitReactionColor[reaction].b;
			else
				info.r = 0.0;
				info.g = 1.0;
				info.b = 1.0;
			end
		end
		return info;
	end
end