#include "Character.h"

Character::Character()
{
	x = 0;
	y = 0;
	z = 0;
	facing = 0;
}
Character::Character(int xData, int yData, int zData)
{
	x = xData;
	y = yData;
	z = zData;
	facing = 0;
}
Character::~Character()
{
}
void Character::setFacing(int data)
{
	facing = data;
}
void Character::setX(int data)
{
	x = data;
}
int Character::getX() const
{
	return x;
}
void Character::setY(int data)
{
	y = data;
}
int Character::getY() const
{
	return y;
}
void Character::setZ(int data)
{
	z = data;
}
int Character::getZ() const
{
	return z;
}
void Character::printPlayer() const
{
	switch(facing)
	{
	case 0:		cout << "^";	break;
	case 1:		cout << ">";	break;
	case 2:		cout << "v";	break;
	case 3:		cout << "<";	break;
	default:	cout << "X";	break;
	}
}
void Character::printLocation() const
{
	cout << "X: " << x << " Y: " << y << " Z: " << z;
}
void Character::Action(string Action)
{
	int action;

	if		(Action == "A" || Action == "a") action = 0;
	else if	(Action == "D" || Action == "d") action = 1;
	else if	(Action == "W" || Action == "w") action = 2;
	else return;//get out in case bad data

	switch(action)
	{
	//Turn left
	case 0:
		if(facing > 0) --facing;
		else facing = 3;
		break;
	//Turn right
	case 1:
		if(facing < 3) ++facing;
		else facing = 0;
		break;
	//Move forward
	case 2:
		switch(facing)
		{
		case 0:		if(y > 0) --y;			break;
		case 1:		if(x < maxX - 1) ++x;	break;
		case 2:		if(y < maxY - 1) ++y;	break;
		case 3:		if(x > 0) --x;			break;
		}
		break;
	}
}