00001 #include "Command.h" 00002 #include "Level.h" 00003 #include "Person.h" 00004 #include "List.h" 00005 00006 using namespace std; 00007 00008 const std::string StopPersonCommand::_id = "stopPerson"; 00009 00010 StopPersonCommand::StopPersonCommand(Person *person) 00011 :_person(person->id()) 00012 { 00013 } 00014 00015 StopPersonCommand::StopPersonCommand(List *command) 00016 { 00017 command = command->rest(); 00018 _person = command->firstString(); 00019 } 00020 00021 void StopPersonCommand::execute() 00022 { 00023 Person *person = (Person *)Level::instance()->getObject(_person); 00024 if(person == NULL) 00025 return; 00026 person->setVelocity(0,0); 00027 } 00028 00029 std::string StopPersonCommand::getString() 00030 { 00031 List *command = new List(); 00032 command->snoc(new Atom(_id)); 00033 command->snoc(new Atom(_person)); 00034 string commandString = command->getString(); 00035 delete command; 00036 00037 return commandString; 00038 }
1.4.6-NO