Changeset 2261 for code/trunk/src/orxonox/objects/quest/LocalQuest.cc
- Timestamp:
- Nov 25, 2008, 11:56:40 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/questsystem2 (added) merged: 2109,2146,2159,2191,2193-2196,2205-2206,2208-2209,2221,2226,2228,2251,2258
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/LocalQuest.cc (added) merged: 2146,2159,2191,2205,2251,2258 /code/trunk/src/orxonox/objects/quest/LocalQuest.cc merged: 1925-2089
r2105 r2261 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/infos/PlayerInfo.h" 42 #include "QuestEffect.h" 43 35 44 namespace orxonox { 36 45 37 46 CreateFactory(LocalQuest); 38 47 48 /** 49 @brief 50 Constructor. Registers and initializes the object. 51 */ 39 52 LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator) 40 53 { 41 54 RegisterObject(LocalQuest); 42 43 this->initialize();44 55 } 45 56 … … 53 64 } 54 65 66 /** 67 @brief 68 Method for creating a LocalQuest object through XML. 69 */ 55 70 void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 71 { … … 60 75 } 61 76 62 void LocalQuest::initialize(void) 63 { 64 RegisterObject(LocalQuest); 65 } 66 67 /** 68 @brief 69 Checks whether the quest can be started. 77 /** 78 @brief 79 Fails the Quest for a given player. 80 Invokes all the failEffects on the player. 81 @param player 82 The player. 83 @return 84 Returns true if the Quest could be failed, false if not. 85 */ 86 bool LocalQuest::fail(PlayerInfo* player) 87 { 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; 97 } 98 99 /** 100 @brief 101 Completes the Quest for a given player. 102 Invokes all the complete QuestEffects on the player. 103 @param player 104 The player. 105 @return 106 Returns true if the Quest could be completed, false if not. 107 */ 108 bool LocalQuest::complete(PlayerInfo* player) 109 { 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; 119 } 120 121 /** 122 @brief 123 Checks whether the Quest can be started. 70 124 @param player 71 125 The player for whom is to be checked. 72 126 @return 73 Returns true if the quest can be started, false if not. 74 @throws 75 Throws an exception if isInactive(Player*) throws one. 76 */ 77 bool LocalQuest::isStartable(const Player* player) const 78 { 127 Returns true if the Quest can be started, false if not. 128 @throws 129 Throws an exception if isInactive(PlayerInfo*) throws one. 130 */ 131 bool LocalQuest::isStartable(const PlayerInfo* player) const 132 { 133 if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player))) 134 { 135 return false; 136 } 79 137 return this->isInactive(player); 80 138 } … … 82 140 /** 83 141 @brief 84 Checks whether the quest can be failed.142 Checks whether the Quest can be failed. 85 143 @param player 86 144 The player for whom is to be checked. 87 145 @return 88 Returns true if the quest can be failed, false if not.89 @throws 90 Throws an exception if isActive(Player *) throws one.91 */ 92 bool LocalQuest::isFailable(const Player * player) const146 Returns true if the Quest can be failed, false if not. 147 @throws 148 Throws an exception if isActive(PlayerInfo*) throws one. 149 */ 150 bool LocalQuest::isFailable(const PlayerInfo* player) const 93 151 { 94 152 return this->isActive(player); … … 97 155 /** 98 156 @brief 99 Checks whether the quest can be completed.157 Checks whether the Quest can be completed. 100 158 @param player 101 159 The player for whom is to be checked. 102 160 @return 103 Returns true if the quest can be completed, false if not.104 @throws 105 Throws an exception if isInactive(Player *) throws one.106 */ 107 bool LocalQuest::isCompletable(const Player * player) const161 Returns true if the Quest can be completed, false if not. 162 @throws 163 Throws an exception if isInactive(PlayerInfo*) throws one. 164 */ 165 bool LocalQuest::isCompletable(const PlayerInfo* player) const 108 166 { 109 167 return this->isActive(player); … … 112 170 /** 113 171 @brief 114 Returns the status of the quest for a specific player.172 Returns the status of the Quest for a specific player. 115 173 @param player 116 174 The player. 117 175 @return 118 Returns the status of the quest for the input player.176 Returns the status of the Quest for the input player. 119 177 @throws 120 178 Throws an Exception if player is NULL. 121 179 */ 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()) 180 questStatus::Enum LocalQuest::getStatus(const PlayerInfo* player) const 181 { 182 if(player == NULL) //!< No player has no defined status. 183 { 184 ThrowException(Argument, "The input PlayerInfo* is NULL."); 185 } 186 187 std::map<const PlayerInfo*, questStatus::Enum>::const_iterator it = this->playerStatus_.find(player); 188 if (it != this->playerStatus_.end()) //!< If there is a player in the map. 131 189 { 132 190 return it->second; 133 191 } 134 return questStatus::inactive; 192 193 return questStatus::inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'. 135 194 } 136 195 … … 138 197 @brief 139 198 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 .199 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! 200 @param player 201 The player the status should be set for. 143 202 @param status 144 The status .203 The status to be set. 145 204 @return 146 205 Returns false if player is NULL. 147 206 */ 148 bool LocalQuest::setStatus(Player * player, const questStatus::Enum & status)149 { 150 if(player == NULL) 207 bool LocalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status) 208 { 209 if(player == NULL) //!< We can't set a status for no player. 151 210 { 152 211 return false; 153 212 } 213 154 214 this->playerStatus_[player] = status; 155 215 return true; - Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.