Changeset 2076 for code/branches/questsystem/src/orxonox
- Timestamp:
- Oct 31, 2008, 7:35:08 AM (16 years ago)
- Location:
- code/branches/questsystem/src/orxonox/objects
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem/src/orxonox/objects/AddQuest.cc
r2068 r2076 43 43 AddQuest::AddQuest() : ChangeQuestStatus() 44 44 { 45 46 }47 48 /**49 @brief50 Constructor.51 @param questId52 The id of the quest to be added.53 */54 AddQuest::AddQuest(std::string questId) : ChangeQuestStatus(questId)55 {56 45 RegisterObject(AddQuest); 57 46 } … … 63 52 AddQuest::~AddQuest() 64 53 { 54 } 55 56 void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 { 58 SUPER(AddQuest, XMLPort, xmlelement, mode); 59 65 60 } 66 61 -
code/branches/questsystem/src/orxonox/objects/AddQuest.h
r2068 r2076 32 32 #include <string> 33 33 34 #include "core/XMLPort.h" 34 35 #include "ChangeQuestStatus.h" 35 36 … … 48 49 public: 49 50 AddQuest(); 50 AddQuest(std::string questId);51 51 ~AddQuest(); 52 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 54 53 55 virtual bool invoke(Player* player); //!< Invokes the effect. -
code/branches/questsystem/src/orxonox/objects/AddQuestHint.cc
r2068 r2076 41 41 42 42 } 43 44 /**45 @brief46 Constructor.47 @param hintId48 The id of the hint to be set to active.49 */50 AddQuestHint::AddQuestHint(std::string hintId) : QuestEffect()51 {52 RegisterObject(AddQuestHint);53 this->hintId_ = hintId;54 }55 43 56 44 /** … … 60 48 AddQuestHint::~AddQuestHint() 61 49 { 50 } 51 52 void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 53 { 54 SUPER(AddQuestHint, XMLPort, xmlelement, mode); 55 56 XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); 57 62 58 } 63 59 -
code/branches/questsystem/src/orxonox/objects/AddQuestHint.h
r2068 r2076 48 48 public: 49 49 AddQuestHint(); 50 AddQuestHint(std::string hintId);51 50 ~AddQuestHint(); 51 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 53 53 54 virtual bool invoke(Player* player); //!< Invokes the effect. … … 55 56 private: 56 57 std::string hintId_; 58 59 inline const std::string & getHintId(void) const 60 { return this->hintId_; } 61 inline void setHintId(const std::string & id) 62 { this->hintId_ = id; } 57 63 58 64 }; -
code/branches/questsystem/src/orxonox/objects/AddReward.cc
r2068 r2076 37 37 AddReward::AddReward() : QuestEffect() 38 38 { 39 40 }41 42 /**43 @brief44 Constructor. Creates a new AddReward effect with an input reward.45 @param reward46 A reward.47 */48 AddReward::AddReward(Rewardable* reward) : QuestEffect()49 {50 39 this->initialize(); 51 this->addRewardable(reward);52 }53 54 /**55 @brief56 Constructor. Creates a new AddReward effect with an input list of rewards.57 @param rewards58 A list of rewards.59 */60 AddReward::AddReward(std::list<Rewardable*>* rewards) : QuestEffect()61 {62 this->initialize();63 this->rewards_ = rewards;64 40 } 65 41 … … 72 48 } 73 49 50 void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode) 51 { 52 SUPER(AddReward, XMLPort, xmlelement, mode); 53 54 XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); 55 56 } 57 74 58 /** 75 59 @brief … … 79 63 { 80 64 RegisterObject(AddReward); 65 } 66 67 const Rewardable* AddReward::getRewardables(unsigned int index) const 68 { 69 int i = index; 70 for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward) 71 { 72 if(i == 0) 73 { 74 return *reward; 75 } 76 i--; 77 } 78 return NULL; 81 79 } 82 80 … … 91 89 bool AddReward::invoke(Player* player) 92 90 { 93 if ( this->rewards_ == NULL )94 {95 COUT(2) << "NULL-Rewards list encountered." << std::endl;96 return false;97 }98 99 91 bool check = true; 100 for ( std::list<Rewardable*>::iterator reward = this->rewards_ ->begin(); reward != this->rewards_->end(); ++reward )92 for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward ) 101 93 { 102 94 check = check && (*reward)->reward(player); -
code/branches/questsystem/src/orxonox/objects/AddReward.h
r2068 r2076 32 32 #include <list> 33 33 34 #include "core/XMLPort.h" 34 35 #include "Rewardable.h" 35 36 #include "QuestEffect.h" … … 49 50 public: 50 51 AddReward(); 51 AddReward(Rewardable* reward);52 AddReward(std::list<Rewardable*>* rewards);53 52 ~AddReward(); 53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 55 55 56 virtual bool invoke(Player* player); //!< Invokes the effect. 56 57 57 58 private: 58 std::list<Rewardable*> *rewards_;59 std::list<Rewardable*> rewards_; 59 60 60 61 void initialize(void); //!< Initializes the object. 61 62 62 63 inline void addRewardable(Rewardable* reward) 63 { this->rewards_->push_back(reward); } 64 { this->rewards_.push_back(reward); } 65 const Rewardable* getRewardables(unsigned int index) const; 64 66 65 67 }; -
code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.cc
r2021 r2076 35 35 ChangeQuestStatus::ChangeQuestStatus() : QuestEffect() 36 36 { 37 37 RegisterObject(ChangeQuestStatus); 38 38 } 39 39 40 /**41 @brief42 Constructor.43 @param questId44 The id of the quest the status should be changed of.45 */46 ChangeQuestStatus::ChangeQuestStatus(std::string questId) : QuestEffect()47 {48 RegisterObject(ChangeQuestStatus);49 this->questId_ = questId;50 }51 52 40 /** 53 41 @brief … … 57 45 { 58 46 } 47 48 void ChangeQuestStatus::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 { 50 SUPER(ChangeQuestStatus, XMLPort, xmlelement, mode); 51 52 XMLPortParam(ChangeQuestStatus, "questId", setQuestId, getQuestId, xmlelement, mode); 53 } 59 54 60 55 } -
code/branches/questsystem/src/orxonox/objects/ChangeQuestStatus.h
r2068 r2076 32 32 #include <string> 33 33 34 #include "core/XMLPort.h" 34 35 #include "QuestEffect.h" 35 36 … … 48 49 public: 49 50 ChangeQuestStatus(); 50 ChangeQuestStatus(std::string questId);51 51 virtual ~ChangeQuestStatus(); 52 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 54 53 55 virtual bool invoke(Player* player) = 0; //!< Invokes the effect. 54 56 55 57 protected: 56 inline std::string getQuestId(void)//!< Returns the quest id.57 { return questId_; }58 inline const std::string & getQuestId(void) const //!< Returns the quest id. 59 { return this->questId_; } 58 60 59 61 std::string questId_; //!< The id of the quest the status should be changed of. 62 63 private: 64 inline void setQuestId(const std::string & id) 65 { this->questId_ = id; } 60 66 61 67 }; -
code/branches/questsystem/src/orxonox/objects/CompleteQuest.cc
r2068 r2076 40 40 CompleteQuest::CompleteQuest() : ChangeQuestStatus() 41 41 { 42 43 }44 45 /**46 @brief47 Constructor.48 @param questId49 The id of the quest to be completed.50 */51 CompleteQuest::CompleteQuest(std::string questId) : ChangeQuestStatus(questId)52 {53 42 RegisterObject(CompleteQuest); 54 43 } … … 60 49 CompleteQuest::~CompleteQuest() 61 50 { 51 } 52 53 void CompleteQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 { 55 SUPER(CompleteQuest, XMLPort, xmlelement, mode); 62 56 } 63 57 -
code/branches/questsystem/src/orxonox/objects/CompleteQuest.h
r2068 r2076 32 32 #include <string> 33 33 34 #include "core/XMLPort.h" 34 35 #include "ChangeQuestStatus.h" 35 36 … … 48 49 public: 49 50 CompleteQuest(); 50 CompleteQuest(std::string questId);51 51 ~CompleteQuest(); 52 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 54 53 55 virtual bool invoke(Player* player); //!< Invokes the effect. -
code/branches/questsystem/src/orxonox/objects/FailQuest.cc
r2068 r2076 40 40 FailQuest::FailQuest() : ChangeQuestStatus() 41 41 { 42 43 }44 45 /**46 @brief47 Constructor.48 @param questId49 The id of the quest to be failed.50 */51 FailQuest::FailQuest(std::string questId) : ChangeQuestStatus(questId)52 {53 42 RegisterObject(FailQuest); 54 43 } … … 60 49 FailQuest::~FailQuest() 61 50 { 51 } 52 53 void FailQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 { 55 SUPER(FailQuest, XMLPort, xmlelement, mode); 62 56 } 63 57 -
code/branches/questsystem/src/orxonox/objects/FailQuest.h
r2068 r2076 32 32 #include <string> 33 33 34 #include "core/XMLPort.h" 34 35 #include "ChangeQuestStatus.h" 35 36 … … 48 49 public: 49 50 FailQuest(); 50 FailQuest(std::string questId);51 51 ~FailQuest(); 52 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 54 53 55 virtual bool invoke(Player* player); //!< Invokes the effect. -
code/branches/questsystem/src/orxonox/objects/GlobalQuest.cc
r2068 r2076 44 44 this->initialize(); 45 45 } 46 47 /**48 @brief49 Constructor.50 @param id51 The unique identifier.52 @param title53 The title of the quest.54 @param description55 The description of the quest.56 */57 GlobalQuest::GlobalQuest(std::string id) : Quest(id)58 {59 this->initialize();60 }61 46 62 47 /** … … 67 52 { 68 53 54 } 55 56 void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 { 58 SUPER(GlobalQuest, XMLPort, xmlelement, mode); 59 60 COUT(1) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 69 61 } 70 62 -
code/branches/questsystem/src/orxonox/objects/GlobalQuest.h
r2068 r2076 32 32 #include <set> 33 33 34 #include "core/XMLPort.h" 34 35 #include "Quest.h" 35 36 … … 49 50 public: 50 51 GlobalQuest(); 51 GlobalQuest(std::string id);52 52 ~GlobalQuest(); 53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 55 54 56 protected: -
code/branches/questsystem/src/orxonox/objects/LocalQuest.cc
r2068 r2076 40 40 this->initialize(); 41 41 } 42 43 /**44 @brief45 Constructor.46 @param id47 The unique identifier.48 */49 LocalQuest::LocalQuest(std::string id) : Quest(id)50 {51 this->initialize();52 }53 42 54 43 /** … … 59 48 { 60 49 50 } 51 52 void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 53 { 54 SUPER(LocalQuest, XMLPort, xmlelement, mode); 55 56 COUT(1) << "New LocalQuest {" << this->getId() << "} created." << std::endl; 61 57 } 62 58 -
code/branches/questsystem/src/orxonox/objects/LocalQuest.h
r2068 r2076 33 33 #include <string> 34 34 35 #include "core/XMLPort.h" 35 36 #include "Quest.h" 36 37 … … 49 50 public: 50 51 LocalQuest(); 51 LocalQuest(std::string id);52 52 ~LocalQuest(); 53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 55 54 56 protected: -
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 /** -
code/branches/questsystem/src/orxonox/objects/Quest.h
r2068 r2076 33 33 #include <string> 34 34 35 #include "core/XMLPort.h" 35 36 #include "QuestDescription.h" 36 37 #include "QuestItem.h" … … 67 68 public: 68 69 Quest(); 69 Quest(std::string id);70 70 virtual ~Quest(); 71 72 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 71 73 72 74 inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. 73 75 { return this->parentQuest_; } 74 inline const std::list<Quest*> & getSubQuest (void) const //!< Returns the list of sub quests.76 inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests. 75 77 { return this->subQuests_; } 76 78 … … 83 85 bool fail(Player* player); //!< Fails the quest. 84 86 bool complete(Player* player); //!< Completes the quest. 85 86 bool addHint(QuestHint* hint); //!< Add a hint to the list of hints.87 87 88 88 protected: … … 95 95 bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest. 96 96 bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest. 97 bool addHint(QuestHint* hint); //!< Add a hint to the list of hints. 98 bool addFailEffect(QuestEffect* effect); 99 bool addCompleteEffect(QuestEffect* effect); 100 101 const Quest* getParentQuest(void); 102 const Quest* getSubQuests(unsigned int index) const; 103 const QuestHint* getHints(unsigned int index) const; 104 const QuestEffect* getFailEffects(unsigned int index) const; 105 const QuestEffect* getCompleteEffects(unsigned int index) const; 97 106 98 107 virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player. -
code/branches/questsystem/src/orxonox/objects/QuestDescription.cc
r2068 r2076 39 39 this->initialize(); 40 40 } 41 42 /**43 @brief44 Constructor. Creates a new QuestDescription object and adds a title and description.45 @param title46 @param description47 */48 QuestDescription::QuestDescription(std::string title, std::string description) : BaseObject()49 {50 this->initialize();51 this->title_ = title;52 this->description_ = description;53 }54 41 55 42 QuestDescription::~QuestDescription() … … 65 52 XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); 66 53 67 COUT(1) << " QuestDescription created!" << std::endl;54 COUT(1) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 68 55 } 69 56 -
code/branches/questsystem/src/orxonox/objects/QuestDescription.h
r2068 r2076 48 48 public: 49 49 QuestDescription(); 50 QuestDescription(std::string title, std::string description = "");51 50 ~QuestDescription(); 52 51 -
code/branches/questsystem/src/orxonox/objects/QuestHint.cc
r2068 r2076 45 45 this->initialize(); 46 46 } 47 48 /**49 @brief50 Constructor. Needs as input a unique identifier to be able to identify different instances of this class (and subclasses).51 @param id52 The unique identifier.53 @param title54 The title of the hint.55 @param description56 The description of the hint, resp. the hint itself.57 */58 QuestHint::QuestHint(std::string id) : QuestItem(id)59 {60 this->initialize();61 }62 47 63 48 /** … … 78 63 { 79 64 SUPER(QuestHint, XMLPort, xmlelement, mode); 65 66 COUT(1) << "New QuestHint {" << this->getId() << "} created." << std::endl; 80 67 } 81 68 -
code/branches/questsystem/src/orxonox/objects/QuestHint.h
r2068 r2076 67 67 public: 68 68 QuestHint(); 69 QuestHint(std::string id);70 69 ~QuestHint(); 71 70 -
code/branches/questsystem/src/orxonox/objects/QuestItem.cc
r2068 r2076 32 32 33 33 namespace orxonox { 34 35 CreateFactory(QuestItem);36 34 37 35 QuestItem::QuestItem() : BaseObject() 38 36 { 39 37 this->initialize(); 40 }41 42 /**43 @brief44 Constructor. Needs as input a unique identifier to be able to identify different instances of this class (and subclasses).45 @param id46 The unique identifier. Should be of GUID form: http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure47 */48 QuestItem::QuestItem(std::string id) : BaseObject()49 {50 this->initialize();51 52 this->id_ = id;53 38 } 54 39 -
code/branches/questsystem/src/orxonox/objects/QuestItem.h
r2068 r2076 51 51 public: 52 52 QuestItem(); 53 QuestItem(std::string id);54 53 virtual ~QuestItem(); 55 54
Note: See TracChangeset
for help on using the changeset viewer.