local unit

WhatsNext:AddConditionalStatement("Time Till Death",{
	category = "Death Clocks",
	test = function(checkTable) 
		local time = DeathClock_TimeTillDeath and DeathClock_TimeTillDeath(checkTable.unit);
		return time and time <= tonumber(checkTable.time) 
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. " is expected to die within " .. tostring(checkTable.time) .. " seconds. (Requires the Death Clocks addon)"
	end,
	arguments = {
		unit = {label = "Unit", type = "dropdown", default = "target", possibleValues = WhatsNext.valueLists.unitAny},
		time = {label = "Seconds", type = "integer", default = 3, min = 1, max = 60},
	}
})

WhatsNext:AddConditionalStatement("Life Expectancy",{
	category = "Death Clocks",
	test = function(checkTable) 
		local time = DeathClock_TimeTillDeath and DeathClock_TimeTillDeath(checkTable.unit);
		return time and time >= tonumber(checkTable.time) 
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. " is expected to live for at least " .. tostring(checkTable.time) .. " seconds. (Requires the Death Clocks addon)"
	end,
	arguments = {
		unit = {label = "Unit", type = "dropdown", default = "target", possibleValues = WhatsNext.valueLists.unitAny},
		time = {label = "Seconds", type = "integer", default = 3, min = 1, max = 60},
	}
})

WhatsNext:AddConditionalStatement("Time Till Execute Range",{
	category = "Death Clocks",
	test = function(checkTable) 
		local time = DeathClock_TimeTillExecuteRange and DeathClock_TimeTillExecuteRange(checkTable.unit);
		return time and time <= tonumber(checkTable.time) 
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. " is expected to enter execute range within " .. tostring(checkTable.time) .. " seconds. (Requires the Death Clocks addon)"
	end,
	arguments = {
		unit = {label = "Unit", type = "dropdown", default = "target", possibleValues = WhatsNext.valueLists.unitAny},
		time = {label = "Seconds", type = "integer", default = 3, min = 1, max = 60},
	}
})

WhatsNext:AddConditionalStatement("Time Out Of Execute Range",{
	category = "Death Clocks",
	test = function(checkTable) 
		local time = DeathClock_TimeTillExecuteRange and DeathClock_TimeTillExecuteRange(checkTable.unit);
		return time and time >= tonumber(checkTable.time) 
	end,
	text = function(checkTable) 
		return GetUnitDisplayText(checkTable.unit) .. " is expected to remain out of execute range for at least " .. tostring(checkTable.time) .. " seconds. (Requires the Death Clocks addon)"
	end,
	arguments = {
		unit = {label = "Unit", type = "dropdown", default = "target", possibleValues = WhatsNext.valueLists.unitAny},
		time = {label = "Seconds", type = "integer", default = 3, min = 1, max = 60},
	}
})