Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 23, 2008, 10:40:38 PM (16 years ago)
Author:
rgrieder
Message:

merged revisions 2260 - 2508 from trunk to buggy.
I'm sorry that I have to commit every merge. But otherwise I get tons of conflicts I have to solve ten times over.
Note: did not merge deletion of src/util/testing, tortoise wasn't very friendly with that.

Location:
code/branches/bugger
Files:
32 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/bugger

  • code/branches/bugger/src/orxonox/objects/quest/AddQuest.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file AddQuest.cc
     31    @brief
     32    Implementation of the AddQuest class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "AddQuest.h"
    3137
    3238#include <string>
     39
    3340#include "core/CoreIncludes.h"
    3441#include "util/Exception.h"
    3542
     43#include "orxonox/objects/infos/PlayerInfo.h"
    3644#include "QuestManager.h"
    3745#include "Quest.h"
     
    4149    CreateFactory(AddQuest);
    4250
    43 
     51    /**
     52    @brief
     53        Constructor. Registers the object.
     54    */
    4455    AddQuest::AddQuest(BaseObject* creator) : ChangeQuestStatus(creator)
    4556    {
     
    5566    }
    5667
     68    /**
     69    @brief
     70        Method for creating a AddQuest object through XML.
     71    */
    5772    void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5873    {
    5974        SUPER(AddQuest, XMLPort, xmlelement, mode);
    60 
     75       
     76        COUT(3) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
    6177    }
    6278
    6379    /**
    6480    @brief
    65         Invokes the effect.
     81        Invokes the QuestEffect.
    6682    @param player
    67         The player the effect is invoked on.
     83        The player the QuestEffect is invoked on.
    6884    @return
    69         Returns true if the effect was successfully invoked.
     85        Returns true if the QuestEffect was successfully invoked.
    7086    */
    71     bool AddQuest::invoke(Player* player)
     87    bool AddQuest::invoke(PlayerInfo* player)
    7288    {
    73         if(player == NULL)
     89        if(player == NULL) //!< Null-pointers are badass.
    7490        {
    7591            COUT(2) << "Input player is NULL." << std::endl;
     
    7793        }
    7894
     95        COUT(3) << "AddQuest on player: " << player << " ." << std::endl;
     96
    7997        try
    8098        {
    8199            Quest* quest = QuestManager::findQuest(this->getQuestId());
    82             if(!quest->start(player))
     100            if(quest == NULL || !quest->start(player))
    83101            {
    84102               return false;
     
    91109        }
    92110
     111        COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl;
    93112        return true;
    94113    }
  • code/branches/bugger/src/orxonox/objects/quest/AddQuest.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file AddQuest.h
     31    @brief
     32    Definition of the AddQuest class.
     33*/
     34
    2935#ifndef _AddQuest_H__
    3036#define _AddQuest_H__
     
    3945namespace orxonox {
    4046
    41     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    42 
    4347    /**
    4448    @brief
    45         Adds a quest, resp. changes the quests status to active.
     49        Adds a Quest, resp. changes the quests status to active for the player invoking the Quest.
     50       
     51        Creating a AddQuest through XML goes as follows:
     52       
     53        <AddQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
    4654    @author
    4755        Damian 'Mozork' Frick
     
    5361            virtual ~AddQuest();
    5462
    55             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
    5664
    57             virtual bool invoke(Player* player); //!< Invokes the effect.
     65            virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    5866
    5967    };
  • code/branches/bugger/src/orxonox/objects/quest/AddQuestHint.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file AddQuestHint.cc
     31    @brief
     32    Implementation of the AddQuestHint class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "AddQuestHint.h"
     
    3339#include "util/Exception.h"
    3440
     41#include "orxonox/objects/infos/PlayerInfo.h"
    3542#include "QuestManager.h"
    3643#include "QuestItem.h"
     
    4148    CreateFactory(AddQuestHint);
    4249
     50    /**
     51    @brief
     52        Constructor. Registers the object.
     53    */
    4354    AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator)
    4455    {
     
    5465    }
    5566
     67    /**
     68    @brief
     69        Method for creating a AddQuestHint object through XML.
     70    */
    5671    void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5772    {
     
    5974
    6075        XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
    61 
     76       
     77        COUT(3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;
    6278    }
    6379
    64     inline void AddQuestHint::setHintId(const std::string & id)
     80    /**
     81    @brief
     82        Sets the id of the QuestHint to be added to the player the QuestEffect is invoked on.
     83    @param id
     84        The QuestHint id.
     85    @param
     86        Returns true if successful.
     87    */
     88    bool AddQuestHint::setHintId(const std::string & id)
    6589    {
    6690        if(!QuestItem::isId(id))
    6791        {
    6892            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
    69             return;
     93            return false;
    7094        }
     95       
    7196        this->hintId_ = id;
     97        return true;
    7298    }
    7399
    74100    /**
    75101    @brief
    76         Invokes the effect.
     102        Invokes the QuestEffect.
    77103    @param player
    78104        The player.
    79105    @return
    80         Returns true if the effect was successfully invoked.
     106        Returns true if the QuestEffect was successfully invoked.
    81107    */
    82     bool AddQuestHint::invoke(Player* player)
     108    bool AddQuestHint::invoke(PlayerInfo* player)
    83109    {
    84         if(player == NULL)
     110        if(player == NULL) //!< NULL-pointers are evil!
    85111        {
    86112            COUT(2) << "The input player is NULL." << std::endl;
     
    88114        }
    89115
     116        COUT(3) << "AddQuestHint on player: " << player << " ." << std::endl;
     117
    90118        try
    91119        {
    92120            QuestHint* hint = QuestManager::findHint(this->hintId_);
    93             if(!hint->activate(player))
     121            if(hint == NULL || !hint->setActive(player))
    94122            {
    95123                return false;
     
    102130        }
    103131
     132        COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player." << std::endl;
    104133        return true;
    105134
  • code/branches/bugger/src/orxonox/objects/quest/AddQuestHint.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file AddQuestHint.h
     31    @brief
     32    Definition of the AddQuestHint class.
     33*/
     34
    2935#ifndef _AddQuestHint_H__
    3036#define _AddQuestHint_H__
     
    3844namespace orxonox {
    3945
    40     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    41 
    4246    /**
    4347    @brief
    44         Adds a QuestHint, resp. Activates the QuestHint.
     48        Adds a QuestHint, resp. activates the QuestHint of the given id for the player the QuestEffect is invoked on.
     49       
     50    Creating a AddQuestHint through XML goes as follows:
     51       
     52        <AddQuestHint hintId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added.
    4553    @author
    4654        Damian 'Mozork' Frick
     
    5260            virtual ~AddQuestHint();
    5361
    54             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     62            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuestHint object through XML.
    5563
    56             virtual bool invoke(Player* player); //!< Invokes the effect.
     64            virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    5765
    5866        private:
    59             std::string hintId_;
     67            std::string hintId_; //!< The id of the QuestHint.
    6068
     69            /**
     70            @brief Returns the id of the QuestHint.
     71            @return Returns the id of the QuestHint.
     72            */
    6173            inline const std::string & getHintId(void) const
    6274                { return this->hintId_; }
    63             void setHintId(const std::string & id);
     75            bool setHintId(const std::string & id); //!< Sets the id of the QuestHint.
    6476
    6577    };
  • code/branches/bugger/src/orxonox/objects/quest/AddReward.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file AddReward.cc
     31    @brief
     32    Implementation of the AddReward class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "AddReward.h"
     
    3238#include "core/CoreIncludes.h"
    3339
     40#include "orxonox/objects/infos/PlayerInfo.h"
    3441#include "Rewardable.h"
    3542
     
    3845    CreateFactory(AddReward);
    3946
     47    /**
     48    @brief
     49        Constructor. Registers the object.
     50    */
    4051    AddReward::AddReward(BaseObject* creator) : QuestEffect(creator)
    4152    {
    4253        RegisterObject(AddReward);
    43 
    44         this->initialize();
    4554    }
    4655
     
    5362    }
    5463
     64    /**
     65        Method for creating a AddReward object through XML.
     66    */
    5567    void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5668    {
     
    5870
    5971        XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
    60 
     72       
     73        COUT(3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;
    6174    }
    6275
    6376    /**
    6477    @brief
    65         Initializes the object. Needs to be called first by every constructor of this class.
     78        Returns the Rewardable object at the given index.
     79    @param index
     80        The index.
     81    @return
     82        Returns a pointer to the Rewardable object at the given index.
    6683    */
    67     void AddReward::initialize(void)
    68     {
    69         RegisterObject(AddReward);
    70     }
    71 
    7284    const Rewardable* AddReward::getRewardables(unsigned int index) const
    7385    {
     
    8698    /**
    8799    @brief
    88         Invokes the effect.
     100        Invokes the QuestEffect.
    89101    @param player
    90102        The player.
    91103    @return
    92         Returns true if the effect was invoked successfully.
     104        Returns true if the QuestEffect was invoked successfully.
    93105    */
    94     bool AddReward::invoke(Player* player)
     106    bool AddReward::invoke(PlayerInfo* player)
    95107    {
    96108        bool check = true;
  • code/branches/bugger/src/orxonox/objects/quest/AddReward.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file AddReward.h
     31    @brief
     32    Definition of the AddReward class.
     33*/
     34
    2935#ifndef _AddReward_H__
    3036#define _AddReward_H__
     
    3945namespace orxonox {
    4046
    41     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    42 
    4347    /**
    4448    @brief
    45         Adds a list of rewards to a player.
     49        Adds a list of Rewardables to a player.
     50       
     51        Creating a AddReward through XML goes as follows:
     52       
     53        <AddReward>
     54            <Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations.
     55            ...
     56            <Rewardable />
     57        </AddReward>
    4658    @author
    4759        Damian 'Mozork' Frick
     
    5365            virtual ~AddReward();
    5466
    55             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     67            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddReward object through XML.
    5668
    57             virtual bool invoke(Player* player); //!< Invokes the effect.
     69            virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    5870
    5971        private:
    60             std::list<Rewardable*> rewards_;
     72            std::list<Rewardable*> rewards_; //!< A list of Rewardables to be added to the player invoking the QuestEffect.
    6173
    62             void initialize(void); //!< Initializes the object.
    63 
     74            /**
     75            @brief Add a Rewardable object to the list of objects to be awarded to the player invoking the QuestEffect.
     76            @param reward Pointer to the Rewardable to be added.
     77            */
    6478            inline void addRewardable(Rewardable* reward)
    6579                { this->rewards_.push_back(reward); }
    66             const Rewardable* getRewardables(unsigned int index) const;
     80            const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index.
    6781
    6882    };
  • code/branches/bugger/src/orxonox/objects/quest/CMakeLists.txt

    r2131 r2530  
    1111  QuestDescription.cc
    1212  QuestEffect.cc
     13  QuestEffectBeacon.cc
    1314  QuestHint.cc
    1415  QuestItem.cc
  • code/branches/bugger/src/orxonox/objects/quest/ChangeQuestStatus.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file ChangeQuestStatus.cc
     31    @brief
     32    Implementation of the ChangeQuestStatus class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "ChangeQuestStatus.h"
     
    3642namespace orxonox {
    3743
     44    /**
     45    @brief
     46        Constructor. Registers the object.
     47    */
    3848    ChangeQuestStatus::ChangeQuestStatus(BaseObject* creator) : QuestEffect(creator)
    3949    {
     
    4959    }
    5060
    51     void ChangeQuestStatus::setQuestId(const std::string & id)
    52     {
    53         if(!QuestItem::isId(id))
    54         {
    55             COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
    56             return;
    57         }
    58         this->questId_ = id;
    59     }
    60 
     61    /**
     62    @brief
     63        Method for creating a ChangeQuestStatus object through XML.
     64    */
    6165    void ChangeQuestStatus::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6266    {
     
    6670    }
    6771
     72    /**
     73    @brief
     74        Sets the id of the Quest the Questffect changes the status of.
     75    @param id
     76        The id of the Quest.
     77    @return
     78        Returns true if successful.
     79    */
     80    bool ChangeQuestStatus::setQuestId(const std::string & id)
     81    {
     82        if(!QuestItem::isId(id))
     83        {
     84            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
     85            return false;
     86        }
     87       
     88        this->questId_ = id;
     89        return true;
     90    }
     91
    6892}
  • code/branches/bugger/src/orxonox/objects/quest/ChangeQuestStatus.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file ChangeQuestStatus.h
     31    @brief
     32    Definition of the ChangeQuestStatus class.
     33*/
     34
    2935#ifndef _ChangeQuestStatus_H__
    3036#define _ChangeQuestStatus_H__
     
    3945namespace orxonox {
    4046
    41     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    42 
    4347    /**
    4448    @brief
    45         An effect which changes a quests status.
     49        A QuestEffect which changes the status of a specified Quest for the player invoking the QuestEffect.
    4650    @author
    4751        Damian 'Mozork' Frick
     
    5357            virtual ~ChangeQuestStatus();
    5458
    55             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     59            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a ChangeQuestStatus object through XML.
    5660
    57             virtual bool invoke(Player* player) = 0; //!< Invokes the effect.
     61            virtual bool invoke(PlayerInfo* player) = 0; //!< Invokes the QuestEffect.
    5862
    5963        protected:
    60             inline const std::string & getQuestId(void) const //!< Returns the quest id.
     64            /**
     65                @brief Returns the id of the Quest.
     66                @return Returns the id of the Quest.
     67            */
     68            inline const std::string & getQuestId(void) const
    6169                { return this->questId_; }
    6270
    63             std::string questId_; //!< The id of the quest the status should be changed of.
    64 
    6571        private:
    66             void setQuestId(const std::string & id);
     72            std::string questId_; //!< The id of the Quest the status should be changed of.
     73           
     74            bool setQuestId(const std::string & id); //!< Sets the id of the Quest.
    6775
    6876    };
  • code/branches/bugger/src/orxonox/objects/quest/CompleteQuest.cc

    r2105 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file CompleteQuest.cc
     31    @brief
     32    Implementation of the CompleteQuest class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
     
    3339#include "util/Exception.h"
    3440
     41#include "orxonox/objects/infos/PlayerInfo.h"
    3542#include "QuestManager.h"
    3643#include "Quest.h"
     
    4047    CreateFactory(CompleteQuest);
    4148
     49    /**
     50    @brief
     51        Constructor. Registers the object.
     52    */
    4253    CompleteQuest::CompleteQuest(BaseObject* creator) : ChangeQuestStatus(creator)
    4354    {
     
    5364    }
    5465
     66    /**
     67    @brief
     68        Method for creating a CompleteQuest object through XML.
     69    */
    5570    void CompleteQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5671    {
    5772        SUPER(CompleteQuest, XMLPort, xmlelement, mode);
     73       
     74        COUT(3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
    5875    }
    5976
    6077    /**
    6178    @brief
    62         Invokes the effect.
     79        Invokes the QuestEffect.
    6380    @param player
    64         The player the effect is invoked on.
     81        The player the QuestEffect is invoked on.
    6582    @return
    66         Returns true if the effect was invoked successfully.
     83        Returns true if the QuestEffect was invoked successfully.
    6784    */
    68     bool CompleteQuest::invoke(Player* player)
     85    bool CompleteQuest::invoke(PlayerInfo* player)
    6986    {
    70         if(player == NULL)
     87        if(player == NULL) //!< You know, what we think of NULL-pointers...
    7188        {
    7289            COUT(2) << "Input player is NULL." << std::endl;
     
    7491        }
    7592
     93        COUT(3) << "CompleteQuest on player: " << player << " ." << std::endl;
     94
     95        Quest* quest;
     96
    7697        try
    7798        {
    78             Quest* quest = QuestManager::findQuest(this->getQuestId());
    79             if(!quest->complete(player))
     99            quest = QuestManager::findQuest(this->getQuestId());
     100            if(quest == NULL || !quest->complete(player))
    80101            {
    81102               return false;
     
    88109        }
    89110
     111        COUT(3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;
    90112        return true;
    91113    }
  • code/branches/bugger/src/orxonox/objects/quest/CompleteQuest.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file CompleteQuest.h
     31    @brief
     32    Definition of the CompleteQuest class.
     33*/
     34
    2935#ifndef _CompleteQuest_H__
    3036#define _CompleteQuest_H__
     
    3945namespace orxonox {
    4046
    41     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    42 
    4347    /**
    4448    @brief
    45         Completes a quest.
     49        Completes a Quest (with a specified id) for the player invoking the QuestEffect.
     50       
     51        Creating a CompleteQuest through XML goes as follows:
     52       
     53        <CompleteQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be completed.
    4654    @author
    4755        Damian 'Mozork' Frick
     
    5361            virtual ~CompleteQuest();
    5462
    55             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CompleteQuest object through XML.
    5664
    57             virtual bool invoke(Player* player); //!< Invokes the effect.
     65            virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    5866
    5967    };
  • code/branches/bugger/src/orxonox/objects/quest/FailQuest.cc

    r2105 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file FailQuest.cc
     31    @brief
     32    Implementation of the FailQuest class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
     
    3339#include "util/Exception.h"
    3440
     41#include "orxonox/objects/infos/PlayerInfo.h"
    3542#include "QuestManager.h"
    3643#include "Quest.h"
     
    4047    CreateFactory(FailQuest);
    4148
     49    /**
     50    @brief
     51        Constructor. Registers the object.
     52    */
    4253    FailQuest::FailQuest(BaseObject* creator) : ChangeQuestStatus(creator)
    4354    {
     
    5364    }
    5465
     66    /**
     67    @brief
     68        Method for creating a FailQuest object through XML.
     69    */
    5570    void FailQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5671    {
    5772        SUPER(FailQuest, XMLPort, xmlelement, mode);
     73       
     74        COUT(3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
    5875    }
    5976
    6077    /**
    6178    @brief
    62         Invokes the effect.
     79        Invokes the QuestEffect.
    6380    @param player
    64         The player the effect is invoked on.
     81        The player the QuestEffect is invoked on.
    6582    @return
    66         Returns true if the effect was invoked successfully.
     83        Returns true if the QuestEffect was invoked successfully.
    6784    */
    68     bool FailQuest::invoke(Player* player)
     85    bool FailQuest::invoke(PlayerInfo* player)
    6986    {
    70         if(player == NULL)
     87        if(player == NULL) //!< We don't know what to do with no player.
    7188        {
    7289            COUT(2) << "Input player is NULL." << std::endl;
     
    7491        }
    7592
     93        COUT(3) << "FailQuest on player: " << player << " ." << std::endl;
     94
     95        Quest* quest;
    7696        try
    7797        {
    78             Quest* quest = QuestManager::findQuest(this->getQuestId());
    79             if(!quest->fail(player))
     98            quest = QuestManager::findQuest(this->getQuestId());
     99            if(quest == NULL || !quest->fail(player))
    80100            {
    81101               return false;
     
    87107            return false;
    88108        }
    89 
     109       
     110        COUT(3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
    90111        return true;
    91112    }
  • code/branches/bugger/src/orxonox/objects/quest/FailQuest.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file FailQuest.h
     31    @brief
     32    Definition of the FailQuest class.
     33*/
     34
    2935#ifndef _FailQuest_H__
    3036#define _FailQuest_H__
     
    3945namespace orxonox {
    4046
    41     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    42 
    4347    /**
    4448    @brief
    45         Fails a quest.
     49        Fails a quest (with a specified id) for the player invoking the QuestEffect.
     50       
     51        Creating a FailQuest through XML goes as follows:
     52       
     53        <FailQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be failed.
    4654    @author
    4755        Damian 'Mozork' Frick
     
    5361            virtual ~FailQuest();
    5462
    55             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a FailQuest object through XML.
    5664
    57             virtual bool invoke(Player* player); //!< Invokes the effect.
     65            virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    5866
    5967    };
  • code/branches/bugger/src/orxonox/objects/quest/GlobalQuest.cc

    r2105 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file GlobalQuest.cc
     31    @brief
     32    Implementation of the GlobalQuest class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
    3036#include "GlobalQuest.h"
    3137
     38#include "orxonox/objects/infos/PlayerInfo.h"
    3239#include "core/CoreIncludes.h"
    3340#include "util/Exception.h"
    3441
     42#include "QuestEffect.h"
     43
    3544namespace orxonox {
    3645
     
    3948    /**
    4049    @brief
    41         Constructor.
     50        Constructor. Registers the object.
    4251    */
    4352    GlobalQuest::GlobalQuest(BaseObject* creator) : Quest(creator)
    4453    {
    4554        RegisterObject(GlobalQuest);
    46 
    47         this->initialize();
    4855    }
    4956
     
    5663
    5764    }
    58 
     65   
     66    /**
     67    @brief
     68        Method for creating a GlobalQuest object through XML.
     69    */
    5970    void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6071    {
    6172        SUPER(GlobalQuest, XMLPort, xmlelement, mode);
     73       
     74        XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode);
    6275
    6376        COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
    6477    }
    65 
    66     void GlobalQuest::initialize(void)
    67     {
    68         RegisterObject(GlobalQuest);
    69     }
    70 
    71     /**
    72     @brief
    73         Checks whether the quest can be started.
     78   
     79    /**
     80    @brief
     81        Fails the Quest for all players.
     82        Invokes the fail QuestEffects on all the players possessing this Quest.
     83    @param player
     84        The player failing it.
     85    @return
     86        Returns true if the Quest could be failed, false if not.
     87    */
     88    bool GlobalQuest::fail(PlayerInfo* player)
     89    {
     90        if(this->isFailable(player)) //!< Check whether the Quest can be failed.
     91        {
     92            this->setStatus(player, questStatus::failed);
     93           
     94            //! Iterate through all players possessing this Quest.
     95            for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     96            {
     97                QuestEffect::invokeEffects(*it, this->getFailEffectList());
     98            }
     99
     100            return true;
     101        }
     102       
     103        COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
     104        return false;
     105    }
     106
     107    /**
     108    @brief
     109        Completes the Quest for all players.
     110        Invokes the complete QuestEffects on all the players possessing this Quest.
     111        Invokes the reward QuestEffects on the player completing the Quest.
     112    @param player
     113        The player completing it.
     114    @return
     115        Returns true if the Quest could be completed, false if not.
     116    */
     117    bool GlobalQuest::complete(PlayerInfo* player)
     118    {
     119        if(this->isCompletable(player)) //!< Check whether the Quest can be completed.
     120        {
     121            this->setStatus(player, questStatus::completed);
     122           
     123            //! Iterate through all players possessing the Quest.
     124            for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     125            {
     126                QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
     127            }
     128           
     129            QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
     130            return true;
     131        }
     132       
     133        COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
     134        return false;
     135    }
     136
     137    /**
     138    @brief
     139        Checks whether the Quest can be started.
    74140    @param player
    75141        The player for whom is to be checked.
     
    79145        Throws an exception if either isInactive() of isActive() throws one.
    80146    */
    81     bool GlobalQuest::isStartable(const Player* player) const
    82     {
    83         return this->isInactive(player) ||  this->isActive(player);
    84     }
    85 
    86     /**
    87     @brief
    88         Checks whether the quest can be failed.
     147    bool GlobalQuest::isStartable(const PlayerInfo* player) const
     148    {
     149        if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player)))
     150        {
     151            return false;
     152        }
     153        return (this->isInactive(player) && !(this->status_ == questStatus::completed || this->status_ == questStatus::failed));
     154    }
     155
     156    /**
     157    @brief
     158        Checks whether the Quest can be failed.
    89159    @param player
    90160        The player for whom is to be checked.
    91161    @return
    92         Returns true if the quest can be failed, false if not.
     162        Returns true if the Quest can be failed, false if not.
    93163    @throws
    94164        Throws an Exception if isActive() throws one.
    95165    */
    96     bool GlobalQuest::isFailable(const Player* player) const
     166    bool GlobalQuest::isFailable(const PlayerInfo* player) const
    97167    {
    98168        return this->isActive(player);
     
    102172    /**
    103173    @brief
    104         Checks whether the quest can be completed.
     174        Checks whether the Quest can be completed.
    105175    @param player
    106176        The player for whom is to be checked.
    107177    @return
    108         Returns true if the quest can be completed, false if not.
     178        Returns true if the Quest can be completed, false if not.
    109179    @throws
    110180        Throws an Exception if isActive() throws one.
    111181    */
    112     bool GlobalQuest::isCompletable(const Player* player) const
     182    bool GlobalQuest::isCompletable(const PlayerInfo* player) const
    113183    {
    114184        return this->isActive(player);
     
    117187    /**
    118188    @brief
    119         Returns the status of the quest for a specific player.
     189        Returns the status of the Quest for a specific player.
    120190    @param player
    121191        The player.
     
    123193        Throws an Exception if player is NULL.
    124194    */
    125     questStatus::Enum GlobalQuest::getStatus(const Player* player) const
    126     {
    127         if(player == NULL)
    128         {
    129             ThrowException(Argument, "The input Player* is NULL.");
    130         }
    131 
    132         //TDO: Does this really work???
    133         std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player);
    134         if (it != this->players_.end())
     195    questStatus::Enum GlobalQuest::getStatus(const PlayerInfo* player) const
     196    {
     197        if(player == NULL) //!< We don't want NULL-Pointers!
     198        {
     199            ThrowException(Argument, "The input PlayerInfo* is NULL.");
     200        }
     201
     202        //! Find the player.
     203        std::set<PlayerInfo*>::const_iterator it = this->players_.find((PlayerInfo*)(void*)player);
     204        if (it != this->players_.end()) //!< If the player was found.
    135205        {
    136206            return this->status_;
    137207        }
    138         else
    139         {
    140            return questStatus::inactive;
    141         }
    142 
     208
     209    return questStatus::inactive;
    143210    }
    144211
     
    154221        Returns false if player is NULL.
    155222    */
    156     bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status)
    157     {
    158         if(player == NULL)
     223    bool GlobalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status)
     224    {
     225        if(player == NULL) //!< We don't want NULL-Pointers!
    159226        {
    160227            return false;
    161228        }
    162229
    163         std::set<Player*>::const_iterator it = this->players_.find(player);
     230        //! Find the player.
     231        std::set<PlayerInfo*>::const_iterator it = this->players_.find(player);
    164232        if (it == this->players_.end()) //!< Player is not yet in the list.
    165233        {
    166             this->players_.insert(player);
    167         }
    168         this->status_ = status;
     234            this->players_.insert(player); //!< Add the player to the set.
     235        }
     236       
     237        this->status_ = status; //!< Set the status, which is global, remember...?
    169238        return true;
    170239    }
     240   
     241    /**
     242    @brief
     243        Adds a reward QuestEffect to the list of reward QuestEffects.
     244    @param effect
     245        The QuestEffect to be added.
     246    @return
     247        Returns true if successful.
     248    */
     249    bool GlobalQuest::addRewardEffect(QuestEffect* effect)
     250    {
     251        if(effect == NULL) //!< We don't want NULL-Pointers!
     252        {
     253            COUT(2) << "The reward effect to be added to quest {" << this->getId() << "} was NULL." << std::endl;
     254            return false;
     255        }
     256
     257        this->rewards_.push_back(effect); //!< Add the QuestEffect to the list.
     258
     259        COUT(3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;
     260        return true;
     261    }
     262   
     263    /**
     264    @brief
     265        Returns the reward QuestEffect at the given index.
     266    @param index
     267        The index.
     268    @return
     269        Returns the QuestEffect at the given index.
     270    */
     271    const QuestEffect* GlobalQuest::getRewardEffects(unsigned int index) const
     272    {
     273        int i = index;
     274        for (std::list<QuestEffect*>::const_iterator effect = this->rewards_.begin(); effect != this->rewards_.end(); ++effect)
     275        {
     276            if(i == 0)
     277            {
     278               return *effect;
     279            }
     280            i--;
     281        }
     282        return NULL;
     283    }
    171284
    172285
  • code/branches/bugger/src/orxonox/objects/quest/GlobalQuest.h

    r2096 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file GlobalQuest.h
     31    @brief
     32    Definition of the GlobalQuest class.
     33*/
    2834
    2935#ifndef _GlobalQuest_H__
     
    3339
    3440#include <set>
     41#include <list>
    3542
    3643#include "core/XMLPort.h"
     
    3946namespace orxonox {
    4047
    41     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    42 
    4348    /**
    4449    @brief
    45         Global quests are quests, that have the same status for all players.
    46         This means, that when a player successfully completes this quest, it is completed for all players that have it.
     50        GlobalQuests are Quests, that have the same status for all players.
     51        This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it.
     52       
     53        Creating a GlobalQuest through XML goes as follows:
     54       
     55        <GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
     56            <QuestDescription title="Title" description="Description." /> //The description of the quest.
     57            <subquests>
     58        <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
     59        ...
     60        <Quest id="questIdn" />
     61        </subquests>
     62        <hints>
     63        <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
     64        ...
     65        <QuestHint id="hintIdn" />
     66        </hints>
     67            <fail-effects>
     68                <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation.
     69                ...
     70                <QuestEffect />
     71            </fail-effects>
     72            <complete-effects>
     73                <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is completed, see QuestEffect for the full XML representation.
     74                ...
     75                <QuestEffect />
     76            </complete-effects>
     77            <reward-effects>
     78                <QuestEffect /> //A list of QuestEffects, invoked on the player completing this quest. See QuestEffect for the full XML representation.
     79                ...
     80                <QuestEffect />
     81            </reward-effects>
     82        </GlobalQuest>
    4783    @author
    4884        Damian 'Mozork' Frick
     
    5490            virtual ~GlobalQuest();
    5591
    56             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     92            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a GlobalQuest object through XML.
     93           
     94            virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
     95            virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
    5796
    5897        protected:
    59             virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started.
    60             virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed.
    61             virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed.
     98            virtual bool isStartable(const PlayerInfo* player) const; //!< Checks whether the Quest can be started.
     99            virtual bool isFailable(const PlayerInfo* player) const; //!< Checks whether the Quest can be failed.
     100            virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
    62101
    63             virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player.
    64             virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
     102            virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
     103           
     104            virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
    65105
    66106        private:
    67             std::set<Player*> players_; //!< The set of players which possess this quest.
    68             questStatus::Enum status_; //!< The status of this quest.
    69 
    70             void initialize(void);
     107            std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest.
     108            questStatus::Enum status_; //!< The status of this Quest.
     109            std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
     110           
     111            bool addRewardEffect(QuestEffect* effect); //!< Adds a reward QuestEffect to the list of reward QuestEffects.
     112            const QuestEffect* getRewardEffects(unsigned int index) const; //!< Returns the reward QuestEffect at the given index.
    71113
    72114    };
  • code/branches/bugger/src/orxonox/objects/quest/LocalQuest.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file LocalQuest.cc
     31    @brief
     32    Implementation of the LocalQuest class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "LocalQuest.h"
     
    3339#include "util/Exception.h"
    3440
     41#include "orxonox/objects/infos/PlayerInfo.h"
     42#include "QuestEffect.h"
     43
    3544namespace orxonox {
    3645
    3746    CreateFactory(LocalQuest);
    3847
     48    /**
     49    @brief
     50        Constructor. Registers and initializes the object.
     51    */
    3952    LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator)
    4053    {
    4154        RegisterObject(LocalQuest);
    42 
    43         this->initialize();
    4455    }
    4556
     
    5364    }
    5465
     66    /**
     67    @brief
     68        Method for creating a LocalQuest object through XML.
     69    */
    5570    void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5671    {
     
    6075    }
    6176
    62     void LocalQuest::initialize(void)
    63     {
    64         RegisterObject(LocalQuest);
    65     }
    66 
    67     /**
    68     @brief
    69         Checks whether the quest can be started.
     77    /**
     78    @brief
     79        Fails the Quest for a given player.
     80        Invokes all the failEffects on the player.
     81    @param player
     82        The player.
     83    @return
     84        Returns true if the Quest could be failed, false if not.
     85    */
     86    bool LocalQuest::fail(PlayerInfo* player)
     87    {
     88        if(this->isFailable(player)) //!< Checks whether the quest can be failed.
     89        {
     90            this->setStatus(player, questStatus::failed);
     91            QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects.
     92            return true;
     93        }
     94       
     95        COUT(4) << "A non-failable quest was trying to be failed." << std::endl;
     96        return false;
     97    }
     98
     99    /**
     100    @brief
     101        Completes the Quest for a given player.
     102    Invokes all the complete QuestEffects on the player.
     103    @param player
     104        The player.
     105    @return
     106        Returns true if the Quest could be completed, false if not.
     107    */
     108    bool LocalQuest::complete(PlayerInfo* player)
     109    {
     110        if(this->isCompletable(player)) //!< Checks whether the Quest can be completed.
     111        {
     112            this->setStatus(player, questStatus::completed);
     113            QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects.
     114            return true;
     115        }
     116       
     117        COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
     118        return false;
     119    }
     120
     121    /**
     122    @brief
     123        Checks whether the Quest can be started.
    70124    @param player
    71125        The player for whom is to be checked.
    72126    @return
    73         Returns true if the quest can be started, false if not.
    74     @throws
    75         Throws an exception if isInactive(Player*) throws one.
    76     */
    77     bool LocalQuest::isStartable(const Player* player) const
    78     {
     127        Returns true if the Quest can be started, false if not.
     128    @throws
     129        Throws an exception if isInactive(PlayerInfo*) throws one.
     130    */
     131    bool LocalQuest::isStartable(const PlayerInfo* player) const
     132    {
     133        if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player)))
     134        {
     135            return false;
     136        }
    79137        return this->isInactive(player);
    80138    }
     
    82140    /**
    83141    @brief
    84         Checks whether the quest can be failed.
     142        Checks whether the Quest can be failed.
    85143    @param player
    86144        The player for whom is to be checked.
    87145    @return
    88         Returns true if the quest can be failed, false if not.
    89     @throws
    90         Throws an exception if isActive(Player*) throws one.
    91     */
    92     bool LocalQuest::isFailable(const Player* player) const
     146        Returns true if the Quest can be failed, false if not.
     147    @throws
     148        Throws an exception if isActive(PlayerInfo*) throws one.
     149    */
     150    bool LocalQuest::isFailable(const PlayerInfo* player) const
    93151    {
    94152        return this->isActive(player);
     
    97155    /**
    98156    @brief
    99         Checks whether the quest can be completed.
     157        Checks whether the Quest can be completed.
    100158    @param player
    101159        The player for whom is to be checked.
    102160    @return
    103         Returns true if the quest can be completed, false if not.
    104     @throws
    105         Throws an exception if isInactive(Player*) throws one.
    106     */
    107     bool LocalQuest::isCompletable(const Player* player) const
     161        Returns true if the Quest can be completed, false if not.
     162    @throws
     163        Throws an exception if isInactive(PlayerInfo*) throws one.
     164    */
     165    bool LocalQuest::isCompletable(const PlayerInfo* player) const
    108166    {
    109167        return this->isActive(player);
     
    112170    /**
    113171    @brief
    114         Returns the status of the quest for a specific player.
     172        Returns the status of the Quest for a specific player.
    115173    @param player
    116174        The player.
    117175    @return
    118         Returns the status of the quest for the input player.
     176        Returns the status of the Quest for the input player.
    119177    @throws
    120178        Throws an Exception if player is NULL.
    121179    */
    122     questStatus::Enum LocalQuest::getStatus(const Player* player) const
    123     {
    124         if(player == NULL)
    125         {
    126             ThrowException(Argument, "The input Player* is NULL.");
    127         }
    128 
    129         std::map<Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'.
    130         if (it != this->playerStatus_.end())
     180    questStatus::Enum LocalQuest::getStatus(const PlayerInfo* player) const
     181    {
     182        if(player == NULL) //!< No player has no defined status.
     183        {
     184            ThrowException(Argument, "The input PlayerInfo* is NULL.");
     185        }
     186
     187        std::map<const PlayerInfo*, questStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
     188        if (it != this->playerStatus_.end()) //!< If there is a player in the map.
    131189        {
    132190            return it->second;
    133191        }
    134         return questStatus::inactive;
     192       
     193        return questStatus::inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.
    135194    }
    136195
     
    138197    @brief
    139198        Sets the status for a specific player.
    140         But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing.
    141     @param player
    142         The player.
     199        But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing. Really!
     200    @param player
     201        The player the status should be set for.
    143202    @param status
    144         The status.
     203        The status to be set.
    145204    @return
    146205        Returns false if player is NULL.
    147206    */
    148     bool LocalQuest::setStatus(Player* player, const questStatus::Enum & status)
    149     {
    150         if(player == NULL)
     207    bool LocalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status)
     208    {
     209        if(player == NULL) //!< We can't set a status for no player.
    151210        {
    152211            return false;
    153212        }
     213       
    154214        this->playerStatus_[player] = status;
    155215        return true;
  • code/branches/bugger/src/orxonox/objects/quest/LocalQuest.h

    r2096 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file LocalQuest.h
     31    @brief
     32    Definition of the LocalQuest class.
     33*/
    2834
    2935#ifndef _LocalQuest_H__
     
    4046namespace orxonox {
    4147
    42     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    43 
    4448    /**
    4549    @brief
    46         Handles quests which have different states for different players.
     50        Handles Quests which have different states for different players.
     51        LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest.
     52       
     53        Creating a LocalQuest through XML goes as follows:
     54       
     55        <LocalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
     56            <QuestDescription title="Title" description="Description." /> //The description of the quest.
     57            <subquests>
     58        <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
     59        ...
     60        <Quest id="questIdn" />
     61        </subquests>
     62        <hints>
     63        <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
     64        ...
     65        <QuestHint id="hintIdn" />
     66        </hints>
     67            <fail-effects>
     68                <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation.
     69                ...
     70                <QuestEffect />
     71            </fail-effects>
     72            <complete-effects>
     73                <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation.
     74                ...
     75                <QuestEffect />
     76            </complete-effects>
     77        </LocalQuest>
    4778    @author
    4879        Damian 'Mozork' Frick
     
    5485            virtual ~LocalQuest();
    5586
    56             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     87            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a LocalQuest object through XML.
     88           
     89            virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
     90            virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
    5791
    5892        protected:
    59             virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started.
    60             virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed.
    61             virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed.
     93            virtual bool isStartable(const PlayerInfo* player) const; //!< Checks whether the Quest can be started.
     94            virtual bool isFailable(const PlayerInfo* player) const; //!< Checks whether the Quest can be failed.
     95            virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
    6296
    63             virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player.
    64             virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
     97            virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
     98            virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
    6599
    66100        private:
    67             std::map<Player*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
    68 
    69             void initialize(void);
     101            std::map<const PlayerInfo*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
    70102
    71103    };
    72 
    73104
    74105}
  • code/branches/bugger/src/orxonox/objects/quest/Quest.cc

    r2105 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file Quest.cc
     31    @brief
     32    Implementation of the Quest class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
     
    3238#include "core/CoreIncludes.h"
    3339
     40#include "orxonox/objects/infos/PlayerInfo.h"
    3441#include "QuestManager.h"
    3542#include "QuestDescription.h"
     
    3946namespace orxonox {
    4047
     48    /**
     49    @brief
     50        Constructor. Registers and initializes object.
     51    */
    4152    Quest::Quest(BaseObject* creator) : QuestItem(creator)
    4253    {
    4354        RegisterObject(Quest);
    4455
    45         this->initialize();
     56        this->parentQuest_ = NULL;
    4657    }
    4758
     
    5566    }
    5667
     68    /**
     69    @brief
     70        Method for creating a Quest object through XML.
     71    */
    5772    void Quest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5873    {
    5974        SUPER(Quest, XMLPort, xmlelement, mode);
    6075
    61         XMLPortObject(Quest, Quest, "", addSubQuest, getSubQuests, xmlelement, mode);
    62         XMLPortObject(Quest, QuestHint, "", addHint, getHints, xmlelement, mode);
    63         XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffects, xmlelement, mode);
    64         XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffects, xmlelement, mode);
    65 
    66         QuestManager::registerQuest(this); //Registers the quest with the QuestManager.
    67     }
    68 
    69     /**
    70     @brief
    71         Initializes the object. Needs to be called first in every constructor of this class.
    72     */
    73     void Quest::initialize(void)
    74     {
    75         RegisterObject(Quest);
    76 
    77         this->parentQuest_ = NULL;
    78     }
    79 
    80     /**
    81     @brief
    82         Sets the parent quest of the quest.
     76        XMLPortObject(Quest, Quest, "subquests", addSubQuest, getSubQuest, xmlelement, mode);
     77        XMLPortObject(Quest, QuestHint, "hints", addHint, getHint, xmlelement, mode);
     78        XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffect, xmlelement, mode);
     79        XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode);
     80
     81        QuestManager::registerQuest(this); //!<Registers the Quest with the QuestManager.
     82    }
     83
     84    /**
     85    @brief
     86        Sets the parentquest of the Quest.
    8387    @param quest
    84         A pointer to the quest to be set as parent quest.
    85     @return
    86         Returns true if the parentQuest could be set.
     88        A pointer to the Quest to be set as parentquest.
     89    @return
     90        Returns true if the parentquest could be set.
    8791    */
    8892    bool Quest::setParentQuest(Quest* quest)
    8993    {
    90         if(quest == NULL)
     94        if(quest == NULL) //!< We don't want to set NULL-Pointers.
    9195        {
    9296            COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl;
     
    102106    /**
    103107    @brief
    104         Adds a sub quest to the quest.
     108        Adds a subquest to the Quest.
    105109    @param quest
    106         A pointer to the quest to be set as sub quest.
    107     @return
    108         Returns true if the subQuest vould be set.
     110        A pointer to the Quest to be set as subquest.
     111    @return
     112        Returns true if the subquest could be set.
    109113    */
    110114    bool Quest::addSubQuest(Quest* quest)
    111115    {
    112         if(quest == NULL)
     116        if(quest == NULL) //!< We don't want to set NULL-Pointers.
    113117        {
    114118            COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl;
     
    116120        }
    117121
    118         quest->setParentQuest(this);
    119         this->subQuests_.push_back(quest);
     122        quest->setParentQuest(this); //!< Sets the currentQuest (this) as parentquest for the added subquest.
     123        this->subQuests_.push_back(quest); //!< Adds the Quest to the end of the list of subquests.
    120124
    121125        COUT(3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
     
    126130    /**
    127131    @brief
    128         Adds a Hint to the list of hints
     132        Adds a QuestHint to the list of QuestHints
    129133    @param hint
    130         The hint that should be added to the list of hints.
     134        The QuestHint that should be added to the list of QuestHints.
    131135    @return
    132136        Returns true if the hint was successfully added.
     
    134138    bool Quest::addHint(QuestHint* hint)
    135139    {
    136         if(hint == NULL)
     140        if(hint == NULL) //!< We don't want to set NULL-Pointers. Seriously!
    137141        {
    138142            COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl;
     
    140144        }
    141145
    142         this->hints_.push_back(hint);
    143         hint->setQuest(this);
     146        hint->setQuest(this); //!< Sets the current Quest (this) as Quest for the added QuestHint.
     147        this->hints_.push_back(hint); //!< Adds the QuestHint to the end of the list of QuestHints.
    144148
    145149        COUT(3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
     
    149153    /**
    150154    @brief
    151 
     155        Adds an QuestEffect to the list of fail QuestEffects.
     156    @param effect
     157        The QuestEffect to be added.
     158    @return
     159        Returns true if successful.
    152160    */
    153161    bool Quest::addFailEffect(QuestEffect* effect)
    154162    {
    155         if(effect == NULL)
     163        if(effect == NULL) //!< We don't want to set NULL-Pointers.
    156164        {
    157165            COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl;
     
    159167        }
    160168
    161         this->failEffects_.push_back(effect);
     169        this->failEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of fail QuestEffects.
    162170
    163171        COUT(3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;
     
    167175    /**
    168176    @brief
    169 
     177        Adds an QuestEffect to the list of complete QuestEffects.
     178    @param effect
     179        The QuestEffect to be added.
     180    @return
     181        Returns true if successful.
    170182    */
    171183    bool Quest::addCompleteEffect(QuestEffect* effect)
    172184    {
    173         if(effect == NULL)
     185        if(effect == NULL) //!< We don't want to set NULL-Pointers.
    174186        {
    175187            COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl;
     
    177189        }
    178190
    179         this->completeEffects_.push_back(effect);
     191        this->completeEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of complete QuestEffects.
    180192
    181193        COUT(3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;
     
    185197    /**
    186198    @brief
    187 
     199        Returns the parentquest of the Quest.
     200    @return
     201        Returns a pointer to the parentquest of the Quest.
    188202    */
    189203    const Quest* Quest::getParentQuest(void)
     
    194208    /**
    195209    @brief
    196 
    197     */
    198     const Quest* Quest::getSubQuests(unsigned int index) const
     210        Returns the subquest at the given index.
     211    @param
     212        The index.
     213    @return
     214        Returns a pointer to the subquest at the given index. NULL if there is no element at the given index.
     215    */
     216    const Quest* Quest::getSubQuest(unsigned int index) const
    199217    {
    200218        int i = index;
     219       
     220        //! Iterate through all subquests.
    201221        for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest)
    202222        {
    203             if(i == 0)
     223            if(i == 0) //!< We're counting down...
    204224            {
    205225               return *subQuest;
     
    207227            i--;
    208228        }
    209         return NULL;
    210     }
    211 
    212     /**
    213     @brief
    214 
    215     */
    216     const QuestHint* Quest::getHints(unsigned int index) const
     229       
     230        return NULL; //!< If the index is greater than the number of elements in the list.
     231    }
     232
     233    /**
     234    @brief
     235        Returns the QuestHint at the given index.
     236    @param
     237        The index.
     238    @return
     239        Returns a pointer to the QuestHint at the given index. NULL if there is no element at the given index.
     240    */
     241    const QuestHint* Quest::getHint(unsigned int index) const
    217242    {
    218243        int i = index;
     244       
     245        //! Iterate through all QuestHints.
    219246        for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint)
    220247        {
    221             if(i == 0)
     248            if(i == 0) //!< We're counting down...
    222249            {
    223250               return *hint;
     
    225252            i--;
    226253        }
    227         return NULL;
    228     }
    229 
    230     /**
    231     @brief
    232 
    233     */
    234     const QuestEffect* Quest::getFailEffects(unsigned int index) const
     254        return NULL; //!< If the index is greater than the number of elements in the list.
     255    }
     256
     257    /**
     258    @brief
     259        Returns the fail QuestEffect at the given index.
     260    @param
     261        The index.
     262    @return
     263        Returns a pointer to the fail QuestEffect at the given index. NULL if there is no element at the given index.
     264    */
     265    const QuestEffect* Quest::getFailEffect(unsigned int index) const
    235266    {
    236267        int i = index;
     268       
     269        //! Iterate through all fail QuestEffects.
    237270        for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect)
    238271        {
    239             if(i == 0)
     272            if(i == 0) //!< We're counting down...
    240273            {
    241274               return *effect;
     
    243276            i--;
    244277        }
    245         return NULL;
    246     }
    247 
    248     /**
    249     @brief
    250 
    251     */
    252     const QuestEffect* Quest::getCompleteEffects(unsigned int index) const
     278        return NULL; //!< If the index is greater than the number of elements in the list.
     279    }
     280
     281    /**
     282    @brief
     283        Returns the complete QuestEffect at the given index.
     284    @param
     285        The index.
     286    @return
     287        Returns a pointer to the complete QuestEffect at the given index. NULL if there is no element at the given index.
     288    */
     289    const QuestEffect* Quest::getCompleteEffect(unsigned int index) const
    253290    {
    254291        int i = index;
     292       
     293        //! Iterate through all complete QuestEffects.
    255294        for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect)
    256295        {
    257             if(i == 0)
     296            if(i == 0) //!< We're counting down...
    258297            {
    259298               return *effect;
     
    261300            i--;
    262301        }
    263         return NULL;
     302        return NULL; //!< If the index is greater than the number of elements in the list.
    264303    }
    265304
     
    274313        Throws an exception if getStatus throws one.
    275314    */
    276     bool Quest::isInactive(const Player* player) const
     315    bool Quest::isInactive(const PlayerInfo* player) const
    277316    {
    278317        return this->getStatus(player) == questStatus::inactive;
     
    289328        Throws an exception if getStatus throws one.
    290329    */
    291     bool Quest::isActive(const Player* player) const
     330    bool Quest::isActive(const PlayerInfo* player) const
    292331    {
    293332
     
    305344        Throws an exception if getStatus throws one.
    306345    */
    307     bool Quest::isFailed(const Player* player) const
     346    bool Quest::isFailed(const PlayerInfo* player) const
    308347    {
    309348        return this->getStatus(player) == questStatus::failed;
     
    320359        Throws an exception if getStatus throws one.
    321360    */
    322     bool Quest::isCompleted(const Player* player) const
     361    bool Quest::isCompleted(const PlayerInfo* player) const
    323362    {
    324363        return this->getStatus(player) == questStatus::completed;
     
    327366    /**
    328367    @brief
    329         Starts the quest.
    330     @param player
    331         The player.
    332     @return
    333         Returns true if the quest could be started, false if not.
    334     */
    335     bool Quest::start(Player* player)
    336     {
    337         if(this->isStartable(player))
     368        Starts the Quest for an input player.
     369    @param player
     370        The player.
     371    @return
     372        Returns true if the Quest could be started, false if not.
     373    */
     374    bool Quest::start(PlayerInfo* player)
     375    {
     376        if(this->isStartable(player)) //!< Checks whether the quest can be started.
    338377        {
    339378            this->setStatus(player, questStatus::active);
    340379            return true;
    341380        }
    342         COUT(2) << "A non-startable quest was trying to be started." << std::endl;
     381       
     382        COUT(4) << "A non-startable quest was trying to be started." << std::endl;
    343383        return false;
    344384    }
    345385
    346     /**
    347     @brief
    348         Fails the quest.
    349     @param player
    350         The player.
    351     @return
    352         Returns true if the quest could be failed, false if not.
    353     */
    354     bool Quest::fail(Player* player)
    355     {
    356         if(this->isFailable(player))
    357         {
    358             this->setStatus(player, questStatus::failed);
    359             QuestEffect::invokeEffects(player, this->failEffects_);
    360             return true;
    361         }
    362         COUT(2) << "A non-failable quest was trying to be failed." << std::endl;
    363         return false;
    364     }
    365 
    366     /**
    367     @brief
    368         Completes the quest.
    369     @param player
    370         The player.
    371     @return
    372         Returns true if the quest could be completed, false if not.
    373     */
    374     bool Quest::complete(Player* player)
    375     {
    376         if(this->isCompletable(player))
    377         {
    378             this->setStatus(player, questStatus::completed);
    379             QuestEffect::invokeEffects(player, this->completeEffects_);
    380             return true;
    381         }
    382         COUT(2) << "A non-completable quest was trying to be completed." << std::endl;
    383         return false;
    384     }
    385 
    386386}
  • code/branches/bugger/src/orxonox/objects/quest/Quest.h

    r2096 r2530  
    2626 *
    2727 */
    28 
     28 
     29/**
     30    @file Quest.h
     31    @brief
     32    Definition of the Quest class.
     33   
     34    The Quest is the parent class of LocalQuest and GlobalQuest.
     35*/
     36 
    2937#ifndef _Quest_H__
    3038#define _Quest_H__
     
    3644
    3745#include "core/XMLPort.h"
     46
    3847#include "QuestItem.h"
    3948
     
    4150{
    4251
     52    //!Different states of a Quest.
    4353    enum Enum
    4454    {
     
    5363namespace orxonox {
    5464
    55     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    56 
    5765    /**
    5866    @brief
    59         Represents a quest in the game.
    60         A quest has a list of subquests and a parentquest (if it is not a rootquest).
    61         Each quest exists only once but it has a different status (inactive, active, failed or completed) for each player.
     67        Represents a Quest in the game.
     68        A Quest has a list of subquests and a parentquest (if it is not a rootquest).
     69        Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player.
     70        A Quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the Quest.
     71        A Quest has a list of QuestEffects that are invoked when the quest is failed and also a list of QuestEffects that are invoked, when the Quest is completed.
     72       
     73        Quest itself should not be instantiated, if you want to create a quest either go for LocalQuest or GlobalQuest, whichever suits you needs better.
    6274    @author
    6375        Damian 'Mozork' Frick
     
    6981            virtual ~Quest();
    7082
    71             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     83            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Quest object through XML.
    7284
    73             inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest.
     85            /**
     86            @brief Returns the parentquest of the Quest.
     87            @return Returns a pointer to the parentquest of the Quest.
     88            */
     89            inline Quest* getParentQuest(void) const
    7490                { return this->parentQuest_; }
    75             inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests.
    76                 { return this->subQuests_; }
    77 
    78             bool isInactive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
    79             bool isActive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'active'.
    80             bool isFailed(const Player* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
    81             bool isCompleted(const Player* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
    82 
    83             bool start(Player* player); //!< Sets a quest to active.
    84             bool fail(Player* player); //!< Fails the quest.
    85             bool complete(Player* player); //!< Completes the quest.
     91               
     92            /**
     93            @brief Returns the list of subquests.
     94            @return Returns a reference to the list of subquests of the quest.
     95            */
     96            inline const std::list<Quest*> & getSubQuestList(void) const
     97                { return this->subQuests_; }
     98                   
     99            /**
     100            @brief Returns the list of all QuestHints of this Quest.
     101            @return Returns a reference to the list of QuestHints of the Quest.
     102            */
     103            inline const std::list<QuestHint*> & getHintsList(void) const
     104                { return this->hints_; }
     105           
     106            bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
     107            bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
     108            bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
     109            bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
     110           
     111            bool start(PlayerInfo* player); //!< Sets a Quest to active.
     112            virtual bool fail(PlayerInfo* player) = 0; //!< Fails the Quest.
     113            virtual bool complete(PlayerInfo* player) = 0; //!< Completes the Quest.
    86114
    87115        protected:
    88             void initialize(void); //!< Initialized the object.
     116            virtual bool isStartable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be started.
     117            virtual bool isFailable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be failed.
     118            virtual bool isCompletable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be completed.
    89119
    90             virtual bool isStartable(const Player* player) const = 0; //!< Checks whether the quest can be started.
    91             virtual bool isFailable(const Player* player) const = 0; //!< Checks whether the quest can be failed.
    92             virtual bool isCompletable(const Player* player) const = 0; //!< Checks whether the quest can be completed.
     120            const Quest* getParentQuest(void); //!< Returns the parentquest of the Quest.
     121            const Quest* getSubQuest(unsigned int index) const; //!<Returns the subquest at the given index.
     122            const QuestHint* getHint(unsigned int index) const; //!< Returns the QuestHint at the given index.
     123            const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the fail QuestEffect at the given index.
     124            const QuestEffect* getCompleteEffect(unsigned int index) const; //!< Returns the complete QuestEffect at the given index.
     125           
     126            /**
     127            @brief Returns the list of fail QuestEffects.
     128            @return Returns a reference to the list of fail QuestEffects.
     129            */
     130            inline std::list<QuestEffect*> & getFailEffectList(void)
     131                { return this->failEffects_; }
     132               
     133            /**
     134            @brief Returns the list of complete QuestEffects.
     135            @return Returns a reference to the list of complete QuestEffects.
     136            */
     137            inline std::list<QuestEffect*> & getCompleteEffectList(void)
     138                { return this->completeEffects_; }
    93139
    94             bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest.
    95             bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest.
    96             bool addHint(QuestHint* hint); //!< Add a hint to the list of hints.
    97             bool addFailEffect(QuestEffect* effect);
    98             bool addCompleteEffect(QuestEffect* effect);
     140            virtual questStatus::Enum getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
     141            virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
     142           
     143    private:
     144            Quest* parentQuest_; //!< Pointer to the parentquest.
     145            std::list<Quest*> subQuests_; //!< List of all the subquests.
    99146
    100             const Quest* getParentQuest(void);
    101             const Quest* getSubQuests(unsigned int index) const;
    102             const QuestHint* getHints(unsigned int index) const;
    103             const QuestEffect* getFailEffects(unsigned int index) const;
    104             const QuestEffect* getCompleteEffects(unsigned int index) const;
     147            std::list<QuestHint*> hints_; //!< A list of all the QuestHints tied to this Quest.
    105148
    106             virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player.
    107             virtual bool setStatus(Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
    108 
    109             Quest* parentQuest_; //!< Pointer to the parent quest.
    110             std::list<Quest*> subQuests_; //!< List of all the sub quests.
    111 
    112             std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest.
    113 
    114             std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed.
    115             std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed.
     149            std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed.
     150            std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed.
     151           
     152            bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest.
     153            bool addSubQuest(Quest* quest); //!< Adds a subquest to the Quest.
     154            bool addHint(QuestHint* hint); //!< Add a QuestHint to the list of QuestHints.
     155            bool addFailEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of fail QuestEffects.
     156            bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects.
    116157
    117158    };
  • code/branches/bugger/src/orxonox/objects/quest/QuestDescription.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file QuestDescription.cc
     31    @brief
     32    Implementation of the QuestDescription class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
     36
    3037#include "QuestDescription.h"
    3138
     
    3643    CreateFactory(QuestDescription);
    3744
     45    /**
     46    @brief
     47        Constructor. Registers and initializes the object.
     48    */
    3849    QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator)
    3950    {
    4051        RegisterObject(QuestDescription);
    41 
    42         this->initialize();
     52       
     53        this->title_ = "";
     54        this->description_ = "";
    4355    }
    4456
     57    /**
     58    @brief
     59        Destructor.
     60    */
    4561    QuestDescription::~QuestDescription()
    4662    {
     
    4864    }
    4965
     66    /**
     67    @brief
     68        Method for creating a QuestDescription object through XML.
     69    */
    5070    void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5171    {
     
    5878    }
    5979
    60     /**
    61     @brief
    62         Initializes the object. Has to be called first in every constructor of this class.
    63     */
    64     void QuestDescription::initialize(void)
    65     {
    66         RegisterObject(QuestDescription);
    67     }
    68 
    6980
    7081}
  • code/branches/bugger/src/orxonox/objects/quest/QuestDescription.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file QuestDescription.h
     31    @brief
     32    Definition of the QuestDescription class.
     33*/
     34
    2935#ifndef _QuestDescription_H__
    3036#define _QuestDescription_H__
     
    4349        This class is a description of a QuestItem.
    4450        It holds a title and a description.
     51       
     52        Creating a QuestDescription through XML goes as follows:
     53       
     54        <QuestDescription title="Title" description="Description Text" />
    4555    @author
    4656        Damian 'Mozork' Frick
     
    5262            virtual ~QuestDescription();
    5363
    54             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML.
    5565
    56             inline const std::string & getTitle(void) const //!< Returns the title.
     66        /**
     67        @brief Returns the title.
     68        @return Returns a string containing the title of the QuestDescription.
     69        */
     70            inline const std::string & getTitle(void) const
    5771                { return this->title_; }
    58             inline const std::string & getDescription(void) const //!< Returns the description text.
     72       
     73        /**
     74        @brief Returns the description text.
     75        @return Returns a string containing the description text of the QuestDescription.
     76        */
     77            inline const std::string & getDescription(void) const
    5978                { return this->description_; }
    6079
    6180        private:
    62             void initialize(void);
    63 
    64             inline void setTitle(const std::string & title) //!< Sets the title.
    65                 { this->title_ = title; }
    66             inline void setDescription(const std::string & description) //!< Sets the description text.
    67                 { this->description_ = description; }
    68 
    6981            std::string title_; //!< The title.
    7082            std::string description_; //!< The description.
     83
     84            /**
     85            @brief Sets the title.
     86            @param title The title to be set.
     87            */
     88            inline void setTitle(const std::string & title)
     89                { this->title_ = title; }
     90               
     91        /**
     92            @brief Sets the description text.
     93            @param description The description text to be set.
     94            */
     95            inline void setDescription(const std::string & description)
     96                { this->description_ = description; }
    7197
    7298    };
  • code/branches/bugger/src/orxonox/objects/quest/QuestEffect.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file QuestEffect.cc
     31    @brief
     32    Implementation of the QuestEffect class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "QuestEffect.h"
    3137
    3238#include "core/CoreIncludes.h"
     39
     40#include "orxonox/objects/infos/PlayerInfo.h"
    3341
    3442namespace orxonox {
     
    5563    /**
    5664    @brief
    57         Static method. Invoke all effects of an effect list.
     65        Static method. Invoke all QuestEffects in an QuestEffect-list on a given player.
    5866    @param player
    59         The player the effects are invoked on.
     67        The player the QuestEffects are invoked on.
    6068    @param effects
    61         A list of all the effects to be invoked.
     69        A list of all the QuestEffects to be invoked.
    6270    @return
    6371        Returns false if there was an error, view console of log for further detail.
    6472    */
    65     bool QuestEffect::invokeEffects(Player* player, std::list<QuestEffect*> & effects)
     73    bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)
    6674    {
    6775        bool check = true;
  • code/branches/bugger/src/orxonox/objects/quest/QuestEffect.h

    r2096 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file QuestEffect.h
     31    @brief
     32    Definition of the QuestEffect class.
     33*/
    2834
    2935#ifndef _QuestEffect_H__
     
    3844namespace orxonox {
    3945
    40     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    41 
    4246    /**
    4347    @brief
    44         Handles effects for quests.
     48        Handles QuestEffects for Quests.
     49        QuestEffects are the only way for Quests to have any sideeffects in the game world. They are also the only way for a player to gain, complete or fail Quests.
    4550    @author
    4651        Damian 'Mozork' Frick
     
    5257            virtual ~QuestEffect();
    5358
    54             virtual bool invoke(Player* player) = 0; //!< Invokes the effect.
    55             static bool invokeEffects(Player* player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list.
     59            virtual bool invoke(PlayerInfo* player) = 0; //!< Invokes the QuestEffect.
     60            static bool invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects); //!< Invokes all QuestEffects in the list.
    5661
    5762
  • code/branches/bugger/src/orxonox/objects/quest/QuestEffectBeacon.cc

    • Property svn:eol-style set to native
  • code/branches/bugger/src/orxonox/objects/quest/QuestEffectBeacon.h

    • Property svn:eol-style set to native
    r2261 r2530  
    113113
    114114        private:
    115             static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
     115            //static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
    116116       
    117117            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
  • code/branches/bugger/src/orxonox/objects/quest/QuestHint.cc

    r2105 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file QuestHint.cc
     31    @brief
     32    Implementation of the QuestHint class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
     
    3339#include "util/Exception.h"
    3440
     41#include "orxonox/objects/infos/PlayerInfo.h"
     42#include "QuestManager.h"
    3543#include "Quest.h"
    3644
     
    4149    /**
    4250    @brief
    43         Constructor.
     51        Constructor. Registers the object.
    4452    */
    4553    QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator)
    4654    {
    4755        RegisterObject(QuestHint);
    48 
    49         this->initialize();
    5056    }
    5157
     
    5965    }
    6066
    61     void QuestHint::initialize(void)
    62     {
    63         RegisterObject(QuestHint);
    64     }
    65 
     67    /**
     68    @brief
     69        Method for creating a QuestHint object through XML.
     70    */
    6671    void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6772    {
    6873        SUPER(QuestHint, XMLPort, xmlelement, mode);
    6974
     75        QuestManager::registerHint(this); //!< Registers the QuestHint with the QuestManager.
     76       
    7077        COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
    7178    }
     
    7481    /**
    7582    @brief
    76         Checks whether the hint is active for a specific player.
     83        Checks whether the QuestHint is active for a specific player.
    7784    @param player
    7885        The player.
     
    8087        Throws an Argument Exception if the input Player-pointer is NULL.
    8188    @return
    82         Returns true if the hint is active for the specified player.
     89        Returns true if the QuestHint is active for the specified player.
    8390    */
    84     bool QuestHint::isActive(Player* player)
     91    bool QuestHint::isActive(const PlayerInfo* player) const
    8592    {
    86         if(player == NULL)
     93        if(player == NULL) //!< NULL-Pointers are ugly!
    8794        {
    88             ThrowException(Argument, "The input Player* is NULL.");
     95            ThrowException(Argument, "The input PlayerInfo* is NULL.");
    8996            return false;
    9097        }
    9198
    92         std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
    93         if (it != this->playerStatus_.end())
     99        //! Find the player.
     100        std::map<const PlayerInfo*, questHintStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
     101        if (it != this->playerStatus_.end()) //!< If the player is in the map.
    94102        {
    95103            return it->second;
    96104        }
     105       
    97106        return questStatus::inactive;
    98107    }
     
    106115        Returns true if the activation was successful, false if there were problems.
    107116    */
    108     bool QuestHint::activate(Player* player)
     117    bool QuestHint::setActive(PlayerInfo* player)
    109118    {
    110         if(this->quest_->isActive(player))
     119        if(this->quest_->isActive(player)) //!< For a hint to get activated the quest must be active.
    111120        {
    112             if(!(this->isActive(player)))
     121            if(!(this->isActive(player)))  //!< If the hint is already active, activation is pointless.
    113122            {
    114123                this->playerStatus_[player] = questHintStatus::active;
     
    121130            }
    122131        }
     132       
    123133        COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
    124134        return false;
     
    127137    /**
    128138    @brief
    129         Sets the quest the QuestHitn belongs to.
     139        Sets the Quest the QuestHint belongs to.
    130140    @param quest
     141        The Quest to be set as Quest the QuestHint is attached to.
    131142    @return
     143        Returns true if successful.
    132144    */
    133145    bool QuestHint::setQuest(Quest* quest)
    134146    {
    135         if(quest == NULL)
     147        if(quest == NULL) //!< NULL-Pointer. Again..?
    136148        {
    137149            COUT(2) << "The input Quest* is NULL." << std::endl;
  • code/branches/bugger/src/orxonox/objects/quest/QuestHint.h

    r2096 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file QuestHint.h
     31    @brief
     32    Definition of the QuestHint class.
     33*/
    2834
    2935#ifndef _QuestHint_H__
     
    4147{
    4248
     49    //! The status of the hint.
    4350    enum Enum
    4451    {
     
    5259{
    5360
    54     class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    55 
    5661    /**
    5762    @brief
    5863        Represents a hint in the game towards completing a Quest.
    59         Consists of title and description in textual form and must belong to a quest.
    60         A QuestHit has a defined status (inactive or active, where inactive is default) for each player, which means each QuestHint exists only once for all players, it doesn't belong to a player, it just has different stati for each of them.
     64        Consists of title and description (which is stored in a QuestDescription object) in textual form and must belong to a quest.
     65        A QuestHint has a defined status (inactive or active, where inactive is default) for each player, which means each a QuestHint exists only once for all players, it doesn't belong to a player, it just has different states for each of them.
     66       
     67        Creating a QuestHint through XML goes as follows:
     68       
     69        <QuestHint id="hintId">  //Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
     70            <QuestDesctription title="" description="" />
     71        </QuestHint>
    6172    @author
    6273        Damian 'Mozork' Frick
     
    6980            virtual ~QuestHint();
    7081
    71             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     82            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestHint object through XML.
    7283
    73             bool isActive(Player* player); //!< Returns true if the hint is active for the input player.
     84            bool isActive(const PlayerInfo* player) const; //!< Returns true if the QuestHint is active for the input player.
    7485
    75             bool activate(Player* player); //!< Activates the hint for the input player.
     86            bool setActive(PlayerInfo* player); //!< Activates the QuestHint for the input player.
     87            bool setQuest(Quest* quest); //!< Sets the Quest the QuestHint belongs to.
    7688
    77             bool setQuest(Quest* quest); //!< Sets the quest the hint belongs to.
    78 
     89            /**
     90            @brief Returns the Quest the QuestHint is attached to.
     91            @return  Returns a pointer to the Quest the QuestHint is attached to.
     92            */
    7993            inline Quest* getQuest(void)
    8094               { return this->quest_; }
    8195
    8296        private:
    83 
    84             void initialize(void);
    85 
    86             Quest* quest_; //!< The quest the hint belongs to.
    87             std::map<Player*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
     97            Quest* quest_; //!< The Quest the QuestHint belongs to.
     98            std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
    8899
    89100    };
  • code/branches/bugger/src/orxonox/objects/quest/QuestItem.cc

    r2105 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file QuestItem.cc
     31    @brief
     32    Implementation of the QuestItem class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
     
    3642namespace orxonox {
    3743
     44    /**
     45    @brief
     46        Constructor. Registers and initializes the object.
     47    */
    3848    QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator)
    3949    {
    4050        RegisterObject(QuestItem);
    4151
    42         this->initialize();
     52        this->id_ = "";
    4353    }
    4454
     
    5262    }
    5363
     64    /**
     65    @brief
     66        Method for creating a QuestItem object through XML.
     67    */
    5468    void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5569    {
     
    5771
    5872        XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode);
    59         //Doesn't getDescription have to be of type getDescription(unsigned int) ?
    60         //XMLPortObjectTemplate(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode, unsigned int);
    6173        XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode);
    62 
    6374    }
    64 
    6575
    6676    /**
    6777    @brief
    68         Initializes the object.
    69         Should be called first in every constructor of this class.
     78        Sets the id of the QuestItem.
     79    The id must be of GUID form. See 'http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure' for more information.
     80    @param id
     81        The id to be set.
    7082    */
    71     void QuestItem::initialize(void)
    72     {
    73         RegisterObject(QuestItem);
    74 
    75         this->id_ = "";
    76     }
    77 
    7883    void QuestItem::setId(const std::string & id)
    7984    {
    80         if(!isId(id))
     85        if(!isId(id)) //!< Checks whether the id is a valid id.
    8186        {
    8287            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
    8388            return;
    8489        }
     90       
    8591        this->id_ = id;
    8692    }
    87 
    88     //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem.
    89     //{
    90     //    if(index != 0)
    91     //        return NULL;
    92     //    return this->description_;
    93     //}
    9493
    9594    /**
  • code/branches/bugger/src/orxonox/objects/quest/QuestItem.h

    r2096 r2530  
    2626 *
    2727 */
     28 
     29/**
     30    @file QuestItem.h
     31    @brief
     32    Definition of the QuestItem class.
     33   
     34    The QuestItem is the parent class of Quest and QuestHint.
     35*/
     36
    2837
    2938#ifndef _QuestItem_H__
     
    4251    /**
    4352    @brief
    44         Functions as a base class for Quest classes such as Quest or QuestHint.
     53        Functions as a base class for quest classes such as Quest or QuestHint.
    4554        Has a unique identifier and a description.
    4655    @author
     
    5463            virtual ~QuestItem();
    5564
    56             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     65            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestItem object through XML.
    5766
    58             inline const std::string & getId(void) const //!< Returns the id of this quest.
     67            /**
     68            @brief Returns the id of this QuestItem.
     69        @return Returns the id of the QuestItem.
     70            */
     71            inline const std::string & getId(void) const
    5972                { return this->id_; }
    60             inline const QuestDescription* getDescription(void) const //!< Returns the description of the QuestItem.
     73        /**
     74        @brief Returns the QuestDescription of the QuestItem.
     75        @return Returns a pointer to the QuestDescription object of the QuestItem.
     76        */
     77            inline const QuestDescription* getDescription(void) const
    6178                { return this->description_; }
    62             //const QuestDescription* getDescription(unsigned int index) const; //!< Returns the description of the QuestItem.
    6379
    6480            static bool isId(const std::string & id); //!< Checks whether a given id is valid.
    6581
    6682        protected:
    67             void setId(const std::string & id);
     83            void setId(const std::string & id); //!< Sets the id of the QuestItem.
     84           
     85            /**
     86            @brief Sets the description of the QuestItem.
     87            @param description The QuestDescription to be set.
     88            */
    6889            inline void setDescription(QuestDescription* description)
    6990                { this->description_ = description; }
     
    7192        private:
    7293            std::string id_; //!< Identifier. Should be of GUID form: http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure
    73             QuestDescription* description_; //!< The description of the QuestItem.
    74 
    75             void initialize(void); //!< Initializes the object.
     94            QuestDescription* description_; //!< The QuestDescription of the QuestItem.
    7695
    7796    };
  • code/branches/bugger/src/orxonox/objects/quest/QuestManager.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file QuestManager.cc
     31    @brief
     32    Implementation of the QuestManager class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "QuestManager.h"
     
    3844namespace orxonox {
    3945
    40     std::map<std::string, Quest*> QuestManager::questMap_;
    41     std::map<std::string, QuestHint*> QuestManager::hintMap_;
    42 
     46    //! All Quests registered by their id's.
     47    std::map<std::string, Quest*> QuestManager::questMap_s;
     48    //! All QuestHints registered by their id's.
     49    std::map<std::string, QuestHint*> QuestManager::hintMap_s;
     50
     51    /**
     52    @brief
     53        Constructor. Registers the object.
     54    */
    4355    QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator)
    4456    {
     
    4658    }
    4759
    48 
     60    /**
     61    @brief
     62        Destructor.
     63    */
    4964    QuestManager::~QuestManager()
    5065    {
     
    5469    /**
    5570    @brief
    56         Registers a quest with the QuestManager to make it globally accessable.
     71        Registers a Quest with the QuestManager to make it globally accessable.
     72        Uses it's id to make sure to be able to be identify and retrieve it later.
    5773    @param quest
    58         The quest that is to be registered.
     74        The Quest that is to be registered.
    5975    @return
    6076        Returns true if successful, false if not.
     
    6278    bool QuestManager::registerQuest(Quest* quest)
    6379    {
    64         if(quest == NULL)
     80        if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers.
    6581        {
    6682            COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl;
     
    6884        }
    6985
    70         std::pair<std::map<std::string, Quest*>::iterator,bool> ret;
    71         ret = questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) );
    72 
    73         if(ret.second)
     86        std::pair<std::map<std::string, Quest*>::iterator,bool> result;
     87        result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.
     88
     89        if(result.second) //!< If inserting was a success.
    7490        {
    7591            COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl;
     
    86102    @brief
    87103        Registers a QuestHint with the QuestManager to make it globally accessable.
     104        Uses it's id to make sure to be able to be identify and retrieve it later.
    88105    @param hint
    89106        The QuestHint to be registered.
     
    93110    bool QuestManager::registerHint(QuestHint* hint)
    94111    {
    95         if(hint == NULL)
     112        if(hint == NULL) //!< Still not liking NULL-pointers.
    96113        {
    97114            COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl;
     
    99116        }
    100117
    101         std::pair<std::map<std::string, QuestHint*>::iterator,bool> ret;
    102         ret = hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) );
    103 
    104         if(ret.second)
     118        std::pair<std::map<std::string, QuestHint*>::iterator,bool> result;
     119        result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.
     120
     121        if(result.second) //!< If inserting was a success.
    105122        {
    106123            COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl;
     
    116133    /**
    117134    @brief
    118         Finds a quest with the given id.
     135        Finds a Quest with the given id.
    119136    @param questId
    120         The id of the quest sought for.
    121     @return
    122         Returns a reference to the quest with the input id.
    123         Returns NULL if there is no quest with the given questId.
     137        The id of the Quest sought for.
     138    @return
     139        Returns a pointer to the Quest with the input id.
     140        Returns NULL if there is no Quest with the given questId.
    124141    @throws
    125142        Throws an exception if the given questId is invalid.
     
    127144    Quest* QuestManager::findQuest(const std::string & questId)
    128145    {
    129         if(!QuestItem::isId(questId))
     146        if(!QuestItem::isId(questId)) //!< Check vor validity of the given id.
    130147        {
    131148            ThrowException(Argument, "Invalid questId.");
     
    133150
    134151        Quest* quest;
    135         std::map<std::string, Quest*>::iterator it = questMap_.find(questId);
    136         if (it != questMap_.end())
     152        std::map<std::string, Quest*>::iterator it = questMap_s.find(questId);
     153        if (it != questMap_s.end()) //!< If the Quest is registered.
    137154        {
    138155            quest = it->second;
     
    150167    /**
    151168    @brief
    152         Finds a hint with the given id.
     169        Finds a QuestHint with the given id.
    153170    @param hintId
    154         The id of the hint sought for.
    155     @return
    156         Returns a reference to the hint with the input id.
    157         Returns NULL if there is no hint with the given hintId.
     171        The id of the QuestHint sought for.
     172    @return
     173        Returns a pointer to the QuestHint with the input id.
     174        Returns NULL if there is no QuestHint with the given hintId.
    158175    @throws
    159176        Throws an exception if the given hintId is invalid.
     
    161178    QuestHint* QuestManager::findHint(const std::string & hintId)
    162179    {
    163         if(!QuestItem::isId(hintId))
     180        if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id.
    164181        {
    165182            ThrowException(Argument, "Invalid hintId.");
     
    167184
    168185        QuestHint* hint;
    169         std::map<std::string, QuestHint*>::iterator it = hintMap_.find(hintId);
    170         if (it != hintMap_.end())
     186        std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId);
     187        if (it != hintMap_s.end()) //!< If the QuestHint is registered.
    171188        {
    172189            hint = it->second;
  • code/branches/bugger/src/orxonox/objects/quest/QuestManager.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file QuestManager.h
     31    @brief
     32    Definition of the QuestManager class.
     33*/
     34
    2935#ifndef _QuestManager_H__
    3036#define _QuestManager_H__
     
    4147    /**
    4248    @brief
    43         Manages quests, by making them globally accessable.
    44         Quests (and Hints) are registered in the QuestManager trough their id, and can be accessed in the same way.
     49        Is a static class and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()).
     50        Quests (and QuestHints) are registered in the QuestManager with their id, and can be accessed in the same way.
    4551    @author
    4652        Damian 'Mozork' Frick
     
    5359            virtual ~QuestManager();
    5460
    55             static bool registerQuest(Quest* quest); //!< Registers a quest in the QuestManager.
     61            static bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
    5662            static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
    5763
    58             static Quest* findQuest(const std::string & questId); //!< Returns the quest with the input id.
     64            static Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id.
    5965            static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id.
    6066
    6167        private:
    62             static std::map<std::string, Quest*> questMap_; //!< All quests registered by their id's.
    63             static std::map<std::string, QuestHint*> hintMap_; //!< All hints registered by their id's.
     68            static std::map<std::string, Quest*> questMap_s; //!< All Quests registered by their id's.
     69            static std::map<std::string, QuestHint*> hintMap_s; //!< All QuestHints registered by their id's.
    6470
    6571    };
  • code/branches/bugger/src/orxonox/objects/quest/Rewardable.cc

    r2105 r2530  
    2727 */
    2828
     29/**
     30    @file Rewardable.cc
     31    @brief
     32    Implementation of the Rewardable class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "Rewardable.h"
     
    3440namespace orxonox {
    3541
    36 
     42    /**
     43    @brief
     44        Constructor. Registers the object.
     45    */
    3746    Rewardable::Rewardable(BaseObject* creator) : BaseObject(creator)
    3847    {
     
    4049    }
    4150
    42 
     51    /**
     52    @brief
     53        Destructor,
     54    */
    4355    Rewardable::~Rewardable()
    4456    {
  • code/branches/bugger/src/orxonox/objects/quest/Rewardable.h

    r2096 r2530  
    2727 */
    2828
     29/**
     30    @file Rewardable.h
     31    @brief
     32    Definition of the Rewardable class.
     33*/
     34
    2935#ifndef _Rewardable_H__
    3036#define _Rewardable_H__
     
    3642namespace orxonox {
    3743
    38     class Player; //Forward declaration, remove when fully integrated in objecthirarchy.
    39 
    4044    /**
    4145    @brief
    42         Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward to a player through QuestEffects.
     46        Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward to a player through QuestEffects. (With the AddReward effect.)
     47       
     48        It just needs to inherit form Rewardable, and implement the reward() method.
    4349    @author
    4450        Damian 'Mozork' Frick
     
    5157            virtual ~Rewardable();
    5258
    53             virtual bool reward(Player* player) = 0; //!<Method to transcribe a rewardable object to the player.
     59            /**
     60            @brief
     61                Method to transcribe a rewardable object to the player.
     62                Must be implemented by every class inheriting from Rewardable.
     63        @param player
     64                A pointer to the ControllableEntity, do whatever you want with it.
     65        @return
     66                Return true if successful.
     67            */
     68            virtual bool reward(PlayerInfo* player) = 0; //!<
    5469
    5570    };
Note: See TracChangeset for help on using the changeset viewer.