- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/Documents and Settings/jegan/Desktop/projectX/AddWeaponCommand.cpp

Go to the documentation of this file.

    00001 #include "Command.h"
    00002 #include "List.h"
    00003 #include "Level.h"
    00004 #include "Player.h"
    00005
    00006 #include <iostream>
    00007
    00008 using namespace std;
    00009
    00010 const string AddWeaponCommand::_id = "addWeapon";
    00011
    00012 AddWeaponCommand::AddWeaponCommand(Player *player, std::string filename)
    00013 :_player(player),_filename(filename)
    00014 {
    00015 }
    00016
    00017 AddWeaponCommand::AddWeaponCommand(List *command)
    00018 {
    00019         command = command->rest();
    00020         _player = (Player *)Level::instance()->getObject(command->firstString());
    00021         _filename = command->rest()->firstString();
    00022 }
    00023
    00024 void AddWeaponCommand::execute()
    00025 {
    00026         _player->addSecondary(_filename);
    00027 }
    00028
    00029 std::string AddWeaponCommand::getString()
    00030 {
    00031         List *command = new List();
    00032         command->snoc(new Atom(_id));
    00033         command->snoc(new Atom(_player->id()));
    00034         command->snoc(new Atom(_filename));
    00035
    00036         string commandString = command->getString();
    00037         delete command;
    00038
    00039         return commandString;
    00040 }