#include "NbVisibleUnitLow.h"
#include "DebugAI.h"

NbVisibleUnitLow::NbVisibleUnitLow(void){
	name = NB_VISIBLE_UNIT_LOW;
	begin = 20;
	end = 50;
}

NbVisibleUnitLow::NbVisibleUnitLow(NbVisibleUnit* aFuzzyNumber){
	fuzzyNumber = aFuzzyNumber;
	fuzzyNumber->addFV(this);
	name = NB_VISIBLE_UNIT_LOW;
	begin = 20;
	end = 50;
}

NbVisibleUnitLow::~NbVisibleUnitLow(void)
{
}

void NbVisibleUnitLow::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 NbVisibleUnitLow::setBegin(float aBegin){
	begin = aBegin;
}

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