Changeset 2092 for code/trunk/src
- Timestamp:
- Nov 1, 2008, 8:32:10 PM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/CMakeLists.txt
r2087 r2092 68 68 objects/worldentities/ParticleSpawner.cc 69 69 # objects/worldentities/Backlight.cc 70 71 objects/quest/AddQuest.cc 72 objects/quest/AddQuestHint.cc 73 objects/quest/AddReward.cc 74 objects/quest/ChangeQuestStatus.cc 75 objects/quest/CompleteQuest.cc 76 objects/quest/FailQuest.cc 77 objects/quest/GlobalQuest.cc 78 objects/quest/LocalQuest.cc 79 objects/quest/Quest.cc 80 objects/quest/QuestDescription.cc 81 objects/quest/QuestEffect.cc 82 objects/quest/QuestHint.cc 83 objects/quest/QuestItem.cc 84 objects/quest/QuestManager.cc 85 objects/quest/Rewardable.cc 70 86 71 87 objects/worldentities/triggers/Trigger.cc -
code/trunk/src/orxonox/objects/quest/AddQuest.cc
r2091 r2092 41 41 42 42 43 AddQuest::AddQuest( ) : ChangeQuestStatus()43 AddQuest::AddQuest(BaseObject* creator) : ChangeQuestStatus(creator) 44 44 { 45 45 RegisterObject(AddQuest); 46 46 } 47 47 48 48 /** 49 49 @brief 50 50 Destructor. 51 */ 51 */ 52 52 AddQuest::~AddQuest() 53 53 { 54 54 } 55 55 56 56 void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 57 { 58 58 SUPER(AddQuest, XMLPort, xmlelement, mode); 59 59 60 60 } 61 61 62 62 /** 63 63 @brief … … 75 75 return false; 76 76 } 77 77 78 78 try 79 79 { … … 89 89 return false; 90 90 } 91 91 92 92 return true; 93 93 } -
code/trunk/src/orxonox/objects/quest/AddQuest.h
r2091 r2092 48 48 { 49 49 public: 50 AddQuest( );51 ~AddQuest();52 50 AddQuest(BaseObject* creator); 51 virtual ~AddQuest(); 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 54 55 55 virtual bool invoke(Player* player); //!< Invokes the effect. 56 56 57 57 }; 58 58 -
code/trunk/src/orxonox/objects/quest/AddQuestHint.cc
r2091 r2092 38 38 CreateFactory(AddQuestHint); 39 39 40 AddQuestHint::AddQuestHint( ) : QuestEffect()40 AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator) 41 41 { 42 42 RegisterObject(AddQuestHint); 43 43 } 44 44 45 45 /** 46 46 @brief … … 50 50 { 51 51 } 52 52 53 53 void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 54 { 55 55 SUPER(AddQuestHint, XMLPort, xmlelement, mode); 56 56 57 57 XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); 58 58 59 59 } 60 60 … … 98 98 return false; 99 99 } 100 100 101 101 return true; 102 102 103 103 } 104 104 } -
code/trunk/src/orxonox/objects/quest/AddQuestHint.h
r2091 r2092 47 47 { 48 48 public: 49 AddQuestHint( );50 ~AddQuestHint();51 49 AddQuestHint(BaseObject* creator); 50 virtual ~AddQuestHint(); 51 52 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 53 54 54 virtual bool invoke(Player* player); //!< Invokes the effect. 55 55 56 56 private: 57 57 std::string hintId_; 58 58 59 59 inline const std::string & getHintId(void) const 60 60 { return this->hintId_; } 61 61 void setHintId(const std::string & id); 62 62 63 63 }; 64 64 -
code/trunk/src/orxonox/objects/quest/AddReward.cc
r2091 r2092 32 32 33 33 namespace orxonox { 34 34 35 35 CreateFactory(AddReward); 36 37 AddReward::AddReward( ) : QuestEffect()36 37 AddReward::AddReward(BaseObject* creator) : QuestEffect(creator) 38 38 { 39 RegisterObject(AddReward); 40 39 41 this->initialize(); 40 42 } 41 43 42 44 /** 43 45 @brief … … 51 53 { 52 54 SUPER(AddReward, XMLPort, xmlelement, mode); 53 55 54 56 XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); 55 57 56 58 } 57 59 … … 64 66 RegisterObject(AddReward); 65 67 } 66 68 67 69 const Rewardable* AddReward::getRewardables(unsigned int index) const 68 70 { … … 94 96 check = check && (*reward)->reward(player); 95 97 } 96 98 97 99 return check; 98 100 } -
code/trunk/src/orxonox/objects/quest/AddReward.h
r2091 r2092 49 49 { 50 50 public: 51 AddReward( );52 ~AddReward();53 51 AddReward(BaseObject* creator); 52 virtual ~AddReward(); 53 54 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 55 56 56 virtual bool invoke(Player* player); //!< Invokes the effect. 57 57 58 58 private: 59 59 std::list<Rewardable*> rewards_; 60 60 61 61 void initialize(void); //!< Initializes the object. 62 62 63 63 inline void addRewardable(Rewardable* reward) 64 64 { this->rewards_.push_back(reward); } 65 65 const Rewardable* getRewardables(unsigned int index) const; 66 66 67 67 }; 68 68 -
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc
r2091 r2092 34 34 namespace orxonox { 35 35 36 ChangeQuestStatus::ChangeQuestStatus( ) : QuestEffect()36 ChangeQuestStatus::ChangeQuestStatus(BaseObject* creator) : QuestEffect(creator) 37 37 { 38 38 RegisterObject(ChangeQuestStatus); … … 46 46 { 47 47 } 48 48 49 49 void ChangeQuestStatus::setQuestId(const std::string & id) 50 50 { … … 56 56 this->questId_ = id; 57 57 } 58 58 59 59 void ChangeQuestStatus::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 60 { 61 61 SUPER(ChangeQuestStatus, XMLPort, xmlelement, mode); 62 62 63 63 XMLPortParam(ChangeQuestStatus, "questId", setQuestId, getQuestId, xmlelement, mode); 64 64 } -
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
r2091 r2092 48 48 { 49 49 public: 50 ChangeQuestStatus( );50 ChangeQuestStatus(BaseObject* creator); 51 51 virtual ~ChangeQuestStatus(); 52 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 54 55 55 virtual bool invoke(Player* player) = 0; //!< Invokes the effect. 56 56 57 57 protected: 58 58 inline const std::string & getQuestId(void) const //!< Returns the quest id. 59 59 { return this->questId_; } 60 60 61 61 std::string questId_; //!< The id of the quest the status should be changed of. 62 62 63 63 private: 64 64 void setQuestId(const std::string & id); -
code/trunk/src/orxonox/objects/quest/CompleteQuest.cc
r2091 r2092 38 38 CreateFactory(CompleteQuest); 39 39 40 CompleteQuest::CompleteQuest( ) : ChangeQuestStatus()40 CompleteQuest::CompleteQuest(BaseObject* creator) : ChangeQuestStatus(creator) 41 41 { 42 42 RegisterObject(CompleteQuest); 43 43 } 44 44 45 45 /** 46 46 @brief … … 50 50 { 51 51 } 52 52 53 53 void CompleteQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 54 { 55 55 SUPER(CompleteQuest, XMLPort, xmlelement, mode); 56 56 } 57 57 58 58 /** 59 59 @brief … … 71 71 return false; 72 72 } 73 73 74 74 try 75 75 { … … 85 85 return false; 86 86 } 87 87 88 88 return true; 89 89 } -
code/trunk/src/orxonox/objects/quest/CompleteQuest.h
r2091 r2092 48 48 { 49 49 public: 50 CompleteQuest( );51 ~CompleteQuest();52 50 CompleteQuest(BaseObject* creator); 51 virtual ~CompleteQuest(); 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 54 55 55 virtual bool invoke(Player* player); //!< Invokes the effect. 56 56 57 57 }; 58 58 -
code/trunk/src/orxonox/objects/quest/FailQuest.cc
r2091 r2092 38 38 CreateFactory(FailQuest); 39 39 40 FailQuest::FailQuest( ) : ChangeQuestStatus()40 FailQuest::FailQuest(BaseObject* creator) : ChangeQuestStatus(creator) 41 41 { 42 42 RegisterObject(FailQuest); 43 43 } 44 44 45 45 /** 46 46 @brief … … 50 50 { 51 51 } 52 52 53 53 void FailQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 54 { 55 55 SUPER(FailQuest, XMLPort, xmlelement, mode); 56 56 } 57 57 58 58 /** 59 59 @brief … … 71 71 return false; 72 72 } 73 73 74 74 try 75 75 { … … 85 85 return false; 86 86 } 87 87 88 88 return true; 89 89 } -
code/trunk/src/orxonox/objects/quest/FailQuest.h
r2091 r2092 48 48 { 49 49 public: 50 FailQuest( );51 ~FailQuest();52 50 FailQuest(BaseObject* creator); 51 virtual ~FailQuest(); 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 54 55 55 virtual bool invoke(Player* player); //!< Invokes the effect. 56 56 57 57 }; 58 58 -
code/trunk/src/orxonox/objects/quest/GlobalQuest.cc
r2091 r2092 40 40 Constructor. 41 41 */ 42 GlobalQuest::GlobalQuest( ) : Quest()42 GlobalQuest::GlobalQuest(BaseObject* creator) : Quest(creator) 43 43 { 44 RegisterObject(GlobalQuest); 45 44 46 this->initialize(); 45 47 } 46 48 47 49 /** 48 50 @brief … … 51 53 GlobalQuest::~GlobalQuest() 52 54 { 53 55 54 56 } 55 57 56 58 void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 59 { … … 60 62 COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 61 63 } 62 64 63 65 void GlobalQuest::initialize(void) 64 66 { 65 67 RegisterObject(GlobalQuest); 66 68 } 67 69 68 70 /** 69 71 @brief … … 80 82 return this->isInactive(player) || this->isActive(player); 81 83 } 82 84 83 85 /** 84 86 @brief … … 96 98 97 99 } 98 100 99 101 /** 100 102 @brief … … 126 128 ThrowException(Argument, "The input Player* is NULL."); 127 129 } 128 130 129 131 //TDO: Does this really work??? 130 132 std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player); … … 139 141 140 142 } 141 143 142 144 /** 143 145 @brief … … 157 159 return false; 158 160 } 159 161 160 162 std::set<Player*>::const_iterator it = this->players_.find(player); 161 163 if (it == this->players_.end()) //!< Player is not yet in the list. -
code/trunk/src/orxonox/objects/quest/GlobalQuest.h
r2091 r2092 49 49 { 50 50 public: 51 GlobalQuest( );52 ~GlobalQuest();53 51 GlobalQuest(BaseObject* creator); 52 virtual ~GlobalQuest(); 53 54 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 55 56 56 protected: 57 57 virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started. 58 58 virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed. 59 59 virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed. 60 60 61 61 virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player. 62 62 virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 63 63 64 64 private: 65 65 std::set<Player*> players_; //!< The set of players which possess this quest. 66 66 questStatus::Enum status_; //!< The status of this quest. 67 67 68 68 void initialize(void); 69 69 70 70 }; 71 71 -
code/trunk/src/orxonox/objects/quest/LocalQuest.cc
r2091 r2092 36 36 CreateFactory(LocalQuest); 37 37 38 LocalQuest::LocalQuest( ) : Quest()38 LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator) 39 39 { 40 RegisterObject(LocalQuest); 41 40 42 this->initialize(); 41 43 } 42 44 43 45 /** 44 46 @brief … … 47 49 LocalQuest::~LocalQuest() 48 50 { 49 51 50 52 } 51 53 52 54 void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 53 55 { … … 56 58 COUT(3) << "New LocalQuest {" << this->getId() << "} created." << std::endl; 57 59 } 58 60 59 61 void LocalQuest::initialize(void) 60 62 { 61 63 RegisterObject(LocalQuest); 62 64 } 63 65 64 66 /** 65 67 @brief … … 76 78 return this->isInactive(player); 77 79 } 78 80 79 81 /** 80 82 @brief … … 91 93 return this->isActive(player); 92 94 } 93 95 94 96 /** 95 97 @brief … … 106 108 return this->isActive(player); 107 109 } 108 110 109 111 /** 110 112 @brief … … 123 125 ThrowException(Argument, "The input Player* is NULL."); 124 126 } 125 127 126 128 std::map<Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'. 127 129 if (it != this->playerStatus_.end()) … … 131 133 return questStatus::inactive; 132 134 } 133 135 134 136 /** 135 137 @brief -
code/trunk/src/orxonox/objects/quest/LocalQuest.h
r2091 r2092 49 49 { 50 50 public: 51 LocalQuest( );52 ~LocalQuest();53 51 LocalQuest(BaseObject* creator); 52 virtual ~LocalQuest(); 53 54 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 55 56 56 protected: 57 57 virtual bool isStartable(const Player* player) const; //!< Checks whether the quest can be started. 58 58 virtual bool isFailable(const Player* player) const; //!< Checks whether the quest can be failed. 59 59 virtual bool isCompletable(const Player* player) const; //!< Checks whether the quest can be completed. 60 60 61 61 virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player. 62 62 virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 63 63 64 64 private: 65 65 std::map<Player*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 66 66 67 67 void initialize(void); 68 68 69 69 }; 70 70 71 71 72 72 } -
code/trunk/src/orxonox/objects/quest/Quest.cc
r2091 r2092 34 34 namespace orxonox { 35 35 36 Quest::Quest() : QuestItem() 37 { 36 Quest::Quest(BaseObject* creator) : QuestItem(creator) 37 { 38 RegisterObject(Quest); 39 38 40 this->initialize(); 39 41 } 40 42 41 43 /** 42 44 @brief … … 45 47 Quest::~Quest() 46 48 { 47 48 } 49 49 50 } 51 50 52 void Quest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 51 53 { 52 54 SUPER(Quest, XMLPort, xmlelement, mode); 53 55 54 56 XMLPortObject(Quest, Quest, "", addSubQuest, getSubQuests, xmlelement, mode); 55 57 XMLPortObject(Quest, QuestHint, "", addHint, getHints, xmlelement, mode); 56 58 XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffects, xmlelement, mode); 57 59 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffects, xmlelement, mode); 58 60 59 61 QuestManager::registerQuest(this); //Registers the quest with the QuestManager. 60 62 } 61 63 62 64 /** 63 65 @brief … … 67 69 { 68 70 RegisterObject(Quest); 69 71 70 72 this->parentQuest_ = NULL; 71 73 } … … 86 88 return false; 87 89 } 88 90 89 91 this->parentQuest_ = quest; 90 92 91 93 COUT(3) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 92 94 return true; 93 95 } 94 96 95 97 /** 96 98 @brief … … 108 110 return false; 109 111 } 110 112 111 113 quest->setParentQuest(this); 112 114 this->subQuests_.push_back(quest); 113 115 114 116 COUT(3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 115 117 return true; 116 118 } 117 118 119 /** 120 @brief 121 Adds a Hint to the list of hints 119 120 121 /** 122 @brief 123 Adds a Hint to the list of hints 122 124 @param hint 123 125 The hint that should be added to the list of hints. … … 132 134 return false; 133 135 } 134 136 135 137 this->hints_.push_back(hint); 136 138 hint->setQuest(this); 137 139 138 140 COUT(3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; 139 141 return true; 140 142 } 141 142 /** 143 @brief 144 143 144 /** 145 @brief 146 145 147 */ 146 148 bool Quest::addFailEffect(QuestEffect* effect) … … 151 153 return false; 152 154 } 153 155 154 156 this->failEffects_.push_back(effect); 155 157 156 158 COUT(3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; 157 159 return true; 158 160 } 159 160 /** 161 @brief 162 161 162 /** 163 @brief 164 163 165 */ 164 166 bool Quest::addCompleteEffect(QuestEffect* effect) … … 169 171 return false; 170 172 } 171 173 172 174 this->completeEffects_.push_back(effect); 173 175 174 176 COUT(3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; 175 177 return true; 176 178 } 177 178 /** 179 @brief 180 179 180 /** 181 @brief 182 181 183 */ 182 184 const Quest* Quest::getParentQuest(void) … … 184 186 return this->parentQuest_; 185 187 } 186 187 /** 188 @brief 189 188 189 /** 190 @brief 191 190 192 */ 191 193 const Quest* Quest::getSubQuests(unsigned int index) const … … 202 204 return NULL; 203 205 } 204 205 /** 206 @brief 207 206 207 /** 208 @brief 209 208 210 */ 209 211 const QuestHint* Quest::getHints(unsigned int index) const … … 220 222 return NULL; 221 223 } 222 223 /** 224 @brief 225 224 225 /** 226 @brief 227 226 228 */ 227 229 const QuestEffect* Quest::getFailEffects(unsigned int index) const … … 238 240 return NULL; 239 241 } 240 241 /** 242 @brief 243 242 243 /** 244 @brief 245 244 246 */ 245 247 const QuestEffect* Quest::getCompleteEffects(unsigned int index) const … … 256 258 return NULL; 257 259 } 258 260 259 261 /** 260 262 @brief … … 271 273 return this->getStatus(player) == questStatus::inactive; 272 274 } 273 275 274 276 /** 275 277 @brief … … 287 289 return this->getStatus(player) == questStatus::active; 288 290 } 289 291 290 292 /** 291 293 @brief … … 302 304 return this->getStatus(player) == questStatus::failed; 303 305 } 304 306 305 307 /** 306 308 @brief … … 317 319 return this->getStatus(player) == questStatus::completed; 318 320 } 319 321 320 322 /** 321 323 @brief … … 336 338 return false; 337 339 } 338 340 339 341 /** 340 342 @brief … … 356 358 return false; 357 359 } 358 360 359 361 /** 360 362 @brief -
code/trunk/src/orxonox/objects/quest/Quest.h
r2091 r2092 67 67 { 68 68 public: 69 Quest( );69 Quest(BaseObject* creator); 70 70 virtual ~Quest(); 71 71 72 72 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 73 73 74 74 inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. 75 75 { return this->parentQuest_; } 76 76 inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests. 77 77 { return this->subQuests_; } 78 78 79 79 bool isInactive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 80 80 bool isActive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'active'. 81 81 bool isFailed(const Player* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 82 82 bool isCompleted(const Player* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 83 83 84 84 bool start(Player* player); //!< Sets a quest to active. 85 85 bool fail(Player* player); //!< Fails the quest. 86 86 bool complete(Player* player); //!< Completes the quest. 87 87 88 88 protected: 89 89 void initialize(void); //!< Initialized the object. 90 90 91 91 virtual bool isStartable(const Player* player) const = 0; //!< Checks whether the quest can be started. 92 92 virtual bool isFailable(const Player* player) const = 0; //!< Checks whether the quest can be failed. 93 93 virtual bool isCompletable(const Player* player) const = 0; //!< Checks whether the quest can be completed. 94 94 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. … … 98 98 bool addFailEffect(QuestEffect* effect); 99 99 bool addCompleteEffect(QuestEffect* effect); 100 100 101 101 const Quest* getParentQuest(void); 102 102 const Quest* getSubQuests(unsigned int index) const; … … 104 104 const QuestEffect* getFailEffects(unsigned int index) const; 105 105 const QuestEffect* getCompleteEffects(unsigned int index) const; 106 106 107 107 virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player. 108 108 virtual bool setStatus(Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. 109 109 110 110 Quest* parentQuest_; //!< Pointer to the parent quest. 111 111 std::list<Quest*> subQuests_; //!< List of all the sub quests. 112 112 113 113 std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest. 114 114 115 115 std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed. 116 116 std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed. -
code/trunk/src/orxonox/objects/quest/QuestDescription.cc
r2091 r2092 34 34 35 35 CreateFactory(QuestDescription); 36 37 QuestDescription::QuestDescription( ) : BaseObject()36 37 QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator) 38 38 { 39 RegisterObject(QuestDescription); 40 39 41 this->initialize(); 40 42 } 41 43 42 44 QuestDescription::~QuestDescription() 43 45 { 44 46 45 47 } 46 48 47 49 void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode) 48 50 { 49 51 SUPER(QuestDescription, XMLPort, xmlelement, mode); 50 52 51 53 XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode); 52 54 XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); 53 55 54 56 COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 55 57 } 56 58 57 59 /** 58 60 @brief -
code/trunk/src/orxonox/objects/quest/QuestDescription.h
r2091 r2092 45 45 */ 46 46 class QuestDescription : public BaseObject { 47 47 48 48 public: 49 QuestDescription( );50 ~QuestDescription();51 49 QuestDescription(BaseObject* creator); 50 virtual ~QuestDescription(); 51 52 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 53 54 54 inline const std::string & getTitle(void) const //!< Returns the title. 55 55 { return this->title_; } 56 56 inline const std::string & getDescription(void) const //!< Returns the description text. 57 57 { return this->description_; } 58 58 59 59 private: 60 60 void initialize(void); 61 61 62 62 inline void setTitle(const std::string & title) //!< Sets the title. 63 63 { this->title_ = title; } 64 64 inline void setDescription(const std::string & description) //!< Sets the description text. 65 65 { this->description_ = description; } 66 66 67 67 std::string title_; //!< The title. 68 68 std::string description_; //!< The description. 69 69 70 70 }; 71 71 -
code/trunk/src/orxonox/objects/quest/QuestEffect.cc
r2091 r2092 38 38 Is not meant to be invoked directly, since this is only an interface. 39 39 */ 40 QuestEffect::QuestEffect( ) : BaseObject()40 QuestEffect::QuestEffect(BaseObject* creator) : BaseObject(creator) 41 41 { 42 42 RegisterObject(QuestEffect); 43 43 } 44 44 45 45 /** 46 46 @brief … … 49 49 QuestEffect::~QuestEffect() 50 50 { 51 51 52 52 } 53 53 54 54 /** 55 55 @brief … … 65 65 { 66 66 bool check = true; 67 67 68 68 for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++) 69 69 { -
code/trunk/src/orxonox/objects/quest/QuestEffect.h
r2091 r2092 47 47 { 48 48 public: 49 QuestEffect( );49 QuestEffect(BaseObject* creator); 50 50 virtual ~QuestEffect(); 51 51 52 52 virtual bool invoke(Player* player) = 0; //!< Invokes the effect. 53 53 static bool invokeEffects(Player* player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list. 54 55 54 55 56 56 }; 57 57 -
code/trunk/src/orxonox/objects/quest/QuestHint.cc
r2091 r2092 41 41 Constructor. 42 42 */ 43 QuestHint::QuestHint( ) : QuestItem()43 QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator) 44 44 { 45 RegisterObject(QuestHint); 46 45 47 this->initialize(); 46 48 } 47 49 48 50 /** 49 51 @brief … … 52 54 QuestHint::~QuestHint() 53 55 { 54 56 55 57 } 56 58 57 59 void QuestHint::initialize(void) 58 60 { 59 61 RegisterObject(QuestHint); 60 62 } 61 63 62 64 void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 63 65 { 64 66 SUPER(QuestHint, XMLPort, xmlelement, mode); 65 67 66 68 COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl; 67 69 } 68 70 69 71 70 72 /** 71 73 @brief … … 85 87 return false; 86 88 } 87 89 88 90 std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player); 89 91 if (it != this->playerStatus_.end()) … … 93 95 return questStatus::inactive; 94 96 } 95 97 96 98 /** 97 99 @brief … … 134 136 return false; 135 137 } 136 138 137 139 this->quest_ = quest; 138 140 return true; -
code/trunk/src/orxonox/objects/quest/QuestHint.h
r2091 r2092 26 26 * 27 27 */ 28 28 29 29 #ifndef _QuestHint_H__ 30 30 #define _QuestHint_H__ … … 64 64 class QuestHint : public QuestItem 65 65 { 66 66 67 67 public: 68 QuestHint( );69 ~QuestHint();70 68 QuestHint(BaseObject* creator); 69 virtual ~QuestHint(); 70 71 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 72 72 73 73 bool isActive(Player* player); //!< Returns true if the hint is active for the input player. 74 74 75 75 bool activate(Player* player); //!< Activates the hint for the input player. 76 76 77 77 bool setQuest(Quest* quest); //!< Sets the quest the hint belongs to. 78 78 79 79 inline Quest* getQuest(void) 80 80 { return this->quest_; } 81 81 82 82 private: 83 83 84 84 void initialize(void); 85 85 86 86 Quest* quest_; //!< The quest the hint belongs to. 87 87 std::map<Player*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 88 88 89 89 }; 90 90 -
code/trunk/src/orxonox/objects/quest/QuestItem.cc
r2091 r2092 32 32 33 33 namespace orxonox { 34 35 QuestItem::QuestItem( ) : BaseObject()34 35 QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) 36 36 { 37 RegisterObject(QuestItem); 38 37 39 this->initialize(); 38 40 } 39 41 40 42 /** 41 43 @brief … … 44 46 QuestItem::~QuestItem() 45 47 { 46 48 47 49 } 48 50 49 51 void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 50 52 { 51 53 SUPER(QuestItem, XMLPort, xmlelement, mode); 52 54 53 55 XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode); 54 56 //Doesn't getDescription have to be of type getDescription(unsigned int) ? … … 58 60 } 59 61 60 62 61 63 /** 62 64 @brief … … 67 69 { 68 70 RegisterObject(QuestItem); 69 71 70 72 this->id_ = ""; 71 73 } 72 74 73 75 void QuestItem::setId(const std::string & id) 74 76 { … … 80 82 this->id_ = id; 81 83 } 82 84 83 85 //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem. 84 86 //{ … … 87 89 // return this->description_; 88 90 //} 89 91 90 92 /** 91 93 @brief -
code/trunk/src/orxonox/objects/quest/QuestItem.h
r2091 r2092 26 26 * 27 27 */ 28 28 29 29 #ifndef _QuestItem_H__ 30 30 #define _QuestItem_H__ … … 38 38 namespace orxonox { 39 39 40 40 41 41 /** 42 42 @brief … … 48 48 class QuestItem : public BaseObject 49 49 { 50 50 51 51 public: 52 QuestItem( );52 QuestItem(BaseObject* creator); 53 53 virtual ~QuestItem(); 54 54 55 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 56 57 57 inline const std::string & getId(void) const //!< Returns the id of this quest. 58 58 { return this->id_; } … … 60 60 { return this->description_; } 61 61 //const QuestDescription* getDescription(unsigned int index) const; //!< Returns the description of the QuestItem. 62 62 63 63 static bool isId(const std::string & id); //!< Checks whether a given id is valid. 64 64 65 65 protected: 66 66 void setId(const std::string & id); 67 67 inline void setDescription(QuestDescription* description) 68 68 { this->description_ = description; } 69 69 70 70 private: 71 71 std::string id_; //!< Identifier. Should be of GUID form: http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure 72 72 QuestDescription* description_; //!< The description of the QuestItem. 73 73 74 74 void initialize(void); //!< Initializes the object. 75 75 76 76 }; 77 77 -
code/trunk/src/orxonox/objects/quest/QuestManager.cc
r2091 r2092 37 37 std::map<std::string, QuestHint*> QuestManager::hintMap_; 38 38 39 QuestManager::QuestManager( ) : BaseObject()39 QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator) 40 40 { 41 41 RegisterObject(QuestManager); 42 42 } 43 44 43 44 45 45 QuestManager::~QuestManager() 46 46 { 47 47 48 48 } 49 49 … … 63 63 return false; 64 64 } 65 65 66 66 std::pair<std::map<std::string, Quest*>::iterator,bool> ret; 67 67 ret = questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); 68 68 69 69 if(ret.second) 70 70 { … … 78 78 } 79 79 } 80 80 81 81 /** 82 82 @brief … … 94 94 return false; 95 95 } 96 96 97 97 std::pair<std::map<std::string, QuestHint*>::iterator,bool> ret; 98 98 ret = hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); 99 99 100 100 if(ret.second) 101 101 { … … 109 109 } 110 110 } 111 111 112 112 /** 113 113 @brief … … 127 127 ThrowException(Argument, "Invalid questId."); 128 128 } 129 129 130 130 Quest* quest; 131 131 std::map<std::string, Quest*>::iterator it = questMap_.find(questId); … … 139 139 COUT(2) << "The quest with id {" << questId << "} is nowhere to be found." << std::endl; 140 140 } 141 141 142 142 return quest; 143 143 144 144 } 145 145 146 146 /** 147 147 @brief … … 161 161 ThrowException(Argument, "Invalid hintId."); 162 162 } 163 163 164 164 QuestHint* hint; 165 165 std::map<std::string, QuestHint*>::iterator it = hintMap_.find(hintId); … … 173 173 COUT(2) << "The hint with id {" << hintId << "} is nowhere to be found." << std::endl; 174 174 } 175 175 176 176 return hint; 177 177 178 178 } 179 179 180 180 181 181 } -
code/trunk/src/orxonox/objects/quest/QuestManager.h
r2091 r2092 48 48 class QuestManager : public BaseObject 49 49 { 50 50 51 51 public: 52 QuestManager( );53 ~QuestManager();54 52 QuestManager(BaseObject* creator); 53 virtual ~QuestManager(); 54 55 55 static bool registerQuest(Quest* quest); //!< Registers a quest in the QuestManager. 56 56 static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 57 57 58 58 static Quest* findQuest(const std::string & questId); //!< Returns the quest with the input id. 59 59 static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id. 60 60 61 61 private: 62 62 static std::map<std::string, Quest*> questMap_; //!< All quests registered by their id's. 63 63 static std::map<std::string, QuestHint*> hintMap_; //!< All hints registered by their id's. 64 64 65 65 }; 66 66 -
code/trunk/src/orxonox/objects/quest/Rewardable.cc
r2091 r2092 33 33 namespace orxonox { 34 34 35 36 Rewardable::Rewardable( ) : BaseObject()35 36 Rewardable::Rewardable(BaseObject* creator) : BaseObject(creator) 37 37 { 38 38 RegisterObject(Rewardable); 39 39 } 40 41 40 41 42 42 Rewardable::~Rewardable() 43 43 { -
code/trunk/src/orxonox/objects/quest/Rewardable.h
r2091 r2092 44 44 class Rewardable : public BaseObject 45 45 { 46 46 47 47 public: 48 Rewardable( );48 Rewardable(BaseObject* creator); 49 49 virtual ~Rewardable(); 50 50 51 51 virtual bool reward(Player* player) = 0; //!<Method to transcribe a rewardable object to the player. 52 52 53 53 }; 54 54
Note: See TracChangeset
for help on using the changeset viewer.