Changeset 7456 for code/trunk/src/modules/questsystem
- Timestamp:
- Sep 15, 2010, 7:29:16 PM (14 years ago)
- Location:
- code/trunk/src/modules/questsystem
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/GlobalQuest.cc
r7163 r7456 28 28 29 29 /** 30 @file 30 @file GlobalQuest.cc 31 31 @brief Implementation of the GlobalQuest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 38 39 #include "QuestEffect.h" 39 40 … … 84 85 bool GlobalQuest::fail(PlayerInfo* player) 85 86 { 86 if(!this->isFailable(player)) // !<Check whether the Quest can be failed.87 if(!this->isFailable(player)) // Check whether the Quest can be failed. 87 88 { 88 89 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; … … 92 93 Quest::fail(player); 93 94 94 //! Iterate through all players possessing this Quest. 95 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 96 { 97 QuestEffect::invokeEffects(*it, this->getFailEffectList()); 98 } 99 100 return true; 95 // Iterate through all players possessing this Quest. 96 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 97 QuestEffect::invokeEffects(*it, this->getFailEffectList()); 98 99 return true; 101 100 } 102 101 … … 113 112 bool GlobalQuest::complete(PlayerInfo* player) 114 113 { 115 if(!this->isCompletable(player)) // !<Check whether the Quest can be completed.114 if(!this->isCompletable(player)) // Check whether the Quest can be completed. 116 115 { 117 116 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; … … 119 118 } 120 119 121 // !Iterate through all players possessing the Quest.120 // Iterate through all players possessing the Quest. 122 121 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 123 {124 122 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 125 }126 123 127 124 Quest::complete(player); 128 125 129 QuestEffect::invokeEffects(player, this->rewards_); // !<Invoke reward QuestEffects on the player completing the Quest.126 QuestEffect::invokeEffects(player, this->rewards_); // Invoke reward QuestEffects on the player completing the Quest. 130 127 return true; 131 128 } … … 144 141 { 145 142 if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player))) 146 { 147 return false; 148 } 143 return false; 144 149 145 return (this->isInactive(player) && !(this->status_ == QuestStatus::Completed || this->status_ == QuestStatus::Failed)); 150 146 } … … 191 187 QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const 192 188 { 193 if(player == NULL) //!< We don't want NULL-Pointers!194 {189 //TODO: Replace with assert. 190 if(player == NULL) // We don't want NULL-Pointers! 195 191 ThrowException(Argument, "The input PlayerInfo* is NULL."); 196 } 197 198 //! Find the player. 192 193 // Find the player. 199 194 std::set<PlayerInfo*>::const_iterator it = this->players_.find((PlayerInfo*)(void*)player); 200 if (it != this->players_.end()) //!< If the player was found. 201 { 195 if (it != this->players_.end()) // If the player was found. 202 196 return this->status_; 203 }204 197 205 198 return QuestStatus::Inactive; … … 219 212 bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status) 220 213 { 221 if(player == NULL) //!< We don't want NULL-Pointers! 222 { 223 return false; 224 } 225 226 //! Find the player. 214 //TODO: Replace with assert. 215 if(player == NULL) // We don't want NULL-Pointers! 216 return false; 217 218 // Find the player. 227 219 std::set<PlayerInfo*>::const_iterator it = this->players_.find(player); 228 if (it == this->players_.end()) //!< Player is not yet in the list. 229 { 230 this->players_.insert(player); //!< Add the player to the set. 231 } 232 233 this->status_ = status; //!< Set the status, which is global, remember...? 220 if (it == this->players_.end()) // Player is not yet in the list. 221 this->players_.insert(player); // Add the player to the set. 222 223 this->status_ = status; // Set the status, which is global, remember...? 234 224 return true; 235 225 } … … 245 235 bool GlobalQuest::addRewardEffect(QuestEffect* effect) 246 236 { 247 if(effect == NULL) //!< We don't want NULL-Pointers! 237 //TODO: Replace with assert? 238 if(effect == NULL) // We don't want NULL-Pointers! 248 239 { 249 240 COUT(2) << "The reward effect to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 251 242 } 252 243 253 this->rewards_.push_back(effect); // !<Add the QuestEffect to the list.244 this->rewards_.push_back(effect); // Add the QuestEffect to the list. 254 245 255 246 COUT(4) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl; … … 271 262 { 272 263 if(i == 0) 273 {274 264 return *effect; 275 } 265 276 266 i--; 277 267 } … … 279 269 } 280 270 281 282 271 } -
code/trunk/src/modules/questsystem/GlobalQuest.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file GlobalQuest.h 31 31 @brief Definition of the GlobalQuest class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 45 46 /** 46 47 @brief 47 GlobalQuests are Quests, that have the same status for all players.48 GlobalQuests are @ref orxonox::Quest "Quests", that have the same status for all players. 48 49 This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it. 49 50 50 51 Creating a GlobalQuest through XML goes as follows: 51 52 52 @code 53 53 <GlobalQuest id="questId"> -
code/trunk/src/modules/questsystem/LocalQuest.cc
r7163 r7456 28 28 29 29 /** 30 @file 30 @file LocalQuest.cc 31 31 @brief Implementation of the LocalQuest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 38 39 #include "QuestEffect.h" 39 40 … … 82 83 bool LocalQuest::fail(PlayerInfo* player) 83 84 { 84 if(!this->isFailable(player)) // !<Checks whether the quest can be failed.85 if(!this->isFailable(player)) // Checks whether the quest can be failed. 85 86 { 86 87 COUT(4) << "A non-failable quest was trying to be failed." << std::endl; … … 90 91 Quest::fail(player); 91 92 92 QuestEffect::invokeEffects(player, this->getFailEffectList()); // !<Invoke the failEffects.93 QuestEffect::invokeEffects(player, this->getFailEffectList()); // Invoke the failEffects. 93 94 return true; 94 95 } … … 105 106 bool LocalQuest::complete(PlayerInfo* player) 106 107 { 107 if(!this->isCompletable(player)) // !<Checks whether the Quest can be completed.108 if(!this->isCompletable(player)) // Checks whether the Quest can be completed. 108 109 { 109 110 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; … … 113 114 Quest::complete(player); 114 115 115 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); // !<Invoke the complete QuestEffects.116 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); // Invoke the complete QuestEffects. 116 117 return true; 117 118 } … … 130 131 { 131 132 if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player))) 132 { 133 return false; 134 } 133 return false; 134 135 135 return this->isInactive(player); 136 136 } … … 178 178 QuestStatus::Value LocalQuest::getStatus(const PlayerInfo* player) const 179 179 { 180 if(player == NULL) //!< No player has no defined status.181 {180 //TODO: Replace with assert. 181 if(player == NULL) // No player has no defined status. 182 182 ThrowException(Argument, "The input PlayerInfo* is NULL."); 183 }184 183 185 184 std::map<const PlayerInfo*, QuestStatus::Value>::const_iterator it = this->playerStatus_.find(player); 186 if (it != this->playerStatus_.end()) //!< If there is a player in the map. 187 { 185 if (it != this->playerStatus_.end()) // If there is a player in the map. 188 186 return it->second; 189 } 190 191 return QuestStatus::Inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'. 187 188 return QuestStatus::Inactive; // If the player is not yet in the map, that means the status of the quest form him is 'inactive'. 192 189 } 193 190 … … 205 202 bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status) 206 203 { 207 if(player == NULL) //!< We can't set a status for no player. 208 { 209 return false; 210 } 204 //TODO: Replace with assert. 205 if(player == NULL) // We can't set a status for no player. 206 return false; 211 207 212 208 this->playerStatus_[player] = status; -
code/trunk/src/modules/questsystem/LocalQuest.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file LocalQuest.h 31 31 @brief Definition of the LocalQuest class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 44 45 /** 45 46 @brief 46 Handles Questswhich have different states for different players.47 LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Questchanges it does not for all the other players which also possess this quest.47 Handles @ref orxonox::Quest "Quests" which have different states for different players. 48 LocalQuests have (as opposed to @ref orxonox::GlobalQuest "GlobalQuests") a different state for each player, that means if for one player the status of the @ref orxonox::Quest "Quest" changes it does not for all the other players which also possess this quest. 48 49 49 50 Creating a LocalQuest through XML goes as follows: 50 51 51 @code 52 52 <LocalQuest id="questId"> -
code/trunk/src/modules/questsystem/Quest.cc
r7403 r7456 28 28 29 29 /** 30 @file 30 @file Quest.cc 31 31 @brief Implementation of the Quest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 39 #include "QuestDescription.h" 40 #include "QuestEffect.h" 41 #include "QuestHint.h" 42 #include "QuestListener.h" 38 43 #include "QuestManager.h" 39 #include "QuestDescription.h"40 #include "QuestHint.h"41 #include "QuestEffect.h"42 #include "QuestListener.h"43 44 44 45 namespace orxonox … … 78 79 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode); 79 80 80 QuestManager::getInstance().registerQuest(this); // !<Registers the Quest with the QuestManager.81 } 82 83 /** 84 @brief 85 Sets the parent quest of the Quest.81 QuestManager::getInstance().registerQuest(this); // Registers the Quest with the QuestManager. 82 } 83 84 /** 85 @brief 86 Sets the parent-quest of the Quest. 86 87 @param quest 87 A pointer to the Quest to be set as parent quest.88 @return 89 Returns true if the parent quest could be set.88 A pointer to the Quest to be set as parent-quest. 89 @return 90 Returns true if the parent-quest could be set. 90 91 */ 91 92 bool Quest::setParentQuest(Quest* quest) 92 93 { 93 if(quest == NULL) //!< We don't want to set NULL-Pointers. 94 //TODO: Replace with assert. 95 if(quest == NULL) // We don't want to set NULL-Pointers. 94 96 { 95 97 COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 105 107 /** 106 108 @brief 107 Adds a sub quest to the Quest.109 Adds a sub-quest to the Quest. 108 110 @param quest 109 A pointer to the Quest to be set as sub quest.110 @return 111 Returns true if the sub quest could be set.111 A pointer to the Quest to be set as sub-quest. 112 @return 113 Returns true if the sub-quest could be set. 112 114 */ 113 115 bool Quest::addSubQuest(Quest* quest) 114 116 { 115 if(quest == NULL) //!< We don't want to set NULL-Pointers. 117 //TODO: Replace with assert. 118 if(quest == NULL) // We don't want to set NULL-Pointers. 116 119 { 117 120 COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 119 122 } 120 123 121 quest->setParentQuest(this); // !< Sets the currentQuest (this) as parentquest for the added subquest.122 this->subQuests_.push_back(quest); // !< Adds the Quest to the end of the list of subquests.124 quest->setParentQuest(this); // Sets the currentQuest (this) as parent-quest for the added sub-quest. 125 this->subQuests_.push_back(quest); // Adds the Quest to the end of the list of sub-quests. 123 126 124 127 COUT(4) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 137 140 bool Quest::addHint(QuestHint* hint) 138 141 { 139 if(hint == NULL) //!< We don't want to set NULL-Pointers. Seriously! 142 //TODO: Replace with assert. 143 if(hint == NULL) // We don't want to set NULL-Pointers. Seriously! 140 144 { 141 145 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; … … 143 147 } 144 148 145 hint->setQuest(this); // !<Sets the current Quest (this) as Quest for the added QuestHint.146 this->hints_.push_back(hint); // !<Adds the QuestHint to the end of the list of QuestHints.149 hint->setQuest(this); // Sets the current Quest (this) as Quest for the added QuestHint. 150 this->hints_.push_back(hint); // Adds the QuestHint to the end of the list of QuestHints. 147 151 148 152 COUT(4) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 160 164 bool Quest::addFailEffect(QuestEffect* effect) 161 165 { 162 if(effect == NULL) //!< We don't want to set NULL-Pointers. 166 //TODO: Replace with assert. 167 if(effect == NULL) // We don't want to set NULL-Pointers. 163 168 { 164 169 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 166 171 } 167 172 168 this->failEffects_.push_back(effect); // !<Adds the QuestEffect to the end of the list of fail QuestEffects.173 this->failEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of fail QuestEffects. 169 174 170 175 COUT(4) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 182 187 bool Quest::addCompleteEffect(QuestEffect* effect) 183 188 { 184 if(effect == NULL) //!< We don't want to set NULL-Pointers. 189 //TODO: Replace with assert. 190 if(effect == NULL) // We don't want to set NULL-Pointers. 185 191 { 186 192 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 188 194 } 189 195 190 this->completeEffects_.push_back(effect); // !<Adds the QuestEffect to the end of the list of complete QuestEffects.196 this->completeEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of complete QuestEffects. 191 197 192 198 COUT(4) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 196 202 /** 197 203 @brief 198 Returns the sub quest at the given index.204 Returns the sub-quest at the given index. 199 205 @param index 200 206 The index. 201 207 @return 202 Returns a pointer to the sub quest at the given index. NULL if there is no element at the given index.208 Returns a pointer to the sub-quest at the given index. NULL if there is no element at the given index. 203 209 */ 204 210 const Quest* Quest::getSubQuest(unsigned int index) const … … 206 212 int i = index; 207 213 208 // !Iterate through all subquests.214 // Iterate through all subquests. 209 215 for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest) 210 216 { 211 if(i == 0) //!< We're counting down... 212 { 217 if(i == 0) // We're counting down... 213 218 return *subQuest; 214 } 219 215 220 i--; 216 221 } 217 222 218 return NULL; // !<If the index is greater than the number of elements in the list.223 return NULL; // If the index is greater than the number of elements in the list. 219 224 } 220 225 … … 231 236 int i = index; 232 237 233 // !Iterate through all QuestHints.238 // Iterate through all QuestHints. 234 239 for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint) 235 240 { 236 if(i == 0) //!< We're counting down... 237 { 241 if(i == 0) // We're counting down... 238 242 return *hint; 239 } 243 240 244 i--; 241 245 } 242 return NULL; // !<If the index is greater than the number of elements in the list.246 return NULL; // If the index is greater than the number of elements in the list. 243 247 } 244 248 … … 255 259 int i = index; 256 260 257 // !Iterate through all fail QuestEffects.261 // Iterate through all fail QuestEffects. 258 262 for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect) 259 263 { 260 if(i == 0) //!< We're counting down... 261 { 264 if(i == 0) // We're counting down... 262 265 return *effect; 263 } 266 264 267 i--; 265 268 } 266 return NULL; // !<If the index is greater than the number of elements in the list.269 return NULL; // If the index is greater than the number of elements in the list. 267 270 } 268 271 … … 279 282 int i = index; 280 283 281 // !Iterate through all complete QuestEffects.284 // Iterate through all complete QuestEffects. 282 285 for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect) 283 286 { 284 if(i == 0) //!< We're counting down... 285 { 287 if(i == 0) // We're counting down... 286 288 return *effect; 287 } 289 288 290 i--; 289 291 } 290 return NULL; // !<If the index is greater than the number of elements in the list.292 return NULL; // If the index is greater than the number of elements in the list. 291 293 } 292 294 … … 318 320 bool Quest::isActive(const PlayerInfo* player) const 319 321 { 320 321 322 return this->getStatus(player) == QuestStatus::Active; 322 323 } … … 362 363 bool Quest::fail(PlayerInfo* player) 363 364 { 364 QuestListener::advertiseStatusChange(this->listeners_, "fail"); // !<Tells the QuestListeners, that the status has changed to failed.365 QuestListener::advertiseStatusChange(this->listeners_, "fail"); // Tells the QuestListeners, that the status has changed to failed. 365 366 this->setStatus(player, QuestStatus::Failed); 366 367 … … 381 382 bool Quest::complete(PlayerInfo* player) 382 383 { 383 QuestListener::advertiseStatusChange(this->listeners_, "complete"); // !<Tells the QuestListeners, that the status has changed to completed.384 QuestListener::advertiseStatusChange(this->listeners_, "complete"); // Tells the QuestListeners, that the status has changed to completed. 384 385 this->setStatus(player, QuestStatus::Completed); 385 386 … … 400 401 bool Quest::start(PlayerInfo* player) 401 402 { 402 if(!this->isStartable(player)) // !<Checks whether the quest can be started.403 if(!this->isStartable(player)) // Checks whether the quest can be started. 403 404 { 404 405 COUT(4) << "A non-startable quest was trying to be started." << std::endl; … … 408 409 COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl; 409 410 410 QuestListener::advertiseStatusChange(this->listeners_, "start"); // !<Tells the QuestListeners, that the status has changed to active.411 QuestListener::advertiseStatusChange(this->listeners_, "start"); // Tells the QuestListeners, that the status has changed to active. 411 412 412 413 this->setStatus(player, QuestStatus::Active); … … 426 427 bool Quest::addListener(QuestListener* listener) 427 428 { 429 //TODO: Replace with assert? 428 430 if(listener == NULL) 429 431 { -
code/trunk/src/modules/questsystem/Quest.h
r7163 r7456 28 28 29 29 /** 30 @file 30 @file Quest.h 31 31 @brief Definition of the Quest class. 32 The Quest is the parent class of LocalQuest and GlobalQuest. 32 The Quest class is the parent class of @ref orxonox::LocalQuest "LocalQuest" and @ref orxonox::GlobalQuest "GlobalQuest". 33 @ingroup Questsystem 33 34 */ 34 35 … … 45 46 namespace QuestStatus 46 47 { 47 //! Different states of a Quest.48 //! Different states of a @ref orxonox::Quest "Quest". 48 49 enum Value 49 50 { … … 57 58 /** 58 59 @brief 59 Represents a Quest in the game. 60 A Quest has a list of subquests and a parentquest (if it is not a rootquest). 60 Represents a Quest in the game. A Quest is a task that the player can (or has to) fulfill upon which he will (possibly) receive some kind of reward. 61 62 A Quest can have a list of sub-quests and has a parent-quest (if it is not a root-quest). 61 63 Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player. 62 A Quest has several hints (QuestHint) that can be unlocked through QuestEffectsand then display aid in solving the Quest.63 A Quest has a list of QuestEffects that are invoked when the quest is failed and also a list of QuestEffectsthat are invoked, when the Quest is completed.64 A Quest can have several hints (QuestHint) that can be unlocked through @ref orxonox::QuestEffect "QuestEffects" and then display aid in solving the Quest. 65 A Quest can have a list of @ref orxonox::QuestEffect "QuestEffects" that are invoked when the quest is failed and also a list of @ref orxonox::QuestEffect "QuestEffects" that are invoked, when the Quest is completed. 64 66 65 Quest itself should not be instantiated, if you want to create a quest either go forLocalQuest or GlobalQuest, whichever suits you needs better.67 Quest itself should not be instantiated, if you want to create a quest either use LocalQuest or GlobalQuest, whichever suits you needs better. 66 68 @author 67 69 Damian 'Mozork' Frick … … 77 79 78 80 /** 79 @brief Returns the parent quest of the Quest.80 @return Returns a pointer to the parent quest of the Quest.81 @brief Returns the parent-quest of the Quest. 82 @return Returns a pointer to the parent-quest of the Quest. 81 83 */ 82 84 inline Quest* getParentQuest(void) const … … 84 86 85 87 /** 86 @brief Returns the list of sub quests.87 @return Returns a reference to the list of sub quests of the quest.88 @brief Returns the list of sub-quests. 89 @return Returns a reference to the list of sub-quests of the quest. 88 90 */ 89 91 inline const std::list<Quest*> & getSubQuestList(void) const … … 113 115 virtual bool isCompletable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be completed. 114 116 115 const Quest* getSubQuest(unsigned int index) const; //!<Returns the sub quest at the given index.117 const Quest* getSubQuest(unsigned int index) const; //!<Returns the sub-quest at the given index. 116 118 const QuestHint* getHint(unsigned int index) const; //!< Returns the QuestHint at the given index. 117 119 const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the fail QuestEffect at the given index. … … 136 138 137 139 private: 138 Quest* parentQuest_; //!< Pointer to the parent quest.139 std::list<Quest*> subQuests_; //!< List of all the sub quests.140 Quest* parentQuest_; //!< Pointer to the parent-quest. 141 std::list<Quest*> subQuests_; //!< List of all the sub-quests. 140 142 141 143 std::list<QuestHint*> hints_; //!< A list of all the QuestHints tied to this Quest. … … 146 148 std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest. 147 149 148 bool setParentQuest(Quest* quest); //!< Sets the parent quest of the Quest.149 bool addSubQuest(Quest* quest); //!< Adds a sub quest to the Quest.150 bool setParentQuest(Quest* quest); //!< Sets the parent-quest of the Quest. 151 bool addSubQuest(Quest* quest); //!< Adds a sub-quest to the Quest. 150 152 bool addHint(QuestHint* hint); //!< Add a QuestHint to the list of QuestHints. 151 153 bool addFailEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of fail QuestEffects. -
code/trunk/src/modules/questsystem/QuestDescription.cc
r7403 r7456 28 28 29 29 /** 30 @file 30 @file QuestDescription.cc 31 31 @brief Implementation of the QuestDescription class. 32 32 */ … … 37 37 #include "core/CoreIncludes.h" 38 38 #include "core/XMLPort.h" 39 39 40 #include "QuestNotification.h" 40 41 … … 93 94 std::string message; 94 95 if(item == "hint") 95 {96 96 message = "You received a hint: '" + this->title_ + '\''; 97 }98 97 else if(item == "quest") 99 98 { 100 99 if(status == "start") 101 {102 100 message = "You received a new quest: '" + this->title_ + '\''; 103 }104 101 else if(status == "fail") 105 {106 102 message = "You failed the quest: '" + this->title_ + '\''; 107 }108 103 else if(status == "complete") 109 {110 104 message = "You successfully completed the quest: '" + this->title_ + '\''; 111 }112 105 else 113 106 { -
code/trunk/src/modules/questsystem/QuestDescription.h
r7403 r7456 28 28 29 29 /** 30 @file 30 @file QuestDescription.h 31 31 @brief Definition of the QuestDescription class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 45 46 /** 46 47 @brief 47 This class is a description of a QuestItem .48 It holds a title and a description. 48 This class is a description of a QuestItem (@ref orxonox::Quest "Quest" and @ref orxonox::QuestHint "QuestHint"). 49 It holds a title and a description. For quests also messages that are sent, when failing or completing the quest can be added. 49 50 50 51 Creating a QuestDescription through XML goes as follows: 51 52 52 @code 53 53 <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" /> -
code/trunk/src/modules/questsystem/QuestEffect.cc
r6417 r7456 28 28 29 29 /** 30 @file 30 @file QuestEffect.cc 31 31 @brief Implementation of the QuestEffect class. 32 32 */ … … 64 64 A list of all the QuestEffects to be invoked. 65 65 @return 66 Returns false if there was an error, view console o f log for further detail.66 Returns false if there was an error, view console or log for further details. 67 67 */ 68 68 /*static*/ bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects) … … 73 73 74 74 for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++) 75 {76 75 check = check && (*effect)->invoke(player); 77 } 76 78 77 return check; 79 78 } -
code/trunk/src/modules/questsystem/QuestEffect.h
r5781 r7456 28 28 29 29 /** 30 @file 30 @file QuestEffect.h 31 31 @brief Definition of the QuestEffect class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 44 45 /** 45 46 @brief 46 Handles QuestEffects for Quests.47 QuestEffects are the only way for Quests to have any sideeffects in the game world. They are also the only way for a player to gain, complete or fail Quests.47 Handles QuestEffects for @ref orxonox::Quest "Quests". 48 QuestEffects are one of the ways for @ref orxonox::Quest "Quests" to have any side effects on the game world and for the game world to influence the @ref orxonox::Quest "Quests". 48 49 @author 49 50 Damian 'Mozork' Frick … … 58 59 static bool invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects); //!< Invokes all QuestEffects in the list. 59 60 60 61 61 }; 62 62 -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestEffectBeacon.cc 31 31 @brief Implementation of the QuestEffectBeacon class. 32 32 */ … … 37 37 #include "core/XMLPort.h" 38 38 #include "core/EventIncludes.h" 39 40 #include "interfaces/PlayerTrigger.h" 39 41 #include "worldentities/pawns/Pawn.h" 40 #include "interfaces/PlayerTrigger.h" 42 41 43 #include "objects/triggers/MultiTriggerContainer.h" 42 44 #include "QuestEffect.h" … … 50 52 Constructor. Registers the object and initializes defaults. 51 53 */ 54 //TODO: Make just BaseObject? 52 55 QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : StaticEntity(creator) 53 56 { … … 99 102 Returns true if successfully executed, false if not. 100 103 */ 104 //TODO: Eliminate MultiTriggerContainer stuff, since they are now PlayerTriggers as well. 101 105 bool QuestEffectBeacon::execute(bool bTriggered, BaseObject* trigger) 102 106 { … … 105 109 return false; 106 110 } 107 if(!(this->isActive())) // !<If the QuestEffectBeacon is inactive it cannot be executed.111 if(!(this->isActive())) // If the QuestEffectBeacon is inactive it cannot be executed. 108 112 { 109 113 COUT(4) << "The QuestEffectBeacon is inactive." << std::endl; … … 115 119 Pawn* pawn = NULL; 116 120 117 // !If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it.121 // If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it. 118 122 if(pTrigger == NULL && mTrigger == NULL) 119 123 return false; … … 122 126 if(pTrigger != NULL) 123 127 { 124 if(!pTrigger->isForPlayer()) // !<The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.128 if(!pTrigger->isForPlayer()) // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one. 125 129 return false; 126 130 else … … 140 144 } 141 145 142 // !Extract the PlayerInfo from the Pawn.146 // Extract the PlayerInfo from the Pawn. 143 147 PlayerInfo* player = pawn->getPlayer(); 144 148 … … 151 155 COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl; 152 156 153 bool check = QuestEffect::invokeEffects(player, this->effects_); // !<Invoke the QuestEffects on the PlayerInfo.157 bool check = QuestEffect::invokeEffects(player, this->effects_); // Invoke the QuestEffects on the PlayerInfo. 154 158 if(check) 155 159 { 156 this->decrementTimes(); // !<Decrement the number of times the beacon can be used.160 this->decrementTimes(); // Decrement the number of times the beacon can be used. 157 161 return true; 158 162 } … … 171 175 bool QuestEffectBeacon::setActive(bool activate) 172 176 { 173 if(this->getTimes() == 0 && activate) //!< A QuestEffectBeacon that can be executed only 0 times is always inactive. 174 { 175 return false; 176 } 177 if(this->getTimes() == 0 && activate) // A QuestEffectBeacon that can be executed only 0 times is always inactive. 178 return false; 177 179 178 180 if(activate) 179 181 { 180 this->status_ = QuestEffectBeaconStatus::Active;181 return true;182 this->status_ = QuestEffectBeaconStatus::Active; 183 return true; 182 184 } 183 185 … … 194 196 bool QuestEffectBeacon::decrementTimes(void) 195 197 { 196 if(!(this->isActive())) //!< The QuestEffectBeacon mus be active to decrement the number of times it can be executed. 197 { 198 return false; 199 } 200 if(this->getTimes() == INFINITE_TIME) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times. 201 { 198 if(!(this->isActive())) // The QuestEffectBeacon mus be active to decrement the number of times it can be executed. 199 return false; 200 201 if(this->getTimes() == INFINITE_TIME) // If times is infinity the QuestEffectBeacon can be executed an infinite number fo times. 202 202 return true; 203 } 204 205 this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed. 206 if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 207 { 203 204 this->times_ = this->times_ - 1; // Decrement number of times the QuestEffectBeacon can be executed. 205 if(this->getTimes() == 0) // Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 208 206 this->status_ = QuestEffectBeaconStatus::Inactive; 209 }210 207 211 208 return true; … … 225 222 { 226 223 if(n < 0 && n != INFINITE_TIME) 227 { 228 return false; 229 } 224 return false; 230 225 231 226 this->times_ = n; … … 243 238 bool QuestEffectBeacon::addEffect(QuestEffect* effect) 244 239 { 245 if(effect == NULL) //!< NULL-pointers are not well liked here... 240 //TODO: Replace with assert. 241 if(effect == NULL) // NULL-pointers are not well liked here... 246 242 { 247 243 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 269 265 { 270 266 if(i == 0) 271 {272 267 return *effect; 273 } 268 274 269 i--; 275 270 } -
code/trunk/src/modules/questsystem/QuestEffectBeacon.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestEffectBeacon.h 31 31 @brief Definition of the QuestEffectBeacon class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 44 45 namespace QuestEffectBeaconStatus 45 46 { 46 //! The status of the beacon, can be either active or inactive.47 //! The status of the @ref orxonox::QuestEffectBeacon "QuestEffectBeacon", can be either active or inactive. 47 48 enum Value 48 49 { … … 54 55 /** 55 56 @brief 56 A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number QuestEffectson players meeting the condition(s).57 The conditions under which the QuestEffects are invoked on the player are defined by Triggers.57 A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number of @ref orxonox::QuestEffect "QuestEffects" on players meeting the condition(s). 58 The conditions under which the @ref orxonox::QuestEffect "QuestEffects" are invoked on the player are defined by @ref orxonox::Trigger "Triggers" (or really any kind of entity firing events, e.g. @ref oroxnox::EventListener "EventListeners"). The trigger the event originates from, however has to be a @ref orxonox::PlayerTrigger PlayerTrigger. 58 59 A QuestEffectBeacon can be executed a defined number of times. 59 A QuestEffectBeacon can be inactive or active. 60 A QuestEffectBeacon can be inactive or active. While inactive it can't be executed. 60 61 61 62 Creating a QuestEffectBeacon through XML goes as follows: 62 63 63 @code 64 64 <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times. -
code/trunk/src/modules/questsystem/QuestHint.cc
r7403 r7456 28 28 29 29 /** 30 @file 30 @file QuestHint.cc 31 31 @brief Implementation of the QuestHint class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 39 #include "Quest.h" 40 #include "QuestDescription.h" 38 41 #include "QuestManager.h" 39 #include "QuestDescription.h"40 #include "Quest.h"41 42 42 43 namespace orxonox … … 71 72 SUPER(QuestHint, XMLPort, xmlelement, mode); 72 73 73 QuestManager::getInstance().registerHint(this); // !<Registers the QuestHint with the QuestManager.74 QuestManager::getInstance().registerHint(this); // Registers the QuestHint with the QuestManager. 74 75 75 76 COUT(4) << "New QuestHint {" << this->getId() << "} created." << std::endl; … … 89 90 bool QuestHint::isActive(const PlayerInfo* player) const 90 91 { 91 if(player == NULL) //!< NULL-Pointers are ugly! 92 //TODO: Replace with asser. 93 if(player == NULL) // NULL-Pointers are ugly! 92 94 { 93 95 ThrowException(Argument, "The input PlayerInfo* is NULL."); … … 95 97 } 96 98 97 // !Find the player.99 // Find the player. 98 100 std::map<const PlayerInfo*, QuestHintStatus::Value>::const_iterator it = this->playerStatus_.find(player); 99 if (it != this->playerStatus_.end()) //!< If the player is in the map. 100 { 101 if (it != this->playerStatus_.end()) // If the player is in the map. 101 102 return it->second; 102 }103 103 104 104 return QuestStatus::Inactive; … … 115 115 bool QuestHint::setActive(PlayerInfo* player) 116 116 { 117 if(this->quest_->isActive(player)) // !<For a hint to get activated the quest must be active.117 if(this->quest_->isActive(player)) // For a hint to get activated the quest must be active. 118 118 { 119 if(!(this->isActive(player))) // !<If the hint is already active, activation is pointless.119 if(!(this->isActive(player))) // If the hint is already active, activation is pointless. 120 120 { 121 121 this->playerStatus_[player] = QuestHintStatus::Active; … … 145 145 bool QuestHint::setQuest(Quest* quest) 146 146 { 147 if(quest == NULL) //!< NULL-Pointer. Again..? 147 //TODO: Replace with assert. 148 if(quest == NULL) // NULL-Pointer. Again..? 148 149 { 149 150 COUT(2) << "The input Quest* is NULL." << std::endl; -
code/trunk/src/modules/questsystem/QuestHint.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestHint.h 31 31 @brief Definition of the QuestHint class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 42 43 namespace orxonox // tolua_export 43 44 { // tolua_export 45 44 46 namespace QuestHintStatus 45 47 { 46 //! The state of the hint.48 //! The state of the @ref orxonox::QuestHint "QuestHint". 47 49 enum Value 48 50 { … … 54 56 /** 55 57 @brief 56 Represents a hint in the game t owards completing a Quest.57 Consists of title and description (which is stored in a QuestDescriptionobject) in textual form and must belong to a quest.58 Represents a hint in the game that gives aid towards completing a @ref orxonox::Quest "Quest". 59 Consists of title and description (which is stored in a @ref orxonox::QuestDescription "QuestDescription" object) in textual form and must belong to a quest. 58 60 A QuestHint has a defined status (inactive or active, where inactive is default) for each player, which means each a QuestHint exists only once for all players, it doesn't belong to a player, it just has different states for each of them. 59 61 60 62 Creating a QuestHint through XML goes as follows: 61 62 63 @code 63 64 <QuestHint id="hintId"> -
code/trunk/src/modules/questsystem/QuestItem.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestItem.cc 31 31 @brief Implementation of the QuestItem class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 38 39 #include "QuestDescription.h" 39 40 … … 86 87 void QuestItem::setId(const std::string & id) 87 88 { 88 if(id.compare(BLANKSTRING) == 0) // !<Checks whether the id is a valid id.89 if(id.compare(BLANKSTRING) == 0) // Checks whether the id is a valid id. 89 90 { 90 91 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/trunk/src/modules/questsystem/QuestItem.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestItem.h 31 31 @brief Definition of the QuestItem class. 32 The QuestItem is the parent class of Quest and QuestHint. 32 The @ref orxonox::QuestItem "QuestItem" is the parent class of @ref orxonox::Quest "Quest" and @ref orxonox::QuestHint "QuestHint". 33 @ingroup Questsystem 33 34 */ 34 35 … … 47 48 /** 48 49 @brief 49 Functions as a base class for quest classes such as Quest or QuestHint.50 Has a unique identifier and a description.50 Functions as a base class for quest classes such as @ref orxonox::Quest "Quest" or @ref orxonox::QuestHint "QuestHint". 51 Has a unique identifier and a @ref orxonox::QuestDescription "QuestDescription". 51 52 @author 52 53 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/QuestListener.cc
r7163 r7456 28 28 29 29 /** 30 @file 30 @file QuestListener.cc 31 31 @brief Implementation of the QuestListener class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 38 39 #include "Quest.h" 39 40 #include "QuestManager.h" … … 43 44 CreateFactory(QuestListener); 44 45 46 //! Initialization of the static variables for the modes as strings. 47 /*static*/ const std::string QuestListener::ALL = "all"; 48 /*static*/ const std::string QuestListener::START = "start"; 49 /*static*/ const std::string QuestListener::FAIL = "fail"; 50 /*static*/ const std::string QuestListener::COMPLETE = "complete"; 51 45 52 /** 46 53 @brief … … 75 82 76 83 if(this->quest_ != NULL) 77 this->quest_->addListener(this); // !<Adds the QuestListener to the Quests list of listeners.84 this->quest_->addListener(this); // Adds the QuestListener to the Quests list of listeners. 78 85 79 86 COUT(4) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; … … 90 97 /* static */ void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status) 91 98 { 92 for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) // !<Iterate through all QuestListeners99 for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) // Iterate through all QuestListeners 93 100 { 94 101 QuestListener* listener = *it; 95 if(listener->getMode() == status || listener->getMode() == "all") //!< Check whether the status change affects the give QuestListener. 96 { 102 if(listener->getMode() == status || listener->getMode() == QuestListener::ALL) // Check whether the status change affects the give QuestListener. 97 103 listener->execute(); 98 }99 104 } 100 105 } … … 110 115 bool QuestListener::setQuestId(const std::string & id) 111 116 { 112 this->quest_ = QuestManager::getInstance().findQuest(id); // !<Find the Quest corresponding to the given questId.113 114 if(this->quest_ == NULL) // !<If there is no such Quest.117 this->quest_ = QuestManager::getInstance().findQuest(id); // Find the Quest corresponding to the given questId. 118 119 if(this->quest_ == NULL) // If there is no such Quest. 115 120 { 116 121 ThrowException(Argument, "This is bad! The QuestListener has not found a Quest with a corresponding id.."); … … 131 136 bool QuestListener::setMode(const std::string & mode) 132 137 { 133 if(mode == "all") 134 { 138 if(mode == QuestListener::ALL) 135 139 this->mode_ = QuestListenerMode::All; 136 } 137 else if(mode == "start") 138 { 140 else if(mode == QuestListener::START) 139 141 this->mode_ = QuestListenerMode::Start; 140 } 141 else if(mode == "fail") 142 { 142 else if(mode == QuestListener::FAIL) 143 143 this->mode_ = QuestListenerMode::Fail; 144 } 145 else if(mode == "complete") 146 { 144 else if(mode == QuestListener::COMPLETE) 147 145 this->mode_ = QuestListenerMode::Complete; 148 }149 146 else 150 147 { 151 148 COUT(2) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << std::endl; 152 this->mode_ = QuestListenerMode::All;153 return false;149 this->mode_ = QuestListenerMode::All; 150 return false; 154 151 } 155 152 … … 161 158 Get the mode of the QuestListener. 162 159 @return 163 Return the mode of the QuestListener. Can be ei ghter 'all', 'start', 'fail' or 'complete'.160 Return the mode of the QuestListener. Can be either 'all', 'start', 'fail' or 'complete'. 164 161 */ 165 162 std::string QuestListener::getMode(void) 166 163 { 167 if(this->mode_ == QuestListenerMode::All) 168 { 169 return "all"; 170 } 171 else if(this->mode_ == QuestListenerMode::Start) 172 { 173 return "start"; 174 } 175 else if(this->mode_ == QuestListenerMode::Fail) 176 { 177 return "fail"; 178 } 179 else if(this->mode_ == QuestListenerMode::Complete) 180 { 181 return "complete"; 182 } 183 else 184 { 185 COUT(1) << "An unforseen, never to happen, Error has occurred. This is impossible!" << std::endl; 186 return ""; 164 switch(this->mode_) 165 { 166 case QuestListenerMode::All: 167 return QuestListener::ALL; 168 case QuestListenerMode::Start: 169 return QuestListener::START; 170 case QuestListenerMode::Fail: 171 return QuestListener::FAIL; 172 case QuestListenerMode::Complete: 173 return QuestListener::COMPLETE; 174 default: // This will never happen. 175 return QuestListener::ALL; 187 176 } 188 177 } -
code/trunk/src/modules/questsystem/QuestListener.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestListener.h 31 31 @brief Definition of the QuestListener class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 45 46 namespace QuestListenerMode 46 47 { 47 //! The mode of the QuestListener.48 //! The mode of the @ref orxonox::QuestListener "QuestListener". 48 49 enum Value 49 50 { … … 57 58 /** 58 59 @brief 59 Provides a way to react to the starting, completing and failing of Quests.60 Provides a way to react to the starting, completing and failing of @ref orxonox::Quest "Quests". 60 61 61 62 The XML representation goes as follows: 62 You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes.63 64 63 @code 65 64 <BaseObject> // The object that should react to the status change of a Quest. … … 71 70 </BaseObject> 72 71 @endcode 72 73 You can use the QuestListener as if it were a @ref orxonox::Trigger "Trigger" or @ref orxonox::EventListener "EventListener", that fires an Event when the status (depending on the set mode) of the given @ref orxonox::Quest "Quest" changes. 73 74 @author 74 75 Damian 'Mozork' Frick … … 76 77 class _QuestsystemExport QuestListener : public BaseObject 77 78 { 78 public:79 QuestListener(BaseObject* creator);80 virtual ~QuestListener();81 79 82 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML. 80 public: 81 QuestListener(BaseObject* creator); 82 virtual ~QuestListener(); 83 83 84 static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status); //!< Makes all QuestListener in the list aware that a certain status change has occured.84 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML. 85 85 86 bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to. 87 bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener. 86 static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status); //!< Makes all QuestListener in the list aware that a certain status change has occured. 88 87 89 std::string getMode(void); //!< Get the mode of the QuestListener. 88 bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to. 89 bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener. 90 90 91 const std::string & getQuestId(void); 92 bool execute(void); //!< Executes the QuestListener, resp. fires an Event. 91 std::string getMode(void); //!< Get the mode of the QuestListener. 93 92 94 private: 95 QuestListenerMode::Value mode_; //!< The mode of the QuestListener. 96 Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to. 93 const std::string & getQuestId(void); 94 bool execute(void); //!< Executes the QuestListener, resp. fires an Event. 95 96 private: 97 QuestListenerMode::Value mode_; //!< The mode of the QuestListener. 98 Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to. 99 100 //! Static variables for the modes as strings. 101 static const std::string ALL; 102 static const std::string START; 103 static const std::string FAIL; 104 static const std::string COMPLETE; 97 105 98 106 }; -
code/trunk/src/modules/questsystem/QuestManager.cc
r7284 r7456 28 28 29 29 /** 30 @file 30 @file QuestManager.cc 31 31 @brief Implementation of the QuestManager class. 32 32 */ … … 34 34 #include "QuestManager.h" 35 35 36 #include <CEGUIWindow.h>37 38 36 #include "util/Exception.h" 39 37 #include "util/ScopedSingletonManager.h" 38 #include "core/command/ConsoleCommand.h" 40 39 #include "core/CoreIncludes.h" 41 40 #include "core/GUIManager.h" 42 41 #include "core/LuaState.h" 43 #include "core/command/ConsoleCommand.h" 42 44 43 #include "infos/PlayerInfo.h" 45 #include "overlays/GUIOverlay.h" 46 47 #include "ToluaBindQuestsystem.h" 44 48 45 #include "Quest.h" 49 46 #include "QuestHint.h" 50 47 #include "QuestItem.h" 48 49 #include "ToluaBindQuestsystem.h" 51 50 52 51 namespace orxonox … … 66 65 { 67 66 RegisterRootObject(QuestManager); 67 68 COUT(3) << "QuestManager created." << std::endl; 68 69 } 69 70 … … 74 75 QuestManager::~QuestManager() 75 76 { 76 77 COUT(3) << "QuestManager destroyed." << std::endl; 77 78 } 78 79 … … 99 100 bool QuestManager::registerQuest(Quest* quest) 100 101 { 101 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. 102 //TODO: Replace with assert. 103 if(quest == NULL) // Doh! Just as if there were actual quests behind NULL-pointers. 102 104 { 103 105 COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl; … … 106 108 107 109 std::pair<std::map<std::string, Quest*>::iterator,bool> result; 108 result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); // !<Inserting the Quest.109 110 if(result.second) // !<If inserting was a success.110 result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); // Inserting the Quest. 111 112 if(result.second) // If inserting was a success. 111 113 { 112 114 quest->setRegistered(); … … 141 143 bool QuestManager::registerHint(QuestHint* hint) 142 144 { 143 if(hint == NULL) //!< Still not liking NULL-pointers. 145 //TODO: Replace with assert. 146 if(hint == NULL) // Still not liking NULL-pointers. 144 147 { 145 148 COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl; … … 148 151 149 152 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; 150 result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); // !<Inserting the QuestHSint.151 152 if(result.second) // !<If inserting was a success.153 result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); // Inserting the QuestHSint. 154 155 if(result.second) // If inserting was a success. 153 156 { 154 157 hint->setRegistered(); … … 185 188 Quest* QuestManager::findQuest(const std::string & questId) 186 189 { 187 if(questId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 188 { 190 if(questId.compare(BLANKSTRING) == 1) // Check vor validity of the given id. 189 191 ThrowException(Argument, "Invalid questId."); 190 }191 192 192 193 Quest* quest; 193 194 std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId); 194 if (it != this->questMap_.end()) //!< If the Quest is registered. 195 { 195 if (it != this->questMap_.end()) // If the Quest is registered. 196 196 quest = it->second; 197 }198 197 else 199 198 { … … 203 202 204 203 return quest; 205 206 204 } 207 205 … … 219 217 QuestHint* QuestManager::findHint(const std::string & hintId) 220 218 { 221 if(hintId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 222 { 219 if(hintId.compare(BLANKSTRING) == 1) // Check vor validity of the given id. 223 220 ThrowException(Argument, "Invalid hintId."); 224 }225 221 226 222 QuestHint* hint; 227 223 std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId); 228 if (it != this->hintMap_.end()) //!< If the QuestHint is registered. 229 { 224 if (it != this->hintMap_.end()) // If the QuestHint is registered. 230 225 hint = it->second; 231 }232 226 else 233 227 { … … 237 231 238 232 return hint; 239 240 } 241 242 int QuestManager::getNumParentQuests(PlayerInfo* player) 233 } 234 235 /** 236 @brief 237 Get the number of Quests the input player has, that are root quests. 238 @param player 239 The player. 240 @return 241 Returns the number of Quests the input player has, that are root quests. 242 */ 243 int QuestManager::getNumRootQuests(PlayerInfo* player) 243 244 { 244 245 int numQuests = 0; … … 251 252 } 252 253 253 Quest* QuestManager::getParentQuest(PlayerInfo* player, int index) 254 /** 255 @brief 256 Get the index-th root quest of the input player. 257 @param player 258 The player. 259 @param index 260 The index of the root quest. 261 @return 262 Returns the index-th root quest of the input player. 263 */ 264 Quest* QuestManager::getRootQuest(PlayerInfo* player, int index) 254 265 { 255 266 for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++) … … 261 272 } 262 273 274 /** 275 @brief 276 Get the number of sub-quest of an input Quest for the input player. 277 @param quest 278 The quest to get the sub-quests of. 279 @param player 280 The player. 281 @return 282 Returns the number of sub-quest of an input Quest for the input player. 283 */ 263 284 int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player) 264 285 { … … 273 294 } 274 295 296 /** 297 @brief 298 Get the index-th sub-quest of the input Quest for the input player. 299 @param quest 300 The Quest to get the sub-quest of. 301 @param player 302 The player. 303 @param index 304 The index of the sub-quest. 305 */ 275 306 Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index) 276 307 { … … 284 315 } 285 316 317 /** 318 @brief 319 Get the number of QuestHints of the input Quest for the input player. 320 @param quest 321 The quest to get the hints of. 322 @param player 323 The player. 324 @return Returns the number of QuestHints of the input Quest for the input player. 325 */ 286 326 int QuestManager::getNumHints(Quest* quest, PlayerInfo* player) 287 327 { … … 296 336 } 297 337 338 /** 339 @brief 340 Get the index-th QuestHint of the input Quest for the input player. 341 @param quest 342 The Quest to get the QuestHint of. 343 @param player 344 The player. 345 @param index 346 The index of the QuestHint. 347 */ 298 348 QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index) 299 349 { … … 307 357 } 308 358 359 /** 360 @brief 361 Get the QuestDescription of the input Quest. 362 @param item 363 The Quest to get the QuestDescription of. 364 @return 365 Return a pointer ot the QuestDescription of the input Quest. 366 */ 309 367 QuestDescription* QuestManager::getDescription(Quest* item) 310 368 { … … 312 370 } 313 371 372 /** 373 @brief 374 Get the QuestDescription of the input QuestHint. 375 @param item 376 The QuestHint to get the QuestDescription of. 377 @return 378 Returns a pointer to the QuestDescription of the input QuestHint. 379 */ 314 380 QuestDescription* QuestManager::getDescription(QuestHint* item) 315 381 { -
code/trunk/src/modules/questsystem/QuestManager.h
r7163 r7456 28 28 29 29 /** 30 @file 30 @file QuestManager.h 31 31 @brief Definition of the QuestManager class. 32 @ingroup Questsystem 32 33 */ 33 34 … … 44 45 #include "core/OrxonoxClass.h" 45 46 46 // tolua_begin 47 namespace orxonox 48 { 47 namespace orxonox // tolua_export 48 { // tolua_export 49 49 /** 50 50 @brief 51 Is a Singleton and manages Quests, by registering every Quest/QuestHint(through registerX()) and making them globally accessible (through findX()).52 Quests (and QuestHints) are registered in the QuestManager with their id, and can be accessed in the same way.51 Is a Singleton and manages @ref orxonox::Quest "Quests", by registering every @ref orxonox::Quest "Quest" / @ref orxonox::QuestHint "QuestHint" (through registerX()) and making them globally accessible (through findX()). 52 @ref orxonox::Quest "Quests" (and @ref orxonox::QuestHint 2) are registered in the QuestManager with their id, and can be accessed in the same way. 53 53 @author 54 54 Damian 'Mozork' Frick 55 55 */ 56 class _QuestsystemExport QuestManager 57 // tolua_end 56 class _QuestsystemExport QuestManager // tolua_export 58 57 : public Singleton<QuestManager>, public orxonox::OrxonoxClass 59 58 { // tolua_export … … 65 64 virtual ~QuestManager(); 66 65 67 //! Returns a reference to the single instance of the Quest 66 //! Returns a reference to the single instance of the QuestManager. 68 67 static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export 69 68 70 69 // tolua_begin 71 int getNum ParentQuests(orxonox::PlayerInfo* player);72 Quest* get ParentQuest(orxonox::PlayerInfo* player, int index);70 int getNumRootQuests(orxonox::PlayerInfo* player); //!< Get the number of Quests the input player has, that are root quests. 71 Quest* getRootQuest(orxonox::PlayerInfo* player, int index); //!< Get the index-th root quest of the input player. 73 72 74 int getNumSubQuests(Quest* quest, orxonox::PlayerInfo* player); 75 Quest* getSubQuest(Quest* quest, orxonox::PlayerInfo* player, int index); 73 int getNumSubQuests(Quest* quest, orxonox::PlayerInfo* player); //!< Get the number of sub-quest of an input Quest for an input player. 74 Quest* getSubQuest(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th sub-quest of the input Quest for the input player. 76 75 77 int getNumHints(Quest* quest, orxonox::PlayerInfo* player); 78 QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); 76 int getNumHints(Quest* quest, orxonox::PlayerInfo* player); //!< Get the number of QuestHints of the input Quest for the input player. 77 QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th QuestHint of the input Quest for the input player. 79 78 80 79 QuestDescription* getDescription(Quest* item); -
code/trunk/src/modules/questsystem/QuestNotification.cc
r7403 r7456 26 26 * 27 27 */ 28 29 /** 30 @file QuestNotification.cc 31 @brief Implementation of the QuestNotification class. 32 */ 28 33 29 34 #include "QuestNotification.h" -
code/trunk/src/modules/questsystem/QuestNotification.h
r7403 r7456 26 26 * 27 27 */ 28 29 /** 30 @file QuestNotification.h 31 @brief Definition of the QuestNotification class. 32 @ingroup Questsystem 33 */ 28 34 29 35 #ifndef _QuestNotification_H__ -
code/trunk/src/modules/questsystem/effects/AddQuest.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file AddQuest.cc 31 31 @brief Implementation of the AddQuest class. 32 32 */ … … 34 34 #include "AddQuest.h" 35 35 36 #include "core/CoreIncludes.h" 37 #include "core/XMLPort.h" 36 38 #include "util/Exception.h" 37 #include "core/CoreIncludes.h" 39 40 #include "questsystem/Quest.h" 38 41 #include "questsystem/QuestManager.h" 39 #include "questsystem/Quest.h"40 42 41 43 namespace orxonox … … 81 83 bool AddQuest::invoke(PlayerInfo* player) 82 84 { 83 if(player == NULL) //!< Null-pointers are badass. 85 //TODO: Replace with assert? 86 if(player == NULL) // Null-pointers are badass. 84 87 { 85 88 COUT(2) << "Input player is NULL." << std::endl; … … 93 96 Quest* quest = QuestManager::getInstance().findQuest(this->getQuestId()); 94 97 if(quest == NULL || !quest->start(player)) 95 {96 98 return false; 97 }98 99 } 99 100 catch(const orxonox::Exception& ex) -
code/trunk/src/modules/questsystem/effects/AddQuest.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file AddQuest.h 31 31 @brief Definition of the AddQuest class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 42 43 /** 43 44 @brief 44 Adds a Quest, resp. changes the quests status to active for the player invoking the Quest.45 Adds a @ref orxonox::Quest "Quest", resp. changes the @ref orxonox::Quest "Quests" status to active for the player invoking the @ref orxonox::Quest "Quest". 45 46 46 Creating a AddQuest through XML goes as follows: 47 47 Creating an AddQuest through XML goes as follows: 48 48 @code 49 49 <AddQuest questId="id" /> //Where id identifies the Quest that should be added. -
code/trunk/src/modules/questsystem/effects/AddQuestHint.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file AddQuestHint.cc 31 31 @brief Implementation of the AddQuestHint class. 32 32 */ … … 34 34 #include "AddQuestHint.h" 35 35 36 #include "util/Exception.h"37 36 #include "core/CoreIncludes.h" 38 37 #include "core/XMLPort.h" 38 #include "util/Exception.h" 39 40 #include "questsystem/QuestHint.h" 39 41 #include "questsystem/QuestManager.h" 40 42 #include "questsystem/QuestItem.h" 41 #include "questsystem/QuestHint.h"42 43 43 44 namespace orxonox … … 105 106 bool AddQuestHint::invoke(PlayerInfo* player) 106 107 { 107 if(player == NULL) //!< NULL-pointers are evil! 108 //TODO: Replace with assert? 109 if(player == NULL) // NULL-pointers are evil! 108 110 { 109 111 COUT(2) << "The input player is NULL." << std::endl; … … 117 119 QuestHint* hint = QuestManager::getInstance().findHint(this->hintId_); 118 120 if(hint == NULL || !hint->setActive(player)) 119 {120 121 return false; 121 }122 122 } 123 123 catch(const Exception& e) -
code/trunk/src/modules/questsystem/effects/AddQuestHint.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file AddQuestHint.h 31 31 @brief Definition of the AddQuestHint class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 44 45 /** 45 46 @brief 46 Adds a QuestHint, resp. activates the QuestHintof the given id for the player the QuestEffect is invoked on.47 Adds a @ref orxonox::QuestHint "QuestHint", resp. activates the @ref orxonox::QuestHint "QuestHint" of the given id for the player the QuestEffect is invoked on. 47 48 48 49 Creating a AddQuestHint through XML goes as follows: 49 50 50 @code 51 51 <AddQuestHint hintId="id" /> //Where id identifies the QuestHint that should be added. -
code/trunk/src/modules/questsystem/effects/AddReward.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file AddReward.cc 31 31 @brief Implementation of the AddReward class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 38 39 #include "interfaces/Rewardable.h" 39 40 … … 57 58 AddReward::~AddReward() 58 59 { 60 59 61 } 60 62 … … 85 87 { 86 88 if(i == 0) 87 {88 89 return *reward; 89 }90 90 i--; 91 91 } … … 107 107 bool check = true; 108 108 for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward ) 109 {110 109 check = check && (*reward)->reward(player); 111 }112 110 113 111 COUT(4) << "Rewardable successfully added to player." << player << " ." << std::endl; -
code/trunk/src/modules/questsystem/effects/AddReward.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file AddReward.h 31 31 @brief Definition of the AddReward class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 44 45 /** 45 46 @brief 46 Adds a list of Rewardablesto a player.47 Adds a list of @ref orxonox::Rewardable "Rewardables" to a player. 47 48 48 49 Creating a AddReward through XML goes as follows: 49 50 50 @code 51 51 <AddReward> -
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file ChangeQuestStatus.cc 31 31 @brief Implementation of the ChangeQuestStatus class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 36 37 #include "core/CoreIncludes.h" 37 38 #include "core/XMLPort.h" 39 38 40 #include "questsystem/QuestItem.h" 39 41 … … 55 57 ChangeQuestStatus::~ChangeQuestStatus() 56 58 { 59 57 60 } 58 61 -
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file ChangeQuestStatus.h 31 31 @brief Definition of the ChangeQuestStatus class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 44 45 /** 45 46 @brief 46 A QuestEffect which changes the status of a specified Questfor the player invoking the QuestEffect.47 A QuestEffect which changes the status of a specified @ref orxonox::Quest "Quest" for the player invoking the QuestEffect. 47 48 @author 48 49 Damian 'Mozork' Frick -
code/trunk/src/modules/questsystem/effects/CompleteQuest.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file CompleteQuest.cc 31 31 @brief Implementation of the CompleteQuest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 39 #include "questsystem/Quest.h" 38 40 #include "questsystem/QuestManager.h" 39 #include "questsystem/Quest.h"40 41 41 42 namespace orxonox … … 58 59 CompleteQuest::~CompleteQuest() 59 60 { 61 60 62 } 61 63 … … 81 83 bool CompleteQuest::invoke(PlayerInfo* player) 82 84 { 83 if(player == NULL) //!< You know, what we think of NULL-pointers... 85 //TODO: Replace with assert? 86 if(player == NULL) // You know, what we think of NULL-pointers... 84 87 { 85 88 COUT(2) << "Input player is NULL." << std::endl; … … 95 98 quest = QuestManager::getInstance().findQuest(this->getQuestId()); 96 99 if(quest == NULL || !quest->complete(player)) 97 {98 100 return false; 99 }100 101 } 101 102 catch(const Exception& e) -
code/trunk/src/modules/questsystem/effects/CompleteQuest.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file CompleteQuest.h 31 31 @brief Definition of the CompleteQuest class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 42 43 /** 43 44 @brief 44 Completes a Quest(with a specified id) for the player invoking the QuestEffect.45 Completes a @ref orxonox::Quest "Quest" (with a specified id) for the player invoking the QuestEffect. 45 46 46 47 Creating a CompleteQuest through XML goes as follows: 47 48 48 @code 49 49 <CompleteQuest questId="id" /> //Where id identifies the Quest that should be completed. -
code/trunk/src/modules/questsystem/effects/FailQuest.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file FailQuest.cc 31 31 @brief Implementation of the FailQuest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 39 #include "questsystem/Quest.h" 38 40 #include "questsystem/QuestManager.h" 39 #include "questsystem/Quest.h"40 41 41 42 namespace orxonox … … 58 59 FailQuest::~FailQuest() 59 60 { 61 60 62 } 61 63 … … 68 70 SUPER(FailQuest, XMLPort, xmlelement, mode); 69 71 70 COUT(4) << "New FailQ Uest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;72 COUT(4) << "New FailQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 71 73 } 72 74 … … 81 83 bool FailQuest::invoke(PlayerInfo* player) 82 84 { 83 if(player == NULL) //!< We don't know what to do with no player. 85 //TODO: Replace with assert? 86 if(player == NULL) // We don't know what to do with no player. 84 87 { 85 88 COUT(2) << "Input player is NULL." << std::endl; … … 94 97 quest = QuestManager::getInstance().findQuest(this->getQuestId()); 95 98 if(quest == NULL || !quest->fail(player)) 96 {97 99 return false; 98 }99 100 } 100 101 catch(const Exception& e) -
code/trunk/src/modules/questsystem/effects/FailQuest.h
r7401 r7456 28 28 29 29 /** 30 @file 30 @file FailQuest.h 31 31 @brief Definition of the FailQuest class. 32 @ingroup QuestEffects 32 33 */ 33 34 … … 42 43 /** 43 44 @brief 44 Fails a quest(with a specified id) for the player invoking the QuestEffect.45 Fails a @ref orxonox::Quest "Quest" (with a specified id) for the player invoking the QuestEffect. 45 46 46 47 Creating a FailQuest through XML goes as follows: 47 48 48 @code 49 49 <FailQuest questId="id" /> //Where id identifies the Quest that should be failed.
Note: See TracChangeset
for help on using the changeset viewer.