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