Changeset 2076 for code/branches/questsystem/src/orxonox/objects/Quest.cc
- Timestamp:
- Oct 31, 2008, 7:35:08 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem/src/orxonox/objects/Quest.cc
r2068 r2076 38 38 this->initialize(); 39 39 } 40 41 /**42 @brief43 Constructor. Creates a quest with a given id, title and description.44 @param id45 The unique identifier of the quest.46 @param title47 The title of the quest.48 @param description49 The description of the quest.50 */51 Quest::Quest(std::string id) : QuestItem(id)52 {53 this->initialize();54 }55 40 56 41 /** … … 63 48 } 64 49 50 void Quest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 51 { 52 SUPER(Quest, XMLPort, xmlelement, mode); 53 54 XMLPortObject(Quest, Quest, "", addSubQuest, getSubQuests, xmlelement, mode); 55 XMLPortObject(Quest, QuestHint, "", addHint, getHints, xmlelement, mode); 56 XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffects, xmlelement, mode); 57 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffects, xmlelement, mode); 58 59 QuestManager::registerQuest(this); //Registers the quest with the QuestManager. 60 } 61 65 62 /** 66 63 @brief … … 72 69 73 70 this->parentQuest_ = NULL; 74 QuestManager::registerQuest(this); //Registers the quest with the QuestManager.75 71 } 76 72 … … 111 107 } 112 108 109 quest->setParentQuest(this); 113 110 this->subQuests_.push_back(quest); 114 111 return true; 112 } 113 114 115 /** 116 @brief 117 Adds a Hint to the list of hints 118 @param hint 119 The hint that should be added to the list of hints. 120 @return 121 Returns true if the hint was successfully added. 122 */ 123 bool Quest::addHint(QuestHint* hint) 124 { 125 if(hint == NULL) 126 { 127 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; 128 return false; 129 } 130 131 this->hints_.push_back(hint); 132 hint->setQuest(this); 133 return true; 134 } 135 136 /** 137 @brief 138 139 */ 140 bool Quest::addFailEffect(QuestEffect* effect) 141 { 142 if(effect == NULL) 143 { 144 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; 145 return false; 146 } 147 148 this->failEffects_.push_back(effect); 149 return true; 150 } 151 152 /** 153 @brief 154 155 */ 156 bool Quest::addCompleteEffect(QuestEffect* effect) 157 { 158 if(effect == NULL) 159 { 160 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; 161 return false; 162 } 163 164 this->completeEffects_.push_back(effect); 165 return true; 166 } 167 168 /** 169 @brief 170 171 */ 172 const Quest* Quest::getParentQuest(void) 173 { 174 return this->parentQuest_; 175 } 176 177 /** 178 @brief 179 180 */ 181 const Quest* Quest::getSubQuests(unsigned int index) const 182 { 183 int i = index; 184 for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest) 185 { 186 if(i == 0) 187 { 188 return *subQuest; 189 } 190 i--; 191 } 192 return NULL; 193 } 194 195 /** 196 @brief 197 198 */ 199 const QuestHint* Quest::getHints(unsigned int index) const 200 { 201 int i = index; 202 for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint) 203 { 204 if(i == 0) 205 { 206 return *hint; 207 } 208 i--; 209 } 210 return NULL; 211 } 212 213 /** 214 @brief 215 216 */ 217 const QuestEffect* Quest::getFailEffects(unsigned int index) const 218 { 219 int i = index; 220 for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect) 221 { 222 if(i == 0) 223 { 224 return *effect; 225 } 226 i--; 227 } 228 return NULL; 229 } 230 231 /** 232 @brief 233 234 */ 235 const QuestEffect* Quest::getCompleteEffects(unsigned int index) const 236 { 237 int i = index; 238 for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect) 239 { 240 if(i == 0) 241 { 242 return *effect; 243 } 244 i--; 245 } 246 return NULL; 115 247 } 116 248 … … 175 307 return this->getStatus(player) == questStatus::completed; 176 308 } 177 178 /**179 @brief180 Adds a Hint to the list of hints181 @param hint182 The hint that should be added to the list of hints.183 @return184 Returns true if the hint was successfully added.185 */186 bool Quest::addHint(QuestHint* hint)187 {188 if(hint == NULL)189 {190 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl;191 return false;192 }193 194 this->hints_.push_back(hint);195 hint->setQuest(this);196 return true;197 }198 309 199 310 /**
Note: See TracChangeset
for help on using the changeset viewer.