Changeset 2021
- Timestamp:
- Oct 27, 2008, 8:31:20 PM (16 years ago)
- Location:
- code/branches/questsystem/src/orxonox
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem/src/orxonox/CMakeLists.txt
r1844 r2021 62 62 objects/RotatingProjectile.cc 63 63 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 64 78 65 79 tolua/tolua_bind.cc -
code/branches/questsystem/src/orxonox/objects/AddQuest.cc
r1996 r2021 27 27 */ 28 28 29 #include <string> 30 29 31 #include "core/CoreIncludes.h" 32 33 #include "QuestManager.h" 34 #include "Quest.h" 30 35 #include "AddQuest.h" 31 36 … … 33 38 34 39 CreateFactory(AddQuest); 40 41 42 AddQuest::AddQuest() : ChangeQuestStatus() 43 { 44 45 } 35 46 36 47 /** … … 59 70 The player the effect is invoked on. 60 71 */ 61 void AddQuest::invoke(Player &player)72 void AddQuest::invoke(Player* player) 62 73 { 63 Quest quest = QuestManager::findQuest(this->getQuestId());64 quest .start(player);74 Quest* quest = QuestManager::findQuest(this->getQuestId()); 75 quest->start(player); 65 76 } 66 77 -
code/branches/questsystem/src/orxonox/objects/AddQuest.h
r1992 r2021 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 39 38 40 /** 39 41 @brief … … 45 47 { 46 48 public: 49 AddQuest(); 47 50 AddQuest(std::string questId); 48 51 ~AddQuest(); 49 52 50 virtual void invoke(Player &player); //!< Invokes the effect.53 virtual void invoke(Player* player); //!< Invokes the effect. 51 54 52 55 }; -
code/branches/questsystem/src/orxonox/objects/AddQuestHint.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 31 #include "QuestManager.h" 30 32 #include "AddQuestHint.h" 31 33 … … 33 35 34 36 CreateFactory(AddQuestHint); 37 38 AddQuestHint::AddQuestHint() : QuestEffect() 39 { 40 41 } 35 42 36 43 /** … … 60 67 The player. 61 68 */ 62 void invoke(Player &player)69 void AddQuestHint::invoke(Player* player) 63 70 { 64 QuestHint hint = QuestManager::findHint(this->hintId_);65 hint .activate(player);71 QuestHint* hint = QuestManager::findHint(this->hintId_); 72 hint->activate(player); 66 73 } 67 74 } -
code/branches/questsystem/src/orxonox/objects/AddQuestHint.h
r1992 r2021 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 39 38 40 /** 39 41 @brief … … 45 47 { 46 48 public: 49 AddQuestHint(); 47 50 AddQuestHint(std::string hintId); 48 51 ~AddQuestHint(); 49 52 50 virtual void invoke(Player &player); //!< Invokes the effect.53 virtual void invoke(Player* player); //!< Invokes the effect. 51 54 52 55 private: -
code/branches/questsystem/src/orxonox/objects/AddReward.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "AddReward.h" 31 32 … … 33 34 34 35 CreateFactory(AddReward); 36 37 AddReward::AddReward() : QuestEffect() 38 { 39 40 } 35 41 36 42 /** … … 40 46 A reward. 41 47 */ 42 AddReward::AddReward(Rewardable & reward)48 AddReward::AddReward(Rewardable* reward) : QuestEffect() 43 49 { 44 50 this->initialize(); … … 52 58 A list of rewards. 53 59 */ 54 AddReward::AddReward(std::list<Rewardable > & rewards)60 AddReward::AddReward(std::list<Rewardable*>* rewards) : QuestEffect() 55 61 { 56 62 this->initialize(); … … 81 87 The player. 82 88 */ 83 void AddReward::invoke(Player &player)89 void AddReward::invoke(Player* player) 84 90 { 85 91 if ( this->rewards_ == NULL ) … … 88 94 return; 89 95 } 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 ) 91 97 { 92 reward.reward(player);98 (*reward)->reward(player); 93 99 } 94 100 } -
code/branches/questsystem/src/orxonox/objects/AddReward.h
r1992 r2021 32 32 #include <list> 33 33 34 #include " orxonox/quests/Rewardable.h"34 #include "Rewardable.h" 35 35 #include "QuestEffect.h" 36 36 37 37 namespace orxonox { 38 39 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 38 40 39 41 /** … … 46 48 { 47 49 public: 48 AddReward(Rewardable & reward); 49 AddReward(std::list<Rewardable> & rewards); 50 AddReward(); 51 AddReward(Rewardable* reward); 52 AddReward(std::list<Rewardable*>* rewards); 50 53 ~AddReward(); 51 54 52 virtual void invoke(Player &player); //!< Invokes the effect.55 virtual void invoke(Player* player); //!< Invokes the effect. 53 56 54 57 private: 55 56 std::list<Rewardable> rewards_; 58 std::list<Rewardable*>* rewards_; 57 59 58 60 void initialize(void); //!< Initializes the object. 59 61 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); } 62 64 63 65 }; -
code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.cc
r1992 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "ChangeQuestStatus.h" 31 32 32 33 namespace orxonox { 33 34 34 CreateFactory(ChangeQuestStatus); 35 ChangeQuestStatus::ChangeQuestStatus() : QuestEffect() 36 { 37 38 } 35 39 36 40 /** -
code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.h
r1996 r2021 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 39 38 40 /** 39 41 @brief … … 45 47 { 46 48 public: 49 ChangeQuestStatus(); 47 50 ChangeQuestStatus(std::string questId); 48 51 virtual ~ChangeQuestStatus(); 49 52 50 virtual void invoke(Player &player) = 0; //!< Invokes the effect.53 virtual void invoke(Player* player) = 0; //!< Invokes the effect. 51 54 52 55 protected: -
code/branches/questsystem/src/orxonox/objects/CompleteQuest.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 31 #include "QuestManager.h" 32 #include "Quest.h" 30 33 #include "CompleteQuest.h" 31 34 … … 34 37 CreateFactory(CompleteQuest); 35 38 39 CompleteQuest::CompleteQuest() : ChangeQuestStatus() 40 { 41 42 } 43 36 44 /** 37 45 @brief … … 59 67 The player the effect is invoked on. 60 68 */ 61 void CompleteQuest::invoke(Player &player)69 void CompleteQuest::invoke(Player* player) 62 70 { 63 Quest quest = QuestManager::findQuest(this->getQuestId());64 quest .complete(player);71 Quest* quest = QuestManager::findQuest(this->getQuestId()); 72 quest->complete(player); 65 73 } 66 74 -
code/branches/questsystem/src/orxonox/objects/CompleteQuest.h
r1992 r2021 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 39 38 40 /** 39 41 @brief … … 45 47 { 46 48 public: 49 CompleteQuest(); 47 50 CompleteQuest(std::string questId); 48 51 ~CompleteQuest(); 49 52 50 virtual void invoke(Player &player); //!< Invokes the effect.53 virtual void invoke(Player* player); //!< Invokes the effect. 51 54 52 55 }; -
code/branches/questsystem/src/orxonox/objects/FailQuest.cc
r1996 r2021 27 27 */ 28 28 29 #include "core/CoreIncludes"; 29 #include "core/CoreIncludes.h" 30 31 #include "QuestManager.h" 32 #include "Quest.h" 30 33 #include "FailQuest.h" 31 34 … … 33 36 34 37 CreateFactory(FailQuest); 38 39 FailQuest::FailQuest() : ChangeQuestStatus() 40 { 41 42 } 35 43 36 44 /** … … 59 67 The player the effect is invoked on. 60 68 */ 61 void FailQuest::invoke(Player &player)69 void FailQuest::invoke(Player* player) 62 70 { 63 Quest quest = QuestManager::findQuest(this->getQuestId());64 quest .fail(player);71 Quest* quest = QuestManager::findQuest(this->getQuestId()); 72 quest->fail(player); 65 73 } 66 74 -
code/branches/questsystem/src/orxonox/objects/FailQuest.h
r1992 r2021 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 39 38 40 /** 39 41 @brief … … 45 47 { 46 48 public: 49 FailQuest(); 47 50 FailQuest(std::string questId); 48 51 ~FailQuest(); 49 52 50 virtual void invoke(Player &player); //!< Invokes the effect.53 virtual void invoke(Player* player); //!< Invokes the effect. 51 54 52 55 }; -
code/branches/questsystem/src/orxonox/objects/GlobalQuest.cc
r1996 r2021 35 35 CreateFactory(GlobalQuest); 36 36 37 GlobalQuest::GlobalQuest() : Quest() 38 { 39 40 } 41 37 42 /** 38 43 @brief … … 45 50 The description of the quest. 46 51 */ 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) 48 53 { 49 54 RegisterObject(GlobalQuest); … … 67 72 Returns true if the quest can be started, false if not. 68 73 */ 69 bool GlobalQuest::isStartable( const Player & player) const74 bool GlobalQuest::isStartable(Player* player) 70 75 { 71 76 return this->isInactive(player) || this->isActive(player); … … 80 85 Returns true if the quest can be failed, false if not. 81 86 */ 82 bool GlobalQuest::isFailable( const Player & player) const87 bool GlobalQuest::isFailable(Player* player) 83 88 { 84 89 return this->isActive(player); … … 93 98 Returns true if the quest can be completed, false if not. 94 99 */ 95 bool GlobalQuest::isCompletable( const Player & player) const100 bool GlobalQuest::isCompletable(Player* player) 96 101 { 97 102 return this->isActive(player); … … 104 109 The player. 105 110 */ 106 questStatus::Enum getStatus(const Player & player) const111 questStatus::Enum GlobalQuest::getStatus(const Player* player) 107 112 { 108 113 //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()) 110 116 { 111 117 return this->status_; … … 126 132 The status to be set. 127 133 */ 128 void setStatus(const Player &player, const questStatus::Enum & status)134 bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status) 129 135 { 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. 131 138 { 132 this->players_.insert( &player);139 this->players_.insert(player); 133 140 } 134 141 this->status_ = status; 142 return true; 135 143 } 136 144 -
code/branches/questsystem/src/orxonox/objects/GlobalQuest.h
r1996 r2021 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 39 38 40 /** 39 41 @brief … … 46 48 { 47 49 public: 50 GlobalQuest(); 48 51 GlobalQuest(std::string id, std::string title = "", std::string description = ""); 49 virtual~GlobalQuest();52 ~GlobalQuest(); 50 53 51 54 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. 55 58 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. 58 61 59 62 private: -
code/branches/questsystem/src/orxonox/objects/LocalQuest.cc
r1996 r2021 35 35 CreateFactory(LocalQuest); 36 36 37 LocalQuest::LocalQuest() : Quest() 38 { 39 40 } 41 37 42 /** 38 43 @brief … … 45 50 The description of the quest. 46 51 */ 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) 48 53 { 49 54 RegisterObject(LocalQuest); … … 67 72 Returns true if the quest can be started, false if not. 68 73 */ 69 bool LocalQuest::isStartable( const Player & player) const74 bool LocalQuest::isStartable(Player* player) 70 75 { 71 76 return this->isInactive(player); … … 80 85 Returns true if the quest can be failed, false if not. 81 86 */ 82 bool LocalQuest::isFailable( const Player & player) const87 bool LocalQuest::isFailable(Player* player) 83 88 { 84 89 return this->isActive(player); … … 93 98 Returns true if the quest can be completed, false if not. 94 99 */ 95 bool LocalQuest::isCompletable( const Player & player) const100 bool LocalQuest::isCompletable(Player* player) 96 101 { 97 102 return this->isActive(player); … … 106 111 Returns the status of the quest for the input player. 107 112 */ 108 virtual questStatus::Enum LocalQuest::getStatus(const Player & player) const113 questStatus::Enum LocalQuest::getStatus(const Player* player) 109 114 { 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'. 111 116 if (it != this->playerStatus_.end()) 112 117 { … … 124 129 The status. 125 130 */ 126 virtual void LocalQuest::setStatus(const Player &player, const questStatus::Enum & status)131 bool LocalQuest::setStatus(Player* player, const questStatus::Enum & status) 127 132 { 128 this->playerStatus[&player] = status; 133 this->playerStatus_[player] = status; 134 return true; 129 135 } 130 136 -
code/branches/questsystem/src/orxonox/objects/LocalQuest.h
r1996 r2021 37 37 namespace orxonox { 38 38 39 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 40 39 41 /** 40 42 @brief … … 46 48 { 47 49 public: 50 LocalQuest(); 48 51 LocalQuest(std::string id, std::string title = "", std::string description = ""); 49 virtual~LocalQuest();52 ~LocalQuest(); 50 53 51 54 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. 55 58 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. 58 61 59 62 private: -
code/branches/questsystem/src/orxonox/objects/Quest.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "Quest.h" 31 32 32 33 namespace orxonox { 33 34 34 CreateFactory(Quest); 35 Quest::Quest() : QuestItem() 36 { 37 38 } 35 39 36 40 /** … … 44 48 The description of the quest. 45 49 */ 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) 47 51 { 48 52 initialize(); … … 75 79 A pointer to the quest to be set as parent quest. 76 80 */ 77 bool setParentQuest(Quest* quest)81 bool Quest::setParentQuest(Quest* quest) 78 82 { 79 83 this->parentQuest_ = quest; … … 87 91 A pointer to the quest to be set as sub quest. 88 92 */ 89 bool addSubQuest(Quest &quest)93 bool Quest::addSubQuest(Quest* quest) 90 94 { 91 this->subQuests_.push_back = quest;95 this->subQuests_.push_back(quest); 92 96 return true; 93 97 } … … 99 103 The hint that should be added to the list of hints. 100 104 */ 101 void Quest::addHint(QuestHint &hint)105 void Quest::addHint(QuestHint* hint) 102 106 { 103 107 if ( hint != NULL ) 104 108 { 105 109 this->hints_.push_back(hint); 106 hint .setQuest(this);110 hint->setQuest(this); 107 111 } 108 112 else … … 120 124 Returns true if the quest could be started, false if not. 121 125 */ 122 bool Quest::start( const Player &player)126 bool Quest::start(Player* player) 123 127 { 124 128 if(this->isStartable(player)) … … 139 143 Returns true if the quest could be failed, false if not. 140 144 */ 141 void Quest::fail(Player &player)145 bool Quest::fail(Player* player) 142 146 { 143 147 if(this->isFailable(player)) … … 159 163 Returns true if the quest could be completed, false if not. 160 164 */ 161 void Quest::complete(Player &player)165 bool Quest::complete(Player* player) 162 166 { 163 167 if(this->isCompletable(player)) -
code/branches/questsystem/src/orxonox/objects/Quest.h
r1996 r2021 38 38 #include "QuestEffect.h" 39 39 40 namespace orxonox {41 42 /**43 @brief44 Represents a quest in the game.45 A quest has a sub46 47 @author48 Damian 'Mozork' Frick49 */50 class Quest : public QuestItem51 {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 102 40 namespace questStatus 103 41 { … … 113 51 } 114 52 53 namespace 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 115 120 #endif /* _Quest_H__ */ -
code/branches/questsystem/src/orxonox/objects/QuestDescription.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "QuestDescription.h" 31 32 … … 34 35 CreateFactory(QuestDescription); 35 36 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() 37 43 { 38 44 initialize(); -
code/branches/questsystem/src/orxonox/objects/QuestDescription.h
r1996 r2021 46 46 47 47 public: 48 QuestDescription(); 48 49 QuestDescription(std::string title, std::string description = ""); 49 50 ~QuestDescription(); -
code/branches/questsystem/src/orxonox/objects/QuestEffect.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "QuestEffect.h" 31 32 32 33 namespace orxonox { 33 34 CreateFactory(QuestEffect);35 34 36 35 /** … … 61 60 A list of all the effects to be invoked. 62 61 */ 63 void QuestEffect::invokeEffects(Player & player, std::list<QuestEffect> & effects)62 void QuestEffect::invokeEffects(Player* player, std::list<QuestEffect*> & effects) 64 63 { 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++) 71 65 { 72 effect.invoke(player);66 (*effect)->invoke(player); 73 67 } 74 68 } -
code/branches/questsystem/src/orxonox/objects/QuestEffect.h
r1996 r2021 32 32 #include <list> 33 33 34 #include " BaseObject.h"34 #include "core/BaseObject.h" 35 35 36 36 namespace orxonox { 37 38 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 37 39 38 40 /** … … 48 50 virtual ~QuestEffect(); 49 51 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. 52 54 53 55 -
code/branches/questsystem/src/orxonox/objects/QuestHint.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 31 #include "Quest.h" 30 32 #include "QuestHint.h" 31 33 … … 33 35 34 36 CreateFactory(QuestHint); 37 38 QuestHint::QuestHint() : QuestItem() 39 { 40 41 } 35 42 36 43 /** … … 44 51 The description of the hint, resp. the hint itself. 45 52 */ 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) 47 54 { 48 55 RegisterObject(QuestHint); … … 66 73 Returns 67 74 */ 68 bool QuestHint::isActive( const Player & player) const75 bool QuestHint::isActive(Player* player) 69 76 { 70 std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find( &player);77 std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player); 71 78 if (it != this->playerStatus_.end()) 72 79 { … … 76 83 } 77 84 78 bool QuestHint::activate(const Player & player) 85 /** 86 @brief 87 @param player 88 @return 89 */ 90 bool QuestHint::activate(Player* player) 79 91 { 80 if(this->quest_->isActive(player) && ! this->isActive())92 if(this->quest_->isActive(player) && !(this->isActive(player))) 81 93 { 82 this->playerStatus_[ &player] = questHintStatus::active;94 this->playerStatus_[player] = questHintStatus::active; 83 95 return true; 84 96 } … … 87 99 } 88 100 101 /** 102 @brief 103 @param quest 104 @return 105 */ 89 106 void QuestHint::setQuest(Quest* quest) 90 107 { -
code/branches/questsystem/src/orxonox/objects/QuestHint.h
r1996 r2021 34 34 35 35 #include "QuestDescription.h" 36 #include "Quest.h"37 36 #include "QuestItem.h" 37 38 namespace questHintStatus 39 { 40 41 enum Enum 42 { 43 inactive, 44 active 45 }; 46 47 } 38 48 39 49 namespace orxonox 40 50 { 51 52 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. 53 class Quest; //To avoid circual includes. 41 54 42 55 /** … … 51 64 52 65 public: 66 QuestHint(); 53 67 QuestHint(std::string id, std::string title = "", std::string description = ""); 54 68 ~QuestHint(); 55 69 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. 57 71 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. 59 73 60 74 void setQuest(Quest* quest); //!< Sets the quest the hint belongs to. 61 75 62 private: 76 private: 63 77 64 78 Quest* quest_; … … 69 83 } 70 84 71 namespace questHintStatus72 {73 74 enum Enum75 {76 inactive,77 active78 };79 80 }81 82 85 #endif /* _QuestHint_H__ */ -
code/branches/questsystem/src/orxonox/objects/QuestItem.cc
r1992 r2021 35 35 CreateFactory(QuestItem); 36 36 37 QuestItem::QuestItem() : BaseObject() 38 { 39 40 } 41 37 42 /** 38 43 @brief … … 45 50 The description of this QuestItem. Has an empty string as default. 46 51 */ 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() 48 53 { 49 54 this->initialize(); -
code/branches/questsystem/src/orxonox/objects/QuestItem.h
r1996 r2021 32 32 #include <string> 33 33 34 #include " orxonox/quests/QuestDescription.h"35 #include " BaseObject.h"34 #include "QuestDescription.h" 35 #include "core/BaseObject.h" 36 36 37 37 namespace orxonox { … … 49 49 50 50 public: 51 QuestItem(); 51 52 QuestItem(std::string id, std::string title = "", std::string description = ""); 52 53 virtual ~QuestItem(); -
code/branches/questsystem/src/orxonox/objects/QuestManager.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "QuestManager.h" 31 32 32 33 namespace orxonox { 33 34 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_; 36 37 37 38 QuestManager::QuestManager() : BaseObject() … … 54 55 Returns true if successful, false if not. 55 56 */ 56 bool QuestManager::registerQuest(Quest &quest)57 bool QuestManager::registerQuest(Quest* quest) 57 58 { 58 this->questMap_.insert ( pair<std::string,Quest>(quest .getId(),quest) );59 this->questMap_.insert ( pair<std::string,Quest>(quest->getId(),quest) ); 59 60 return true; 60 61 } … … 68 69 Returns true if successful, false if not. 69 70 */ 70 bool QuestManager::registerHint(QuestHint &hint)71 bool QuestManager::registerHint(QuestHint* hint) 71 72 { 72 this->hintMap_.insert ( pair<std::string,Hint>(hint .getId(),hint) );73 this->hintMap_.insert ( pair<std::string,Hint>(hint->getId(),hint) ); 73 74 return true; 74 75 } … … 84 85 Throw exceptions in case of errors. 85 86 */ 86 Quest & QuestManager::findQuest(const std::string & questId) const87 Quest* QuestManager::findQuest(const std::string & questId) 87 88 { 88 89 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); 90 91 if (it != this->questMap_.end()) 91 92 { … … 98 99 } 99 100 100 return *quest;101 return quest; 101 102 102 103 } … … 112 113 Throw exceptopns in case of errors. 113 114 */ 114 QuestHint &QuestManager::findHint(const std::string & hintId) const115 QuestHint* QuestManager::findHint(const std::string & hintId) const 115 116 { 116 117 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); 118 119 if (it != this->hintMap_.end()) 119 120 { -
code/branches/questsystem/src/orxonox/objects/QuestManager.h
r1996 r2021 52 52 ~QuestManager(); 53 53 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. 56 56 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. 59 59 60 60 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_; 63 63 64 64 }; -
code/branches/questsystem/src/orxonox/objects/Rewardable.cc
r1996 r2021 28 28 29 29 #include "core/CoreIncludes.h" 30 30 31 #include "Rewardable.h" 31 32 -
code/branches/questsystem/src/orxonox/objects/Rewardable.h
r1996 r2021 34 34 namespace orxonox { 35 35 36 class Player; //Forward declaration, remove when fully integrated in objecthirarchy. 37 36 38 /** 37 39 @brief … … 47 49 virtual ~Rewardable(); 48 50 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. 50 52 51 53 };
Note: See TracChangeset
for help on using the changeset viewer.