- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

Go to the documentation of this file.

    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 string AddHealthCommand::_id = "addHealth";
    00012
    00013 AddHealthCommand::AddHealthCommand(Person *person, int dHealth)
    00014 :_person(person),_dHealth(dHealth)
    00015 {
    00016 }
    00017
    00018 AddHealthCommand::AddHealthCommand(List *command)
    00019 {
    00020         command = command->rest();
    00021         _person = (Person *)Level::instance()->getObject(command->firstString());
    00022         _dHealth = command->rest()->firstInt();
    00023 }
    00024
    00025 void AddHealthCommand::execute()
    00026 {
    00027         _person->addHealth(_dHealth);
    00028         PlaySoundCommand("sounds/male_mmh_02.wav").execute();
    00029 }
    00030
    00031 std::string AddHealthCommand::getString()
    00032 {
    00033         List *command = new List();
    00034         command->snoc(new Atom(_id));
    00035         command->snoc(new Atom(_person->id()));
    00036         command->snoc(new Atom(_dHealth));
    00037
    00038         string commandString = command->getString();
    00039         delete command;
    00040
    00041         return commandString;
    00042 }