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

#include <iostream>

using namespace std;

const string AddWeaponCommand::_id = "addWeapon";

AddWeaponCommand::AddWeaponCommand(Player *player, std::string filename)
:_player(player),_filename(filename)
{
}

AddWeaponCommand::AddWeaponCommand(List *command)
{
	command = command->rest();
	_player = (Player *)Level::instance()->getObject(command->firstString());
	_filename = command->rest()->firstString();
}

void AddWeaponCommand::execute()
{
	_player->addSecondary(_filename);
}

std::string AddWeaponCommand::getString()
{
	List *command = new List();
	command->snoc(new Atom(_id));
	command->snoc(new Atom(_player->id()));
	command->snoc(new Atom(_filename));

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

	return commandString;
}