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

#include <iostream>

using namespace std;

const string AddHealthCommand::_id = "addHealth";

AddHealthCommand::AddHealthCommand(Person *person, int dHealth)
:_person(person),_dHealth(dHealth)
{
}

AddHealthCommand::AddHealthCommand(List *command)
{
	command = command->rest();
	_person = (Person *)Level::instance()->getObject(command->firstString());
	_dHealth = command->rest()->firstInt();
}

void AddHealthCommand::execute()
{
	_person->addHealth(_dHealth);
	PlaySoundCommand("sounds/male_mmh_02.wav").execute();
}

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

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

	return commandString;
}