/* 
 * Tactic is the legal property of its developers, whose names are too numerous 
 * to list here.  Please refer to the COPYRIGHT file distributed with this 
 * source distribution. 
 * 
 * This library is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version. 
 * 
 * This library is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 * Lesser General Public License for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library; if not, write to the Free Software 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 *
 * See README for more informations
 *
 * NbVisibleUnit.cpp
 *
 * Date 18/03/06
 *
 */

#include "NbVisibleUnit.h"
#include "NbVisibleUnitHigh.h"
#include "NbVisibleUnitMiddle.h"
#include "NbVisibleUnitLow.h"
#include "NbEnnemyIsNotZero.h"

using namespace std;
	
NbVisibleUnit::NbVisibleUnit(void){
	name = NB_VISIBLE_UNIT;
}

NbVisibleUnit::NbVisibleUnit(vector<FuzzyValue*> vect){
	name = NB_VISIBLE_UNIT;
	this->setVect(vect);
}

NbVisibleUnit::NbVisibleUnit(FuzzyValue* fv1, FuzzyValue* fv2, FuzzyValue* fv3, NbEnnemyIsNotZero* fv4){
	name = NB_VISIBLE_UNIT;
	vector<FuzzyValue*> vect = vector<FuzzyValue*>();
	vect.push_back(fv1);
	vect.push_back(fv2);
	vect.push_back(fv3);
	vect.push_back(fv4);
	this->setVect(vect);
}

NbVisibleUnit::~NbVisibleUnit(void){}

void NbVisibleUnit::update(void){
	// à voir
	int known;
	int all;
	known = ennemy->getVisible();
	all = ennemy->getAlive();
	if(all > 0){
	value = (float)known/(float)all;
	}
	else value = 0;
	value = value * 100;
	notify();
	DebugAI::trace('n', "nb known = " + Converter::floatToString(known));
	DebugAI::trace('n', "nb of all ennemies = " + Converter::floatToString(all));
	DebugAI::trace('n', toString());
}

void NbVisibleUnit::setEnnemy(EnnemyManager* ennemy){
	this->ennemy = ennemy;
}

