/* 
 * 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
 *
 * Distance.cpp
 *
 * This class is represent the distance between the current GroupAI and a square
 *
 * Date 19/03/06
 *
 */

#include "Distance.h"
#include "FarZone.h"
#include "ClosedZone.h"
#include "GroundMap.h"
#include "DebugAI.h"

using namespace std;
	
Distance::Distance(void){
	name = DISTANCE;
}

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

Distance::Distance(FarZone* fv1, ClosedZone* fv2){
	name = DISTANCE;
	vector<FuzzyValue*> vect = vector<FuzzyValue*>();
	vect.push_back(fv1);
	vect.push_back(fv2);
	this->setVect(vect);
}

Distance::~Distance(void){}

void Distance::update(void){
	// à voir
	ground::GroundMap::getInstance().computePath(allyCoordinates,pt2dConsidered);
	// Si on ne voit pas un ennemi, ses coordonnées sont (0, 0) on va le considèrer à l'infini
	if(pt2dConsidered.getX() == 0 && pt2dConsidered.getY() == 0){
		value = 100;
	}
	else{
		value = ground::GroundMap::getInstance().getLastPath().size();
	}
	notify();
	DebugAI::trace('n', toString());
	DebugAI::trace('n', "allyCoordinates = " + allyCoordinates.toString());
	DebugAI::trace('n', "ennemiesCoordinates = " + pt2dConsidered.toString());
}

void Distance::setAllyCoordinates(Point2D pt2D){
	allyCoordinates = pt2D;
}

void Distance::setPoint2D(Point2D pt2D){
	pt2dConsidered = pt2D;
}
