Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2021 for code


Ignore:
Timestamp:
Oct 27, 2008, 8:31:20 PM (16 years ago)
Author:
dafrick
Message:

Nearly compiles, some minor improvements.

Location:
code/branches/questsystem/src/orxonox
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem/src/orxonox/CMakeLists.txt

    r1844 r2021  
    6262  objects/RotatingProjectile.cc
    6363  objects/ParticleProjectile.cc
     64 
     65  objects/AddQuest.cc
     66  objects/AddQuestHint.cc
     67  objects/AddReward.cc
     68  objects/ChangeQuestStatus.cc
     69  objects/CompleteQuest.cc
     70  objects/FailQuest.cc
     71  objects/GlobalQuest.cc
     72  objects/LocalQuest.cc
     73  objects/Quest.cc
     74  objects/QuestDescription.cc
     75  objects/QuestEffect.cc
     76  objects/QuestHint.cc
     77  objects/QuestItem.cc
    6478
    6579  tolua/tolua_bind.cc
  • code/branches/questsystem/src/orxonox/objects/AddQuest.cc

    r1996 r2021  
    2727 */
    2828
     29#include <string>
     30
    2931#include "core/CoreIncludes.h"
     32
     33#include "QuestManager.h"
     34#include "Quest.h"
    3035#include "AddQuest.h"
    3136
     
    3338
    3439    CreateFactory(AddQuest);
     40
     41
     42    AddQuest::AddQuest() : ChangeQuestStatus()
     43    {
     44       
     45    }
    3546
    3647    /**
     
    5970        The player the effect is invoked on.
    6071    */
    61     void AddQuest::invoke(Player & player)
     72    void AddQuest::invoke(Player* player)
    6273    {
    63         Quest quest = QuestManager::findQuest(this->getQuestId());
    64         quest.start(player);
     74        Quest* quest = QuestManager::findQuest(this->getQuestId());
     75        quest->start(player);
    6576    }
    6677
  • code/branches/questsystem/src/orxonox/objects/AddQuest.h

    r1992 r2021  
    3636namespace orxonox {
    3737
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     39
    3840    /**
    3941    @brief
     
    4547    {
    4648        public:
     49            AddQuest();
    4750            AddQuest(std::string questId);
    4851            ~AddQuest();
    4952           
    50             virtual void invoke(Player & player); //!< Invokes the effect.
     53            virtual void invoke(Player* player); //!< Invokes the effect.
    5154   
    5255    };
  • code/branches/questsystem/src/orxonox/objects/AddQuestHint.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
     31#include "QuestManager.h"
    3032#include "AddQuestHint.h"
    3133
     
    3335
    3436    CreateFactory(AddQuestHint);
     37
     38    AddQuestHint::AddQuestHint() : QuestEffect()
     39    {
     40       
     41    }
    3542
    3643    /**
     
    6067        The player.
    6168    */
    62     void invoke(Player & player)
     69    void AddQuestHint::invoke(Player* player)
    6370    {
    64         QuestHint hint = QuestManager::findHint(this->hintId_);
    65         hint.activate(player);
     71        QuestHint* hint = QuestManager::findHint(this->hintId_);
     72        hint->activate(player);
    6673    }
    6774}
  • code/branches/questsystem/src/orxonox/objects/AddQuestHint.h

    r1992 r2021  
    3636namespace orxonox {
    3737
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     39
    3840    /**
    3941    @brief
     
    4547    {
    4648        public:
     49            AddQuestHint();
    4750            AddQuestHint(std::string hintId);
    4851            ~AddQuestHint();
    4952           
    50             virtual void invoke(Player & player); //!< Invokes the effect.
     53            virtual void invoke(Player* player); //!< Invokes the effect.
    5154           
    5255        private:
  • code/branches/questsystem/src/orxonox/objects/AddReward.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "AddReward.h"
    3132
     
    3334   
    3435    CreateFactory(AddReward);
     36   
     37    AddReward::AddReward() : QuestEffect()
     38    {
     39       
     40    }
    3541   
    3642    /**
     
    4046        A reward.
    4147    */
    42     AddReward::AddReward(Rewardable & reward)
     48    AddReward::AddReward(Rewardable* reward) : QuestEffect()
    4349    {
    4450        this->initialize();
     
    5258        A list of rewards.
    5359    */
    54     AddReward::AddReward(std::list<Rewardable> & rewards)
     60    AddReward::AddReward(std::list<Rewardable*>* rewards) : QuestEffect()
    5561    {
    5662        this->initialize();
     
    8187        The player.
    8288    */
    83     void AddReward::invoke(Player & player)
     89    void AddReward::invoke(Player* player)
    8490    {
    8591        if ( this->rewards_ == NULL )
     
    8894            return;
    8995        }
    90         for ( std::list<Rewardable>::iterator = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
     96        for ( std::list<Rewardable*>::iterator reward = this->rewards_->begin(); reward != this->rewards_->end(); ++reward )
    9197        {
    92             reward.reward(player);
     98            (*reward)->reward(player);
    9399        }
    94100    }
  • code/branches/questsystem/src/orxonox/objects/AddReward.h

    r1992 r2021  
    3232#include <list>
    3333
    34 #include "orxonox/quests/Rewardable.h"
     34#include "Rewardable.h"
    3535#include "QuestEffect.h"
    3636
    3737namespace orxonox {
     38
     39    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    3840
    3941    /**
     
    4648    {
    4749        public:
    48             AddReward(Rewardable & reward);
    49             AddReward(std::list<Rewardable> & rewards);
     50            AddReward();
     51            AddReward(Rewardable* reward);
     52            AddReward(std::list<Rewardable*>* rewards);
    5053            ~AddReward();
    5154           
    52             virtual void invoke(Player & player); //!< Invokes the effect.
     55            virtual void invoke(Player* player); //!< Invokes the effect.
    5356           
    5457        private:
    55        
    56             std::list<Rewardable> rewards_;
     58            std::list<Rewardable*>* rewards_;
    5759       
    5860            void initialize(void); //!< Initializes the object.
    5961       
    60             inline void addRewardable(const Rewardable & reward)
    61                 { this->rewards_.push_back(reward); }
     62            inline void addRewardable(Rewardable* reward)
     63                { this->rewards_->push_back(reward); }
    6264   
    6365    };
  • code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.cc

    r1992 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "ChangeQuestStatus.h"
    3132
    3233namespace orxonox {
    3334
    34     CreateFactory(ChangeQuestStatus);
     35    ChangeQuestStatus::ChangeQuestStatus() : QuestEffect()
     36    {
     37       
     38    }
    3539
    3640    /**
  • code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.h

    r1996 r2021  
    3636namespace orxonox {
    3737
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     39
    3840    /**
    3941    @brief
     
    4547    {
    4648        public:
     49            ChangeQuestStatus();
    4750            ChangeQuestStatus(std::string questId);
    4851            virtual ~ChangeQuestStatus();
    4952           
    50             virtual void invoke(Player & player) = 0; //!< Invokes the effect.
     53            virtual void invoke(Player* player) = 0; //!< Invokes the effect.
    5154           
    5255        protected:
  • code/branches/questsystem/src/orxonox/objects/CompleteQuest.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
     31#include "QuestManager.h"
     32#include "Quest.h"
    3033#include "CompleteQuest.h"
    3134
     
    3437    CreateFactory(CompleteQuest);
    3538
     39    CompleteQuest::CompleteQuest() : ChangeQuestStatus()
     40    {
     41       
     42    }
     43   
    3644    /**
    3745    @brief
     
    5967        The player the effect is invoked on.
    6068    */
    61     void CompleteQuest::invoke(Player & player)
     69    void CompleteQuest::invoke(Player* player)
    6270    {
    63         Quest quest = QuestManager::findQuest(this->getQuestId());
    64         quest.complete(player);
     71        Quest* quest = QuestManager::findQuest(this->getQuestId());
     72        quest->complete(player);
    6573    }
    6674
  • code/branches/questsystem/src/orxonox/objects/CompleteQuest.h

    r1992 r2021  
    3636namespace orxonox {
    3737
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     39
    3840    /**
    3941    @brief
     
    4547    {
    4648        public:
     49            CompleteQuest();
    4750            CompleteQuest(std::string questId);
    4851            ~CompleteQuest();
    4952           
    50             virtual void invoke(Player & player); //!< Invokes the effect.
     53            virtual void invoke(Player* player); //!< Invokes the effect.
    5154   
    5255    };
  • code/branches/questsystem/src/orxonox/objects/FailQuest.cc

    r1996 r2021  
    2727 */
    2828
    29 #include "core/CoreIncludes";
     29#include "core/CoreIncludes.h"
     30
     31#include "QuestManager.h"
     32#include "Quest.h"
    3033#include "FailQuest.h"
    3134
     
    3336
    3437    CreateFactory(FailQuest);
     38
     39    FailQuest::FailQuest() : ChangeQuestStatus()
     40    {
     41       
     42    }
    3543
    3644    /**
     
    5967        The player the effect is invoked on.
    6068    */
    61     void FailQuest::invoke(Player & player)
     69    void FailQuest::invoke(Player* player)
    6270    {
    63         Quest quest = QuestManager::findQuest(this->getQuestId());
    64         quest.fail(player);
     71        Quest* quest = QuestManager::findQuest(this->getQuestId());
     72        quest->fail(player);
    6573    }
    6674
  • code/branches/questsystem/src/orxonox/objects/FailQuest.h

    r1992 r2021  
    3636namespace orxonox {
    3737
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     39
    3840    /**
    3941    @brief
     
    4547    {
    4648        public:
     49            FailQuest();
    4750            FailQuest(std::string questId);
    4851            ~FailQuest();
    4952           
    50             virtual void invoke(Player & player); //!< Invokes the effect.
     53            virtual void invoke(Player* player); //!< Invokes the effect.
    5154   
    5255    };
  • code/branches/questsystem/src/orxonox/objects/GlobalQuest.cc

    r1996 r2021  
    3535    CreateFactory(GlobalQuest);
    3636
     37    GlobalQuest::GlobalQuest() : Quest()
     38    {
     39       
     40    }
     41
    3742    /**
    3843    @brief
     
    4550        The description of the quest.
    4651    */
    47     GlobalQuest::GlobalQuest(std::string id, std::string title = "", std::string description = "") : Quest(id, title, description)
     52    GlobalQuest::GlobalQuest(std::string id, std::string title, std::string description) : Quest(id, title, description)
    4853    {
    4954        RegisterObject(GlobalQuest);
     
    6772        Returns true if the quest can be started, false if not.
    6873    */
    69     bool GlobalQuest::isStartable(const Player & player) const
     74    bool GlobalQuest::isStartable(Player* player)
    7075    {
    7176        return this->isInactive(player) || this->isActive(player);
     
    8085        Returns true if the quest can be failed, false if not.
    8186    */
    82     bool GlobalQuest::isFailable(const Player & player) const
     87    bool GlobalQuest::isFailable(Player* player)
    8388    {
    8489        return this->isActive(player);
     
    9398        Returns true if the quest can be completed, false if not.
    9499    */
    95     bool GlobalQuest::isCompletable(const Player & player) const
     100    bool GlobalQuest::isCompletable(Player* player)
    96101    {
    97102        return this->isActive(player);
     
    104109        The player.
    105110    */
    106     questStatus::Enum getStatus(const Player & player) const
     111    questStatus::Enum GlobalQuest::getStatus(const Player* player)
    107112    {
    108113        //TDO: Does this really work???
    109         if (this->players_.find(&player) != this->players_.end())
     114        std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player);
     115        if (it != this->players_.end())
    110116        {
    111117            return this->status_;
     
    126132        The status to be set.
    127133    */
    128     void setStatus(const Player & player, const questStatus::Enum & status)
     134    bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status)
    129135    {
    130         if (this->players_.find(&player) == this->players_.end()) //!< Player is not yet in the list.
     136        std::set<Player*>::const_iterator it = this->players_.find(player);
     137        if (it == this->players_.end()) //!< Player is not yet in the list.
    131138        {
    132             this->players_.insert(&player);
     139            this->players_.insert(player);
    133140        }
    134141        this->status_ = status;
     142        return true;
    135143    }
    136144
  • code/branches/questsystem/src/orxonox/objects/GlobalQuest.h

    r1996 r2021  
    3636namespace orxonox {
    3737
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     39
    3840    /**
    3941    @brief
     
    4648    {
    4749        public:
     50            GlobalQuest();
    4851            GlobalQuest(std::string id, std::string title = "", std::string description = "");
    49             virtual ~GlobalQuest();
     52            ~GlobalQuest();
    5053           
    5154        protected:
    52             virtual bool isStartable(const Player & player) const; //!< Checks whether the quest can be started.
    53             virtual bool isFailable(const Player & player) const; //!< Checks whether the quest can be failed.
    54             virtual bool isCompletable(const Player & player) const; //!< Checks whether the quest can be completed.
     55            virtual bool isStartable(Player* player); //!< Checks whether the quest can be started.
     56            virtual bool isFailable(Player* player); //!< Checks whether the quest can be failed.
     57            virtual bool isCompletable(Player* player); //!< Checks whether the quest can be completed.
    5558       
    56             virtual questStatus::Enum getStatus(const Player & player) const; //!< Returns the status of the quest for a specific player.
    57             virtual bool setStatus(const Player & player, const questStatus::Enum & status); //!< Sets the status for a specific player.
     59            virtual questStatus::Enum getStatus(const Player* player); //!< Returns the status of the quest for a specific player.
     60            virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
    5861           
    5962        private:
  • code/branches/questsystem/src/orxonox/objects/LocalQuest.cc

    r1996 r2021  
    3535    CreateFactory(LocalQuest);
    3636
     37    LocalQuest::LocalQuest() : Quest()
     38    {
     39       
     40    }
     41
    3742    /**
    3843    @brief
     
    4550        The description of the quest.
    4651    */
    47     LocalQuest::LocalQuest(std::string id, std::string title = "", std::string description = "") : Quest(id, title, description)
     52    LocalQuest::LocalQuest(std::string id, std::string title, std::string description) : Quest(id, title, description)
    4853    {
    4954        RegisterObject(LocalQuest);
     
    6772        Returns true if the quest can be started, false if not.
    6873    */
    69     bool LocalQuest::isStartable(const Player & player) const
     74    bool LocalQuest::isStartable(Player* player)
    7075    {
    7176        return this->isInactive(player);
     
    8085        Returns true if the quest can be failed, false if not.
    8186    */
    82     bool LocalQuest::isFailable(const Player & player) const
     87    bool LocalQuest::isFailable(Player* player)
    8388    {
    8489        return this->isActive(player);
     
    9398        Returns true if the quest can be completed, false if not.
    9499    */
    95     bool LocalQuest::isCompletable(const Player & player) const
     100    bool LocalQuest::isCompletable(Player* player)
    96101    {
    97102        return this->isActive(player);
     
    106111        Returns the status of the quest for the input player.
    107112    */
    108     virtual questStatus::Enum LocalQuest::getStatus(const Player & player) const
     113    questStatus::Enum LocalQuest::getStatus(const Player* player)
    109114    {
    110         std::map<Player*, questStatus::Enum>::iterator it = this->playerStatus_.find(&player);
     115        std::map<Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'.
    111116        if (it != this->playerStatus_.end())
    112117        {
     
    124129        The status.
    125130    */
    126     virtual void LocalQuest::setStatus(const Player & player, const questStatus::Enum & status)
     131    bool LocalQuest::setStatus(Player* player, const questStatus::Enum & status)
    127132    {
    128         this->playerStatus[&player] = status;
     133        this->playerStatus_[player] = status;
     134        return true;
    129135    }
    130136
  • code/branches/questsystem/src/orxonox/objects/LocalQuest.h

    r1996 r2021  
    3737namespace orxonox {
    3838
     39    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     40
    3941    /**
    4042    @brief
     
    4648    {
    4749        public:
     50            LocalQuest();
    4851            LocalQuest(std::string id, std::string title = "", std::string description = "");
    49             virtual ~LocalQuest();
     52            ~LocalQuest();
    5053           
    5154        protected:
    52             virtual bool isStartable(const Player & player) const; //!< Checks whether the quest can be started.
    53             virtual bool isFailable(const Player & player) const; //!< Checks whether the quest can be failed.
    54             virtual bool isCompletable(const Player & player) const; //!< Checks whether the quest can be completed.
     55            virtual bool isStartable(Player* player); //!< Checks whether the quest can be started.
     56            virtual bool isFailable(Player* player); //!< Checks whether the quest can be failed.
     57            virtual bool isCompletable(Player* player); //!< Checks whether the quest can be completed.
    5558       
    56             virtual questStatus::Enum getStatus(const Player & player) const; //!< Returns the status of the quest for a specific player.
    57             virtual void setStatus(const Player & player, const questStatus::Enum & status); //!< Sets the status for a specific player.
     59            virtual questStatus::Enum getStatus(const Player* player); //!< Returns the status of the quest for a specific player.
     60            virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
    5861               
    5962        private:
  • code/branches/questsystem/src/orxonox/objects/Quest.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "Quest.h"
    3132
    3233namespace orxonox {
    3334
    34     CreateFactory(Quest);
     35    Quest::Quest() : QuestItem()
     36    {
     37       
     38    }
    3539
    3640    /**
     
    4448        The description of the quest.
    4549    */
    46     Quest::Quest(std::string id, std::string title = "", std::string description = "") : QuestItem(id, title, description)
     50    Quest::Quest(std::string id, std::string title, std::string description) : QuestItem(id, title, description)
    4751    {
    4852        initialize();
     
    7579        A pointer to the quest to be set as parent quest.
    7680    */
    77     bool setParentQuest(Quest* quest)
     81    bool Quest::setParentQuest(Quest* quest)
    7882    {
    7983        this->parentQuest_ = quest;
     
    8791        A pointer to the quest to be set as sub quest.
    8892    */
    89     bool addSubQuest(Quest & quest)
     93    bool Quest::addSubQuest(Quest* quest)
    9094    {
    91         this->subQuests_.push_back = quest;
     95        this->subQuests_.push_back(quest);
    9296        return true;
    9397    }
     
    99103        The hint that should be added to the list of hints.
    100104    */
    101     void Quest::addHint(QuestHint & hint)
     105    void Quest::addHint(QuestHint* hint)
    102106    {
    103107        if ( hint != NULL )
    104108        {
    105109            this->hints_.push_back(hint);
    106             hint.setQuest(this);
     110            hint->setQuest(this);
    107111        }
    108112        else
     
    120124        Returns true if the quest could be started, false if not.
    121125    */
    122     bool Quest::start(const Player & player)
     126    bool Quest::start(Player* player)
    123127    {
    124128        if(this->isStartable(player))
     
    139143        Returns true if the quest could be failed, false if not.
    140144    */
    141     void Quest::fail(Player & player)
     145    bool Quest::fail(Player* player)
    142146    {
    143147        if(this->isFailable(player))
     
    159163        Returns true if the quest could be completed, false if not.
    160164    */
    161     void Quest::complete(Player & player)
     165    bool Quest::complete(Player* player)
    162166    {
    163167        if(this->isCompletable(player))
  • code/branches/questsystem/src/orxonox/objects/Quest.h

    r1996 r2021  
    3838#include "QuestEffect.h"
    3939
    40 namespace orxonox {
    41 
    42     /**
    43     @brief
    44         Represents a quest in the game.
    45         A quest has a sub
    46        
    47     @author
    48         Damian 'Mozork' Frick
    49     */
    50     class Quest : public QuestItem
    51     {
    52         public:
    53             Quest(std::string id, std::string title = "", std::string description = "");
    54             virtual ~Quest();
    55    
    56             inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest.
    57                 { return this->parentQuest_; }
    58             inline const std::list<Quest> & getSubQuest(void) const //!< Returns the list of sub quests.
    59                 { return this->subQuests_; }
    60            
    61             //TDO: Necessary? Shouldn't this be decided whilest creating the object?
    62             bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest.
    63             bool addSubQuest(Quest & quest); //!< Adds a sub quest to the quest.
    64            
    65             inline bool isInactive(const Player & player) const //!< Returns true if the quest status for the specific player is 'inactive'.
    66                { return this->getStatus(player) == questStatus::inactive; }
    67             inline bool isActive(const Player & player) const //!< Returns true if the quest status for the specific player is 'active'.
    68                { return this->getStatus(player) == questStatus::active; }
    69             inline bool isFailed(const Player & player) const //!< Returns true if the quest status for the specific player is 'failed'.
    70                { return this->getStatus(player) == questStatus::failed; }
    71             inline bool isCompleted(const Player & player) const //!< Returns true if the quest status for the specific player is 'completed'.
    72                { return this->getStatus(player) == questStatus::completed; }
    73                
    74             bool start(const Player & player); //!< Sets a quest to active.
    75             bool fail(Player & player); //!< Fails the quest.
    76             bool complete(Player & player); //!< Completes the quest.
    77                
    78             void addHint(QuestHint & hint); //!< Add a hint to the list of hints.
    79            
    80         protected:
    81             void initialize(void); //!< Initialized the object.
    82            
    83             virtual bool isStartable(const Player & player) const = 0; //!< Checks whether the quest can be started.
    84             virtual bool isFailable(const Player & player) const = 0; //!< Checks whether the quest can be failed.
    85             virtual bool isCompletable(const Player & player) const = 0; //!< Checks whether the quest can be completed.
    86            
    87             virtual questStatus::Enum getStatus(const Player & player) const = 0; //!< Returns the status of the quest for a specific player.
    88             virtual void setStatus(const Player & player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
    89            
    90             Quest* parentQuest_; //!< Pointer to the parent quest.
    91             std::list<Quest> subQuests_; //!< List of all the sub quests.
    92            
    93             std::list<QuestHint> hints_; //!< A list of all the hints tied to this quest.
    94            
    95             std::list<QuestEffect> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed.
    96             std::list<QuestEffect> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed.
    97 
    98     };
    99 
    100 }
    101 
    10240namespace questStatus
    10341{
     
    11351}
    11452
     53namespace orxonox {
     54
     55    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     56
     57    /**
     58    @brief
     59        Represents a quest in the game.
     60        A quest has a sub
     61       
     62    @author
     63        Damian 'Mozork' Frick
     64    */
     65    class Quest : public QuestItem
     66    {
     67        public:
     68            Quest();
     69            Quest(std::string id, std::string title = "", std::string description = "");
     70            virtual ~Quest();
     71   
     72            inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest.
     73                { return this->parentQuest_; }
     74            inline const std::list<Quest*> & getSubQuest(void) const //!< Returns the list of sub quests.
     75                { return this->subQuests_; }
     76           
     77            //TDO: Necessary? Shouldn't this be decided whilest creating the object?
     78            //     Yes it absolutely should and will. Add these methods to protected then?
     79            bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest.
     80            bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest.
     81           
     82            inline bool isInactive(Player* player) //!< Returns true if the quest status for the specific player is 'inactive'.
     83               { return this->getStatus(player) == questStatus::inactive; }
     84            inline bool isActive(Player* player) //!< Returns true if the quest status for the specific player is 'active'.
     85               { return this->getStatus(player) == questStatus::active; }
     86            inline bool isFailed(Player* player) //!< Returns true if the quest status for the specific player is 'failed'.
     87               { return this->getStatus(player) == questStatus::failed; }
     88            inline bool isCompleted(Player* player) //!< Returns true if the quest status for the specific player is 'completed'.
     89               { return this->getStatus(player) == questStatus::completed; }
     90               
     91            bool start(Player* player); //!< Sets a quest to active.
     92            bool fail(Player* player); //!< Fails the quest.
     93            bool complete(Player* player); //!< Completes the quest.
     94               
     95            void addHint(QuestHint* hint); //!< Add a hint to the list of hints.
     96           
     97        protected:
     98            void initialize(void); //!< Initialized the object.
     99           
     100            virtual bool isStartable(Player* player) = 0; //!< Checks whether the quest can be started.
     101            virtual bool isFailable(Player* player) = 0; //!< Checks whether the quest can be failed.
     102            virtual bool isCompletable(Player* player) = 0; //!< Checks whether the quest can be completed.
     103           
     104            //TDO: Get the parameter const...
     105            virtual questStatus::Enum getStatus(const Player* player) = 0; //!< Returns the status of the quest for a specific player.
     106            virtual bool setStatus(Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
     107           
     108            Quest* parentQuest_; //!< Pointer to the parent quest.
     109            std::list<Quest*> subQuests_; //!< List of all the sub quests.
     110           
     111            std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest.
     112           
     113            std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed.
     114            std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed.
     115
     116    };
     117
     118}
     119
    115120#endif /* _Quest_H__ */
  • code/branches/questsystem/src/orxonox/objects/QuestDescription.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "QuestDescription.h"
    3132
     
    3435    CreateFactory(QuestDescription);
    3536   
    36     QuestDescription(std::string title, std::string description = "") : BaseObject()
     37    QuestDescription::QuestDescription() : BaseObject()
     38    {
     39       
     40    }
     41       
     42    QuestDescription::QuestDescription(std::string title, std::string description) : BaseObject()
    3743    {
    3844        initialize();
  • code/branches/questsystem/src/orxonox/objects/QuestDescription.h

    r1996 r2021  
    4646   
    4747        public:
     48            QuestDescription();
    4849            QuestDescription(std::string title, std::string description = "");
    4950            ~QuestDescription();
  • code/branches/questsystem/src/orxonox/objects/QuestEffect.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "QuestEffect.h"
    3132
    3233namespace orxonox {
    33 
    34     CreateFactory(QuestEffect);
    3534
    3635    /**
     
    6160        A list of all the effects to be invoked.
    6261    */
    63     void QuestEffect::invokeEffects(Player & player, std::list<QuestEffect> & effects)
     62    void QuestEffect::invokeEffects(Player* player, std::list<QuestEffect*> & effects)
    6463    {
    65         if ( effects == NULL )
    66         {
    67             COUT(5) << "NULL-QuestEffect list encountered." << std::endl;
    68             return;
    69         }
    70         for ( std::list<QuestEffect>::iterator = effects.begin(); effect != effects.end(); ++effect )
     64        for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
    7165        {
    72             effect.invoke(player);
     66            (*effect)->invoke(player);
    7367        }
    7468    }
  • code/branches/questsystem/src/orxonox/objects/QuestEffect.h

    r1996 r2021  
    3232#include <list>
    3333
    34 #include "BaseObject.h"
     34#include "core/BaseObject.h"
    3535
    3636namespace orxonox {
     37
     38    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
    3739
    3840    /**
     
    4850            virtual ~QuestEffect();
    4951           
    50             virtual void invoke(Player & player) = 0; //!< Invokes the effect.
    51             static void invokeEffects(Player & player, std::list<QuestEffect> & effects); //!< Invokes all effects in the list.
     52            virtual void invoke(Player* player) = 0; //!< Invokes the effect.
     53            static void invokeEffects(Player* player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list.
    5254           
    5355       
  • code/branches/questsystem/src/orxonox/objects/QuestHint.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
     31#include "Quest.h"
    3032#include "QuestHint.h"
    3133
     
    3335
    3436    CreateFactory(QuestHint);
     37
     38    QuestHint::QuestHint() : QuestItem()
     39    {
     40       
     41    }
    3542
    3643    /**
     
    4451        The description of the hint, resp. the hint itself.
    4552    */
    46     QuestHint::QuestHint(std::string id, std::string title = "", std::string description = "") : QuestItem(id, title, description)
     53    QuestHint::QuestHint(std::string id, std::string title, std::string description) : QuestItem(id, title, description)
    4754    {
    4855        RegisterObject(QuestHint);
     
    6673        Returns
    6774    */
    68     bool QuestHint::isActive(const Player & player) const
     75    bool QuestHint::isActive(Player* player)
    6976    {
    70         std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(&player);
     77        std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
    7178        if (it != this->playerStatus_.end())
    7279        {
     
    7683    }
    7784   
    78     bool QuestHint::activate(const Player & player)
     85    /**
     86    @brief
     87    @param player
     88    @return
     89    */
     90    bool QuestHint::activate(Player* player)
    7991    {
    80         if(this->quest_->isActive(player) && !this->isActive())
     92        if(this->quest_->isActive(player) && !(this->isActive(player)))
    8193        {
    82             this->playerStatus_[&player] = questHintStatus::active;
     94            this->playerStatus_[player] = questHintStatus::active;
    8395            return true;
    8496        }
     
    8799    }
    88100
     101    /**
     102    @brief
     103    @param quest
     104    @return
     105    */
    89106    void QuestHint::setQuest(Quest* quest)
    90107    {
  • code/branches/questsystem/src/orxonox/objects/QuestHint.h

    r1996 r2021  
    3434
    3535#include "QuestDescription.h"
    36 #include "Quest.h"
    3736#include "QuestItem.h"
     37
     38namespace questHintStatus
     39{
     40
     41    enum Enum
     42    {
     43        inactive,
     44        active
     45    };
     46
     47}
    3848
    3949namespace orxonox
    4050{
     51
     52    class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.
     53    class Quest; //To avoid circual includes.
    4154
    4255    /**
     
    5164   
    5265        public:
     66            QuestHint();
    5367            QuestHint(std::string id, std::string title = "", std::string description = "");
    5468            ~QuestHint();
    5569           
    56             bool isActive(const Player & player) const; //!< Returns true if the hint is active for the input player.
     70            bool isActive(Player* player); //!< Returns true if the hint is active for the input player.
    5771           
    58             bool activate(const Player & player); //!< Activates the hint for the input player.
     72            bool activate(Player* player); //!< Activates the hint for the input player.
    5973           
    6074            void setQuest(Quest* quest); //!< Sets the quest the hint belongs to.
    6175           
    62         private: 
     76        private:
    6377           
    6478            Quest* quest_;
     
    6983}
    7084
    71 namespace questHintStatus
    72 {
    73 
    74     enum Enum
    75     {
    76         inactive,
    77         active
    78     };
    79 
    80 }
    81 
    8285#endif /* _QuestHint_H__ */
  • code/branches/questsystem/src/orxonox/objects/QuestItem.cc

    r1992 r2021  
    3535    CreateFactory(QuestItem);
    3636   
     37    QuestItem::QuestItem() : BaseObject()
     38    {
     39       
     40    }
     41   
    3742    /**
    3843    @brief
     
    4550        The description of this QuestItem. Has an empty string as default.
    4651    */
    47     QuestItem::QuestItem(std::string id, std::string title = "", std::string description = "") : BaseObject()
     52    QuestItem::QuestItem(std::string id, std::string title, std::string description) : BaseObject()
    4853    {
    4954        this->initialize();
  • code/branches/questsystem/src/orxonox/objects/QuestItem.h

    r1996 r2021  
    3232#include <string>
    3333
    34 #include "orxonox/quests/QuestDescription.h"
    35 #include "BaseObject.h"
     34#include "QuestDescription.h"
     35#include "core/BaseObject.h"
    3636
    3737namespace orxonox {
     
    4949   
    5050        public:
     51            QuestItem();
    5152            QuestItem(std::string id, std::string title = "", std::string description = "");
    5253            virtual ~QuestItem();
  • code/branches/questsystem/src/orxonox/objects/QuestManager.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "QuestManager.h"
    3132
    3233namespace orxonox {
    3334
    34     std::map<std::string, Quest> QuestManager::questMap_;
    35     std::map<std::string, QuestHint> QuestManager::hintMap_;
     35    std::map<std::string, Quest*> QuestManager::questMap_;
     36    std::map<std::string, QuestHint*> QuestManager::hintMap_;
    3637
    3738    QuestManager::QuestManager() : BaseObject()
     
    5455        Returns true if successful, false if not.
    5556    */
    56     bool QuestManager::registerQuest(Quest & quest)
     57    bool QuestManager::registerQuest(Quest* quest)
    5758    {
    58         this->questMap_.insert ( pair<std::string,Quest>(quest.getId(),quest) );
     59        this->questMap_.insert ( pair<std::string,Quest>(quest->getId(),quest) );
    5960        return true;
    6061    }
     
    6869        Returns true if successful, false if not.
    6970    */
    70     bool QuestManager::registerHint(QuestHint & hint)
     71    bool QuestManager::registerHint(QuestHint* hint)
    7172    {
    72         this->hintMap_.insert ( pair<std::string,Hint>(hint.getId(),hint) );
     73        this->hintMap_.insert ( pair<std::string,Hint>(hint->getId(),hint) );
    7374        return true;
    7475    }
     
    8485        Throw exceptions in case of errors.
    8586    */
    86     Quest & QuestManager::findQuest(const std::string & questId) const
     87    Quest* QuestManager::findQuest(const std::string & questId)
    8788    {
    8889        Quest* quest;
    89         std::map<std::string, Quest>::iterator it = this->questMap_.find(questId);
     90        std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId);
    9091        if (it != this->questMap_.end())
    9192        {
     
    9899        }
    99100       
    100         return *quest;
     101        return quest;
    101102
    102103    }
     
    112113        Throw exceptopns in case of errors.
    113114    */
    114     QuestHint & QuestManager::findHint(const std::string & hintId) const
     115    QuestHint* QuestManager::findHint(const std::string & hintId) const
    115116    {
    116117        QuestHint* hint;
    117         std::map<std::string, QuestHint>::iterator it = this->hintMap_.find(hintId);
     118        std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId);
    118119        if (it != this->hintMap_.end())
    119120        {
  • code/branches/questsystem/src/orxonox/objects/QuestManager.h

    r1996 r2021  
    5252            ~QuestManager();
    5353           
    54             static bool registerQuest(Quest & quest); //!< Registers a quest in the QuestManager.
    55             static bool registerHint(QuestHint & quest); //!< Registers a QuestHint in the QuestManager.
     54            static bool registerQuest(Quest* quest); //!< Registers a quest in the QuestManager.
     55            static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
    5656           
    57             static Quest & findQuest(const std::string & questId) const; //!< Returns the quest with the input id.
    58             static QuestHint & findHint(const std::string & hintId) const; //!< Returns the QuestHint with the input id.
     57            static Quest* findQuest(const std::string & questId); //!< Returns the quest with the input id.
     58            static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id.
    5959                   
    6060        private:
    61             static std::map<std::string, Quest> questMap_;
    62             static std::map<std::string, QuestHint> hintMap_;
     61            static std::map<std::string, Quest*> questMap_;
     62            static std::map<std::string, QuestHint*> hintMap_;
    6363   
    6464    };
  • code/branches/questsystem/src/orxonox/objects/Rewardable.cc

    r1996 r2021  
    2828
    2929#include "core/CoreIncludes.h"
     30
    3031#include "Rewardable.h"
    3132
  • code/branches/questsystem/src/orxonox/objects/Rewardable.h

    r1996 r2021  
    3434namespace orxonox {
    3535
     36    class Player; //Forward declaration, remove when fully integrated in objecthirarchy.
     37
    3638    /**
    3739    @brief
     
    4749            virtual ~Rewardable();
    4850           
    49             virtual bool reward(Player & player) = 0; //!<Method to transcribe a rewardable object to the player.
     51            virtual bool reward(Player* player) = 0; //!<Method to transcribe a rewardable object to the player.
    5052   
    5153    };
Note: See TracChangeset for help on using the changeset viewer.