- Timestamp:
- Nov 6, 2008, 12:02:05 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem2/src/orxonox/objects/quest/LocalQuest.cc
r2105 r2146 27 27 */ 28 28 29 /** 30 @file LocalQuest.cc 31 @brief 32 Implementation of the LocalQuest class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "LocalQuest.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/worldentities/ControllableEntity.h" 42 #include "QuestEffect.h" 43 35 44 namespace orxonox { 36 45 37 46 CreateFactory(LocalQuest); 38 47 48 /** 49 @brief 50 Constructor. Initializes the object. 51 */ 39 52 LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator) 40 53 { 54 this->initialize(); 55 } 56 57 /** 58 @brief 59 Initializes the object. 60 */ 61 void LocalQuest::initialize(void) 62 { 41 63 RegisterObject(LocalQuest); 42 43 this->initialize();44 64 } 45 65 … … 53 73 } 54 74 75 /** 76 @brief 77 Method for creating a LocalQuest object through XML. 78 */ 55 79 void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 80 { … … 60 84 } 61 85 62 void LocalQuest::initialize(void) 63 { 64 RegisterObject(LocalQuest); 86 /** 87 @brief 88 Fails the quest for a given player. 89 Invokes all the failEffects on the player. 90 @param player 91 The player. 92 @return 93 Returns true if the quest could be failed, false if not. 94 */ 95 bool LocalQuest::fail(ControllableEntity* player) 96 { 97 if(this->isFailable(player)) //!< Checks whether the quest can be failed. 98 { 99 this->setStatus(player, questStatus::failed); 100 QuestEffect::invokeEffects(player, this->failEffects_); //!< Invoke the failEffects. 101 return true; 102 } 103 104 COUT(2) << "A non-failable quest was trying to be failed." << std::endl; 105 return false; 106 } 107 108 /** 109 @brief 110 Completes the quest for a given player. 111 Invokes all the completeEffects on the player. 112 @param player 113 The player. 114 @return 115 Returns true if the quest could be completed, false if not. 116 */ 117 bool LocalQuest::complete(ControllableEntity* player) 118 { 119 if(this->isCompletable(player)) //!< Checks whether the quest can be completed. 120 { 121 this->setStatus(player, questStatus::completed); 122 QuestEffect::invokeEffects(player, this->completeEffects_); //!< Invoke the completeEffects. 123 return true; 124 } 125 126 COUT(2) << "A non-completable quest was trying to be completed." << std::endl; 127 return false; 65 128 } 66 129 … … 73 136 Returns true if the quest can be started, false if not. 74 137 @throws 75 Throws an exception if isInactive( Player*) throws one.76 */ 77 bool LocalQuest::isStartable(const Player* player) const138 Throws an exception if isInactive(ControllableEntity*) throws one. 139 */ 140 bool LocalQuest::isStartable(const ControllableEntity* player) const 78 141 { 79 142 return this->isInactive(player); … … 88 151 Returns true if the quest can be failed, false if not. 89 152 @throws 90 Throws an exception if isActive( Player*) throws one.91 */ 92 bool LocalQuest::isFailable(const Player* player) const153 Throws an exception if isActive(ControllableEntity*) throws one. 154 */ 155 bool LocalQuest::isFailable(const ControllableEntity* player) const 93 156 { 94 157 return this->isActive(player); … … 103 166 Returns true if the quest can be completed, false if not. 104 167 @throws 105 Throws an exception if isInactive( Player*) throws one.106 */ 107 bool LocalQuest::isCompletable(const Player* player) const168 Throws an exception if isInactive(ControllableEntity*) throws one. 169 */ 170 bool LocalQuest::isCompletable(const ControllableEntity* player) const 108 171 { 109 172 return this->isActive(player); … … 120 183 Throws an Exception if player is NULL. 121 184 */ 122 questStatus::Enum LocalQuest::getStatus(const Player* player) const123 { 124 if(player == NULL) 125 { 126 ThrowException(Argument, "The input Player* is NULL.");127 } 128 129 std::map< Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'.130 if (it != this->playerStatus_.end()) 185 questStatus::Enum LocalQuest::getStatus(const ControllableEntity* player) const 186 { 187 if(player == NULL) //!< No player has no defined status. 188 { 189 ThrowException(Argument, "The input ControllableEntity* is NULL."); 190 } 191 192 std::map<ControllableEntity*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((ControllableEntity*)(void*)player); //Thx. to x3n for the (ControllableEntity*)(void*) 'hack'. 193 if (it != this->playerStatus_.end()) //!< If there is a player in the map. 131 194 { 132 195 return it->second; 133 196 } 134 return questStatus::inactive; 197 198 return questStatus::inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'. 135 199 } 136 200 … … 138 202 @brief 139 203 Sets the status for a specific player. 140 But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing. 141 @param player 142 The player .204 But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing. Really! 205 @param player 206 The player the status should be set for. 143 207 @param status 144 The status .208 The status to be set. 145 209 @return 146 210 Returns false if player is NULL. 147 211 */ 148 bool LocalQuest::setStatus( Player* player, const questStatus::Enum & status)149 { 150 if(player == NULL) 212 bool LocalQuest::setStatus(ControllableEntity* player, const questStatus::Enum & status) 213 { 214 if(player == NULL) //!< We can't set a status for no player. 151 215 { 152 216 return false; 153 217 } 218 154 219 this->playerStatus_[player] = status; 155 220 return true;
Note: See TracChangeset
for help on using the changeset viewer.