Changeset 2352 for code/branches/questsystem3/src/orxonox/objects
- Timestamp:
- Dec 7, 2008, 11:39:44 PM (16 years ago)
- Location:
- code/branches/questsystem3/src/orxonox/objects/quest
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.cc
r2346 r2352 29 29 /** 30 30 @file AddQuest.cc 31 @brief 32 Implementation of the AddQuest class. 31 @brief Implementation of the AddQuest class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.h
r2261 r2352 29 29 /** 30 30 @file AddQuest.h 31 @brief 32 Definition of the AddQuest class. 31 @brief Definition of the AddQuest class. 33 32 */ 34 33 … … 58 57 { 59 58 public: 60 61 62 63 64 65 59 AddQuest(BaseObject* creator); 60 virtual ~AddQuest(); 61 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML. 63 64 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 66 65 67 66 }; -
code/branches/questsystem3/src/orxonox/objects/quest/AddQuestHint.cc
r2261 r2352 29 29 /** 30 30 @file AddQuestHint.cc 31 @brief 32 Implementation of the AddQuestHint class. 31 @brief Implementation of the AddQuestHint class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/AddQuestHint.h
r2261 r2352 29 29 /** 30 30 @file AddQuestHint.h 31 @brief 32 Definition of the AddQuestHint class. 31 @brief Definition of the AddQuestHint class. 33 32 */ 34 33 … … 73 72 inline const std::string & getHintId(void) const 74 73 { return this->hintId_; } 74 75 75 bool setHintId(const std::string & id); //!< Sets the id of the QuestHint. 76 76 -
code/branches/questsystem3/src/orxonox/objects/quest/AddReward.cc
r2261 r2352 29 29 /** 30 30 @file AddReward.cc 31 @brief 32 Implementation of the AddReward class. 31 @brief Implementation of the AddReward class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/AddReward.h
r2261 r2352 29 29 /** 30 30 @file AddReward.h 31 @brief 32 Definition of the AddReward class. 31 @brief Definition of the AddReward class. 33 32 */ 34 33 … … 78 77 inline void addRewardable(Rewardable* reward) 79 78 { this->rewards_.push_back(reward); } 79 80 80 const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index. 81 81 -
code/branches/questsystem3/src/orxonox/objects/quest/ChangeQuestStatus.cc
r2261 r2352 29 29 /** 30 30 @file ChangeQuestStatus.cc 31 @brief 32 Implementation of the ChangeQuestStatus class. 31 @brief Implementation of the ChangeQuestStatus class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/ChangeQuestStatus.h
r2261 r2352 29 29 /** 30 30 @file ChangeQuestStatus.h 31 @brief 32 Definition of the ChangeQuestStatus class. 31 @brief Definition of the ChangeQuestStatus class. 33 32 */ 34 33 … … 63 62 protected: 64 63 /** 65 66 64 @brief Returns the id of the Quest. 65 @return Returns the id of the Quest. 67 66 */ 68 67 inline const std::string & getQuestId(void) const -
code/branches/questsystem3/src/orxonox/objects/quest/CompleteQuest.cc
r2346 r2352 29 29 /** 30 30 @file CompleteQuest.cc 31 @brief 32 Implementation of the CompleteQuest class. 31 @brief Implementation of the CompleteQuest class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/CompleteQuest.h
r2261 r2352 29 29 /** 30 30 @file CompleteQuest.h 31 @brief 32 Definition of the CompleteQuest class. 31 @brief Definition of the CompleteQuest class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.cc
r2346 r2352 29 29 /** 30 30 @file FailQuest.cc 31 @brief 32 Implementation of the FailQuest class. 31 @brief Implementation of the FailQuest class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.h
r2261 r2352 29 29 /** 30 30 @file FailQuest.h 31 @brief 32 Definition of the FailQuest class. 31 @brief Definition of the FailQuest class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/GlobalQuest.cc
r2328 r2352 29 29 /** 30 30 @file GlobalQuest.cc 31 @brief 32 Implementation of the GlobalQuest class. 31 @brief Implementation of the GlobalQuest class. 33 32 */ 34 33 … … 96 95 97 96 Quest::fail(player); 98 99 100 101 102 103 104 105 97 98 //! Iterate through all players possessing this Quest. 99 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 100 { 101 QuestEffect::invokeEffects(*it, this->getFailEffectList()); 102 } 103 104 return true; 106 105 } 107 106 … … 125 124 126 125 //! Iterate through all players possessing the Quest. 127 128 129 130 131 132 133 134 135 126 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 127 { 128 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 129 } 130 131 Quest::complete(player); 132 133 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest. 134 return true; 136 135 } 137 136 … … 208 207 } 209 208 210 return questStatus::inactive;209 return questStatus::inactive; 211 210 } 212 211 -
code/branches/questsystem3/src/orxonox/objects/quest/GlobalQuest.h
r2261 r2352 29 29 /** 30 30 @file GlobalQuest.h 31 @brief 32 Definition of the GlobalQuest class. 31 @brief Definition of the GlobalQuest class. 33 32 */ 34 33 … … 56 55 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 56 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.59 ...60 <Quest id="questIdn" />61 </subquests>62 <hints>63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.64 ...65 <QuestHint id="hintIdn" />66 </hints>57 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 58 ... 59 <Quest id="questIdn" /> 60 </subquests> 61 <hints> 62 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 63 ... 64 <QuestHint id="hintIdn" /> 65 </hints> 67 66 <fail-effects> 68 67 <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation. -
code/branches/questsystem3/src/orxonox/objects/quest/LocalQuest.cc
r2328 r2352 29 29 /** 30 30 @file LocalQuest.cc 31 @brief 32 Implementation of the LocalQuest class. 31 @brief Implementation of the LocalQuest class. 33 32 */ 34 33 … … 95 94 Quest::fail(player); 96 95 97 98 96 QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects. 97 return true; 99 98 } 100 99 … … 118 117 Quest::complete(player); 119 118 120 121 119 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects. 120 return true; 122 121 } 123 122 -
code/branches/questsystem3/src/orxonox/objects/quest/LocalQuest.h
r2261 r2352 29 29 /** 30 30 @file LocalQuest.h 31 @brief 32 Definition of the LocalQuest class. 31 @brief Definition of the LocalQuest class. 33 32 */ 34 33 … … 65 64 <QuestHint id="hintIdn" /> 66 65 </hints> 67 68 69 70 71 72 73 74 75 76 66 <fail-effects> 67 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation. 68 ... 69 <QuestEffect /> 70 </fail-effects> 71 <complete-effects> 72 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation. 73 ... 74 <QuestEffect /> 75 </complete-effects> 77 76 </LocalQuest> 78 77 @author -
code/branches/questsystem3/src/orxonox/objects/quest/Quest.cc
r2346 r2352 29 29 /** 30 30 @file Quest.cc 31 @brief 32 Implementation of the Quest class. 31 @brief Implementation of the Quest class. 33 32 */ 34 33 … … 420 419 421 420 this->getDescription()->sendAddQuestNotification(); 422 421 return true; 423 422 } 424 423 -
code/branches/questsystem3/src/orxonox/objects/quest/Quest.h
r2328 r2352 29 29 /** 30 30 @file Quest.h 31 @brief 32 Definition of the Quest class. 33 34 The Quest is the parent class of LocalQuest and GlobalQuest. 31 @brief Definition of the Quest class. 32 The Quest is the parent class of LocalQuest and GlobalQuest. 35 33 */ 36 34 … … 90 88 { return this->parentQuest_; } 91 89 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 90 /** 91 @brief Returns the list of subquests. 92 @return Returns a reference to the list of subquests of the quest. 93 */ 94 inline const std::list<Quest*> & getSubQuestList(void) const 95 { return this->subQuests_; } 96 97 /** 98 @brief Returns the list of all QuestHints of this Quest. 99 @return Returns a reference to the list of QuestHints of the Quest. 100 */ 101 inline const std::list<QuestHint*> & getHintsList(void) const 102 { return this->hints_; } 103 104 bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 105 bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'. 106 bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 107 bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 108 109 bool start(PlayerInfo* player); //!< Sets a Quest to active. 110 virtual bool fail(PlayerInfo* player); //!< Fails the Quest. 111 virtual bool complete(PlayerInfo* player); //!< Completes the Quest. 112 113 bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest. 116 114 117 115 protected: … … 133 131 { return this->failEffects_; } 134 132 135 136 137 138 139 133 /** 134 @brief Returns the list of complete QuestEffects. 135 @return Returns a reference to the list of complete QuestEffects. 136 */ 137 inline std::list<QuestEffect*> & getCompleteEffectList(void) 140 138 { return this->completeEffects_; } 141 139 … … 143 141 virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. 144 142 145 private:143 private: 146 144 Quest* parentQuest_; //!< Pointer to the parentquest. 147 145 std::list<Quest*> subQuests_; //!< List of all the subquests. -
code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.cc
r2349 r2352 29 29 /** 30 30 @file QuestDescription.cc 31 @brief 32 Implementation of the QuestDescription class. 31 @brief Implementation of the QuestDescription class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.h
r2346 r2352 29 29 /** 30 30 @file QuestDescription.h 31 @brief 32 Definition of the QuestDescription class. 31 @brief Definition of the QuestDescription class. 33 32 */ 34 33 … … 64 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML. 65 64 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 65 /** 66 @brief Returns the title. 67 @return Returns a string containing the title of the QuestDescription. 68 */ 69 inline const std::string & getTitle(void) const 70 { return this->title_; } 71 72 /** 73 @brief Returns the description text. 74 @return Returns a string containing the description text of the QuestDescription. 75 */ 76 inline const std::string & getDescription(void) const 77 { return this->description_; } 78 79 /** 80 @brief Returns the fail message. 81 @return Returns a string containing the fail message of the QuestDescription. 82 */ 83 inline const std::string & getFailMessage(void) const 84 { return this->failMessage_; } 85 86 /** 87 @brief Returns the complete message. 88 @return Returns a string containing the complete message of the QuestDescription. 89 */ 90 inline const std::string & getCompleteMessage(void) const 91 { return this->completeMessage_; } 92 93 /** 94 @brief Sends a Notification displaying that a QuestHint was added. 95 @return Returns true if successful. 96 */ 97 inline bool sendAddHintNotification(void) const 99 98 { return notificationHelper("hint", ""); } 100 101 102 103 104 105 99 100 /** 101 @brief Sends a Notification displaying that a Quest was added. 102 @return Returns true if successful. 103 */ 104 inline bool sendAddQuestNotification(void) const 106 105 { return notificationHelper("quest", "start"); } 107 108 109 110 111 112 106 107 /** 108 @brief Sends a Notification displaying that a Quest was failed. 109 @return Returns true if successful. 110 */ 111 inline bool sendFailQuestNotification(void) const 113 112 { return notificationHelper("quest", "fail"); } 114 115 116 117 118 119 113 114 /** 115 @brief Sends a Notification displaying that a Quest was completed. 116 @return Returns true if successful. 117 */ 118 inline bool sendCompleteQuestNotification(void) const 120 119 { return notificationHelper("quest", "complete"); } 121 120 … … 149 148 { this->failMessage_ = message; } 150 149 151 150 /** 152 151 @brief Sets the complete message. 153 152 @param message The complete message to be set. -
code/branches/questsystem3/src/orxonox/objects/quest/QuestEffect.cc
r2261 r2352 29 29 /** 30 30 @file QuestEffect.cc 31 @brief 32 Implementation of the QuestEffect class. 31 @brief Implementation of the QuestEffect class. 33 32 */ 34 33 … … 71 70 Returns false if there was an error, view console of log for further detail. 72 71 */ 73 bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)72 /*static*/ bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects) 74 73 { 75 74 bool check = true; -
code/branches/questsystem3/src/orxonox/objects/quest/QuestEffect.h
r2261 r2352 29 29 /** 30 30 @file QuestEffect.h 31 @brief 32 Definition of the QuestEffect class. 31 @brief Definition of the QuestEffect class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/QuestEffectBeacon.cc
r2349 r2352 29 29 /** 30 30 @file QuestEffectBeacon.cc 31 @brief 32 Implementation of the QuestEffectBeacon class. 31 @brief Implementation of the QuestEffectBeacon class. 33 32 */ 34 33 … … 145 144 this->decrementTimes(); //!< Decrement the number of times the beacon can be used. 146 145 return true; 147 }148 149 return false;146 } 147 148 return false; 150 149 } 151 150 … … 167 166 if(activate) 168 167 { 169 170 168 this->status_ = QuestEffectBeaconStatus::active; 169 return true; 171 170 } 172 171 … … 193 192 194 193 this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed. 195 196 197 198 199 194 if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 195 { 196 this->status_ = QuestEffectBeaconStatus::inactive; 197 } 198 200 199 return true; 201 200 } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestEffectBeacon.h
r2349 r2352 29 29 /** 30 30 @file QuestEffectBeacon.h 31 @brief 32 Definition of the QuestEffectBeacon class. 31 @brief Definition of the QuestEffectBeacon class. 33 32 */ 34 33 … … 61 60 A QuestEffectBeacon can be inactive or active. 62 61 63 Creating a QuestEffectBeacon through XML goes as follows:64 65 <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.66 67 68 69 70 71 72 <execute>73 <EventListener event=eventIdString />74 </execute>75 </events>76 <attached>77 <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.78 </attached>79 </QuestEffectBeacon>62 Creating a QuestEffectBeacon through XML goes as follows: 63 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. 65 <effects> 66 <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation. 67 ... 68 <QuestEffect /> 69 </effects> 70 <events> 71 <execute> 72 <EventListener event=eventIdString /> 73 </execute> 74 </events> 75 <attached> 76 <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon. 77 </attached> 78 </QuestEffectBeacon> 80 79 @author 81 80 Damian 'Mozork' Frick … … 83 82 class _OrxonoxExport QuestEffectBeacon : public PositionableEntity 84 83 { 85 public: 86 QuestEffectBeacon(BaseObject* creator); 87 virtual ~QuestEffectBeacon(); 88 89 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML. 90 91 virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon. 92 93 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. 94 95 /** 96 @brief Tests whether the QuestEffectBeacon is active. 97 @return Returns true if the QuestEffectBeacon is active, fals if not. 98 */ 99 inline bool isActive(void) 100 { return this->status_ == QuestEffectBeaconStatus::active; } 101 102 bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon. 103 104 protected: 105 bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed. 106 107 /** 108 @brief Returns the number of times the QUestEffectBeacon can still be executed. 109 @return Returns the number of times the QUestEffectBeacon can still be executed. 110 */ 111 inline const int & getTimes(void) const 112 { return this->times_; } 113 114 private: 115 static const int INFINITE = -1; //!< Constant to avoid using magic numbers. 84 public: 85 QuestEffectBeacon(BaseObject* creator); 86 virtual ~QuestEffectBeacon(); 87 88 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML. 89 90 virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon. 91 92 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. 93 94 /** 95 @brief Tests whether the QuestEffectBeacon is active. 96 @return Returns true if the QuestEffectBeacon is active, fals if not. 97 */ 98 inline bool isActive(void) 99 { return this->status_ == QuestEffectBeaconStatus::active; } 100 101 bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon. 102 103 protected: 104 bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed. 105 106 /** 107 @brief Returns the number of times the QUestEffectBeacon can still be executed. 108 @return Returns the number of times the QUestEffectBeacon can still be executed. 109 */ 110 inline const int & getTimes(void) const 111 { return this->times_; } 116 112 117 std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player. 118 int times_; //!< Number of times the beacon can be exectued. 119 QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive. 120 121 bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed. 122 bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon. 123 124 const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index. 113 private: 114 static const int INFINITE = -1; //!< Constant to avoid using magic numbers. 115 116 std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player. 117 int times_; //!< Number of times the beacon can be exectued. 118 QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive. 119 120 bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed. 121 bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon. 122 123 const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index. 125 124 126 125 }; -
code/branches/questsystem3/src/orxonox/objects/quest/QuestHint.cc
r2346 r2352 29 29 /** 30 30 @file QuestHint.cc 31 @brief 32 Implementation of the QuestHint class. 31 @brief Implementation of the QuestHint class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/QuestHint.h
r2261 r2352 29 29 /** 30 30 @file QuestHint.h 31 @brief 32 Definition of the QuestHint class. 31 @brief Definition of the QuestHint class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/QuestItem.cc
r2261 r2352 29 29 /** 30 30 @file QuestItem.cc 31 @brief 32 Implementation of the QuestItem class. 31 @brief Implementation of the QuestItem class. 33 32 */ 34 33 … … 102 101 Clarify form, more vigorous checks. 103 102 */ 104 bool QuestItem::isId(const std::string & id)103 /*static*/ bool QuestItem::isId(const std::string & id) 105 104 { 106 105 return id.size() >= 32; -
code/branches/questsystem3/src/orxonox/objects/quest/QuestItem.h
r2346 r2352 29 29 /** 30 30 @file QuestItem.h 31 @brief 32 Definition of the QuestItem class. 33 34 The QuestItem is the parent class of Quest and QuestHint. 31 @brief Definition of the QuestItem class. 32 The QuestItem is the parent class of Quest and QuestHint. 35 33 */ 36 34 … … 71 69 inline const std::string & getId(void) const 72 70 { return this->id_; } 73 /** 74 @brief Returns the QuestDescription of the QuestItem. 75 @return Returns a pointer to the QuestDescription object of the QuestItem. 76 */ 71 72 /** 73 @brief Returns the QuestDescription of the QuestItem. 74 @return Returns a pointer to the QuestDescription object of the QuestItem. 75 */ 77 76 inline const QuestDescription* getDescription(void) const 78 77 { return this->description_; } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.cc
r2346 r2352 27 27 */ 28 28 29 /** 30 @file QuestListener.cc 31 @brief Implementation of the QuestListener class. 32 */ 33 29 34 #include "OrxonoxStableHeaders.h" 30 35 #include "QuestListener.h" … … 40 45 CreateFactory(QuestListener); 41 46 47 /** 48 @brief 49 Constructor. Registers the object and initializes variables. 50 */ 42 51 QuestListener::QuestListener(BaseObject* creator) : BaseObject(creator) 43 52 { 44 53 RegisterObject(QuestListener); 45 54 46 this->status_ = questListener Status::start;55 this->status_ = questListenerMode::all; 47 56 this->quest_ = NULL; 48 57 } 49 58 59 /** 60 @brief 61 Destructor. 62 */ 50 63 QuestListener::~QuestListener() 51 64 { … … 61 74 62 75 XMLPortParam(QuestListener, "questId", setQuestId, getQuestId, xmlelement, mode); 63 XMLPortParam(QuestListener, "questStatus", setQuestStatus, getQuestStatus, xmlelement, mode); 64 65 this->quest_->addListener(this); 66 67 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} and status '" << this->getQuestStatus() << "'." << std::endl; 68 } 69 70 void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status) 71 { 72 for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) 76 XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode); 77 78 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 79 80 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getQuestStatus() << "'." << std::endl; 81 } 82 83 /** 84 @brief 85 Makes all QuestListener in the list aware that a certain status change has occured and executes them if the status change affects them. 86 @param listeners 87 The list of QuestListeners that have to be made aware of the status change. 88 @param status 89 The status that has changed. Can be 'start' (if the Quest was started), 'complete' (if the Quest was completed) or 'fail' (if the Quest was failed). 90 */ 91 /* static */ void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status) 92 { 93 for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) //!< Iterate through all QuestListeners 73 94 { 74 95 QuestListener* listener = *it; 75 if(listener->get QuestStatus() == status)96 if(listener->getMode() == status || listener->getMode() == questListenerMode::all) //!< Check whether the status change affects the give QuestListener. 76 97 { 77 98 listener->execute(); … … 80 101 } 81 102 103 /** 104 @brief 105 Sets the questId of the Quest the QuestListener reacts to. 106 @param id 107 The questId of the Quest the QUestListener reacts to. 108 @return 109 Returns true if successful. 110 */ 111 bool QuestListener::setQuestId(const std::string & id) 112 { 113 this->quest_ = QuestManager::findQuest(id); //!< Find the Quest corresponding to the given questId. 114 115 if(this->quest_ == NULL) //!< If there is no such Quest. 116 { 117 COUT(1) << "This is bad! The QuestListener has not found a Quest qith a corresponding id." << std::endl; //TDO Throw a damn Exception! 118 return false; 119 } 120 121 return true; 122 } 123 124 /** 125 @brief 126 Sets the mode of the QuestListener. 127 @param mode 128 The mode to be set. Can be eighter 'all', 'start', 'fail' or 'complete'. 129 @return 130 Returns true if successful. 131 */ 132 bool QuestListener::setMode(const std::string & mode) 133 { 134 if(status == "all") 135 { 136 this->status_ = questListenerMode::all; 137 } 138 else if(status == "start") 139 { 140 this->status_ = questListenerMode::start; 141 } 142 else if(status == "fail") 143 { 144 this->status_ = questListenerMode::fail; 145 } 146 else if(status == "complete") 147 { 148 this->status_ = questListenerMode::complete; 149 } 150 else 151 { 152 COUT(2) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << std::endl; 153 this->status_ = questListenerMode::all; 154 return false; 155 } 156 157 return true; 158 } 159 160 /** 161 @brief 162 Get the mode of the QuestListener. 163 @return 164 Return the mode of the QuestListener. Can be eighter 'all', 'start', 'fail' or 'complete'. 165 */ 166 const std::string QuestListener::getMode(void) 167 { 168 if(this->status_ == questListenerMode::all) 169 { 170 return "all"; 171 } 172 else if(this->status_ == questListenerMode::start) 173 { 174 return "start"; 175 } 176 else if(this->status_ == questListenerMode::fail) 177 { 178 return "fail"; 179 } 180 else if(this->status_ == questListenerMode::complete) 181 { 182 return "complete"; 183 } 184 else 185 { 186 COUT(1) << "An unforseen, never to happen, Error has occured. This is impossible!" << std::endl; 187 return ""; 188 } 189 } 190 191 /** 192 @brief 193 Executes the QuestListener, resp. fires an Event. 194 @return 195 Returns true if successful. 196 */ 82 197 bool QuestListener::execute() 83 198 { … … 85 200 return true; 86 201 } 87 88 bool QuestListener::setQuestId(const std::string & id)89 {90 this->quest_ = QuestManager::findQuest(id);91 if(this->quest_ == NULL)92 {93 COUT(1) << "This is bad!" << std::endl; //TDO Find a better way.94 return false;95 }96 97 return true;98 }99 100 bool QuestListener::setQuestStatus(const std::string & status)101 {102 if(status == "start")103 {104 this->status_ = questListenerStatus::start;105 return true;106 }107 else if(status == "fail")108 {109 this->status_ = questListenerStatus::fail;110 return true;111 }112 else if(status == "complete")113 {114 this->status_ = questListenerStatus::complete;115 return true;116 }117 else118 {119 COUT(2) << "QuestListener with invalid status '" << status << "' created. Status set to 'start'." << std::endl;120 this->status_ = questListenerStatus::start;121 return false;122 }123 }124 125 const std::string QuestListener::getQuestStatus(void)126 {127 if(this->status_ == questListenerStatus::start)128 {129 return "start";130 }131 else if(this->status_ == questListenerStatus::fail)132 {133 return "fail";134 }135 else if(this->status_ == questListenerStatus::complete)136 {137 return "complete";138 }139 else140 {141 COUT(1) << "An unforseen, never to happen, Error has occured. This is impossible!" << std::endl;142 return "";143 }144 }145 146 202 147 203 } -
code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.h
r2346 r2352 27 27 */ 28 28 29 /** 30 @file QuestListener.h 31 @brief Definition of the QuestListener class. 32 */ 33 29 34 #ifndef _QuestListener_H__ 30 35 #define _QuestListener_H__ … … 36 41 37 42 #include "core/BaseObject.h" 43 38 44 #include "Quest.h" 39 45 40 namespace questListener Status46 namespace questListenerMode 41 47 { 42 48 49 //! The mode of the QuestListener. 43 50 enum Enum 44 51 { 52 all, 45 53 start, 46 54 fail, … … 54 62 /** 55 63 @brief 64 Provides a way to react to the starting, completing and failing of Quests. 56 65 66 The XML representation goes as follows: 67 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. 68 69 <BaseObject> // The object that should react to the status change of a Quest. 70 <events> 71 <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity. 72 <QuestListener questId="someQuestId" mode="someMode" /> // Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail). 73 </function> 74 </events> 75 </BaseObject> 57 76 @author 58 77 Damian 'Mozork' Frick … … 66 85 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML. 67 86 68 bool setQuestId(const std::string & id); 69 bool setQuestStatus(const std::string & status); 87 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. 70 88 71 const std::string getQuestStatus(void); 89 bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to. 90 bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener. 91 92 const std::string getMode(void); //!< Get the mode of the QuestListener. 93 94 /** 95 @brief Get the questId of the Quest the QuestListener reacts to. 96 @return Returns the questId of the Quest the QuestListener reacts to. 97 */ 72 98 inline const std::string & getQuestId(void) 73 99 { return this->quest_->getId(); } 74 75 static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status);76 100 77 bool execute(void); 101 bool execute(void); //!< Executes the QuestListener, resp. fires an Event. 78 102 79 103 private: 80 questListener Status::Enum status_;81 Quest* quest_; 104 questListenerMode::Enum mode_; //!< The mode of the QuestListener. 105 Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to. 82 106 83 107 }; -
code/branches/questsystem3/src/orxonox/objects/quest/QuestManager.cc
r2261 r2352 29 29 /** 30 30 @file QuestManager.cc 31 @brief 32 Implementation of the QuestManager class. 31 @brief Implementation of the QuestManager class. 33 32 */ 34 33 … … 76 75 Returns true if successful, false if not. 77 76 */ 78 bool QuestManager::registerQuest(Quest* quest)77 /*static*/ bool QuestManager::registerQuest(Quest* quest) 79 78 { 80 79 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. … … 108 107 Returns true if successful, false if not. 109 108 */ 110 bool QuestManager::registerHint(QuestHint* hint)109 /*static*/ bool QuestManager::registerHint(QuestHint* hint) 111 110 { 112 111 if(hint == NULL) //!< Still not liking NULL-pointers. … … 142 141 Throws an exception if the given questId is invalid. 143 142 */ 144 Quest* QuestManager::findQuest(const std::string & questId)143 /*static*/ Quest* QuestManager::findQuest(const std::string & questId) 145 144 { 146 145 if(!QuestItem::isId(questId)) //!< Check vor validity of the given id. … … 176 175 Throws an exception if the given hintId is invalid. 177 176 */ 178 QuestHint* QuestManager::findHint(const std::string & hintId)177 /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId) 179 178 { 180 179 if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id. -
code/branches/questsystem3/src/orxonox/objects/quest/QuestManager.h
r2261 r2352 29 29 /** 30 30 @file QuestManager.h 31 @brief 32 Definition of the QuestManager class. 31 @brief Definition of the QuestManager class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/Rewardable.cc
r2261 r2352 29 29 /** 30 30 @file Rewardable.cc 31 @brief 32 Implementation of the Rewardable class. 31 @brief Implementation of the Rewardable class. 33 32 */ 34 33 -
code/branches/questsystem3/src/orxonox/objects/quest/Rewardable.h
r2261 r2352 29 29 /** 30 30 @file Rewardable.h 31 @brief 32 Definition of the Rewardable class. 31 @brief Definition of the Rewardable class. 33 32 */ 34 33 … … 61 60 Method to transcribe a rewardable object to the player. 62 61 Must be implemented by every class inheriting from Rewardable. 63 @param player62 @param player 64 63 A pointer to the ControllableEntity, do whatever you want with it. 65 @return64 @return 66 65 Return true if successful. 67 66 */ 68 virtual bool reward(PlayerInfo* player) = 0; //!<67 virtual bool reward(PlayerInfo* player) = 0; 69 68 70 69 };
Note: See TracChangeset
for help on using the changeset viewer.