Changeset 7456 for code/trunk/src/modules/questsystem/GlobalQuest.cc
- Timestamp:
- Sep 15, 2010, 7:29:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/GlobalQuest.cc
r7163 r7456 28 28 29 29 /** 30 @file 30 @file GlobalQuest.cc 31 31 @brief Implementation of the GlobalQuest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 38 39 #include "QuestEffect.h" 39 40 … … 84 85 bool GlobalQuest::fail(PlayerInfo* player) 85 86 { 86 if(!this->isFailable(player)) // !<Check whether the Quest can be failed.87 if(!this->isFailable(player)) // Check whether the Quest can be failed. 87 88 { 88 89 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; … … 92 93 Quest::fail(player); 93 94 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; 95 // Iterate through all players possessing this Quest. 96 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 97 QuestEffect::invokeEffects(*it, this->getFailEffectList()); 98 99 return true; 101 100 } 102 101 … … 113 112 bool GlobalQuest::complete(PlayerInfo* player) 114 113 { 115 if(!this->isCompletable(player)) // !<Check whether the Quest can be completed.114 if(!this->isCompletable(player)) // Check whether the Quest can be completed. 116 115 { 117 116 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; … … 119 118 } 120 119 121 // !Iterate through all players possessing the Quest.120 // Iterate through all players possessing the Quest. 122 121 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 123 {124 122 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 125 }126 123 127 124 Quest::complete(player); 128 125 129 QuestEffect::invokeEffects(player, this->rewards_); // !<Invoke reward QuestEffects on the player completing the Quest.126 QuestEffect::invokeEffects(player, this->rewards_); // Invoke reward QuestEffects on the player completing the Quest. 130 127 return true; 131 128 } … … 144 141 { 145 142 if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player))) 146 { 147 return false; 148 } 143 return false; 144 149 145 return (this->isInactive(player) && !(this->status_ == QuestStatus::Completed || this->status_ == QuestStatus::Failed)); 150 146 } … … 191 187 QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const 192 188 { 193 if(player == NULL) //!< We don't want NULL-Pointers!194 {189 //TODO: Replace with assert. 190 if(player == NULL) // We don't want NULL-Pointers! 195 191 ThrowException(Argument, "The input PlayerInfo* is NULL."); 196 } 197 198 //! Find the player. 192 193 // Find the player. 199 194 std::set<PlayerInfo*>::const_iterator it = this->players_.find((PlayerInfo*)(void*)player); 200 if (it != this->players_.end()) //!< If the player was found. 201 { 195 if (it != this->players_.end()) // If the player was found. 202 196 return this->status_; 203 }204 197 205 198 return QuestStatus::Inactive; … … 219 212 bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status) 220 213 { 221 if(player == NULL) //!< We don't want NULL-Pointers! 222 { 223 return false; 224 } 225 226 //! Find the player. 214 //TODO: Replace with assert. 215 if(player == NULL) // We don't want NULL-Pointers! 216 return false; 217 218 // Find the player. 227 219 std::set<PlayerInfo*>::const_iterator it = this->players_.find(player); 228 if (it == this->players_.end()) //!< Player is not yet in the list. 229 { 230 this->players_.insert(player); //!< Add the player to the set. 231 } 232 233 this->status_ = status; //!< Set the status, which is global, remember...? 220 if (it == this->players_.end()) // Player is not yet in the list. 221 this->players_.insert(player); // Add the player to the set. 222 223 this->status_ = status; // Set the status, which is global, remember...? 234 224 return true; 235 225 } … … 245 235 bool GlobalQuest::addRewardEffect(QuestEffect* effect) 246 236 { 247 if(effect == NULL) //!< We don't want NULL-Pointers! 237 //TODO: Replace with assert? 238 if(effect == NULL) // We don't want NULL-Pointers! 248 239 { 249 240 COUT(2) << "The reward effect to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 251 242 } 252 243 253 this->rewards_.push_back(effect); // !<Add the QuestEffect to the list.244 this->rewards_.push_back(effect); // Add the QuestEffect to the list. 254 245 255 246 COUT(4) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl; … … 271 262 { 272 263 if(i == 0) 273 {274 264 return *effect; 275 } 265 276 266 i--; 277 267 } … … 279 269 } 280 270 281 282 271 }
Note: See TracChangeset
for help on using the changeset viewer.