/* 
 * 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
 *
 * NbEnnemis.cpp
 *
 * This class is represent the difference in number between the current ally group
 * and the closest ennemis.
 *
 * Date 19/03/06
 *
 */

#include "NbEnnemis.h"
#include "NbEnnemyUnitHigh.h"
#include "NbEnnemyUnitMiddle.h"
#include "NbEnnemyUnitLow.h"
#include "GroupAI.h"

using namespace std;
	
NbEnnemis::NbEnnemis(void){
	name = NB_ENNEMIS;
}

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

NbEnnemis::NbEnnemis(NbEnnemyUnitHigh* fv1, NbEnnemyUnitMiddle* fv2, NbEnnemyUnitLow* fv3){
	name = NB_ENNEMIS;
	vector<FuzzyValue*> vect = vector<FuzzyValue*>();
	vect.push_back(fv1);
	vect.push_back(fv2);
	vect.push_back(fv3);
	this->setVect(vect);
}

NbEnnemis::~NbEnnemis(void){}

void NbEnnemis::update(void){
	// à voir
	float nbE = ennemy->getNumber();
	float nbA = ally->getNumber();
	if(nbE + nbA >0 && nbE != 0){
		value = nbE/(nbE + nbA);
	}
	else{
		// In the case you don't see ennemies you consider they are numerous
		value = 0;
	}
	value = value * 100;
	notify();
	DebugAI::trace('n', "nb ennemies = " + Converter::floatToString(nbE));
	DebugAI::trace('n', "nb allies = " + Converter::floatToString(nbA));
	DebugAI::trace('n', toString());
}

void NbEnnemis::setEnnemy(GroupEnnemy* ennemy){
	this->ennemy = ennemy;
}

void NbEnnemis::setAlly(GroupAI* ally){
	this->ally = ally;
}
