Changeset 2328 for code/branches/questsystem3/src/orxonox/objects/quest
- Timestamp:
- Dec 3, 2008, 4:40:00 PM (16 years ago)
- Location:
- code/branches/questsystem3/src/orxonox/objects/quest
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.cc
r2261 r2328 42 42 43 43 #include "orxonox/objects/infos/PlayerInfo.h" 44 #include "orxonox/overlays/notifications/Notification.h" 44 45 #include "QuestManager.h" 45 46 #include "Quest.h" … … 110 111 111 112 COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl; 113 Notification* notification = new Notification("Crazy Message...", "Title", 30); 114 notification->send(); 112 115 return true; 113 116 } -
code/branches/questsystem3/src/orxonox/objects/quest/CMakeLists.txt
r2261 r2328 14 14 QuestHint.cc 15 15 QuestItem.cc 16 QuestListener.cc 16 17 QuestManager.cc 17 18 Rewardable.cc -
code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.cc
r2261 r2328 40 40 41 41 #include "orxonox/objects/infos/PlayerInfo.h" 42 #include "orxonox/overlays/notifications/Notification.h" 42 43 #include "QuestManager.h" 43 44 #include "Quest.h" -
code/branches/questsystem3/src/orxonox/objects/quest/GlobalQuest.cc
r2261 r2328 38 38 #include "orxonox/objects/infos/PlayerInfo.h" 39 39 #include "core/CoreIncludes.h" 40 #include "core/Super.h" 40 41 #include "util/Exception.h" 41 42 … … 88 89 bool GlobalQuest::fail(PlayerInfo* player) 89 90 { 90 if( this->isFailable(player)) //!< Check whether the Quest can be failed.91 { 92 this->setStatus(player, questStatus::failed);93 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; 101 } 102 103 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; 104 return false;91 if(!this->isFailable(player)) //!< Check whether the Quest can be failed. 92 { 93 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; 94 return false; 95 } 96 97 Quest::fail(player); 98 99 //! Iterate through all players possessing this Quest. 100 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 101 { 102 QuestEffect::invokeEffects(*it, this->getFailEffectList()); 103 } 104 105 return true; 105 106 } 106 107 … … 117 118 bool GlobalQuest::complete(PlayerInfo* player) 118 119 { 119 if( this->isCompletable(player)) //!< Check whether the Quest can be completed.120 { 121 this->setStatus(player, questStatus::completed);122 123 //! Iterate through all players possessing the Quest.124 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)125 {126 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 127 } 128 129 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest. 130 return true; 131 } 132 133 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 134 return false;120 if(!this->isCompletable(player)) //!< Check whether the Quest can be completed. 121 { 122 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 123 return false; 124 } 125 126 //! Iterate through all players possessing the Quest. 127 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 128 { 129 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 130 } 131 132 Quest::complete(player); 133 134 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest. 135 return true; 135 136 } 136 137 -
code/branches/questsystem3/src/orxonox/objects/quest/LocalQuest.cc
r2261 r2328 37 37 38 38 #include "core/CoreIncludes.h" 39 #include "core/Super.h" 39 40 #include "util/Exception.h" 40 41 … … 86 87 bool LocalQuest::fail(PlayerInfo* player) 87 88 { 88 if(this->isFailable(player)) //!< Checks whether the quest can be failed. 89 { 90 this->setStatus(player, questStatus::failed); 91 QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects. 92 return true; 93 } 94 95 COUT(4) << "A non-failable quest was trying to be failed." << std::endl; 96 return false; 89 if(!this->isFailable(player)) //!< Checks whether the quest can be failed. 90 { 91 COUT(4) << "A non-failable quest was trying to be failed." << std::endl; 92 return false; 93 } 94 95 Quest::fail(player); 96 97 QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects. 98 return true; 97 99 } 98 100 … … 108 110 bool LocalQuest::complete(PlayerInfo* player) 109 111 { 110 if(this->isCompletable(player)) //!< Checks whether the Quest can be completed. 111 { 112 this->setStatus(player, questStatus::completed); 113 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects. 114 return true; 115 } 116 117 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 118 return false; 112 if(!this->isCompletable(player)) //!< Checks whether the Quest can be completed. 113 { 114 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 115 return false; 116 } 117 118 Quest::complete(player); 119 120 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects. 121 return true; 119 122 } 120 123 -
code/branches/questsystem3/src/orxonox/objects/quest/Quest.cc
r2261 r2328 43 43 #include "QuestHint.h" 44 44 #include "QuestEffect.h" 45 #include "QuestListener.h" 45 46 46 47 namespace orxonox { … … 363 364 return this->getStatus(player) == questStatus::completed; 364 365 } 366 367 /** 368 @brief 369 Fails the Quest for an input player. 370 @param player 371 The player. 372 @return 373 Returns true if the Quest could be failed, false if not. 374 */ 375 bool Quest::fail(PlayerInfo* player) 376 { 377 QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed. 378 this->setStatus(player, questStatus::failed); 379 return true; 380 } 381 382 /** 383 @brief 384 Completes the Quest for an input player. 385 @param player 386 The player. 387 @return 388 Returns true if the Quest could be completed, false if not. 389 */ 390 bool Quest::complete(PlayerInfo* player) 391 { 392 QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed. 393 this->setStatus(player, questStatus::completed); 394 return true; 395 } 365 396 366 397 /** … … 374 405 bool Quest::start(PlayerInfo* player) 375 406 { 376 if(this->isStartable(player)) //!< Checks whether the quest can be started. 377 { 378 this->setStatus(player, questStatus::active); 379 return true; 380 } 381 382 COUT(4) << "A non-startable quest was trying to be started." << std::endl; 383 return false; 407 if(!this->isStartable(player)) //!< Checks whether the quest can be started. 408 { 409 COUT(4) << "A non-startable quest was trying to be started." << std::endl; 410 return false; 411 } 412 413 QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active. 414 415 this->setStatus(player, questStatus::active); 416 return true; 417 } 418 419 /** 420 @brief 421 Adds a QuestListener to the list of QuestListeners listening to this Quest. 422 @param listener 423 The QuestListener to be added. 424 @return 425 Returns true if successful, false if not. 426 */ 427 bool Quest::addListener(QuestListener* listener) 428 { 429 if(listener == NULL) 430 { 431 COUT(2) << "A NULL-QuestListener was trying to be added to a Quests listeners." << std::endl; 432 return false; 433 } 434 435 this->listeners_.push_back(listener); 436 return true; 384 437 } 385 438 -
code/branches/questsystem3/src/orxonox/objects/quest/Quest.h
r2261 r2328 110 110 111 111 bool start(PlayerInfo* player); //!< Sets a Quest to active. 112 virtual bool fail(PlayerInfo* player) = 0; //!< Fails the Quest. 113 virtual bool complete(PlayerInfo* player) = 0; //!< Completes the Quest. 112 virtual bool fail(PlayerInfo* player); //!< Fails the Quest. 113 virtual bool complete(PlayerInfo* player); //!< Completes the Quest. 114 115 bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest. 114 116 115 117 protected: … … 150 152 std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed. 151 153 154 std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest. 155 152 156 bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest. 153 157 bool addSubQuest(Quest* quest); //!< Adds a subquest to the Quest. -
code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.cc
r2261 r2328 74 74 XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode); 75 75 XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); 76 XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode); 77 XMLPortParam(QuestDescription, "failMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); 76 78 77 79 COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; -
code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.h
r2261 r2328 52 52 Creating a QuestDescription through XML goes as follows: 53 53 54 <QuestDescription title="Title" description="Description Text" />54 <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" /> 55 55 @author 56 56 Damian 'Mozork' Frick … … 64 64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML. 65 65 66 /** 67 @brief Returns the title. 68 @return Returns a string containing the title of the QuestDescription. 69 */ 70 inline const std::string & getTitle(void) const 71 { return this->title_; } 72 73 /** 74 @brief Returns the description text. 75 @return Returns a string containing the description text of the QuestDescription. 76 */ 77 inline const std::string & getDescription(void) const 78 { return this->description_; } 66 /** 67 @brief Returns the title. 68 @return Returns a string containing the title of the QuestDescription. 69 */ 70 inline const std::string & getTitle(void) const 71 { return this->title_; } 72 73 /** 74 @brief Returns the description text. 75 @return Returns a string containing the description text of the QuestDescription. 76 */ 77 inline const std::string & getDescription(void) const 78 { return this->description_; } 79 80 /** 81 @brief Returns the fail message. 82 @return Returns a string containing the fail message of the QuestDescription. 83 */ 84 inline const std::string & getFailMessage(void) const 85 { return this->failMessage_; } 86 87 /** 88 @brief Returns the complete message. 89 @return Returns a string containing the complete message of the QuestDescription. 90 */ 91 inline const std::string & getCompleteMessage(void) const 92 { return this->completeMessage_; } 79 93 80 94 private: 81 95 std::string title_; //!< The title. 82 96 std::string description_; //!< The description. 97 std::string failMessage_; //!< The message displayed when the Quest is failed. 98 std::string completeMessage_; //!< The message displayed when the Quest is completed. 83 99 84 100 /** … … 89 105 { this->title_ = title; } 90 106 91 /**107 /** 92 108 @brief Sets the description text. 93 109 @param description The description text to be set. … … 96 112 { this->description_ = description; } 97 113 114 /** 115 @brief Sets the fail message. 116 @param message The fail message to be set. 117 */ 118 inline void setFailMessage(const std::string & message) 119 { this->failMessage_ = message; } 120 121 /** 122 @brief Sets the complete message. 123 @param message The complete message to be set. 124 */ 125 inline void setCompleteMessage(const std::string & message) 126 { this->completeMessage_ = message; } 127 98 128 }; 99 129
Note: See TracChangeset
for help on using the changeset viewer.