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

using namespace std;

const std::string KillCommand::_id = "kill";

KillCommand::KillCommand(Person *person)
:_person(person->id())
{

}

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

void KillCommand::execute()
{
	((Person *)Level::instance()->getObject(_person))->die();
}

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

	return commandString;
}