Changeset 2146 for code/branches/questsystem2/src/orxonox/objects
- Timestamp:
- Nov 6, 2008, 12:02:05 AM (16 years ago)
- Location:
- code/branches/questsystem2/src/orxonox/objects/quest
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.cc
r2105 r2146 31 31 32 32 #include <string> 33 33 34 #include "core/CoreIncludes.h" 34 35 #include "util/Exception.h" 35 36 37 #include "orxonox/objects/worldentities/ControllableEntity.h" 36 38 #include "QuestManager.h" 37 39 #include "Quest.h" … … 69 71 Returns true if the effect was successfully invoked. 70 72 */ 71 bool AddQuest::invoke( Player* player)73 bool AddQuest::invoke(ControllableEntity* player) 72 74 { 73 75 if(player == NULL) -
code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.h
r2096 r2146 39 39 namespace orxonox { 40 40 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 41 /** 44 42 @brief … … 55 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 54 57 virtual bool invoke( Player* player); //!< Invokes the effect.55 virtual bool invoke(ControllableEntity* player); //!< Invokes the effect. 58 56 59 57 }; -
code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.cc
r2105 r2146 33 33 #include "util/Exception.h" 34 34 35 #include "orxonox/objects/worldentities/ControllableEntity.h" 35 36 #include "QuestManager.h" 36 37 #include "QuestItem.h" … … 80 81 Returns true if the effect was successfully invoked. 81 82 */ 82 bool AddQuestHint::invoke( Player* player)83 bool AddQuestHint::invoke(ControllableEntity* player) 83 84 { 84 85 if(player == NULL) … … 91 92 { 92 93 QuestHint* hint = QuestManager::findHint(this->hintId_); 93 if(!hint-> activate(player))94 if(!hint->setActive(player)) 94 95 { 95 96 return false; -
code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.h
r2096 r2146 38 38 namespace orxonox { 39 39 40 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.41 42 40 /** 43 41 @brief … … 54 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 53 56 virtual bool invoke( Player* player); //!< Invokes the effect.54 virtual bool invoke(ControllableEntity* player); //!< Invokes the effect. 57 55 58 56 private: -
code/branches/questsystem2/src/orxonox/objects/quest/AddReward.cc
r2105 r2146 32 32 #include "core/CoreIncludes.h" 33 33 34 #include "orxonox/objects/worldentities/ControllableEntity.h" 34 35 #include "Rewardable.h" 35 36 … … 92 93 Returns true if the effect was invoked successfully. 93 94 */ 94 bool AddReward::invoke( Player* player)95 bool AddReward::invoke(ControllableEntity* player) 95 96 { 96 97 bool check = true; -
code/branches/questsystem2/src/orxonox/objects/quest/AddReward.h
r2096 r2146 39 39 namespace orxonox { 40 40 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 41 /** 44 42 @brief … … 55 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 54 57 virtual bool invoke( Player* player); //!< Invokes the effect.55 virtual bool invoke(ControllableEntity* player); //!< Invokes the effect. 58 56 59 57 private: -
code/branches/questsystem2/src/orxonox/objects/quest/ChangeQuestStatus.h
r2096 r2146 39 39 namespace orxonox { 40 40 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 41 /** 44 42 @brief … … 55 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 54 57 virtual bool invoke( Player* player) = 0; //!< Invokes the effect.55 virtual bool invoke(ControllableEntity* player) = 0; //!< Invokes the effect. 58 56 59 57 protected: -
code/branches/questsystem2/src/orxonox/objects/quest/CompleteQuest.cc
r2105 r2146 33 33 #include "util/Exception.h" 34 34 35 #include "orxonox/objects/worldentities/ControllableEntity.h" 35 36 #include "QuestManager.h" 36 37 #include "Quest.h" … … 66 67 Returns true if the effect was invoked successfully. 67 68 */ 68 bool CompleteQuest::invoke( Player* player)69 bool CompleteQuest::invoke(ControllableEntity* player) 69 70 { 70 71 if(player == NULL) -
code/branches/questsystem2/src/orxonox/objects/quest/CompleteQuest.h
r2096 r2146 39 39 namespace orxonox { 40 40 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 41 /** 44 42 @brief … … 55 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 54 57 virtual bool invoke( Player* player); //!< Invokes the effect.55 virtual bool invoke(ControllableEntity* player); //!< Invokes the effect. 58 56 59 57 }; -
code/branches/questsystem2/src/orxonox/objects/quest/FailQuest.cc
r2105 r2146 33 33 #include "util/Exception.h" 34 34 35 #include "orxonox/objects/worldentities/ControllableEntity.h" 35 36 #include "QuestManager.h" 36 37 #include "Quest.h" … … 66 67 Returns true if the effect was invoked successfully. 67 68 */ 68 bool FailQuest::invoke( Player* player)69 bool FailQuest::invoke(ControllableEntity* player) 69 70 { 70 71 if(player == NULL) -
code/branches/questsystem2/src/orxonox/objects/quest/FailQuest.h
r2096 r2146 39 39 namespace orxonox { 40 40 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 41 /** 44 42 @brief … … 55 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 54 57 virtual bool invoke( Player* player); //!< Invokes the effect.55 virtual bool invoke(ControllableEntity* player); //!< Invokes the effect. 58 56 59 57 }; -
code/branches/questsystem2/src/orxonox/objects/quest/GlobalQuest.cc
r2105 r2146 26 26 * 27 27 */ 28 29 /** 30 @file GlobalQuest.cc 31 @brief 32 Implementation of the GlobalQuest class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "GlobalQuest.h" 31 37 38 #include "orxonox/objects/worldentities/ControllableEntity.h" 32 39 #include "core/CoreIncludes.h" 33 40 #include "util/Exception.h" 34 41 42 #include "QuestEffect.h" 43 35 44 namespace orxonox { 36 45 … … 39 48 /** 40 49 @brief 41 Constructor. 50 Constructor. Initializes the object. 42 51 */ 43 52 GlobalQuest::GlobalQuest(BaseObject* creator) : Quest(creator) 44 53 { 54 this->initialize(); 55 } 56 57 /** 58 @brief 59 Initializes the object. 60 */ 61 void GlobalQuest::initialize(void) 62 { 45 63 RegisterObject(GlobalQuest); 46 47 this->initialize();48 64 } 49 65 … … 56 72 57 73 } 58 74 75 /** 76 @brief 77 Method for creating a GlobalQuest object through XML. 78 */ 59 79 void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 80 { 61 81 SUPER(GlobalQuest, XMLPort, xmlelement, mode); 82 83 XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode); 62 84 63 85 COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 64 86 } 65 66 void GlobalQuest::initialize(void) 67 { 68 RegisterObject(GlobalQuest); 87 88 /** 89 @brief 90 Fails the quest for all players. 91 Invokes the failEffects on all the players possessing this quest. 92 @param player 93 The player failing it. 94 @return 95 Returns true if the quest could be failed, false if not. 96 */ 97 bool GlobalQuest::fail(ControllableEntity* player) 98 { 99 if(this->isFailable(player)) //!< Check whether the quest can be failed. 100 { 101 this->setStatus(player, questStatus::failed); 102 103 //! Iterate through all players possessing this quest. 104 for(std::set<ControllableEntity*>::const_iterator it = players_.begin(); it != players_.end(); it++) 105 { 106 QuestEffect::invokeEffects(*it, this->failEffects_); 107 } 108 109 return true; 110 } 111 112 COUT(2) << "A non-completable quest was trying to be failed." << std::endl; 113 return false; 114 } 115 116 /** 117 @brief 118 Completes the quest for all players. 119 Invokes the completeEffects on all the players possessing this quest. 120 Invokes the reward effects on the player completing the quest. 121 @param player 122 The player completing it. 123 @return 124 Returns true if the quest could be completed, false if not. 125 */ 126 bool GlobalQuest::complete(ControllableEntity* player) 127 { 128 if(this->isCompletable(player)) //!< Check whether the quest can be completed. 129 { 130 this->setStatus(player, questStatus::completed); 131 132 //! Iterate through all players possessing the quest. 133 for(std::set<ControllableEntity*>::const_iterator it = players_.begin(); it != players_.end(); it++) 134 { 135 QuestEffect::invokeEffects(*it, this->completeEffects_); 136 } 137 138 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward effects on the player completing the quest. 139 return true; 140 } 141 142 COUT(2) << "A non-completable quest was trying to be completed." << std::endl; 143 return false; 69 144 } 70 145 … … 79 154 Throws an exception if either isInactive() of isActive() throws one. 80 155 */ 81 bool GlobalQuest::isStartable(const Player* player) const156 bool GlobalQuest::isStartable(const ControllableEntity* player) const 82 157 { 83 158 return this->isInactive(player) || this->isActive(player); … … 94 169 Throws an Exception if isActive() throws one. 95 170 */ 96 bool GlobalQuest::isFailable(const Player* player) const171 bool GlobalQuest::isFailable(const ControllableEntity* player) const 97 172 { 98 173 return this->isActive(player); … … 110 185 Throws an Exception if isActive() throws one. 111 186 */ 112 bool GlobalQuest::isCompletable(const Player* player) const187 bool GlobalQuest::isCompletable(const ControllableEntity* player) const 113 188 { 114 189 return this->isActive(player); … … 123 198 Throws an Exception if player is NULL. 124 199 */ 125 questStatus::Enum GlobalQuest::getStatus(const Player* player) const126 { 127 if(player == NULL) 128 { 129 ThrowException(Argument, "The input Player* is NULL.");130 } 131 132 // TDO: Does this really work???133 std::set< Player*>::const_iterator it = this->players_.find((Player*)(void*)player);134 if (it != this->players_.end()) 200 questStatus::Enum GlobalQuest::getStatus(const ControllableEntity* player) const 201 { 202 if(player == NULL) //!< We don't want NULL-Pointers! 203 { 204 ThrowException(Argument, "The input ControllableEntity* is NULL."); 205 } 206 207 //! Find the player. 208 std::set<ControllableEntity*>::const_iterator it = this->players_.find((ControllableEntity*)(void*)player); 209 if (it != this->players_.end()) //!< If the player was found. 135 210 { 136 211 return this->status_; 137 212 } 138 else 139 { 140 return questStatus::inactive; 141 } 142 213 214 return questStatus::inactive; 143 215 } 144 216 … … 154 226 Returns false if player is NULL. 155 227 */ 156 bool GlobalQuest::setStatus( Player* player, const questStatus::Enum & status)157 { 158 if(player == NULL) 228 bool GlobalQuest::setStatus(ControllableEntity* player, const questStatus::Enum & status) 229 { 230 if(player == NULL) //!< We don't want NULL-Pointers! 159 231 { 160 232 return false; 161 233 } 162 234 163 std::set<Player*>::const_iterator it = this->players_.find(player); 235 //! Find the player. 236 std::set<ControllableEntity*>::const_iterator it = this->players_.find(player); 164 237 if (it == this->players_.end()) //!< Player is not yet in the list. 165 238 { 166 this->players_.insert(player); 167 } 168 this->status_ = status; 239 this->players_.insert(player); //!< Add the player to the set. 240 } 241 242 this->status_ = status; //!< Set the status, which is global, remember...? 169 243 return true; 170 244 } 245 246 /** 247 @brief 248 Adds a reward effect to the list of reward effects. 249 @param effect 250 The effect to be added. 251 @return 252 Returns true if successful. 253 */ 254 bool GlobalQuest::addRewardEffect(QuestEffect* effect) 255 { 256 if(effect == NULL) //!< We don't want NULL-Pointers! 257 { 258 COUT(2) << "The reward effect to be added to quest {" << this->getId() << "} was NULL." << std::endl; 259 return false; 260 } 261 262 this->rewards_.push_back(effect); //!< Add the effect to the list. 263 264 COUT(3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl; 265 return true; 266 } 267 268 /** 269 @brief 270 Returns the reward effect at the given index. 271 @param index 272 The index. 273 @return 274 Returns the QuestEffect at the given index. 275 */ 276 const QuestEffect* GlobalQuest::getRewardEffects(unsigned int index) const 277 { 278 int i = index; 279 for (std::list<QuestEffect*>::const_iterator effect = this->rewards_.begin(); effect != this->rewards_.end(); ++effect) 280 { 281 if(i == 0) 282 { 283 return *effect; 284 } 285 i--; 286 } 287 return NULL; 288 } 171 289 172 290 -
code/branches/questsystem2/src/orxonox/objects/quest/GlobalQuest.h
r2096 r2146 26 26 * 27 27 */ 28 29 /** 30 @file GlobalQuest.h 31 @brief 32 Definition of the GlobalQuest class. 33 */ 28 34 29 35 #ifndef _GlobalQuest_H__ … … 33 39 34 40 #include <set> 41 #include <list> 35 42 36 43 #include "core/XMLPort.h" … … 39 46 namespace orxonox { 40 47 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 48 /** 44 49 @brief 45 50 Global quests are quests, that have the same status for all players. 46 This means, that when a player successfully completes this quest, it is completed for all players that have it. 51 This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it. 52 53 Creating a GlobalQuest through XML goes as follows: 54 55 <GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 56 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 59 ... 60 <Quest id="questIdn" /> 61 </subquests> 62 <hints> 63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 64 ... 65 <QuestHint id="hintIdn" /> 66 </hints> 67 <fail-effects> 68 <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation. 69 ... 70 <QuestEffect /> 71 </fail-effects> 72 <complete-effects> 73 <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is completed, see QuestEffect for the full XML representation. 74 ... 75 <QuestEffect /> 76 </complete-effects> 77 <reward-effects> 78 <QuestEffect /> //A list of QuestEffects, invoked on the player completing this quest. See QuestEffect for the full XML representation. 79 ... 80 <QuestEffect /> 81 </reward-effects> 82 </GlobalQuest> 47 83 @author 48 84 Damian 'Mozork' Frick … … 54 90 virtual ~GlobalQuest(); 55 91 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 92 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a GlobalQuest object through XML. 93 94 virtual bool fail(ControllableEntity* player); //!< Fails the quest. 95 virtual bool complete(ControllableEntity* player); //!< Completes the quest. 57 96 58 97 protected: 59 virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started.60 virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed.61 virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed.98 virtual bool isStartable(const ControllableEntity* player) const; //!< Checks whether the quest can be started. 99 virtual bool isFailable(const ControllableEntity* player) const; //!< Checks whether the quest can be failed. 100 virtual bool isCompletable(const ControllableEntity* player) const; //!< Checks whether the quest can be completed. 62 101 63 virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player.64 virtual bool setStatus( Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.102 virtual questStatus::Enum getStatus(const ControllableEntity* player) const; //!< Returns the status of the quest for a specific player. 103 virtual bool setStatus(ControllableEntity* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 65 104 66 105 private: 67 std::set< Player*> players_; //!< The set of players which possess this quest.106 std::set<ControllableEntity*> players_; //!< The set of players which possess this quest. 68 107 questStatus::Enum status_; //!< The status of this quest. 108 std::list<QuestEffect*> rewards_; //!< Reward effects only invoked on the player completing the quest. 109 110 bool addRewardEffect(QuestEffect* effect); //!< Adds a reward effect to the list of reward effects. 111 const QuestEffect* getRewardEffects(unsigned int index) const; //!< Returns the reward effect at the given index. 69 112 70 void initialize(void); 113 void initialize(void); //!< Initializes the object. 71 114 72 115 }; -
code/branches/questsystem2/src/orxonox/objects/quest/LocalQuest.cc
r2105 r2146 27 27 */ 28 28 29 /** 30 @file LocalQuest.cc 31 @brief 32 Implementation of the LocalQuest class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "LocalQuest.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/worldentities/ControllableEntity.h" 42 #include "QuestEffect.h" 43 35 44 namespace orxonox { 36 45 37 46 CreateFactory(LocalQuest); 38 47 48 /** 49 @brief 50 Constructor. Initializes the object. 51 */ 39 52 LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator) 40 53 { 54 this->initialize(); 55 } 56 57 /** 58 @brief 59 Initializes the object. 60 */ 61 void LocalQuest::initialize(void) 62 { 41 63 RegisterObject(LocalQuest); 42 43 this->initialize();44 64 } 45 65 … … 53 73 } 54 74 75 /** 76 @brief 77 Method for creating a LocalQuest object through XML. 78 */ 55 79 void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 80 { … … 60 84 } 61 85 62 void LocalQuest::initialize(void) 63 { 64 RegisterObject(LocalQuest); 86 /** 87 @brief 88 Fails the quest for a given player. 89 Invokes all the failEffects on the player. 90 @param player 91 The player. 92 @return 93 Returns true if the quest could be failed, false if not. 94 */ 95 bool LocalQuest::fail(ControllableEntity* player) 96 { 97 if(this->isFailable(player)) //!< Checks whether the quest can be failed. 98 { 99 this->setStatus(player, questStatus::failed); 100 QuestEffect::invokeEffects(player, this->failEffects_); //!< Invoke the failEffects. 101 return true; 102 } 103 104 COUT(2) << "A non-failable quest was trying to be failed." << std::endl; 105 return false; 106 } 107 108 /** 109 @brief 110 Completes the quest for a given player. 111 Invokes all the completeEffects on the player. 112 @param player 113 The player. 114 @return 115 Returns true if the quest could be completed, false if not. 116 */ 117 bool LocalQuest::complete(ControllableEntity* player) 118 { 119 if(this->isCompletable(player)) //!< Checks whether the quest can be completed. 120 { 121 this->setStatus(player, questStatus::completed); 122 QuestEffect::invokeEffects(player, this->completeEffects_); //!< Invoke the completeEffects. 123 return true; 124 } 125 126 COUT(2) << "A non-completable quest was trying to be completed." << std::endl; 127 return false; 65 128 } 66 129 … … 73 136 Returns true if the quest can be started, false if not. 74 137 @throws 75 Throws an exception if isInactive( Player*) throws one.76 */ 77 bool LocalQuest::isStartable(const Player* player) const138 Throws an exception if isInactive(ControllableEntity*) throws one. 139 */ 140 bool LocalQuest::isStartable(const ControllableEntity* player) const 78 141 { 79 142 return this->isInactive(player); … … 88 151 Returns true if the quest can be failed, false if not. 89 152 @throws 90 Throws an exception if isActive( Player*) throws one.91 */ 92 bool LocalQuest::isFailable(const Player* player) const153 Throws an exception if isActive(ControllableEntity*) throws one. 154 */ 155 bool LocalQuest::isFailable(const ControllableEntity* player) const 93 156 { 94 157 return this->isActive(player); … … 103 166 Returns true if the quest can be completed, false if not. 104 167 @throws 105 Throws an exception if isInactive( Player*) throws one.106 */ 107 bool LocalQuest::isCompletable(const Player* player) const168 Throws an exception if isInactive(ControllableEntity*) throws one. 169 */ 170 bool LocalQuest::isCompletable(const ControllableEntity* player) const 108 171 { 109 172 return this->isActive(player); … … 120 183 Throws an Exception if player is NULL. 121 184 */ 122 questStatus::Enum LocalQuest::getStatus(const Player* player) const123 { 124 if(player == NULL) 125 { 126 ThrowException(Argument, "The input Player* is NULL.");127 } 128 129 std::map< Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'.130 if (it != this->playerStatus_.end()) 185 questStatus::Enum LocalQuest::getStatus(const ControllableEntity* player) const 186 { 187 if(player == NULL) //!< No player has no defined status. 188 { 189 ThrowException(Argument, "The input ControllableEntity* is NULL."); 190 } 191 192 std::map<ControllableEntity*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((ControllableEntity*)(void*)player); //Thx. to x3n for the (ControllableEntity*)(void*) 'hack'. 193 if (it != this->playerStatus_.end()) //!< If there is a player in the map. 131 194 { 132 195 return it->second; 133 196 } 134 return questStatus::inactive; 197 198 return questStatus::inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'. 135 199 } 136 200 … … 138 202 @brief 139 203 Sets the status for a specific player. 140 But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing. 141 @param player 142 The player .204 But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing. Really! 205 @param player 206 The player the status should be set for. 143 207 @param status 144 The status .208 The status to be set. 145 209 @return 146 210 Returns false if player is NULL. 147 211 */ 148 bool LocalQuest::setStatus( Player* player, const questStatus::Enum & status)149 { 150 if(player == NULL) 212 bool LocalQuest::setStatus(ControllableEntity* player, const questStatus::Enum & status) 213 { 214 if(player == NULL) //!< We can't set a status for no player. 151 215 { 152 216 return false; 153 217 } 218 154 219 this->playerStatus_[player] = status; 155 220 return true; -
code/branches/questsystem2/src/orxonox/objects/quest/LocalQuest.h
r2096 r2146 26 26 * 27 27 */ 28 29 /** 30 @file LocalQuest.h 31 @brief 32 Definition of the LocalQuest class. 33 */ 28 34 29 35 #ifndef _LocalQuest_H__ … … 40 46 namespace orxonox { 41 47 42 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.43 44 48 /** 45 49 @brief 46 50 Handles quests which have different states for different players. 51 LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest. 52 53 Creating a LocalQuest through XML goes as follows: 54 55 <LocalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 56 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 59 ... 60 <Quest id="questIdn" /> 61 </subquests> 62 <hints> 63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 64 ... 65 <QuestHint id="hintIdn" /> 66 </hints> 67 <fail-effects> 68 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation. 69 ... 70 <QuestEffect /> 71 </fail-effects> 72 <complete-effects> 73 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation. 74 ... 75 <QuestEffect /> 76 </complete-effects> 77 </LocalQuest> 47 78 @author 48 79 Damian 'Mozork' Frick … … 54 85 virtual ~LocalQuest(); 55 86 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 87 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a LocalQuest object through XML. 88 89 virtual bool fail(ControllableEntity* player); //!< Fails the quest. 90 virtual bool complete(ControllableEntity* player); //!< Completes the quest. 57 91 58 92 protected: 59 virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started.60 virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed.61 virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed.93 virtual bool isStartable(const ControllableEntity* player) const; //!< Checks whether the quest can be started. 94 virtual bool isFailable(const ControllableEntity* player) const; //!< Checks whether the quest can be failed. 95 virtual bool isCompletable(const ControllableEntity* player) const; //!< Checks whether the quest can be completed. 62 96 63 virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player.64 virtual bool setStatus( Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player.97 virtual questStatus::Enum getStatus(const ControllableEntity* player) const; //!< Returns the status of the quest for a specific player. 98 virtual bool setStatus(ControllableEntity* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 65 99 66 100 private: 67 std::map< Player*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.101 std::map<ControllableEntity*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 68 102 69 void initialize(void); 103 void initialize(void); //!< Initializes the object. 70 104 71 105 }; 72 73 106 74 107 } -
code/branches/questsystem2/src/orxonox/objects/quest/Quest.cc
r2105 r2146 26 26 * 27 27 */ 28 29 /** 30 @file Quest.cc 31 @brief 32 Implementation of the Quest class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 32 38 #include "core/CoreIncludes.h" 33 39 40 #include "orxonox/objects/worldentities/ControllableEntity.h" 34 41 #include "QuestManager.h" 35 42 #include "QuestDescription.h" … … 39 46 namespace orxonox { 40 47 48 /** 49 @brief 50 Constructor. Initializes object. 51 */ 41 52 Quest::Quest(BaseObject* creator) : QuestItem(creator) 42 53 { 54 this->initialize(); 55 } 56 57 /** 58 @brief 59 Initializes the object. Needs to be called first in every constructor of this class. 60 Sets defaults. 61 */ 62 void Quest::initialize(void) 63 { 43 64 RegisterObject(Quest); 44 65 45 this-> initialize();66 this->parentQuest_ = NULL; 46 67 } 47 68 … … 55 76 } 56 77 78 /** 79 @brief 80 Method for creating a Quest object through XML. 81 */ 57 82 void Quest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 58 83 { 59 84 SUPER(Quest, XMLPort, xmlelement, mode); 60 85 61 XMLPortObject(Quest, Quest, " ", addSubQuest, getSubQuests, xmlelement, mode);62 XMLPortObject(Quest, QuestHint, " ", addHint, getHints, xmlelement, mode);86 XMLPortObject(Quest, Quest, "subquests", addSubQuest, getSubQuests, xmlelement, mode); 87 XMLPortObject(Quest, QuestHint, "hints", addHint, getHints, xmlelement, mode); 63 88 XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffects, xmlelement, mode); 64 89 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffects, xmlelement, mode); 65 90 66 91 QuestManager::registerQuest(this); //Registers the quest with the QuestManager. 67 }68 69 /**70 @brief71 Initializes the object. Needs to be called first in every constructor of this class.72 */73 void Quest::initialize(void)74 {75 RegisterObject(Quest);76 77 this->parentQuest_ = NULL;78 92 } 79 93 … … 88 102 bool Quest::setParentQuest(Quest* quest) 89 103 { 90 if(quest == NULL) 104 if(quest == NULL) //!< We don't want to set NULL-Pointers. 91 105 { 92 106 COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 110 124 bool Quest::addSubQuest(Quest* quest) 111 125 { 112 if(quest == NULL) 126 if(quest == NULL) //!< We don't want to set NULL-Pointers. 113 127 { 114 128 COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 116 130 } 117 131 118 quest->setParentQuest(this); 119 this->subQuests_.push_back(quest); 132 quest->setParentQuest(this); //!< Sets the current quest (this) as parent quest for the added subquest. 133 this->subQuests_.push_back(quest); //!< Adds the quest to the end of the list of subquests. 120 134 121 135 COUT(3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 134 148 bool Quest::addHint(QuestHint* hint) 135 149 { 136 if(hint == NULL) 150 if(hint == NULL) //!< We don't want to set NULL-Pointers. Seriously! 137 151 { 138 152 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; … … 140 154 } 141 155 142 this->hints_.push_back(hint);143 hint->setQuest(this);156 hint->setQuest(this); //!< Sets the current quest (this) as quest for the added hint. 157 this->hints_.push_back(hint); //!< Adds the hint to the end of the list of hints. 144 158 145 159 COUT(3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 149 163 /** 150 164 @brief 151 165 Adds an effect to the list of failEffects. 166 @param effect 167 The QuestEffect to be added. 168 @return 169 Returns true if successful. 152 170 */ 153 171 bool Quest::addFailEffect(QuestEffect* effect) 154 172 { 155 if(effect == NULL) 173 if(effect == NULL) //!< We don't want to set NULL-Pointers. 156 174 { 157 175 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 159 177 } 160 178 161 this->failEffects_.push_back(effect); 179 this->failEffects_.push_back(effect); //!< Adds the effect to the end of the list of failEffects. 162 180 163 181 COUT(3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 167 185 /** 168 186 @brief 169 187 Adds an effect to the list of completeEffects. 188 @param effect 189 The QuestEffect to be added. 190 @return 191 Returns true if successful. 170 192 */ 171 193 bool Quest::addCompleteEffect(QuestEffect* effect) 172 194 { 173 if(effect == NULL) 195 if(effect == NULL) //!< We don't want to set NULL-Pointers. 174 196 { 175 197 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 177 199 } 178 200 179 this->completeEffects_.push_back(effect); 201 this->completeEffects_.push_back(effect); //!< Adds the effect to the end of the list of completeEffects. 180 202 181 203 COUT(3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 185 207 /** 186 208 @brief 187 209 Returns the parent quest of the quest. 210 @return 211 Returns the parent quest of the quest. 188 212 */ 189 213 const Quest* Quest::getParentQuest(void) … … 194 218 /** 195 219 @brief 196 220 Returns the sub quest of the given index. 221 @param 222 The index. 223 @return 224 Returns the subquest of the given index. NULL if there is no element on the given index. 197 225 */ 198 226 const Quest* Quest::getSubQuests(unsigned int index) const 199 227 { 200 228 int i = index; 229 230 //! Iterate through all subquests. 201 231 for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest) 202 232 { 203 if(i == 0) 233 if(i == 0) //!< We're counting down... 204 234 { 205 235 return *subQuest; … … 207 237 i--; 208 238 } 209 return NULL; 210 } 211 212 /** 213 @brief 214 239 240 return NULL; //!< If the index is greater than the number of elements in the list. 241 } 242 243 /** 244 @brief 245 Returns the hint of the given index. 246 @param 247 The index. 248 @return 249 Returns the hint of the given index. NULL if there is no element on the given index. 215 250 */ 216 251 const QuestHint* Quest::getHints(unsigned int index) const 217 252 { 218 253 int i = index; 254 255 //! Iterate through all hints. 219 256 for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint) 220 257 { 221 if(i == 0) 258 if(i == 0) //!< We're counting down... 222 259 { 223 260 return *hint; … … 225 262 i--; 226 263 } 227 return NULL; 228 } 229 230 /** 231 @brief 232 264 return NULL; //!< If the index is greater than the number of elements in the list. 265 } 266 267 /** 268 @brief 269 Returns the failEffect of the given index. 270 @param 271 The index. 272 @return 273 Returns the failEffect of the given index. NULL if there is no element on the given index. 233 274 */ 234 275 const QuestEffect* Quest::getFailEffects(unsigned int index) const 235 276 { 236 277 int i = index; 278 279 //! Iterate through all failEffects. 237 280 for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect) 238 281 { 239 if(i == 0) 282 if(i == 0) //!< We're counting down... 240 283 { 241 284 return *effect; … … 243 286 i--; 244 287 } 245 return NULL; 246 } 247 248 /** 249 @brief 250 288 return NULL; //!< If the index is greater than the number of elements in the list. 289 } 290 291 /** 292 @brief 293 Returns the completeEffect of the given index. 294 @param 295 The index. 296 @return 297 Returns the completeEffect of the given index. NULL if there is no element on the given index. 251 298 */ 252 299 const QuestEffect* Quest::getCompleteEffects(unsigned int index) const 253 300 { 254 301 int i = index; 302 303 //! Iterate through all completeEffects. 255 304 for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect) 256 305 { 257 if(i == 0) 306 if(i == 0) //!< We're counting down... 258 307 { 259 308 return *effect; … … 261 310 i--; 262 311 } 263 return NULL; 312 return NULL; //!< If the index is greater than the number of elements in the list. 264 313 } 265 314 … … 274 323 Throws an exception if getStatus throws one. 275 324 */ 276 bool Quest::isInactive(const Player* player) const325 bool Quest::isInactive(const ControllableEntity* player) const 277 326 { 278 327 return this->getStatus(player) == questStatus::inactive; … … 289 338 Throws an exception if getStatus throws one. 290 339 */ 291 bool Quest::isActive(const Player* player) const340 bool Quest::isActive(const ControllableEntity* player) const 292 341 { 293 342 … … 305 354 Throws an exception if getStatus throws one. 306 355 */ 307 bool Quest::isFailed(const Player* player) const356 bool Quest::isFailed(const ControllableEntity* player) const 308 357 { 309 358 return this->getStatus(player) == questStatus::failed; … … 320 369 Throws an exception if getStatus throws one. 321 370 */ 322 bool Quest::isCompleted(const Player* player) const371 bool Quest::isCompleted(const ControllableEntity* player) const 323 372 { 324 373 return this->getStatus(player) == questStatus::completed; … … 327 376 /** 328 377 @brief 329 Starts the quest .378 Starts the quest for an input player. 330 379 @param player 331 380 The player. … … 333 382 Returns true if the quest could be started, false if not. 334 383 */ 335 bool Quest::start( Player* player)336 { 337 if(this->isStartable(player)) 384 bool Quest::start(ControllableEntity* player) 385 { 386 if(this->isStartable(player)) //!< Checks whether the quest can be started. 338 387 { 339 388 this->setStatus(player, questStatus::active); 340 389 return true; 341 390 } 391 342 392 COUT(2) << "A non-startable quest was trying to be started." << std::endl; 343 393 return false; 344 394 } 345 395 346 /**347 @brief348 Fails the quest.349 @param player350 The player.351 @return352 Returns true if the quest could be failed, false if not.353 */354 bool Quest::fail(Player* player)355 {356 if(this->isFailable(player))357 {358 this->setStatus(player, questStatus::failed);359 QuestEffect::invokeEffects(player, this->failEffects_);360 return true;361 }362 COUT(2) << "A non-failable quest was trying to be failed." << std::endl;363 return false;364 }365 366 /**367 @brief368 Completes the quest.369 @param player370 The player.371 @return372 Returns true if the quest could be completed, false if not.373 */374 bool Quest::complete(Player* player)375 {376 if(this->isCompletable(player))377 {378 this->setStatus(player, questStatus::completed);379 QuestEffect::invokeEffects(player, this->completeEffects_);380 return true;381 }382 COUT(2) << "A non-completable quest was trying to be completed." << std::endl;383 return false;384 }385 386 396 } -
code/branches/questsystem2/src/orxonox/objects/quest/Quest.h
r2096 r2146 26 26 * 27 27 */ 28 28 29 /** 30 @file Quest.h 31 @brief 32 Definition of the Quest class. 33 34 The Quest is the parent class of LocalQuest and GlobalQuest. 35 */ 36 29 37 #ifndef _Quest_H__ 30 38 #define _Quest_H__ … … 38 46 #include "QuestItem.h" 39 47 48 40 49 namespace questStatus 41 50 { 42 51 52 //!Different states of a quest. 43 53 enum Enum 44 54 { … … 53 63 namespace orxonox { 54 64 55 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.56 57 65 /** 58 66 @brief … … 60 68 A quest has a list of subquests and a parentquest (if it is not a rootquest). 61 69 Each quest exists only once but it has a different status (inactive, active, failed or completed) for each player. 70 A quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the quest. 71 A quest has a list of QuestEffects that are invoked when the quest is failed and also a list of effects that are invoked, when the quest is completed. 72 73 Quest itself should not be instantiated, if you want to create a quest either go for LocalQuest or GlobalQuest, whichever suits you needs better. 62 74 @author 63 75 Damian 'Mozork' Frick … … 69 81 virtual ~Quest(); 70 82 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 83 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Quest object through XML. 72 84 73 85 inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. … … 76 88 { return this->subQuests_; } 77 89 78 bool isInactive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.79 bool isActive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'active'.80 bool isFailed(const Player* player) const; //!< Returns true if the quest status for the specific player is 'failed'.81 bool isCompleted(const Player* player) const; //!< Returns true if the quest status for the specific player is 'completed'.90 bool isInactive(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 91 bool isActive(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'active'. 92 bool isFailed(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 93 bool isCompleted(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 82 94 83 bool start( Player* player); //!< Sets a quest to active.84 bool fail(Player* player); //!< Fails the quest.85 bool complete(Player* player); //!< Completes the quest.95 bool start(ControllableEntity* player); //!< Sets a quest to active. 96 virtual bool fail(ControllableEntity* player) = 0; //!< Fails the quest. 97 virtual bool complete(ControllableEntity* player) = 0; //!< Completes the quest. 86 98 87 99 protected: 88 void initialize(void); //!< Initialize dthe object.100 void initialize(void); //!< Initializes the object. 89 101 90 virtual bool isStartable(const Player* player) const = 0; //!< Checks whether the quest can be started.91 virtual bool isFailable(const Player* player) const = 0; //!< Checks whether the quest can be failed.92 virtual bool isCompletable(const Player* player) const = 0; //!< Checks whether the quest can be completed.102 virtual bool isStartable(const ControllableEntity* player) const = 0; //!< Checks whether the quest can be started. 103 virtual bool isFailable(const ControllableEntity* player) const = 0; //!< Checks whether the quest can be failed. 104 virtual bool isCompletable(const ControllableEntity* player) const = 0; //!< Checks whether the quest can be completed. 93 105 94 106 bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest. 95 107 bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest. 96 108 bool addHint(QuestHint* hint); //!< Add a hint to the list of hints. 97 bool addFailEffect(QuestEffect* effect); 98 bool addCompleteEffect(QuestEffect* effect); 109 bool addFailEffect(QuestEffect* effect); //!< Adds an effect to the list of failEffects. 110 bool addCompleteEffect(QuestEffect* effect); //!< Adds an effect to the list of completeEffects. 99 111 100 const Quest* getParentQuest(void); 101 const Quest* getSubQuests(unsigned int index) const; 102 const QuestHint* getHints(unsigned int index) const; 103 const QuestEffect* getFailEffects(unsigned int index) const; 104 const QuestEffect* getCompleteEffects(unsigned int index) const; 112 const Quest* getParentQuest(void); //!< Returns the parent quest of the quest. 113 const Quest* getSubQuests(unsigned int index) const; //!<Returns the sub quest of the given index. 114 const QuestHint* getHints(unsigned int index) const; //!< Returns the hint of the given index. 115 const QuestEffect* getFailEffects(unsigned int index) const; //!< Returns the failEffect of the given index. 116 const QuestEffect* getCompleteEffects(unsigned int index) const; //!Returns the completeEffect of the given index. 105 117 106 virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player.107 virtual bool setStatus( Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.118 virtual questStatus::Enum getStatus(const ControllableEntity* player) const = 0; //!< Returns the status of the quest for a specific player. 119 virtual bool setStatus(ControllableEntity* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. 108 120 109 121 Quest* parentQuest_; //!< Pointer to the parent quest. -
code/branches/questsystem2/src/orxonox/objects/quest/QuestEffect.cc
r2105 r2146 32 32 #include "core/CoreIncludes.h" 33 33 34 #include "orxonox/objects/worldentities/ControllableEntity.h" 35 34 36 namespace orxonox { 35 37 … … 63 65 Returns false if there was an error, view console of log for further detail. 64 66 */ 65 bool QuestEffect::invokeEffects( Player* player, std::list<QuestEffect*> & effects)67 bool QuestEffect::invokeEffects(ControllableEntity* player, std::list<QuestEffect*> & effects) 66 68 { 67 69 bool check = true; -
code/branches/questsystem2/src/orxonox/objects/quest/QuestEffect.h
r2096 r2146 38 38 namespace orxonox { 39 39 40 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.41 42 40 /** 43 41 @brief … … 52 50 virtual ~QuestEffect(); 53 51 54 virtual bool invoke( Player* player) = 0; //!< Invokes the effect.55 static bool invokeEffects( Player* player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list.52 virtual bool invoke(ControllableEntity* player) = 0; //!< Invokes the effect. 53 static bool invokeEffects(ControllableEntity* player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list. 56 54 57 55 -
code/branches/questsystem2/src/orxonox/objects/quest/QuestHint.cc
r2105 r2146 26 26 * 27 27 */ 28 29 /** 30 @file QuestHint.cc 31 @brief 32 Implementation of the QuestHint class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/worldentities/ControllableEntity.h" 35 42 #include "Quest.h" 36 43 … … 41 48 /** 42 49 @brief 43 Constructor. 50 Constructor. Initializes the object. 44 51 */ 45 52 QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator) 46 53 { 54 this->initialize(); 55 } 56 57 /** 58 @brief 59 Initialize the object. 60 */ 61 void QuestHint::initialize(void) 62 { 47 63 RegisterObject(QuestHint); 48 49 this->initialize();50 64 } 51 65 … … 59 73 } 60 74 61 void QuestHint::initialize(void) 62 { 63 RegisterObject(QuestHint); 64 } 65 75 /** 76 @brief 77 Method for creating a QuestHint object through XML. 78 */ 66 79 void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 67 80 { … … 82 95 Returns true if the hint is active for the specified player. 83 96 */ 84 bool QuestHint::isActive( Player* player)97 bool QuestHint::isActive(ControllableEntity* player) 85 98 { 86 if(player == NULL) 99 if(player == NULL) //!< NULL-Pointers are ugly! 87 100 { 88 ThrowException(Argument, "The input Player* is NULL.");101 ThrowException(Argument, "The input ControllableEntity* is NULL."); 89 102 return false; 90 103 } 91 104 92 std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player); 93 if (it != this->playerStatus_.end()) 105 //! Find the player. 106 std::map<ControllableEntity*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player); 107 if (it != this->playerStatus_.end()) //!< If the player is in the map. 94 108 { 95 109 return it->second; 96 110 } 111 97 112 return questStatus::inactive; 98 113 } … … 106 121 Returns true if the activation was successful, false if there were problems. 107 122 */ 108 bool QuestHint:: activate(Player* player)123 bool QuestHint::setActive(ControllableEntity* player) 109 124 { 110 if(this->quest_->isActive(player)) 125 if(this->quest_->isActive(player)) //!< For a hint to get activated the quest must be active. 111 126 { 112 if(!(this->isActive(player))) 127 if(!(this->isActive(player))) //!< If the hint is already active, activation is pointless. 113 128 { 114 129 this->playerStatus_[player] = questHintStatus::active; … … 121 136 } 122 137 } 138 123 139 COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl; 124 140 return false; … … 129 145 Sets the quest the QuestHitn belongs to. 130 146 @param quest 147 The quest to be set as quest the hint is attached to. 131 148 @return 149 Returns true if successful. 132 150 */ 133 151 bool QuestHint::setQuest(Quest* quest) 134 152 { 135 if(quest == NULL) 153 if(quest == NULL) //!< NULL-Pointer. Again..? 136 154 { 137 155 COUT(2) << "The input Quest* is NULL." << std::endl; -
code/branches/questsystem2/src/orxonox/objects/quest/QuestHint.h
r2096 r2146 26 26 * 27 27 */ 28 29 /** 30 @file QuestHint.h 31 @brief 32 Definition of the QuestHint class. 33 */ 28 34 29 35 #ifndef _QuestHint_H__ … … 41 47 { 42 48 49 //! The status of the hint. 43 50 enum Enum 44 51 { … … 52 59 { 53 60 54 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.55 56 61 /** 57 62 @brief 58 63 Represents a hint in the game towards completing a Quest. 59 64 Consists of title and description in textual form and must belong to a quest. 60 A QuestHit has a defined status (inactive or active, where inactive is default) for each player, which means each QuestHint exists only once for all players, it doesn't belong to a player, it just has different stati for each of them. 65 A QuestHit has a defined status (inactive or active, where inactive is default) for each player, which means each QuestHint exists only once for all players, it doesn't belong to a player, it just has different states for each of them. 66 67 Creating a QuestHint through XML goes as follows: 68 69 <QuestHint id="hintId"> //Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 70 <QuestDesctription title="" description="" /> 71 </QuestHint> 61 72 @author 62 73 Damian 'Mozork' Frick … … 69 80 virtual ~QuestHint(); 70 81 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 82 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestHint object through XML. 72 83 73 bool isActive( Player* player); //!< Returns true if the hint is active for the input player.84 bool isActive(ControllableEntity* player); //!< Returns true if the hint is active for the input player. 74 85 75 bool activate(Player* player); //!< Activates the hint for the input player. 76 86 bool setActive(ControllableEntity* player); //!< Activates the hint for the input player. 77 87 bool setQuest(Quest* quest); //!< Sets the quest the hint belongs to. 78 88 79 inline Quest* getQuest(void) 89 inline Quest* getQuest(void) //!< Returns the quest the hint is attached to. 80 90 { return this->quest_; } 81 91 82 92 private: 93 Quest* quest_; //!< The quest the hint belongs to. 94 std::map<ControllableEntity*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 83 95 84 void initialize(void); 85 86 Quest* quest_; //!< The quest the hint belongs to. 87 std::map<Player*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 96 void initialize(void); //!< Initializes the object. 88 97 89 98 }; -
code/branches/questsystem2/src/orxonox/objects/quest/QuestItem.cc
r2105 r2146 26 26 * 27 27 */ 28 29 /** 30 @file QuestItem.cc 31 @brief 32 Implementation of the QuestItem class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 36 42 namespace orxonox { 37 43 44 /** 45 @brief 46 Constructor. Registers and initializes the object. 47 */ 38 48 QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) 39 49 { … … 42 52 this->initialize(); 43 53 } 44 45 /** 46 @brief 47 Destructor. 48 */ 49 QuestItem::~QuestItem() 50 { 51 52 } 53 54 void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 { 56 SUPER(QuestItem, XMLPort, xmlelement, mode); 57 58 XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode); 59 //Doesn't getDescription have to be of type getDescription(unsigned int) ? 60 //XMLPortObjectTemplate(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode, unsigned int); 61 XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode); 62 63 } 64 65 54 66 55 /** 67 56 @brief … … 76 65 } 77 66 67 /** 68 @brief 69 Destructor. 70 */ 71 QuestItem::~QuestItem() 72 { 73 74 } 75 76 /** 77 @brief 78 Method for creating a QuestItem object through XML. 79 */ 80 void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 81 { 82 SUPER(QuestItem, XMLPort, xmlelement, mode); 83 84 XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode); 85 XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode); 86 } 87 88 /** 89 @brief 90 Sets the id of the QuestItem. 91 The id must be of GUID form. See 'http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure' for more information. 92 @param id 93 The id to be set. 94 */ 78 95 void QuestItem::setId(const std::string & id) 79 96 { 80 if(!isId(id)) 97 if(!isId(id)) //!< Checks whether the id is a valid id. 81 98 { 82 99 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; 83 100 return; 84 101 } 102 85 103 this->id_ = id; 86 104 } 87 88 //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem.89 //{90 // if(index != 0)91 // return NULL;92 // return this->description_;93 //}94 105 95 106 /** -
code/branches/questsystem2/src/orxonox/objects/quest/QuestItem.h
r2096 r2146 26 26 * 27 27 */ 28 29 /** 30 @file QuestItem.h 31 @brief 32 Definition of the QuestItem class. 33 34 The QuestItem is the parent class of Quest and QuestHint. 35 */ 36 28 37 29 38 #ifndef _QuestItem_H__ … … 54 63 virtual ~QuestItem(); 55 64 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 65 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestItem object through XML. 57 66 58 67 inline const std::string & getId(void) const //!< Returns the id of this quest. … … 60 69 inline const QuestDescription* getDescription(void) const //!< Returns the description of the QuestItem. 61 70 { return this->description_; } 62 //const QuestDescription* getDescription(unsigned int index) const; //!< Returns the description of the QuestItem.63 71 64 72 static bool isId(const std::string & id); //!< Checks whether a given id is valid. 65 73 66 74 protected: 67 void setId(const std::string & id); 68 inline void setDescription(QuestDescription* description) 75 void setId(const std::string & id); //!< Sets the id of the QuestItem. 76 inline void setDescription(QuestDescription* description) //!< Sets the description of the QuestItem. 69 77 { this->description_ = description; } 70 78 -
code/branches/questsystem2/src/orxonox/objects/quest/Rewardable.h
r2096 r2146 36 36 namespace orxonox { 37 37 38 class Player; //Forward declaration, remove when fully integrated in objecthirarchy.39 40 38 /** 41 39 @brief … … 51 49 virtual ~Rewardable(); 52 50 53 virtual bool reward( Player* player) = 0; //!<Method to transcribe a rewardable object to the player.51 virtual bool reward(ControllableEntity* player) = 0; //!<Method to transcribe a rewardable object to the player. 54 52 55 53 };
Note: See TracChangeset
for help on using the changeset viewer.