
local name, spellId, _

local function UnitBuffByID(unit,buffID)
	for i = 1,40 do
		name, _, _, _, _, _, _, _, _, _, spellId = UnitBuff(unit, i) 
		if not name then
			return
		end
		if name and tonumber(spellId) == tonumber(buffID) then
			return UnitBuff(unit, i) 
		end
	end
end

WhatsNext:AddConditionalStatement("Solar Eclipse",{
	category="Druid",
	test = function(checkTable)
		return UnitBuffByID("player",48517)
	end,
	text = function(checkTable)
		return "player has Eclipse (Solar)."
	end,
	arguments = {}
})

WhatsNext:AddConditionalStatement("Lunar Eclipse",{
	category="Druid",
	test = function(checkTable)
		return UnitBuffByID("player",48518)
	end,
	text = function(checkTable)
		return "player has Eclipse (Lunar)."
	end,
	arguments = {}
})

WhatsNext:AddConditionalStatement("Solar Energy",{
	category="Druid",
	test = function(checkTable)
		return GetEclipseDirection() ~= "moon" and not UnitBuffByID("player",112071)
	end,
	text = function(checkTable)
		return "player can generate Solar Energy."
	end,
	arguments = {}
})

WhatsNext:AddConditionalStatement("Lunar Energy",{
	category="Druid",
	test = function(checkTable)
		return GetEclipseDirection() ~= "sun" and not UnitBuffByID("player",112071)
	end,
	text = function(checkTable)
		return "player can generate Lunar Energy."
	end,
	arguments = {}
})

WhatsNext:AddConditionalStatement("Eclipse Energy",{
	category="Druid",
	test = function(checkTable)
		return GetEclipseDirection() == "none" and not UnitBuffByID("player",112071)
	end,
	text = function(checkTable)
		return "player can generate Lunar and Solar Energy."
	end,
	arguments = {}
})

WhatsNext:AddConditionalStatement("Either Eclipse Energy",{
	category="Druid",
	test = function(checkTable)
		return not UnitBuffByID("player",112071)
	end,
	text = function(checkTable)
		return "player can generate Lunar or Solar Energy."
	end,
	arguments = {}
})

WhatsNext:AddConditionalStatement("Minimum Solar Energy",{
	category="Druid",
	test = function(checkTable)
		return UnitPower("player",8) >= tonumber(checkTable.amount) 
	end,
	text = function(checkTable)
		return "player has at least " .. tostring(checkTable.amount) .. " Solar Energy."
	end,
	arguments = {
		amount = {type = "integer", default = 50},
	}
})

WhatsNext:AddConditionalStatement("Minimum Lunar Energy",{
	category="Druid",
	test = function(checkTable)
		return UnitPower("player",8) <= tonumber(checkTable.amount) * -1
	end,
	text = function(checkTable)
		return "player has at least " .. tostring(checkTable.amount) .. " Lunar Energy."
	end,
	arguments = {
		amount = {type = "integer", default = 50},
	}
})

WhatsNext:AddConditionalStatement("Form",{
	category="Druid",
	test = function(checkTable)
		return WN_GetSpellName(checkTable.form) == (GetShapeshiftForm() and GetShapeshiftForm() > 0 and select(2,GetShapeshiftFormInfo(GetShapeshiftForm())) or 0)
	end,
	text = function(checkTable)
		return "player's active form is "..WN_GetSpellName(checkTable.form) .. "."
	end,
	arguments = {
		form = {type = "dropdown", default = "24858", possibleValues={["24858"]=WN_GetSpellName(24858),["1066"]=WN_GetSpellName(1066),["5487"]=WN_GetSpellName(5487),["768"]=WN_GetSpellName(768),["33943"]=WN_GetSpellName(33943),["40120"]=WN_GetSpellName(40120),["783"]=WN_GetSpellName(783)}},
	}
})

WhatsNext:AddConditionalStatement("Combo Points (Druid)",{
	category = "Druid",
	test = function(checkTable) 
		return GetComboPoints("player",tostring(checkTable.unit)) >= tonumber(checkTable.amount)
	end,
	text = function(checkTable) 
		return "player has at least "..tostring(checkTable.amount).." combo points on " .. GetUnitDisplayText(checkTable.unit) .. "."
	end,
	arguments = {
		unit = {type = "dropdown", default = "target", possibleValues = WhatsNext.valueLists.unitAny},
		amount = {type = "integer", default = 5},
	}
})