Changeset 7552 for code/trunk/src/modules/questsystem
- Timestamp:
- Oct 17, 2010, 10:50:43 PM (14 years ago)
- Location:
- code/trunk/src/modules/questsystem
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/GlobalQuest.cc
r7456 r7552 135 135 @return 136 136 Returns true if the quest can be started, false if not. 137 @throws138 Throws an exception if either isInactive() of isActive() throws one.139 137 */ 140 138 bool GlobalQuest::isStartable(const PlayerInfo* player) const … … 153 151 @return 154 152 Returns true if the Quest can be failed, false if not. 155 @throws156 Throws an Exception if isActive() throws one.157 153 */ 158 154 bool GlobalQuest::isFailable(const PlayerInfo* player) const … … 169 165 @return 170 166 Returns true if the Quest can be completed, false if not. 171 @throws172 Throws an Exception if isActive() throws one.173 167 */ 174 168 bool GlobalQuest::isCompletable(const PlayerInfo* player) const … … 182 176 @param player 183 177 The player. 184 @throws185 Throws an Exception if player is NULL.186 178 */ 187 179 QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const 188 180 { 189 //TODO: Replace with assert. 190 if(player == NULL) // We don't want NULL-Pointers! 191 ThrowException(Argument, "The input PlayerInfo* is NULL."); 181 assert(player); 192 182 193 183 // Find the player. … … 212 202 bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status) 213 203 { 214 //TODO: Replace with assert. 215 if(player == NULL) // We don't want NULL-Pointers! 216 return false; 204 assert(player); 217 205 218 206 // Find the player. … … 235 223 bool GlobalQuest::addRewardEffect(QuestEffect* effect) 236 224 { 237 //TODO: Replace with assert? 238 if(effect == NULL) // We don't want NULL-Pointers! 239 { 240 COUT(2) << "The reward effect to be added to quest {" << this->getId() << "} was NULL." << std::endl; 241 return false; 242 } 225 assert(effect); 243 226 244 227 this->rewards_.push_back(effect); // Add the QuestEffect to the list. -
code/trunk/src/modules/questsystem/GlobalQuest.h
r7456 r7552 44 44 namespace orxonox 45 45 { 46 46 47 /** 47 48 @brief … … 80 81 </GlobalQuest> 81 82 @endcode 83 82 84 @author 83 85 Damian 'Mozork' Frick 86 87 @ingroup Questsystem 84 88 */ 85 89 class _QuestsystemExport GlobalQuest : public Quest -
code/trunk/src/modules/questsystem/LocalQuest.cc
r7456 r7552 125 125 @return 126 126 Returns true if the Quest can be started, false if not. 127 @throws128 Throws an exception if isInactive(PlayerInfo*) throws one.129 127 */ 130 128 bool LocalQuest::isStartable(const PlayerInfo* player) const … … 143 141 @return 144 142 Returns true if the Quest can be failed, false if not. 145 @throws146 Throws an exception if isActive(PlayerInfo*) throws one.147 143 */ 148 144 bool LocalQuest::isFailable(const PlayerInfo* player) const … … 158 154 @return 159 155 Returns true if the Quest can be completed, false if not. 160 @throws161 Throws an exception if isInactive(PlayerInfo*) throws one.162 156 */ 163 157 bool LocalQuest::isCompletable(const PlayerInfo* player) const … … 173 167 @return 174 168 Returns the status of the Quest for the input player. 175 @throws176 Throws an Exception if player is NULL.177 169 */ 178 170 QuestStatus::Value LocalQuest::getStatus(const PlayerInfo* player) const 179 171 { 180 //TODO: Replace with assert. 181 if(player == NULL) // No player has no defined status. 182 ThrowException(Argument, "The input PlayerInfo* is NULL."); 172 assert(player); 183 173 184 174 std::map<const PlayerInfo*, QuestStatus::Value>::const_iterator it = this->playerStatus_.find(player); … … 202 192 bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status) 203 193 { 204 //TODO: Replace with assert. 205 if(player == NULL) // We can't set a status for no player. 206 return false; 194 assert(player); 207 195 208 196 this->playerStatus_[player] = status; -
code/trunk/src/modules/questsystem/LocalQuest.h
r7456 r7552 43 43 namespace orxonox 44 44 { 45 45 46 /** 46 47 @brief … … 74 75 </LocalQuest> 75 76 @endcode 77 76 78 @author 77 79 Damian 'Mozork' Frick 80 81 @ingroup Questsystem 78 82 */ 79 83 class _QuestsystemExport LocalQuest : public Quest -
code/trunk/src/modules/questsystem/Quest.cc
r7456 r7552 92 92 bool Quest::setParentQuest(Quest* quest) 93 93 { 94 //TODO: Replace with assert. 95 if(quest == NULL) // We don't want to set NULL-Pointers. 96 { 97 COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; 98 return false; 99 } 94 assert(quest); 100 95 101 96 this->parentQuest_ = quest; … … 115 110 bool Quest::addSubQuest(Quest* quest) 116 111 { 117 //TODO: Replace with assert. 118 if(quest == NULL) // We don't want to set NULL-Pointers. 119 { 120 COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; 121 return false; 122 } 112 assert(quest); 123 113 124 114 quest->setParentQuest(this); // Sets the currentQuest (this) as parent-quest for the added sub-quest. … … 140 130 bool Quest::addHint(QuestHint* hint) 141 131 { 142 //TODO: Replace with assert. 143 if(hint == NULL) // We don't want to set NULL-Pointers. Seriously! 144 { 145 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; 146 return false; 147 } 132 assert(hint); 148 133 149 134 hint->setQuest(this); // Sets the current Quest (this) as Quest for the added QuestHint. … … 164 149 bool Quest::addFailEffect(QuestEffect* effect) 165 150 { 166 //TODO: Replace with assert. 167 if(effect == NULL) // We don't want to set NULL-Pointers. 168 { 169 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; 170 return false; 171 } 151 assert(effect); 172 152 173 153 this->failEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of fail QuestEffects. … … 187 167 bool Quest::addCompleteEffect(QuestEffect* effect) 188 168 { 189 //TODO: Replace with assert. 190 if(effect == NULL) // We don't want to set NULL-Pointers. 191 { 192 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; 193 return false; 194 } 169 assert(effect); 195 170 196 171 this->completeEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of complete QuestEffects. … … 300 275 @return 301 276 Returns true if the quest status for the specific player is 'inactive'. 302 @throws303 Throws an exception if getStatus throws one.304 277 */ 305 278 bool Quest::isInactive(const PlayerInfo* player) const 306 279 { 280 if(player == NULL) 281 return true; 307 282 return this->getStatus(player) == QuestStatus::Inactive; 308 283 } … … 315 290 @return 316 291 Returns true if the quest status for the specific player is 'active'. 317 @throws318 Throws an exception if getStatus throws one.319 292 */ 320 293 bool Quest::isActive(const PlayerInfo* player) const 321 294 { 295 if(player == NULL) 296 return false; 322 297 return this->getStatus(player) == QuestStatus::Active; 323 298 } … … 330 305 @return 331 306 Returns true if the quest status for the specific player is 'failed'. 332 @throws333 Throws an exception if getStatus throws one.334 307 */ 335 308 bool Quest::isFailed(const PlayerInfo* player) const 336 309 { 310 if(player == NULL) 311 return false; 337 312 return this->getStatus(player) == QuestStatus::Failed; 338 313 } … … 345 320 @return 346 321 Returns true if the quest status for the specific player is 'completed'. 347 @throws348 Throws an exception if getStatus throws one.349 322 */ 350 323 bool Quest::isCompleted(const PlayerInfo* player) const 351 324 { 325 if(player == NULL) 326 return false; 352 327 return this->getStatus(player) == QuestStatus::Completed; 353 328 } … … 427 402 bool Quest::addListener(QuestListener* listener) 428 403 { 429 //TODO: Replace with assert? 430 if(listener == NULL) 431 { 432 COUT(2) << "A NULL-QuestListener was trying to be added to a Quests listeners." << std::endl; 433 return false; 434 } 404 assert(listener); 435 405 436 406 this->listeners_.push_back(listener); -
code/trunk/src/modules/questsystem/Quest.h
r7456 r7552 44 44 namespace orxonox // tolua_export 45 45 { // tolua_export 46 47 /** 48 @brief 49 Different states of a @ref orxonox::Quest "Quest". 50 51 @ingroup Questsystem 52 */ 46 53 namespace QuestStatus 47 54 { 48 //! Different states of a @ref orxonox::Quest "Quest".49 55 enum Value 50 56 { 51 Inactive, 52 Active, 53 Failed, 54 Completed 57 Inactive, //!< The @ref orxonox::Quest "Quest" is inactive. 58 Active, //!< The @ref orxonox::Quest "Quest" is active. 59 Failed, //!< The @ref orxonox::Quest "Quest" has been failed. 60 Completed //!< The @ref orxonox::Quest "Quest" has been completed. 55 61 }; 56 62 } … … 66 72 67 73 Quest itself should not be instantiated, if you want to create a quest either use LocalQuest or GlobalQuest, whichever suits you needs better. 74 68 75 @author 69 76 Damian 'Mozork' Frick 77 78 @ingroup Questsystem 70 79 */ 71 80 class _QuestsystemExport Quest // tolua_export -
code/trunk/src/modules/questsystem/QuestDescription.h
r7474 r7552 44 44 namespace orxonox 45 45 { 46 46 47 /** 47 48 @brief … … 53 54 <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" /> 54 55 @endcode 56 55 57 @author 56 58 Damian 'Mozork' Frick 59 60 @ingroup Questsystem 57 61 */ 58 62 class _QuestsystemExport QuestDescription : public BaseObject -
code/trunk/src/modules/questsystem/QuestEffect.h
r7456 r7552 43 43 namespace orxonox 44 44 { 45 45 46 /** 46 47 @brief 47 48 Handles QuestEffects for @ref orxonox::Quest "Quests". 48 49 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". 50 49 51 @author 50 52 Damian 'Mozork' Frick 53 54 @ingroup Questsystem 51 55 */ 52 56 class _QuestsystemExport QuestEffect : public BaseObject -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r7484 r7552 41 41 #include "worldentities/pawns/Pawn.h" 42 42 43 #include "objects/triggers/MultiTriggerContainer.h"44 43 #include "QuestEffect.h" 45 44 … … 101 100 Returns true if successfully executed, false if not. 102 101 */ 103 //TODO: Eliminate MultiTriggerContainer stuff, since they are now PlayerTriggers as well.104 102 bool QuestEffectBeacon::execute(bool bTriggered, BaseObject* trigger) 105 103 { … … 115 113 116 114 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 117 MultiTriggerContainer* mTrigger = orxonox_cast<MultiTriggerContainer*>(trigger);118 115 Pawn* pawn = NULL; 119 120 // If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it.121 if(pTrigger == NULL && mTrigger == NULL)122 return false;123 116 124 117 // If the trigger is a PlayerTrigger. … … 130 123 pawn = pTrigger->getTriggeringPlayer(); 131 124 } 132 133 // If the trigger is a MultiTrigger (i.e. a MultiTriggerContainer) 134 if(mTrigger != NULL) 135 { 136 pawn = orxonox_cast<Pawn*>(mTrigger->getData()); 137 } 125 else 126 return false; 138 127 139 128 if(pawn == NULL) … … 237 226 bool QuestEffectBeacon::addEffect(QuestEffect* effect) 238 227 { 239 //TODO: Replace with assert. 240 if(effect == NULL) // NULL-pointers are not well liked here... 241 { 242 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; 243 return false; 244 } 228 assert(effect); 245 229 246 230 this->effects_.push_back(effect); -
code/trunk/src/modules/questsystem/QuestEffectBeacon.h
r7489 r7552 43 43 namespace orxonox 44 44 { 45 46 /** 47 @brief 48 The status of the @ref orxonox::QuestEffectBeacon "QuestEffectBeacon", can be either active or inactive. 49 50 @ingroup Questsystem 51 */ 45 52 namespace QuestEffectBeaconStatus 46 53 { 47 //! The status of the @ref orxonox::QuestEffectBeacon "QuestEffectBeacon", can be either active or inactive.48 54 enum Value 49 55 { 50 Inactive, 51 Active 56 Inactive, //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is inactive. 57 Active //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is active. 52 58 }; 53 59 } … … 78 84 </QuestEffectBeacon> 79 85 @endcode 86 80 87 @author 81 88 Damian 'Mozork' Frick 89 90 @ingroup Questsystem 82 91 */ 83 92 class _QuestsystemExport QuestEffectBeacon : public StaticEntity -
code/trunk/src/modules/questsystem/QuestHint.cc
r7548 r7552 83 83 @param player 84 84 The player. 85 @throws86 Throws an Argument Exception if the input Player-pointer is NULL.87 85 @return 88 86 Returns true if the QuestHint is active for the specified player. … … 90 88 bool QuestHint::isActive(const PlayerInfo* player) const 91 89 { 92 //TODO: Replace with assert. 93 if(player == NULL) // NULL-Pointers are ugly! 94 { 95 ThrowException(Argument, "The input PlayerInfo* is NULL."); 90 if(player == NULL) // If the player is NULL, the Quest obviously can't be active. 96 91 return false; 97 }98 92 99 93 // Find the player. … … 145 139 bool QuestHint::setQuest(Quest* quest) 146 140 { 147 //TODO: Replace with assert. 148 if(quest == NULL) // NULL-Pointer. Again..? 149 { 150 COUT(2) << "The input Quest* is NULL." << std::endl; 151 return false; 152 } 141 assert(quest); 153 142 154 143 this->quest_ = quest; -
code/trunk/src/modules/questsystem/QuestHint.h
r7456 r7552 44 44 { // tolua_export 45 45 46 /** 47 @brief 48 The state of the @ref orxonox::QuestHint "QuestHint". 49 50 @ingroup Questsystem 51 */ 46 52 namespace QuestHintStatus 47 53 { 48 //! The state of the @ref orxonox::QuestHint "QuestHint".49 54 enum Value 50 55 { 51 Inactive, 52 Active 56 Inactive, //!< The @ref orxonox::QuestHint "QuestHint" is inactive. 57 Active //!< The @ref orxonox::QuestHint "QuestHint" is active. 53 58 }; 54 59 } … … 66 71 </QuestHint> 67 72 @endcode 73 68 74 @author 69 75 Damian 'Mozork' Frick 76 77 @ingroup Questsystem 70 78 */ 71 79 class _QuestsystemExport QuestHint // tolua_export -
code/trunk/src/modules/questsystem/QuestItem.h
r7456 r7552 50 50 Functions as a base class for quest classes such as @ref orxonox::Quest "Quest" or @ref orxonox::QuestHint "QuestHint". 51 51 Has a unique identifier and a @ref orxonox::QuestDescription "QuestDescription". 52 52 53 @author 53 54 Damian 'Mozork' Frick 55 56 @ingroup Questsystem 54 57 */ 55 58 class _QuestsystemExport QuestItem : public BaseObject -
code/trunk/src/modules/questsystem/QuestListener.h
r7456 r7552 44 44 namespace orxonox 45 45 { 46 /** 47 @brief 48 The mode of the @ref orxonox::QuestListener "QuestListener". 49 50 @ingroup Questsystem 51 */ 46 52 namespace QuestListenerMode 47 53 { 48 //! The mode of the @ref orxonox::QuestListener "QuestListener".49 54 enum Value 50 55 { 51 All, 52 Start, 53 Fail, 54 Complete 56 All, //!< Listens to all events. 57 Start, //!< Only listens to events pertaining the starting of @ref orxonox::Quest "Quests". 58 Fail, //!< Only listens to events pertaining the failing of @ref orxonox::Quest "Quests". 59 Complete //!< Only listens to events pertaining the completing of @ref orxonox::Quest "Quests". 55 60 }; 56 61 } … … 72 77 73 78 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. 79 74 80 @author 75 Damian 'Mozork' Frick 81 Damian 'Mozork' Frick 82 83 @ingroup Questsystem 76 84 */ 77 85 class _QuestsystemExport QuestListener : public BaseObject -
code/trunk/src/modules/questsystem/QuestManager.cc
r7456 r7552 100 100 bool QuestManager::registerQuest(Quest* quest) 101 101 { 102 //TODO: Replace with assert. 103 if(quest == NULL) // Doh! Just as if there were actual quests behind NULL-pointers. 104 { 105 COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl; 106 return false; 107 } 102 assert(quest); 108 103 109 104 std::pair<std::map<std::string, Quest*>::iterator,bool> result; … … 143 138 bool QuestManager::registerHint(QuestHint* hint) 144 139 { 145 //TODO: Replace with assert. 146 if(hint == NULL) // Still not liking NULL-pointers. 147 { 148 COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl; 149 return false; 150 } 140 assert(hint); 151 141 152 142 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; -
code/trunk/src/modules/questsystem/QuestManager.h
r7484 r7552 47 47 namespace orxonox // tolua_export 48 48 { // tolua_export 49 49 50 /** 50 51 @brief 51 52 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 53 @ref orxonox::Quest "Quests" (and @ref orxonox::QuestHint "QuestHints") are registered in the QuestManager with their id, and can be accessed in the same way. 54 53 55 @author 54 56 Damian 'Mozork' Frick 57 58 @ingroup Questsystem 55 59 */ 56 60 class _QuestsystemExport QuestManager // tolua_export -
code/trunk/src/modules/questsystem/effects/AddQuest.cc
r7456 r7552 83 83 bool AddQuest::invoke(PlayerInfo* player) 84 84 { 85 //TODO: Replace with assert? 86 if(player == NULL) // Null-pointers are badass. 87 { 88 COUT(2) << "Input player is NULL." << std::endl; 89 return false; 90 } 85 assert(player); 91 86 92 87 COUT(5) << "AddQuest on player: " << player << " ." << std::endl; -
code/trunk/src/modules/questsystem/effects/AddQuest.h
r7456 r7552 41 41 namespace orxonox 42 42 { 43 43 44 /** 44 45 @brief … … 49 50 <AddQuest questId="id" /> //Where id identifies the Quest that should be added. 50 51 @endcode 52 51 53 @author 52 54 Damian 'Mozork' Frick 55 56 @ingroup QuestEffects 53 57 */ 54 58 class _QuestsystemExport AddQuest : public ChangeQuestStatus -
code/trunk/src/modules/questsystem/effects/AddQuestHint.cc
r7456 r7552 106 106 bool AddQuestHint::invoke(PlayerInfo* player) 107 107 { 108 //TODO: Replace with assert? 109 if(player == NULL) // NULL-pointers are evil! 110 { 111 COUT(2) << "The input player is NULL." << std::endl; 112 return false; 113 } 108 assert(player); 114 109 115 110 COUT(5) << "AddQuestHint on player: " << player << " ." << std::endl; -
code/trunk/src/modules/questsystem/effects/AddQuestHint.h
r7456 r7552 43 43 namespace orxonox 44 44 { 45 45 46 /** 46 47 @brief … … 51 52 <AddQuestHint hintId="id" /> //Where id identifies the QuestHint that should be added. 52 53 @endcode 54 53 55 @author 54 56 Damian 'Mozork' Frick 57 58 @ingroup QuestEffects 55 59 */ 56 60 class _QuestsystemExport AddQuestHint : public QuestEffect -
code/trunk/src/modules/questsystem/effects/AddReward.h
r7456 r7552 43 43 namespace orxonox 44 44 { 45 45 46 /** 46 47 @brief … … 55 56 </AddReward> 56 57 @endcode 58 57 59 @author 58 60 Damian 'Mozork' Frick 61 62 @ingroup QuestEffects 59 63 */ 60 64 class _QuestsystemExport AddReward : public QuestEffect -
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.h
r7456 r7552 43 43 namespace orxonox 44 44 { 45 45 46 /** 46 47 @brief 47 48 A QuestEffect which changes the status of a specified @ref orxonox::Quest "Quest" for the player invoking the QuestEffect. 49 48 50 @author 49 51 Damian 'Mozork' Frick 52 53 @ingroup QuestEffects 50 54 */ 51 55 class _QuestsystemExport ChangeQuestStatus : public QuestEffect -
code/trunk/src/modules/questsystem/effects/CompleteQuest.cc
r7456 r7552 83 83 bool CompleteQuest::invoke(PlayerInfo* player) 84 84 { 85 //TODO: Replace with assert? 86 if(player == NULL) // You know, what we think of NULL-pointers... 87 { 88 COUT(2) << "Input player is NULL." << std::endl; 89 return false; 90 } 85 assert(player); 91 86 92 87 COUT(5) << "CompleteQuest on player: " << player << " ." << std::endl; -
code/trunk/src/modules/questsystem/effects/CompleteQuest.h
r7456 r7552 41 41 namespace orxonox 42 42 { 43 43 44 /** 44 45 @brief … … 49 50 <CompleteQuest questId="id" /> //Where id identifies the Quest that should be completed. 50 51 @endcode 52 51 53 @author 52 54 Damian 'Mozork' Frick 55 56 @ingroup QuestEffects 53 57 */ 54 58 class _QuestsystemExport CompleteQuest : public ChangeQuestStatus -
code/trunk/src/modules/questsystem/effects/FailQuest.cc
r7456 r7552 83 83 bool FailQuest::invoke(PlayerInfo* player) 84 84 { 85 //TODO: Replace with assert? 86 if(player == NULL) // We don't know what to do with no player. 87 { 88 COUT(2) << "Input player is NULL." << std::endl; 89 return false; 90 } 85 assert(player); 91 86 92 87 COUT(4) << "FailQuest on player: " << player << " ." << std::endl; -
code/trunk/src/modules/questsystem/effects/FailQuest.h
r7456 r7552 41 41 namespace orxonox 42 42 { 43 43 44 /** 44 45 @brief … … 49 50 <FailQuest questId="id" /> //Where id identifies the Quest that should be failed. 50 51 @endcode 52 51 53 @author 52 54 Damian 'Mozork' Frick 55 56 @ingroup QuestEffects 53 57 */ 54 58 class _QuestsystemExport FailQuest : public ChangeQuestStatus
Note: See TracChangeset
for help on using the changeset viewer.