C:/Documents and Settings/mtauraso/Desktop/proj3/projectX/CrouchCommand.cpp

Go to the documentation of this file.
00001 #include "Command.h"
00002 #include "Person.h"
00003 #include "Level.h"
00004 #include "List.h"
00005 
00006 
00007 using namespace std;
00008 
00009 const std::string CrouchCommand::_id = "crouch";
00010 
00011 CrouchCommand::CrouchCommand(Person *person, bool crouch)
00012 :_person(person),
00013  _crouch( crouch )
00014 {
00015 }
00016 
00017 CrouchCommand::CrouchCommand(List *command)
00018 {
00019         command = command->rest();
00020         _person = (Person *)Level::instance()->getObject(command->firstString());
00021         command = command->rest();
00022         string crouch = command->firstString();
00023         if(crouch == "true")
00024                 _crouch = true;
00025         else
00026                 _crouch = false;
00027 }
00028 
00029 void CrouchCommand::execute()
00030 {
00031         if( _crouch )
00032                 _person->crouch();
00033         else
00034                 _person->uncrouch();
00035 }
00036 
00037 std::string CrouchCommand::getString()
00038 {
00039         List *command = new List();
00040         command->snoc(new Atom(_id));
00041         command->snoc(new Atom(_person->id()));
00042         if(_crouch)
00043                 command->snoc(new Atom("true"));
00044         else
00045                 command->snoc(new Atom("false"));
00046         string commandString = command->getString();
00047         delete command;
00048 
00049         return commandString;
00050 }

Generated on Sat Apr 22 15:05:20 2006 for ProjectX by  doxygen 1.4.6-NO