#include "NbVisibleUnitHigh.h"
#include "DebugAI.h"

NbVisibleUnitHigh::NbVisibleUnitHigh(void){
	name = NB_VISIBLE_UNIT_HIGH;
	begin = 50;
	end = 80;
}

NbVisibleUnitHigh::NbVisibleUnitHigh(NbVisibleUnit* aFuzzyNumber){
	fuzzyNumber = aFuzzyNumber;
	fuzzyNumber->addFV(this);
	name = NB_VISIBLE_UNIT_HIGH;
	begin = 50;
	end = 80;
}

NbVisibleUnitHigh::~NbVisibleUnitHigh(void)
{
}

void NbVisibleUnitHigh::update(){
	if (this->getFuzzyNumberValue()>= 0 && this->getFuzzyNumberValue()<begin){
		setValue(0);
	}
	if (this->getFuzzyNumberValue()>= end && this->getFuzzyNumberValue()<=100){
		setValue(1);
	}
	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))) - (begin/(end-begin)));
	}
	DebugAI::trace('v', toString());
}

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

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