#include "Command.h"
#include "Screen.h"
#include "List.h"
#include "Level.h"
#include "Object.h"

using namespace std;

const std::string SetCameraCommand::_id = "setCamera";

SetCameraCommand::SetCameraCommand(Object *object)
:_object(object)
{

}

SetCameraCommand::SetCameraCommand(List *command)
{
	command = command->rest();
	_object = Level::instance()->getObject(command->firstString());
}

void SetCameraCommand::execute()
{
	Screen::instance()->registerFollowObj(_object);
	Screen::instance()->recenter();
}

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

	return commandString;
}