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

using namespace std;

const std::string StopPersonCommand::_id = "stopPerson";

StopPersonCommand::StopPersonCommand(Person *person)
:_person(person->id())
{
}

StopPersonCommand::StopPersonCommand(List *command)
{
	command = command->rest();
	_person = command->firstString();
}

void StopPersonCommand::execute()
{
	Person *person = (Person *)Level::instance()->getObject(_person);
	if(person == NULL)
		return;
	person->setVelocity(0,0);
}

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

	return commandString;
}