Changeset 1996 for code/branches
- Timestamp:
- Oct 22, 2008, 4:03:10 PM (16 years ago)
- Location:
- code/branches/questsystem/src/orxonox
- Files:
-
- 6 added
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem/src/orxonox/objects/AddQuest.cc
r1992 r1996 59 59 The player the effect is invoked on. 60 60 */ 61 v irtual void AddQuest::invoke(Player & player)61 void AddQuest::invoke(Player & player) 62 62 { 63 63 Quest quest = QuestManager::findQuest(this->getQuestId()); -
code/branches/questsystem/src/orxonox/objects/AddQuestHint.cc
r1992 r1996 60 60 The player. 61 61 */ 62 v irtual void invoke(Player & player)62 void invoke(Player & player) 63 63 { 64 64 QuestHint hint = QuestManager::findHint(this->hintId_); -
code/branches/questsystem/src/orxonox/objects/AddReward.cc
r1992 r1996 81 81 The player. 82 82 */ 83 v irtual void AddReward::invoke(Player & player)83 void AddReward::invoke(Player & player) 84 84 { 85 85 if ( this->rewards_ == NULL ) -
code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.h
r1992 r1996 46 46 public: 47 47 ChangeQuestStatus(std::string questId); 48 ~ChangeQuestStatus();48 virtual ~ChangeQuestStatus(); 49 49 50 50 virtual void invoke(Player & player) = 0; //!< Invokes the effect. -
code/branches/questsystem/src/orxonox/objects/CompleteQuest.cc
r1992 r1996 59 59 The player the effect is invoked on. 60 60 */ 61 v irtual void CompleteQuest::invoke(Player & player)61 void CompleteQuest::invoke(Player & player) 62 62 { 63 63 Quest quest = QuestManager::findQuest(this->getQuestId()); -
code/branches/questsystem/src/orxonox/objects/FailQuest.cc
r1992 r1996 59 59 The player the effect is invoked on. 60 60 */ 61 v irtual void FailQuest::invoke(Player & player)61 void FailQuest::invoke(Player & player) 62 62 { 63 63 Quest quest = QuestManager::findQuest(this->getQuestId()); -
code/branches/questsystem/src/orxonox/objects/GlobalQuest.cc
r1992 r1996 58 58 59 59 } 60 61 /** 62 @brief 63 Checks whether the quest can be started. 64 @param player 65 The player for whom is to be checked. 66 @return 67 Returns true if the quest can be started, false if not. 68 */ 69 bool GlobalQuest::isStartable(const Player & player) const 70 { 71 return this->isInactive(player) || this->isActive(player); 72 } 73 74 /** 75 @brief 76 Checks whether the quest can be failed. 77 @param player 78 The player for whom is to be checked. 79 @return 80 Returns true if the quest can be failed, false if not. 81 */ 82 bool GlobalQuest::isFailable(const Player & player) const 83 { 84 return this->isActive(player); 85 } 86 87 /** 88 @brief 89 Checks whether the quest can be completed. 90 @param player 91 The player for whom is to be checked. 92 @return 93 Returns true if the quest can be completed, false if not. 94 */ 95 bool GlobalQuest::isCompletable(const Player & player) const 96 { 97 return this->isActive(player); 98 } 60 99 61 100 /** … … 65 104 The player. 66 105 */ 67 virtualquestStatus::Enum getStatus(const Player & player) const106 questStatus::Enum getStatus(const Player & player) const 68 107 { 69 108 //TDO: Does this really work??? … … 87 126 The status to be set. 88 127 */ 89 v irtual void setStatus(const Player & player, const questStatus::Enum & status)128 void setStatus(const Player & player, const questStatus::Enum & status) 90 129 { 91 //TDO: Implement. 130 if (this->players_.find(&player) == this->players_.end()) //!< Player is not yet in the list. 131 { 132 this->players_.insert(&player); 133 } 134 this->status_ = status; 92 135 } 93 136 137 94 138 } -
code/branches/questsystem/src/orxonox/objects/GlobalQuest.h
r1992 r1996 47 47 public: 48 48 GlobalQuest(std::string id, std::string title = "", std::string description = ""); 49 ~GlobalQuest();49 virtual ~GlobalQuest(); 50 50 51 51 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 52 56 virtual questStatus::Enum getStatus(const Player & player) const; //!< Returns the status of the quest for a specific player. 53 virtual voidsetStatus(const Player & player, const questStatus::Enum & status); //!< Sets the status for a specific player.57 virtual bool setStatus(const Player & player, const questStatus::Enum & status); //!< Sets the status for a specific player. 54 58 55 59 private: -
code/branches/questsystem/src/orxonox/objects/LocalQuest.cc
r1992 r1996 61 61 /** 62 62 @brief 63 Checks whether the quest can be started. 64 @param player 65 The player for whom is to be checked. 66 @return 67 Returns true if the quest can be started, false if not. 68 */ 69 bool LocalQuest::isStartable(const Player & player) const 70 { 71 return this->isInactive(player); 72 } 73 74 /** 75 @brief 76 Checks whether the quest can be failed. 77 @param player 78 The player for whom is to be checked. 79 @return 80 Returns true if the quest can be failed, false if not. 81 */ 82 bool LocalQuest::isFailable(const Player & player) const 83 { 84 return this->isActive(player); 85 } 86 87 /** 88 @brief 89 Checks whether the quest can be completed. 90 @param player 91 The player for whom is to be checked. 92 @return 93 Returns true if the quest can be completed, false if not. 94 */ 95 bool LocalQuest::isCompletable(const Player & player) const 96 { 97 return this->isActive(player); 98 } 99 100 /** 101 @brief 63 102 Returns the status of the quest for a specific player. 64 103 @param player 65 The player 104 The player. 105 @return 106 Returns the status of the quest for the input player. 66 107 */ 67 virtual intLocalQuest::getStatus(const Player & player) const108 virtual questStatus::Enum LocalQuest::getStatus(const Player & player) const 68 109 { 69 //TDO: Implenet. 110 std::map<Player*, questStatus::Enum>::iterator it = this->playerStatus_.find(&player); 111 if (it != this->playerStatus_.end()) 112 { 113 return it->second; 114 } 115 return questStatus::inactive; 70 116 } 71 117 … … 80 126 virtual void LocalQuest::setStatus(const Player & player, const questStatus::Enum & status) 81 127 { 82 //TDO: Implement.128 this->playerStatus[&player] = status; 83 129 } 84 130 -
code/branches/questsystem/src/orxonox/objects/LocalQuest.h
r1992 r1996 30 30 #define _LocalQuest_H__ 31 31 32 #include <map> 32 33 #include <string> 33 34 … … 46 47 public: 47 48 LocalQuest(std::string id, std::string title = "", std::string description = ""); 48 ~LocalQuest();49 virtual ~LocalQuest(); 49 50 50 51 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 51 56 virtual questStatus::Enum getStatus(const Player & player) const; //!< Returns the status of the quest for a specific player. 52 57 virtual void setStatus(const Player & player, const questStatus::Enum & status); //!< Sets the status for a specific player. 53 58 54 59 private: 55 //TDO: List of Players and the status of the quest fo them. 56 questStatus::Enum status_; //!< The status of the quest. 60 std::map<Player*, questStatus::Enum> playerStatus_; 57 61 58 62 }; 63 59 64 60 65 } -
code/branches/questsystem/src/orxonox/objects/Quest.cc
r1992 r1996 71 71 /** 72 72 @brief 73 Sets the parent quest of the quest. 74 @param quest 75 A pointer to the quest to be set as parent quest. 76 */ 77 bool setParentQuest(Quest* quest) 78 { 79 this->parentQuest_ = quest; 80 return true; 81 } 82 83 /** 84 @brief 85 Adds a sub quest to the quest. 86 @param quest 87 A pointer to the quest to be set as sub quest. 88 */ 89 bool addSubQuest(Quest & quest) 90 { 91 this->subQuests_.push_back = quest; 92 return true; 93 } 94 95 /** 96 @brief 73 97 Adds a Hint to the list of hints 74 98 @param hint … … 93 117 @param player 94 118 The player. 119 @return 120 Returns true if the quest could be started, false if not. 95 121 */ 96 voidQuest::start(const Player & player)122 bool Quest::start(const Player & player) 97 123 { 98 if(this->is Inactive(player))124 if(this->isStartable(player)) 99 125 { 100 126 this->setStatus(player, questStatus::active); 127 return true; 101 128 } 102 else 103 { 104 COUT(2) << "A non-inactive quest was trying to be started." << std::endl; 105 } 129 COUT(2) << "A non-startable quest was trying to be started." << std::endl; 130 return false; 106 131 } 107 132 … … 111 136 @param player 112 137 The player. 138 @return 139 Returns true if the quest could be failed, false if not. 113 140 */ 114 141 void Quest::fail(Player & player) 115 142 { 116 if(this->is Active(player))143 if(this->isFailable(player)) 117 144 { 118 145 this->setStatus(player, questStatus::failed); 119 146 QuestEffect::invokeEffects(player, this->failEffects_); 147 return true; 120 148 } 121 else 122 { 123 COUT(2) << "A non-pending quest was trying to be failed." << std::endl; 124 } 149 COUT(2) << "A non-failable quest was trying to be failed." << std::endl; 150 return false; 125 151 } 126 152 … … 130 156 @param player 131 157 The player. 158 @return 159 Returns true if the quest could be completed, false if not. 132 160 */ 133 161 void Quest::complete(Player & player) 134 162 { 135 if(this->is Active(player))163 if(this->isCompletable(player)) 136 164 { 137 165 this->setStatus(player, questStatus::completed); 138 166 QuestEffect::invokeEffects(player, this->completeEffects_); 167 return true; 139 168 } 140 else 141 { 142 COUT(2) << "A non-pending quest was trying to be completed." << std::endl; 143 } 169 COUT(2) << "A non-completable quest was trying to be completed." << std::endl; 170 return false; 144 171 } 145 172 -
code/branches/questsystem/src/orxonox/objects/Quest.h
r1992 r1996 33 33 #include <string> 34 34 35 #include " orxonox/quests/QuestDescription.h"35 #include "QuestDescription.h" 36 36 #include "QuestItem.h" 37 37 #include "QuestHint.h" … … 52 52 public: 53 53 Quest(std::string id, std::string title = "", std::string description = ""); 54 ~Quest();54 virtual ~Quest(); 55 55 56 56 inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. … … 60 60 61 61 //TDO: Necessary? Shouldn't this be decided whilest creating the object? 62 inline void setParentQuest(Quest* quest) //!< Sets the parent quest of the quest. 63 { this->parentQuest_ = quest; } 64 inline void addSubQuest(Quest & quest) //!< Adds a sub quest to the quest. 65 { this->subQuests_.push_back = quest; } 62 bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest. 63 bool addSubQuest(Quest & quest); //!< Adds a sub quest to the quest. 66 64 67 65 inline bool isInactive(const Player & player) const //!< Returns true if the quest status for the specific player is 'inactive'. 68 { return this->getStatus(player) != questStatus::inactive; }66 { return this->getStatus(player) == questStatus::inactive; } 69 67 inline bool isActive(const Player & player) const //!< Returns true if the quest status for the specific player is 'active'. 70 68 { return this->getStatus(player) == questStatus::active; } … … 74 72 { return this->getStatus(player) == questStatus::completed; } 75 73 76 void start(const Player & player); //!< Sets a quest to pending.77 voidfail(Player & player); //!< Fails the quest.78 voidcomplete(Player & player); //!< Completes the quest.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. 79 77 80 78 void addHint(QuestHint & hint); //!< Add a hint to the list of hints. … … 82 80 protected: 83 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. 84 86 85 87 virtual questStatus::Enum getStatus(const Player & player) const = 0; //!< Returns the status of the quest for a specific player. -
code/branches/questsystem/src/orxonox/objects/QuestEffect.cc
r1992 r1996 61 61 A list of all the effects to be invoked. 62 62 */ 63 staticvoid QuestEffect::invokeEffects(Player & player, std::list<QuestEffect> & effects)63 void QuestEffect::invokeEffects(Player & player, std::list<QuestEffect> & effects) 64 64 { 65 65 if ( effects == NULL ) -
code/branches/questsystem/src/orxonox/objects/QuestEffect.h
r1992 r1996 46 46 public: 47 47 QuestEffect(); 48 ~QuestEffect();48 virtual ~QuestEffect(); 49 49 50 50 virtual void invoke(Player & player) = 0; //!< Invokes the effect. -
code/branches/questsystem/src/orxonox/objects/QuestHint.cc
r1992 r1996 58 58 } 59 59 60 /** 61 @brief 62 Checks whether the hint is active for a specific player. 63 @param player 64 The player. 65 @return 66 Returns 67 */ 60 68 bool QuestHint::isActive(const Player & player) const 61 69 { 62 //TDO: Implement. 70 std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(&player); 71 if (it != this->playerStatus_.end()) 72 { 73 return it->second; 74 } 75 return questStatus::inactive; 63 76 } 64 77 65 voidQuestHint::activate(const Player & player)78 bool QuestHint::activate(const Player & player) 66 79 { 67 if(this->quest_->isActive(player) )80 if(this->quest_->isActive(player) && !this->isActive()) 68 81 { 69 //TDO: Implement. 82 this->playerStatus_[&player] = questHintStatus::active; 83 return true; 70 84 } 71 else 72 { 73 COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl; 74 } 85 COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl; 86 return false; 75 87 } 76 88 -
code/branches/questsystem/src/orxonox/objects/QuestHint.h
r1992 r1996 30 30 #define _QuestHint_H__ 31 31 32 #include <map> 32 33 #include <string> 33 34 34 #include " orxonox/quests/QuestDescription.h"35 #include "QuestDescription.h" 35 36 #include "Quest.h" 36 37 #include "QuestItem.h" … … 55 56 bool isActive(const Player & player) const; //!< Returns true if the hint is active for the input player. 56 57 57 voidactivate(const Player & player); //!< Activates the hint for the input player.58 bool activate(const Player & player); //!< Activates the hint for the input player. 58 59 59 60 void setQuest(Quest* quest); //!< Sets the quest the hint belongs to. … … 62 63 63 64 Quest* quest_; 64 //TDO: questHint statuslist.65 std::map<Player*, questHintStatus::Enum> playerStatus_; 65 66 66 67 }; -
code/branches/questsystem/src/orxonox/objects/QuestItem.h
r1992 r1996 50 50 public: 51 51 QuestItem(std::string id, std::string title = "", std::string description = ""); 52 ~QuestItem();52 virtual ~QuestItem(); 53 53 54 54 inline std::string getId(void) const //!< Returns the id of this quest.
Note: See TracChangeset
for help on using the changeset viewer.