#include "FreshZone.h"
#include "DebugAI.h"

FreshZone::FreshZone(void){
	name = FRESH_ZONE;
	begin = 100;
	end = 1500;
}

FreshZone::~FreshZone(void)
{
}

FreshZone::FreshZone(Fresh* aFuzzyNumber){
	fuzzyNumber = aFuzzyNumber;
	fuzzyNumber->addFV(this);
	name = FRESH_ZONE;
	begin = 100;
	end = 1500;
}

void FreshZone::update(){
	if (this->getFuzzyNumberValue()>= 0 && this->getFuzzyNumberValue()<=begin){
		setValue(1);
	}
	if (this->getFuzzyNumberValue()>= end){
		setValue(0);
	}
	if (this->getFuzzyNumberValue()<0){
		//If the execution go here they must have a problem.
		setValue(-1);
	}
	if (this->getFuzzyNumberValue()>= begin && this->getFuzzyNumberValue()<end){
		setValue(1-((this->getFuzzyNumberValue()-1)/(end-begin)) );
	}
	DebugAI::trace('v', toString());
}

void FreshZone::setBegin(float aBegin){
	begin = aBegin;
}

void FreshZone::setEnd(float aEnd){
	end = aEnd;
}