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

#include <iostream>

using namespace std;

const std::string ShootCommand::_id = "shoot";

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

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

void ShootCommand::execute()
{
	Person *person = (Person *)Level::instance()->getObject(_person);
	if(person == NULL)
		return;

	person->shoot();
}

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

	string commandString = command->getString();
	delete command;

	return commandString;
}