#include "Command.h"
#include "Person.h"
#include "List.h"
#include "Level.h"
#include "Sprite.h"

using namespace std;

const std::string TurnCommand::_id = "turn";

TurnCommand::TurnCommand(Person *person, xDirection xDir)
:_person(person),_xDir(xDir)
{
	
}
TurnCommand::TurnCommand(List *command)
{
	command = command->rest();
	_person = (Person *)Level::instance()->getObject(command->firstString());
	command = command->rest();
	_xDir = (xDirection)command->firstInt();
}
void TurnCommand::execute()
{
	_person->setXDirection(_xDir);
}

std::string TurnCommand::getString()
{
	List *command = new List();
	command->snoc(new Atom(_id));
	command->snoc(new Atom(_person->id()));
	command->snoc(new Atom(_xDir));
	string commandString = command->getString();
	delete command;

	return commandString;
}