local health,maxHealth
WhatsNext:AddConditionalStatement("Minimum Health",{
	category = "Health",
	test = function(checkTable) 
		health = UnitHealth(tostring(checkTable.unit))
		return health and health >= tonumber(checkTable.amount)
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. "'s health is at or above " .. tostring(checkTable.amount) .. "."
	end,
	arguments = {
		unit = {type = "dropdown", default = "player", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "integer", default = 0}
	}
})

WhatsNext:AddConditionalStatement("Minimum Health Percent",{
	category = "Health",
	test = function(checkTable) 
		health = UnitHealth(tostring(checkTable.unit))
		maxHealth = UnitHealthMax(tostring(checkTable.unit))
		return health and maxHealth and maxHealth > 0 and tonumber(checkTable.amount) <= health / maxHealth
	end,
	text = function(checkTable) 
		health = tonumber(checkTable.amount)
		return GetUnitDisplayText(checkTable.unit) .. "'s health is at or above " .. tostring(health and health*100 or checkTable.amount) .. "%."
	end,
	arguments = {
		unit = {type = "dropdown", default = "player", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "percent", default = .5}
	}
})

WhatsNext:AddConditionalStatement("Maximum Health",{
	category = "Health",
	test = function(checkTable) 
		health = UnitHealth(tostring(checkTable.unit))
		return health and health <= tonumber(checkTable.amount)
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. "'s health is at or below " .. tostring(checkTable.amount) .. "."
	end,
	arguments = {
		unit = {type = "dropdown", default = "player", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "integer", default = 0}
	}
})

WhatsNext:AddConditionalStatement("Maximum Health Percent",{
	category = "Health",
	test = function(checkTable) 
		health = UnitHealth(tostring(checkTable.unit))
		maxHealth = UnitHealthMax(tostring(checkTable.unit))
		return health and maxHealth and maxHealth > 0 and tonumber(checkTable.amount) >= health / maxHealth
	end,
	text = function(checkTable) 
		health = tonumber(checkTable.amount)
		return GetUnitDisplayText(checkTable.unit) .. "'s health is at or below " .. tostring(health and health*100 or checkTable.amount) .. "%."
	end,
	arguments = {
		unit = {type = "dropdown", default = "player", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "percent", default = .5}
	}
})

WhatsNext:AddConditionalStatement("Minimum Missing Health",{
	category = "Health",
	test = function(checkTable) 
		health = UnitHealth(tostring(checkTable.unit))
		maxHealth = UnitHealthMax(tostring(checkTable.unit))
		return health and maxHealth and maxHealth - health >= tonumber(checkTable.amount)
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. "'s health is at least " .. tostring(checkTable.amount) .. " below their maximum health."
	end,
	arguments = {
		unit = {type = "dropdown", default = "player", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "integer", default = 0}
	}
})

WhatsNext:AddConditionalStatement("Maximum Missing Health",{
	category = "Health",
	test = function(checkTable) 
		health = UnitHealth(tostring(checkTable.unit))
		maxHealth = UnitHealthMax(tostring(checkTable.unit))
		return health and maxHealth and maxHealth - health <= tonumber(checkTable.amount)
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. "'s health is no more than " .. tostring(checkTable.amount) .. " below their maximum health."
	end,
	arguments = {
		unit = {type = "dropdown", default = "player", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "integer", default = 0}
	}
})