C:/Documents and Settings/jegan/Desktop/projectX/JumpCommand.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 JumpCommand::_id = "jump";
00010 
00011 JumpCommand::JumpCommand(Person *person, xDirection xDir)
00012 :_person(person->id()),_xDir(xDir)
00013 {
00014 }
00015 
00016 JumpCommand::JumpCommand(List *command)
00017 {
00018         command = command->rest();
00019         //_person = (Person *)Level::instance()->getObject(command->firstString());
00020         _person = command->firstString();
00021         command = command->rest();
00022         _xDir = (xDirection)command->firstInt();
00023 }
00024 
00025 void JumpCommand::execute()
00026 {
00027         Person *person = (Person *)Level::instance()->getObject(_person);
00028         if(person == NULL)
00029                 return;
00030         person->jump(_xDir);
00031 }
00032 
00033 std::string JumpCommand::getString()
00034 {
00035         List *command = new List();
00036         command->snoc(new Atom(_id));
00037         command->snoc(new Atom(_person));
00038         command->snoc(new Atom(_xDir));
00039         string commandString = command->getString();
00040         delete command;
00041 
00042         return commandString;
00043 }

Generated on Fri May 5 00:20:18 2006 for ProjectX by  doxygen 1.4.6-NO