// class definition stuff for Info
// all variables are private members of the class.

#include "info.h"

void Info::Init()
{
	zombieHealth = 5;
	zombieThere = true;
};

bool Info::canHitEnemy(int playerX, int playerY, int enemyX, int enemyY)
{
	if (playerX <= enemyX + 10 || playerX >= enemyX - 10)
		return true;
	else if (playerY <= enemyY + 10 || playerY >= enemyY - 10)
		return true;
	else
		return false;
}

bool Info::returnZombieThere()
{
	if (zombieHealth <= 0)
		return false;
	else 
		return true;
}


void Info::setPosition(char type, int x, int y)
{
	if (type == 'p') //if player
  {
		playerXpos = x;
		playerYpos = y;
	}

	if (type == 'z') //if zombie
	{
		zombieXpos = x;
		zombieYpos = y;
	}
}

void Info::setHealth(char type, int healthRecieved)
{
	if (type == 'p')
    health = healthRecieved;
	if (type == 'z')
		zombieHealth -= healthRecieved;
}

int Info::returnHealth(char type)
{
	if (type == 'p')
	  return health;
	if (type == 'z')
	  return zombieHealth;
	
	else //if invalid charater type
		return -1;
}

void Info::setPlayerInRange(bool inRange)
{
	playerInRange = inRange;
}

void Info::setDirection(char type, int directionRecieved)
{
	if (type == 'p')
		playerDirection = directionRecieved;
	if (type == 'z')
		zombieDirection = directionRecieved;
}

int Info::returnDirection(char type)
{
	if (type == 'p')
		return playerDirection;
	if (type == 'z')
		return zombieDirection;

	else 
		return -1;
}

void Info::setImage(char type, int imageType, SDL_Surface *imageRecieved)
{
	if (type == 'p')
	{
		switch (imageType)
		{
		  case 0: //up image
				playerUpImage = imageRecieved;
				break;
			case 1: //down image
				playerDownImage = imageRecieved;
				break;
			case 2: //left image
				playerLeftImage = imageRecieved;
				break;
			case 3: //right image
				playerRightImage = imageRecieved;
				break;
		}
	}
	if (type == 'z')
	{
		switch (imageType)
		{
		  case 0:
				zombieUpImage = imageRecieved;
				break;
			case 1:
				zombieDownImage = imageRecieved;
				break;
			case 2:
				zombieLeftImage = imageRecieved;
				break;
			case 3:
				zombieRightImage = imageRecieved;
				break;
		}
	}
}

SDL_Surface* Info::returnImage(char type, int imageType)
{
	if (type == 'p')
	{
		switch (imageType)
		{
		  case 0: //up image
				return playerUpImage;
				break;
			case 1: //down image
				return playerDownImage;
				break;
			case 2: //left image
				return playerLeftImage;
				break;
			case 3: //right image
				return playerRightImage;
				break;
			default:
				return playerDownImage;
				break;
		}
	}
	if (type == 'z')
	{
		switch (imageType)
		{
		  case 0:
				return zombieUpImage;
				break;
			case 1:
				return zombieDownImage;
				break;
			case 2:
				return zombieLeftImage;
				break;
			case 3:
				return zombieRightImage;
				break;
			default:
				return zombieDownImage;
				break;
		}
	}		
	else
		return playerUpImage;
}

void Info::setDistance(char type, double distanceRecieved)
{
	if (type == 'z')
		distance = distanceRecieved;
}

double Info::returnDistance()
{
	return distance;
}

bool Info::returnPlayerInRange()
{
	return playerInRange;
}

void Info::setNumberOfZombies(int number)
{
	numberOfZombies = number;
}

int Info::returnNumberOfZombies()
{
	return numberOfZombies;
}

void Info::setAreaNumber(int areaNumberRecieved)
{
	areaNumber = areaNumberRecieved;
}

int Info::returnAreaNumber()
{
	return areaNumber;
}

void Info::initImages(char type)
{
	Sprite sprite;

	if (type == 'p')
	{
	  setImage('p', 1, sprite.loadIMG("pForward.bmp"));
    setImage('p', 0, sprite.loadIMG("pBackwards.bmp"));
	  setImage('p', 2, sprite.loadIMG("pleft.bmp"));
	  setImage('p', 3, sprite.loadIMG("pright.bmp"));
	}

	if (type == 'z')
	{
	  setImage('z', 1, sprite.loadIMG("zForward.bmp"));
    setImage('z', 0, sprite.loadIMG("zBackwards.bmp"));
	  setImage('z', 2, sprite.loadIMG("zleft.bmp"));
	  setImage('z', 3, sprite.loadIMG("zright.bmp"));
	}


}