Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2008, 9:52:12 AM (16 years ago)
Author:
dafrick
Message:

Started with XMLPort…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem/src/orxonox/objects/Quest.cc

    r2021 r2068  
    3030
    3131#include "Quest.h"
     32#include "QuestManager.h"
    3233
    3334namespace orxonox {
     
    3536    Quest::Quest() : QuestItem()
    3637    {
    37        
     38        this->initialize();
    3839    }
    3940
     
    4849        The description of the quest.
    4950    */
    50     Quest::Quest(std::string id, std::string title, std::string description) : QuestItem(id, title, description)
    51     {
    52         initialize();
     51    Quest::Quest(std::string id) : QuestItem(id)
     52    {
     53        this->initialize();
    5354    }
    5455   
     
    5960    Quest::~Quest()
    6061    {
    61         //TDO: Unload lists...
     62       
    6263    }
    6364   
     
    7071        RegisterObject(Quest);
    7172       
    72         this->parentQuest_ = 0;
     73        this->parentQuest_ = NULL;
     74        QuestManager::registerQuest(this); //Registers the quest with the QuestManager.
    7375    }
    7476
     
    7880    @param quest
    7981        A pointer to the quest to be set as parent quest.
     82    @return
     83        Returns true if the parentQuest could be set.
    8084    */
    8185    bool Quest::setParentQuest(Quest* quest)
    8286    {
     87        if(quest == NULL)
     88        {
     89            COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl;
     90            return false;
     91        }
     92       
    8393        this->parentQuest_ = quest;
    8494        return true;
     
    90100    @param quest
    91101        A pointer to the quest to be set as sub quest.
     102    @return
     103        Returns true if the subQuest vould be set.
    92104    */
    93105    bool Quest::addSubQuest(Quest* quest)
    94106    {
     107        if(quest == NULL)
     108        {
     109            COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl;
     110            return false;
     111        }
     112       
    95113        this->subQuests_.push_back(quest);
    96114        return true;
     115    }
     116   
     117    /**
     118    @brief
     119        Returns true if the quest status for the specific player is 'inactive'.
     120    @param player
     121        The player.
     122    @return
     123        Returns true if the quest status for the specific player is 'inactive'.
     124    @throws
     125        Throws an exception if getStatus throws one.
     126    */
     127    bool Quest::isInactive(const Player* player) const
     128    {
     129        return this->getStatus(player) == questStatus::inactive;
     130    }
     131   
     132    /**
     133    @brief
     134        Returns true if the quest status for the specific player is 'active'.
     135    @param player
     136        The player.
     137    @return
     138        Returns true if the quest status for the specific player is 'active'.
     139    @throws
     140        Throws an exception if getStatus throws one.
     141    */
     142    bool Quest::isActive(const Player* player) const
     143    {
     144
     145        return this->getStatus(player) == questStatus::active;
     146    }
     147   
     148    /**
     149    @brief
     150        Returns true if the quest status for the specific player is 'failed'.
     151    @param player
     152        The player.
     153    @return
     154        Returns true if the quest status for the specific player is 'failed'.
     155    @throws
     156        Throws an exception if getStatus throws one.
     157    */
     158    bool Quest::isFailed(const Player* player) const
     159    {
     160        return this->getStatus(player) == questStatus::failed;
     161    }
     162   
     163    /**
     164    @brief
     165        Returns true if the quest status for the specific player is 'completed'.
     166    @param player
     167        The player.
     168    @return
     169        Returns true if the quest status for the specific player is 'completed'.
     170    @throws
     171        Throws an exception if getStatus throws one.
     172    */
     173    bool Quest::isCompleted(const Player* player) const
     174    {
     175        return this->getStatus(player) == questStatus::completed;
    97176    }
    98177
     
    102181    @param hint
    103182        The hint that should be added to the list of hints.
    104     */
    105     void Quest::addHint(QuestHint* hint)
    106     {
    107         if ( hint != NULL )
    108         {
    109             this->hints_.push_back(hint);
    110             hint->setQuest(this);
    111         }
    112         else
     183    @return
     184        Returns true if the hint was successfully added.
     185    */
     186    bool Quest::addHint(QuestHint* hint)
     187    {
     188        if(hint == NULL)
    113189        {
    114190            COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl;
    115         }
     191            return false;
     192        }
     193       
     194        this->hints_.push_back(hint);
     195        hint->setQuest(this);
     196        return true;
    116197    }
    117198   
Note: See TracChangeset for help on using the changeset viewer.