#include "GoapGoal.hpp"
#include "GoapExpression.hpp"

bool GoapGoal::isSatisfied(const GoapBlackboard &blackboard) const
{
	return blackboard.satisfies(target);
}

bool GoapGoal::isValid(const GoapBlackboard &blackboard) const
{
	// If already satisfied, not a valid goal to pursue
	if (isSatisfied(blackboard))
		return false;

	// Evaluate condition if present
	if (!condition.empty()) {
		GoapExpression expr;
		if (expr.parse(condition.c_str())) {
			return expr.evaluate(blackboard);
		}
	}

	return true;
}
