#include "Thinker.h"
#include "scGame.h"

#include "Elf.h"
extern std::vector<Elf*> elves;

Thinker::Thinker(scGame *g)
{
	game = g;
	hp = 3;
	myTurn = false;
	targetGridX = 0;
	targetGridY = 0;
	newTargetGridX = 0;
	newTargetGridY = 0;
	movesRemaining = 0;
	maxMoves = 0;
	x = 0;
	y = 0;
	dead = false;
	thought = false;
	attacking = false;
}
bool Thinker::noElvesAt(int xx, int yy)
{
	for(int i=0;i<elves.size();i++)
		if (elves.at(i)->getX()/TILE_SIZE == xx && elves.at(i)->getY()/TILE_SIZE == yy)
			return false;
	return true;
}
Elf *Thinker::getElfInPath(int xx, int yy)
{
	for(int i=0;i<elves.size();i++)
		if (elves.at(i)->getX()/TILE_SIZE == xx && elves.at(i)->getY()/TILE_SIZE == yy)
				return elves.at(i);
	return NULL;
}
void Thinker::think()
{
	// lol
}
bool Thinker::isMyTurn()
{
	return myTurn;
}
void Thinker::setMyTurn(bool turn)
{
	myTurn = turn;
}
void Thinker::doMyTurn()
{
	// lol
}
bool Thinker::isEndOfTurn()
{
	return false;
}
void Thinker::setMoveCount(int count)
{
	maxMoves = count;
}
int Thinker::getGridWithAirQuotesX()
{
	return newTargetGridX;
}
int Thinker::getGridWithAirQuotesY()
{
	return newTargetGridY;
}
/*int Thinker::getGridX()
{
	return targetGridX;
}
int Thinker::getGridY()
{
	return targetGridY;
}*/
void Thinker::setPosition(int xx, int yy)
{
	x = xx;
	y = yy;
	printf("x: %i, y: %i\n",x,y);
	targetGridX = xx/TILE_SIZE;
	targetGridY = yy/TILE_SIZE;
	newTargetGridX = xx/TILE_SIZE;
	newTargetGridY = yy/TILE_SIZE;
	printf("targetX: %i, targetY: %i\n",targetGridX,targetGridY);
}
int Thinker::getX()
{
	return x;
}
int Thinker::getY()
{
	return y;
}
bool Thinker::isAtTarget()
{
	return x == targetGridX*TILE_SIZE && y == targetGridY*TILE_SIZE;
}
void Thinker::die()
{
	dead = true;
}
bool Thinker::isDead()
{
	return dead;
}