#include "BadSupport.h"
#include "DebugAI.h"

BadSupport::BadSupport(void){
	name = BAD_SUPPORT;
	begin = 30;
	end = 50;
}

BadSupport::~BadSupport(void)
{
}

BadSupport::BadSupport(Support* aFuzzyNumber){
	fuzzyNumber = aFuzzyNumber;
	fuzzyNumber->addFV(this);
	name = BAD_SUPPORT;
	begin = 30;
	end = 50;
}

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

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

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