#include "Command.h"
#include "List.h"
#include "Level.h"
#include <sstream>

using namespace std;

const std::string AddScoreCommand::_id = "addScore";

AddScoreCommand::AddScoreCommand(int score)
:_score(score)
{

}

AddScoreCommand::AddScoreCommand(List *command)
{
	command = command->rest();
	_score = command->firstInt();
}

void AddScoreCommand::execute()
{
	Level::instance()->addScore(_score);
	PlaySoundCommand("sounds/nicechime.wav").execute();
}

std::string AddScoreCommand::getString()
{
	List *command = new List();
	command->snoc(new Atom(_id));
	stringstream score;
	score << _score;
	command->snoc(new Atom(score.str()));
	string commandString = command->getString();
	delete command;

	return commandString;
}