/* 
 * 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
 *
 * AllyHealthPoint.cpp
 *
 * This class is the poucentage of the hp of the ally group 
 *
 * Date 19/03/06
 *
 */

#include "AllyHealthPoint.h"
#include "GroupAI.h"
#include "HPHigh.h"
#include "HPMiddle.h"
#include "HPLow.h"
#include "DebugAI.h"
#include "Converter.h"

using namespace std;
	
AllyHealthPoint::AllyHealthPoint(void){
	name = ALLY_HEALTH_POINT;
}

AllyHealthPoint::AllyHealthPoint(std::vector<FuzzyValue*> vect){
	name = ALLY_HEALTH_POINT;
	this->setVect(vect);
}

AllyHealthPoint::AllyHealthPoint(HPHigh* fv1, HPMiddle* fv2, HPLow* fv3){
	name = ALLY_HEALTH_POINT;
	vector<FuzzyValue*> vect = vector<FuzzyValue*>();
	vect.push_back(fv1);
	vect.push_back(fv2);
	vect.push_back(fv3);
	this->setVect(vect);
}

AllyHealthPoint::~AllyHealthPoint(void){}

void AllyHealthPoint::update(void){
	// à voir
	int hp = ally->getHP();
	if(hp < 0) hp = 0;
	int hpMax = ally->getHPMax();
	if (hpMax > 0){
		value = (float)hp/(float)hpMax;
		value = value * 100;
	}
	else value = 0;
	//string
	notify();
	DebugAI::trace('n', toString());
	DebugAI::trace('n', "allyHP = " + Converter::floatToString(ally->getHP()));
	DebugAI::trace('n', "allyMaxHP = " + Converter::floatToString(ally->getHPMax()));
}

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