Changeset 2530 for code/branches/bugger/src
- Timestamp:
- Dec 23, 2008, 10:40:38 PM (16 years ago)
- Location:
- code/branches/bugger
- Files:
-
- 65 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/bugger
- 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/branches/bugger/src/core/LuaBind.cc
r2344 r2530 87 87 } 88 88 89 char line[1024 ];89 char line[1024*32]; 90 90 std::string levelString = ""; 91 91 92 92 while (file.good() && !file.eof()) 93 93 { 94 file.getline(line, 1024 );94 file.getline(line, 1024*32); 95 95 levelString += line; 96 96 levelString += "\n"; … … 100 100 //std::string output; 101 101 102 if (luaTags) luaSource_ = replaceLuaTags(levelString); 102 if (luaTags) 103 luaSource_ = replaceLuaTags(levelString); 104 else 105 luaSource_ = levelString; 103 106 COUT(5) << "ParsedSourceCode: " << luaSource_ << std::endl; 104 107 } … … 126 129 isRunning_ = true; 127 130 int error = 0; 128 std::string init = "local scr = orxonox.LuaBind:getInstance()\nlocal debug = print\nprint = function(s)\nscr:luaPrint(s)\nend\ninclude = function(f)\nfile = assert(io.open(\"" + this->includePath_ + "\"..\"/\"..f))\ncontent = file:read(\"*a\")\nfile:close()\nsource = scr:replaceLuaTags(content)\nassert(loadstring(source))()\nend\n"; 131 std::string init = 132 "local scr = orxonox.LuaBind:getInstance()\n \ 133 local debug = print\n \ 134 print = function(s)\n \ 135 scr:luaPrint(s)\n \ 136 end\n \ 137 include = function(f)\n \ 138 file = assert(io.open(\"" + this->includePath_ + "\"..\"/\"..f))\n \ 139 content = file:read(\"*a\")\n \ 140 file:close()\n \ 141 source = scr:replaceLuaTags(content)\n \ 142 assert(loadstring(source))()\n \ 143 end\n"; 129 144 init += luaSource_; 130 145 #if LUA_VERSION_NUM == 501 -
code/branches/bugger/src/core/Template.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/core/Template.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/core/XMLFile.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/core/XMLIncludes.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/CameraManager.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/CameraManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/OrxonoxPrereqs.h
r2428 r2530 100 100 class QuestDescription; 101 101 class QuestEffect; 102 class QuestEffectBeacon; 102 103 class QuestHint; 103 104 class QuestItem; … … 138 139 class DistanceTrigger; 139 140 class EventTrigger; 141 class PlayerTrigger; 140 142 141 143 class WeaponSystem; -
code/branches/bugger/src/orxonox/gamestates/GSLevel.cc
r2400 r2530 50 50 namespace orxonox 51 51 { 52 SetCommandLineArgument(level, " sample3.oxw").shortcut("l");52 SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l"); 53 53 54 54 GSLevel::GSLevel() -
code/branches/bugger/src/orxonox/objects/Level.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/Level.cc (added) merged: 2-2106
- Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/Level.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/Level.h (added) merged: 2-2106
- Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.cc (added) merged: 2146,2159,2191,2205,2209,2226,2251 /code/trunk/src/orxonox/objects/quest/AddQuest.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file AddQuest.cc 31 @brief 32 Implementation of the AddQuest class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "AddQuest.h" 31 37 32 38 #include <string> 39 33 40 #include "core/CoreIncludes.h" 34 41 #include "util/Exception.h" 35 42 43 #include "orxonox/objects/infos/PlayerInfo.h" 36 44 #include "QuestManager.h" 37 45 #include "Quest.h" … … 41 49 CreateFactory(AddQuest); 42 50 43 51 /** 52 @brief 53 Constructor. Registers the object. 54 */ 44 55 AddQuest::AddQuest(BaseObject* creator) : ChangeQuestStatus(creator) 45 56 { … … 55 66 } 56 67 68 /** 69 @brief 70 Method for creating a AddQuest object through XML. 71 */ 57 72 void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 58 73 { 59 74 SUPER(AddQuest, XMLPort, xmlelement, mode); 60 75 76 COUT(3) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 61 77 } 62 78 63 79 /** 64 80 @brief 65 Invokes the effect.81 Invokes the QuestEffect. 66 82 @param player 67 The player the effect is invoked on.83 The player the QuestEffect is invoked on. 68 84 @return 69 Returns true if the effect was successfully invoked.85 Returns true if the QuestEffect was successfully invoked. 70 86 */ 71 bool AddQuest::invoke(Player * player)87 bool AddQuest::invoke(PlayerInfo* player) 72 88 { 73 if(player == NULL) 89 if(player == NULL) //!< Null-pointers are badass. 74 90 { 75 91 COUT(2) << "Input player is NULL." << std::endl; … … 77 93 } 78 94 95 COUT(3) << "AddQuest on player: " << player << " ." << std::endl; 96 79 97 try 80 98 { 81 99 Quest* quest = QuestManager::findQuest(this->getQuestId()); 82 if( !quest->start(player))100 if(quest == NULL || !quest->start(player)) 83 101 { 84 102 return false; … … 91 109 } 92 110 111 COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl; 93 112 return true; 94 113 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.h (added) merged: 2146,2159,2191,2205,2221,2251 /code/trunk/src/orxonox/objects/quest/AddQuest.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file AddQuest.h 31 @brief 32 Definition of the AddQuest class. 33 */ 34 29 35 #ifndef _AddQuest_H__ 30 36 #define _AddQuest_H__ … … 39 45 namespace orxonox { 40 46 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 47 /** 44 48 @brief 45 Adds a quest, resp. changes the quests status to active. 49 Adds a Quest, resp. changes the quests status to active for the player invoking the Quest. 50 51 Creating a AddQuest through XML goes as follows: 52 53 <AddQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added. 46 54 @author 47 55 Damian 'Mozork' Frick … … 53 61 virtual ~AddQuest(); 54 62 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML. 56 64 57 virtual bool invoke(Player * player); //!< Invokes the effect.65 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 58 66 59 67 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.cc (added) merged: 2146,2159,2191,2205,2226,2251 /code/trunk/src/orxonox/objects/quest/AddQuestHint.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file AddQuestHint.cc 31 @brief 32 Implementation of the AddQuestHint class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "AddQuestHint.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/infos/PlayerInfo.h" 35 42 #include "QuestManager.h" 36 43 #include "QuestItem.h" … … 41 48 CreateFactory(AddQuestHint); 42 49 50 /** 51 @brief 52 Constructor. Registers the object. 53 */ 43 54 AddQuestHint::AddQuestHint(BaseObject* creator) : QuestEffect(creator) 44 55 { … … 54 65 } 55 66 67 /** 68 @brief 69 Method for creating a AddQuestHint object through XML. 70 */ 56 71 void AddQuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 72 { … … 59 74 60 75 XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode); 61 76 77 COUT(3) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl; 62 78 } 63 79 64 inline void AddQuestHint::setHintId(const std::string & id) 80 /** 81 @brief 82 Sets the id of the QuestHint to be added to the player the QuestEffect is invoked on. 83 @param id 84 The QuestHint id. 85 @param 86 Returns true if successful. 87 */ 88 bool AddQuestHint::setHintId(const std::string & id) 65 89 { 66 90 if(!QuestItem::isId(id)) 67 91 { 68 92 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; 69 return ;93 return false; 70 94 } 95 71 96 this->hintId_ = id; 97 return true; 72 98 } 73 99 74 100 /** 75 101 @brief 76 Invokes the effect.102 Invokes the QuestEffect. 77 103 @param player 78 104 The player. 79 105 @return 80 Returns true if the effect was successfully invoked.106 Returns true if the QuestEffect was successfully invoked. 81 107 */ 82 bool AddQuestHint::invoke(Player * player)108 bool AddQuestHint::invoke(PlayerInfo* player) 83 109 { 84 if(player == NULL) 110 if(player == NULL) //!< NULL-pointers are evil! 85 111 { 86 112 COUT(2) << "The input player is NULL." << std::endl; … … 88 114 } 89 115 116 COUT(3) << "AddQuestHint on player: " << player << " ." << std::endl; 117 90 118 try 91 119 { 92 120 QuestHint* hint = QuestManager::findHint(this->hintId_); 93 if( !hint->activate(player))121 if(hint == NULL || !hint->setActive(player)) 94 122 { 95 123 return false; … … 102 130 } 103 131 132 COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player." << std::endl; 104 133 return true; 105 134 - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.h (added) merged: 2146,2159,2191,2205,2221,2251 /code/trunk/src/orxonox/objects/quest/AddQuestHint.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file AddQuestHint.h 31 @brief 32 Definition of the AddQuestHint class. 33 */ 34 29 35 #ifndef _AddQuestHint_H__ 30 36 #define _AddQuestHint_H__ … … 38 44 namespace orxonox { 39 45 40 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.41 42 46 /** 43 47 @brief 44 Adds a QuestHint, resp. Activates the QuestHint. 48 Adds a QuestHint, resp. activates the QuestHint of the given id for the player the QuestEffect is invoked on. 49 50 Creating a AddQuestHint through XML goes as follows: 51 52 <AddQuestHint hintId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added. 45 53 @author 46 54 Damian 'Mozork' Frick … … 52 60 virtual ~AddQuestHint(); 53 61 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuestHint object through XML. 55 63 56 virtual bool invoke(Player * player); //!< Invokes the effect.64 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 57 65 58 66 private: 59 std::string hintId_; 67 std::string hintId_; //!< The id of the QuestHint. 60 68 69 /** 70 @brief Returns the id of the QuestHint. 71 @return Returns the id of the QuestHint. 72 */ 61 73 inline const std::string & getHintId(void) const 62 74 { return this->hintId_; } 63 void setHintId(const std::string & id);75 bool setHintId(const std::string & id); //!< Sets the id of the QuestHint. 64 76 65 77 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/AddReward.cc (added) merged: 2146,2159,2191,2205,2226,2228,2251 /code/trunk/src/orxonox/objects/quest/AddReward.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file AddReward.cc 31 @brief 32 Implementation of the AddReward class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "AddReward.h" … … 32 38 #include "core/CoreIncludes.h" 33 39 40 #include "orxonox/objects/infos/PlayerInfo.h" 34 41 #include "Rewardable.h" 35 42 … … 38 45 CreateFactory(AddReward); 39 46 47 /** 48 @brief 49 Constructor. Registers the object. 50 */ 40 51 AddReward::AddReward(BaseObject* creator) : QuestEffect(creator) 41 52 { 42 53 RegisterObject(AddReward); 43 44 this->initialize();45 54 } 46 55 … … 53 62 } 54 63 64 /** 65 Method for creating a AddReward object through XML. 66 */ 55 67 void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 68 { … … 58 70 59 71 XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); 60 72 73 COUT(3) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl; 61 74 } 62 75 63 76 /** 64 77 @brief 65 Initializes the object. Needs to be called first by every constructor of this class. 78 Returns the Rewardable object at the given index. 79 @param index 80 The index. 81 @return 82 Returns a pointer to the Rewardable object at the given index. 66 83 */ 67 void AddReward::initialize(void)68 {69 RegisterObject(AddReward);70 }71 72 84 const Rewardable* AddReward::getRewardables(unsigned int index) const 73 85 { … … 86 98 /** 87 99 @brief 88 Invokes the effect.100 Invokes the QuestEffect. 89 101 @param player 90 102 The player. 91 103 @return 92 Returns true if the effect was invoked successfully.104 Returns true if the QuestEffect was invoked successfully. 93 105 */ 94 bool AddReward::invoke(Player * player)106 bool AddReward::invoke(PlayerInfo* player) 95 107 { 96 108 bool check = true; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/AddReward.h (added) merged: 2146,2159,2191,2205,2221,2251 /code/trunk/src/orxonox/objects/quest/AddReward.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file AddReward.h 31 @brief 32 Definition of the AddReward class. 33 */ 34 29 35 #ifndef _AddReward_H__ 30 36 #define _AddReward_H__ … … 39 45 namespace orxonox { 40 46 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 47 /** 44 48 @brief 45 Adds a list of rewards to a player. 49 Adds a list of Rewardables to a player. 50 51 Creating a AddReward through XML goes as follows: 52 53 <AddReward> 54 <Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations. 55 ... 56 <Rewardable /> 57 </AddReward> 46 58 @author 47 59 Damian 'Mozork' Frick … … 53 65 virtual ~AddReward(); 54 66 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 67 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddReward object through XML. 56 68 57 virtual bool invoke(Player * player); //!< Invokes the effect.69 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 58 70 59 71 private: 60 std::list<Rewardable*> rewards_; 72 std::list<Rewardable*> rewards_; //!< A list of Rewardables to be added to the player invoking the QuestEffect. 61 73 62 void initialize(void); //!< Initializes the object. 63 74 /** 75 @brief Add a Rewardable object to the list of objects to be awarded to the player invoking the QuestEffect. 76 @param reward Pointer to the Rewardable to be added. 77 */ 64 78 inline void addRewardable(Rewardable* reward) 65 79 { this->rewards_.push_back(reward); } 66 const Rewardable* getRewardables(unsigned int index) const; 80 const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index. 67 81 68 82 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/CMakeLists.txt
r2131 r2530 11 11 QuestDescription.cc 12 12 QuestEffect.cc 13 QuestEffectBeacon.cc 13 14 QuestHint.cc 14 15 QuestItem.cc -
code/branches/bugger/src/orxonox/objects/quest/ChangeQuestStatus.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/ChangeQuestStatus.cc (added) merged: 2159,2191,2226,2251 /code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file ChangeQuestStatus.cc 31 @brief 32 Implementation of the ChangeQuestStatus class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "ChangeQuestStatus.h" … … 36 42 namespace orxonox { 37 43 44 /** 45 @brief 46 Constructor. Registers the object. 47 */ 38 48 ChangeQuestStatus::ChangeQuestStatus(BaseObject* creator) : QuestEffect(creator) 39 49 { … … 49 59 } 50 60 51 void ChangeQuestStatus::setQuestId(const std::string & id) 52 { 53 if(!QuestItem::isId(id)) 54 { 55 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; 56 return; 57 } 58 this->questId_ = id; 59 } 60 61 /** 62 @brief 63 Method for creating a ChangeQuestStatus object through XML. 64 */ 61 65 void ChangeQuestStatus::XMLPort(Element& xmlelement, XMLPort::Mode mode) 62 66 { … … 66 70 } 67 71 72 /** 73 @brief 74 Sets the id of the Quest the Questffect changes the status of. 75 @param id 76 The id of the Quest. 77 @return 78 Returns true if successful. 79 */ 80 bool ChangeQuestStatus::setQuestId(const std::string & id) 81 { 82 if(!QuestItem::isId(id)) 83 { 84 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; 85 return false; 86 } 87 88 this->questId_ = id; 89 return true; 90 } 91 68 92 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/ChangeQuestStatus.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/ChangeQuestStatus.h (added) merged: 2146,2159,2191,2205,2251 /code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file ChangeQuestStatus.h 31 @brief 32 Definition of the ChangeQuestStatus class. 33 */ 34 29 35 #ifndef _ChangeQuestStatus_H__ 30 36 #define _ChangeQuestStatus_H__ … … 39 45 namespace orxonox { 40 46 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 47 /** 44 48 @brief 45 A n effect which changes a quests status.49 A QuestEffect which changes the status of a specified Quest for the player invoking the QuestEffect. 46 50 @author 47 51 Damian 'Mozork' Frick … … 53 57 virtual ~ChangeQuestStatus(); 54 58 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 59 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a ChangeQuestStatus object through XML. 56 60 57 virtual bool invoke(Player * player) = 0; //!< Invokes the effect.61 virtual bool invoke(PlayerInfo* player) = 0; //!< Invokes the QuestEffect. 58 62 59 63 protected: 60 inline const std::string & getQuestId(void) const //!< Returns the quest id. 64 /** 65 @brief Returns the id of the Quest. 66 @return Returns the id of the Quest. 67 */ 68 inline const std::string & getQuestId(void) const 61 69 { return this->questId_; } 62 70 63 std::string questId_; //!< The id of the quest the status should be changed of.64 65 71 private: 66 void setQuestId(const std::string & id); 72 std::string questId_; //!< The id of the Quest the status should be changed of. 73 74 bool setQuestId(const std::string & id); //!< Sets the id of the Quest. 67 75 68 76 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/CompleteQuest.cc (added) merged: 2146,2159,2191,2205,2209,2226,2251 /code/trunk/src/orxonox/objects/quest/CompleteQuest.cc merged: 1925-2089
r2105 r2530 26 26 * 27 27 */ 28 29 /** 30 @file CompleteQuest.cc 31 @brief 32 Implementation of the CompleteQuest class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/infos/PlayerInfo.h" 35 42 #include "QuestManager.h" 36 43 #include "Quest.h" … … 40 47 CreateFactory(CompleteQuest); 41 48 49 /** 50 @brief 51 Constructor. Registers the object. 52 */ 42 53 CompleteQuest::CompleteQuest(BaseObject* creator) : ChangeQuestStatus(creator) 43 54 { … … 53 64 } 54 65 66 /** 67 @brief 68 Method for creating a CompleteQuest object through XML. 69 */ 55 70 void CompleteQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 71 { 57 72 SUPER(CompleteQuest, XMLPort, xmlelement, mode); 73 74 COUT(3) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 58 75 } 59 76 60 77 /** 61 78 @brief 62 Invokes the effect.79 Invokes the QuestEffect. 63 80 @param player 64 The player the effect is invoked on.81 The player the QuestEffect is invoked on. 65 82 @return 66 Returns true if the effect was invoked successfully.83 Returns true if the QuestEffect was invoked successfully. 67 84 */ 68 bool CompleteQuest::invoke(Player * player)85 bool CompleteQuest::invoke(PlayerInfo* player) 69 86 { 70 if(player == NULL) 87 if(player == NULL) //!< You know, what we think of NULL-pointers... 71 88 { 72 89 COUT(2) << "Input player is NULL." << std::endl; … … 74 91 } 75 92 93 COUT(3) << "CompleteQuest on player: " << player << " ." << std::endl; 94 95 Quest* quest; 96 76 97 try 77 98 { 78 Quest*quest = QuestManager::findQuest(this->getQuestId());79 if( !quest->complete(player))99 quest = QuestManager::findQuest(this->getQuestId()); 100 if(quest == NULL || !quest->complete(player)) 80 101 { 81 102 return false; … … 88 109 } 89 110 111 COUT(3) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl; 90 112 return true; 91 113 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/CompleteQuest.h (added) merged: 2146,2159,2191,2205,2221,2251 /code/trunk/src/orxonox/objects/quest/CompleteQuest.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file CompleteQuest.h 31 @brief 32 Definition of the CompleteQuest class. 33 */ 34 29 35 #ifndef _CompleteQuest_H__ 30 36 #define _CompleteQuest_H__ … … 39 45 namespace orxonox { 40 46 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 47 /** 44 48 @brief 45 Completes a quest. 49 Completes a Quest (with a specified id) for the player invoking the QuestEffect. 50 51 Creating a CompleteQuest through XML goes as follows: 52 53 <CompleteQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be completed. 46 54 @author 47 55 Damian 'Mozork' Frick … … 53 61 virtual ~CompleteQuest(); 54 62 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CompleteQuest object through XML. 56 64 57 virtual bool invoke(Player * player); //!< Invokes the effect.65 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 58 66 59 67 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/FailQuest.cc (added) merged: 2146,2159,2191,2205,2226,2251 /code/trunk/src/orxonox/objects/quest/FailQuest.cc merged: 1925-2089
r2105 r2530 26 26 * 27 27 */ 28 29 /** 30 @file FailQuest.cc 31 @brief 32 Implementation of the FailQuest class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/infos/PlayerInfo.h" 35 42 #include "QuestManager.h" 36 43 #include "Quest.h" … … 40 47 CreateFactory(FailQuest); 41 48 49 /** 50 @brief 51 Constructor. Registers the object. 52 */ 42 53 FailQuest::FailQuest(BaseObject* creator) : ChangeQuestStatus(creator) 43 54 { … … 53 64 } 54 65 66 /** 67 @brief 68 Method for creating a FailQuest object through XML. 69 */ 55 70 void FailQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 71 { 57 72 SUPER(FailQuest, XMLPort, xmlelement, mode); 73 74 COUT(3) << "New FailQUest, with target Quest {" << this->getQuestId() << "}, created." << std::endl; 58 75 } 59 76 60 77 /** 61 78 @brief 62 Invokes the effect.79 Invokes the QuestEffect. 63 80 @param player 64 The player the effect is invoked on.81 The player the QuestEffect is invoked on. 65 82 @return 66 Returns true if the effect was invoked successfully.83 Returns true if the QuestEffect was invoked successfully. 67 84 */ 68 bool FailQuest::invoke(Player * player)85 bool FailQuest::invoke(PlayerInfo* player) 69 86 { 70 if(player == NULL) 87 if(player == NULL) //!< We don't know what to do with no player. 71 88 { 72 89 COUT(2) << "Input player is NULL." << std::endl; … … 74 91 } 75 92 93 COUT(3) << "FailQuest on player: " << player << " ." << std::endl; 94 95 Quest* quest; 76 96 try 77 97 { 78 Quest*quest = QuestManager::findQuest(this->getQuestId());79 if( !quest->fail(player))98 quest = QuestManager::findQuest(this->getQuestId()); 99 if(quest == NULL || !quest->fail(player)) 80 100 { 81 101 return false; … … 87 107 return false; 88 108 } 89 109 110 COUT(3) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl; 90 111 return true; 91 112 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/FailQuest.h (added) merged: 2146,2159,2191,2205,2221,2251 /code/trunk/src/orxonox/objects/quest/FailQuest.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file FailQuest.h 31 @brief 32 Definition of the FailQuest class. 33 */ 34 29 35 #ifndef _FailQuest_H__ 30 36 #define _FailQuest_H__ … … 39 45 namespace orxonox { 40 46 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 47 /** 44 48 @brief 45 Fails a quest. 49 Fails a quest (with a specified id) for the player invoking the QuestEffect. 50 51 Creating a FailQuest through XML goes as follows: 52 53 <FailQuest questId="id" /> //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be failed. 46 54 @author 47 55 Damian 'Mozork' Frick … … 53 61 virtual ~FailQuest(); 54 62 55 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a FailQuest object through XML. 56 64 57 virtual bool invoke(Player * player); //!< Invokes the effect.65 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 58 66 59 67 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/GlobalQuest.cc (added) merged: 2146,2159,2191,2205,2226,2251,2258 /code/trunk/src/orxonox/objects/quest/GlobalQuest.cc merged: 1925-2089
r2105 r2530 26 26 * 27 27 */ 28 29 /** 30 @file GlobalQuest.cc 31 @brief 32 Implementation of the GlobalQuest class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "GlobalQuest.h" 31 37 38 #include "orxonox/objects/infos/PlayerInfo.h" 32 39 #include "core/CoreIncludes.h" 33 40 #include "util/Exception.h" 34 41 42 #include "QuestEffect.h" 43 35 44 namespace orxonox { 36 45 … … 39 48 /** 40 49 @brief 41 Constructor. 50 Constructor. Registers the object. 42 51 */ 43 52 GlobalQuest::GlobalQuest(BaseObject* creator) : Quest(creator) 44 53 { 45 54 RegisterObject(GlobalQuest); 46 47 this->initialize();48 55 } 49 56 … … 56 63 57 64 } 58 65 66 /** 67 @brief 68 Method for creating a GlobalQuest object through XML. 69 */ 59 70 void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 71 { 61 72 SUPER(GlobalQuest, XMLPort, xmlelement, mode); 73 74 XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode); 62 75 63 76 COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl; 64 77 } 65 66 void GlobalQuest::initialize(void) 67 { 68 RegisterObject(GlobalQuest); 69 } 70 71 /** 72 @brief 73 Checks whether the quest can be started. 78 79 /** 80 @brief 81 Fails the Quest for all players. 82 Invokes the fail QuestEffects on all the players possessing this Quest. 83 @param player 84 The player failing it. 85 @return 86 Returns true if the Quest could be failed, false if not. 87 */ 88 bool GlobalQuest::fail(PlayerInfo* player) 89 { 90 if(this->isFailable(player)) //!< Check whether the Quest can be failed. 91 { 92 this->setStatus(player, questStatus::failed); 93 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; 101 } 102 103 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; 104 return false; 105 } 106 107 /** 108 @brief 109 Completes the Quest for all players. 110 Invokes the complete QuestEffects on all the players possessing this Quest. 111 Invokes the reward QuestEffects on the player completing the Quest. 112 @param player 113 The player completing it. 114 @return 115 Returns true if the Quest could be completed, false if not. 116 */ 117 bool GlobalQuest::complete(PlayerInfo* player) 118 { 119 if(this->isCompletable(player)) //!< Check whether the Quest can be completed. 120 { 121 this->setStatus(player, questStatus::completed); 122 123 //! Iterate through all players possessing the Quest. 124 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 125 { 126 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 127 } 128 129 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest. 130 return true; 131 } 132 133 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 134 return false; 135 } 136 137 /** 138 @brief 139 Checks whether the Quest can be started. 74 140 @param player 75 141 The player for whom is to be checked. … … 79 145 Throws an exception if either isInactive() of isActive() throws one. 80 146 */ 81 bool GlobalQuest::isStartable(const Player* player) const 82 { 83 return this->isInactive(player) || this->isActive(player); 84 } 85 86 /** 87 @brief 88 Checks whether the quest can be failed. 147 bool GlobalQuest::isStartable(const PlayerInfo* player) const 148 { 149 if(!(this->getParentQuest() == NULL || this->getParentQuest()->isActive(player))) 150 { 151 return false; 152 } 153 return (this->isInactive(player) && !(this->status_ == questStatus::completed || this->status_ == questStatus::failed)); 154 } 155 156 /** 157 @brief 158 Checks whether the Quest can be failed. 89 159 @param player 90 160 The player for whom is to be checked. 91 161 @return 92 Returns true if the quest can be failed, false if not.162 Returns true if the Quest can be failed, false if not. 93 163 @throws 94 164 Throws an Exception if isActive() throws one. 95 165 */ 96 bool GlobalQuest::isFailable(const Player * player) const166 bool GlobalQuest::isFailable(const PlayerInfo* player) const 97 167 { 98 168 return this->isActive(player); … … 102 172 /** 103 173 @brief 104 Checks whether the quest can be completed.174 Checks whether the Quest can be completed. 105 175 @param player 106 176 The player for whom is to be checked. 107 177 @return 108 Returns true if the quest can be completed, false if not.178 Returns true if the Quest can be completed, false if not. 109 179 @throws 110 180 Throws an Exception if isActive() throws one. 111 181 */ 112 bool GlobalQuest::isCompletable(const Player * player) const182 bool GlobalQuest::isCompletable(const PlayerInfo* player) const 113 183 { 114 184 return this->isActive(player); … … 117 187 /** 118 188 @brief 119 Returns the status of the quest for a specific player.189 Returns the status of the Quest for a specific player. 120 190 @param player 121 191 The player. … … 123 193 Throws an Exception if player is NULL. 124 194 */ 125 questStatus::Enum GlobalQuest::getStatus(const Player * player) const126 { 127 if(player == NULL) 128 { 129 ThrowException(Argument, "The input Player * is NULL.");130 } 131 132 // TDO: Does this really work???133 std::set<Player *>::const_iterator it = this->players_.find((Player*)(void*)player);134 if (it != this->players_.end()) 195 questStatus::Enum GlobalQuest::getStatus(const PlayerInfo* player) const 196 { 197 if(player == NULL) //!< We don't want NULL-Pointers! 198 { 199 ThrowException(Argument, "The input PlayerInfo* is NULL."); 200 } 201 202 //! Find the player. 203 std::set<PlayerInfo*>::const_iterator it = this->players_.find((PlayerInfo*)(void*)player); 204 if (it != this->players_.end()) //!< If the player was found. 135 205 { 136 206 return this->status_; 137 207 } 138 else 139 { 140 return questStatus::inactive; 141 } 142 208 209 return questStatus::inactive; 143 210 } 144 211 … … 154 221 Returns false if player is NULL. 155 222 */ 156 bool GlobalQuest::setStatus(Player * player, const questStatus::Enum & status)157 { 158 if(player == NULL) 223 bool GlobalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status) 224 { 225 if(player == NULL) //!< We don't want NULL-Pointers! 159 226 { 160 227 return false; 161 228 } 162 229 163 std::set<Player*>::const_iterator it = this->players_.find(player); 230 //! Find the player. 231 std::set<PlayerInfo*>::const_iterator it = this->players_.find(player); 164 232 if (it == this->players_.end()) //!< Player is not yet in the list. 165 233 { 166 this->players_.insert(player); 167 } 168 this->status_ = status; 234 this->players_.insert(player); //!< Add the player to the set. 235 } 236 237 this->status_ = status; //!< Set the status, which is global, remember...? 169 238 return true; 170 239 } 240 241 /** 242 @brief 243 Adds a reward QuestEffect to the list of reward QuestEffects. 244 @param effect 245 The QuestEffect to be added. 246 @return 247 Returns true if successful. 248 */ 249 bool GlobalQuest::addRewardEffect(QuestEffect* effect) 250 { 251 if(effect == NULL) //!< We don't want NULL-Pointers! 252 { 253 COUT(2) << "The reward effect to be added to quest {" << this->getId() << "} was NULL." << std::endl; 254 return false; 255 } 256 257 this->rewards_.push_back(effect); //!< Add the QuestEffect to the list. 258 259 COUT(3) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl; 260 return true; 261 } 262 263 /** 264 @brief 265 Returns the reward QuestEffect at the given index. 266 @param index 267 The index. 268 @return 269 Returns the QuestEffect at the given index. 270 */ 271 const QuestEffect* GlobalQuest::getRewardEffects(unsigned int index) const 272 { 273 int i = index; 274 for (std::list<QuestEffect*>::const_iterator effect = this->rewards_.begin(); effect != this->rewards_.end(); ++effect) 275 { 276 if(i == 0) 277 { 278 return *effect; 279 } 280 i--; 281 } 282 return NULL; 283 } 171 284 172 285 - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/GlobalQuest.h (added) merged: 2146,2159,2191,2205,2226,2251 /code/trunk/src/orxonox/objects/quest/GlobalQuest.h merged: 1925-2089
r2096 r2530 26 26 * 27 27 */ 28 29 /** 30 @file GlobalQuest.h 31 @brief 32 Definition of the GlobalQuest class. 33 */ 28 34 29 35 #ifndef _GlobalQuest_H__ … … 33 39 34 40 #include <set> 41 #include <list> 35 42 36 43 #include "core/XMLPort.h" … … 39 46 namespace orxonox { 40 47 41 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.42 43 48 /** 44 49 @brief 45 Global quests are quests, that have the same status for all players. 46 This means, that when a player successfully completes this quest, it is completed for all players that have it. 50 GlobalQuests are Quests, that have the same status for all players. 51 This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it. 52 53 Creating a GlobalQuest through XML goes as follows: 54 55 <GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 56 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 59 ... 60 <Quest id="questIdn" /> 61 </subquests> 62 <hints> 63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 64 ... 65 <QuestHint id="hintIdn" /> 66 </hints> 67 <fail-effects> 68 <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation. 69 ... 70 <QuestEffect /> 71 </fail-effects> 72 <complete-effects> 73 <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is completed, see QuestEffect for the full XML representation. 74 ... 75 <QuestEffect /> 76 </complete-effects> 77 <reward-effects> 78 <QuestEffect /> //A list of QuestEffects, invoked on the player completing this quest. See QuestEffect for the full XML representation. 79 ... 80 <QuestEffect /> 81 </reward-effects> 82 </GlobalQuest> 47 83 @author 48 84 Damian 'Mozork' Frick … … 54 90 virtual ~GlobalQuest(); 55 91 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 92 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a GlobalQuest object through XML. 93 94 virtual bool fail(PlayerInfo* player); //!< Fails the Quest. 95 virtual bool complete(PlayerInfo* player); //!< Completes the Quest. 57 96 58 97 protected: 59 virtual bool isStartable(const Player * player) const; //!< Checks whether the quest can be started.60 virtual bool isFailable(const Player * player) const; //!< Checks whether the quest can be failed.61 virtual bool isCompletable(const Player * player) const; //!< Checks whether the quest can be completed.98 virtual bool isStartable(const PlayerInfo* player) const; //!< Checks whether the Quest can be started. 99 virtual bool isFailable(const PlayerInfo* player) const; //!< Checks whether the Quest can be failed. 100 virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed. 62 101 63 virtual questStatus::Enum getStatus(const Player* player) const; //!< Returns the status of the quest for a specific player. 64 virtual bool setStatus(Player* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 102 virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player. 103 104 virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 65 105 66 106 private: 67 std::set<Player*> players_; //!< The set of players which possess this quest. 68 questStatus::Enum status_; //!< The status of this quest. 69 70 void initialize(void); 107 std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest. 108 questStatus::Enum status_; //!< The status of this Quest. 109 std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest. 110 111 bool addRewardEffect(QuestEffect* effect); //!< Adds a reward QuestEffect to the list of reward QuestEffects. 112 const QuestEffect* getRewardEffects(unsigned int index) const; //!< Returns the reward QuestEffect at the given index. 71 113 72 114 }; - Property svn:mergeinfo changed
-
code/branches/bugger/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 r2530 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
-
code/branches/bugger/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/LocalQuest.h (added) merged: 2146,2159,2191,2205,2251 /code/trunk/src/orxonox/objects/quest/LocalQuest.h merged: 1925-2089
r2096 r2530 26 26 * 27 27 */ 28 29 /** 30 @file LocalQuest.h 31 @brief 32 Definition of the LocalQuest class. 33 */ 28 34 29 35 #ifndef _LocalQuest_H__ … … 40 46 namespace orxonox { 41 47 42 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.43 44 48 /** 45 49 @brief 46 Handles quests which have different states for different players. 50 Handles Quests which have different states for different players. 51 LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest. 52 53 Creating a LocalQuest through XML goes as follows: 54 55 <LocalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 56 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 59 ... 60 <Quest id="questIdn" /> 61 </subquests> 62 <hints> 63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 64 ... 65 <QuestHint id="hintIdn" /> 66 </hints> 67 <fail-effects> 68 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation. 69 ... 70 <QuestEffect /> 71 </fail-effects> 72 <complete-effects> 73 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation. 74 ... 75 <QuestEffect /> 76 </complete-effects> 77 </LocalQuest> 47 78 @author 48 79 Damian 'Mozork' Frick … … 54 85 virtual ~LocalQuest(); 55 86 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 87 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a LocalQuest object through XML. 88 89 virtual bool fail(PlayerInfo* player); //!< Fails the Quest. 90 virtual bool complete(PlayerInfo* player); //!< Completes the Quest. 57 91 58 92 protected: 59 virtual bool isStartable(const Player * player) const; //!< Checks whether the quest can be started.60 virtual bool isFailable(const Player * player) const; //!< Checks whether the quest can be failed.61 virtual bool isCompletable(const Player * player) const; //!< Checks whether the quest can be completed.93 virtual bool isStartable(const PlayerInfo* player) const; //!< Checks whether the Quest can be started. 94 virtual bool isFailable(const PlayerInfo* player) const; //!< Checks whether the Quest can be failed. 95 virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed. 62 96 63 virtual questStatus::Enum getStatus(const Player * player) const; //!< Returns the status of the quest for a specific player.64 virtual bool setStatus(Player * player, const questStatus::Enum & status); //!< Sets the status for a specific player.97 virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player. 98 virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player. 65 99 66 100 private: 67 std::map<Player*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 68 69 void initialize(void); 101 std::map<const PlayerInfo*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 70 102 71 103 }; 72 73 104 74 105 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/Quest.cc (added) merged: 2146,2159,2191,2205,2226,2251 /code/trunk/src/orxonox/objects/quest/Quest.cc merged: 1925-2089
r2105 r2530 26 26 * 27 27 */ 28 29 /** 30 @file Quest.cc 31 @brief 32 Implementation of the Quest class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 32 38 #include "core/CoreIncludes.h" 33 39 40 #include "orxonox/objects/infos/PlayerInfo.h" 34 41 #include "QuestManager.h" 35 42 #include "QuestDescription.h" … … 39 46 namespace orxonox { 40 47 48 /** 49 @brief 50 Constructor. Registers and initializes object. 51 */ 41 52 Quest::Quest(BaseObject* creator) : QuestItem(creator) 42 53 { 43 54 RegisterObject(Quest); 44 55 45 this-> initialize();56 this->parentQuest_ = NULL; 46 57 } 47 58 … … 55 66 } 56 67 68 /** 69 @brief 70 Method for creating a Quest object through XML. 71 */ 57 72 void Quest::XMLPort(Element& xmlelement, XMLPort::Mode mode) 58 73 { 59 74 SUPER(Quest, XMLPort, xmlelement, mode); 60 75 61 XMLPortObject(Quest, Quest, "", addSubQuest, getSubQuests, xmlelement, mode); 62 XMLPortObject(Quest, QuestHint, "", addHint, getHints, xmlelement, mode); 63 XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffects, xmlelement, mode); 64 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffects, xmlelement, mode); 65 66 QuestManager::registerQuest(this); //Registers the quest with the QuestManager. 67 } 68 69 /** 70 @brief 71 Initializes the object. Needs to be called first in every constructor of this class. 72 */ 73 void Quest::initialize(void) 74 { 75 RegisterObject(Quest); 76 77 this->parentQuest_ = NULL; 78 } 79 80 /** 81 @brief 82 Sets the parent quest of the quest. 76 XMLPortObject(Quest, Quest, "subquests", addSubQuest, getSubQuest, xmlelement, mode); 77 XMLPortObject(Quest, QuestHint, "hints", addHint, getHint, xmlelement, mode); 78 XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffect, xmlelement, mode); 79 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode); 80 81 QuestManager::registerQuest(this); //!<Registers the Quest with the QuestManager. 82 } 83 84 /** 85 @brief 86 Sets the parentquest of the Quest. 83 87 @param quest 84 A pointer to the quest to be set as parentquest.85 @return 86 Returns true if the parent Quest could be set.88 A pointer to the Quest to be set as parentquest. 89 @return 90 Returns true if the parentquest could be set. 87 91 */ 88 92 bool Quest::setParentQuest(Quest* quest) 89 93 { 90 if(quest == NULL) 94 if(quest == NULL) //!< We don't want to set NULL-Pointers. 91 95 { 92 96 COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 102 106 /** 103 107 @brief 104 Adds a sub quest to the quest.108 Adds a subquest to the Quest. 105 109 @param quest 106 A pointer to the quest to be set as subquest.107 @return 108 Returns true if the sub Quest vould be set.110 A pointer to the Quest to be set as subquest. 111 @return 112 Returns true if the subquest could be set. 109 113 */ 110 114 bool Quest::addSubQuest(Quest* quest) 111 115 { 112 if(quest == NULL) 116 if(quest == NULL) //!< We don't want to set NULL-Pointers. 113 117 { 114 118 COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 116 120 } 117 121 118 quest->setParentQuest(this); 119 this->subQuests_.push_back(quest); 122 quest->setParentQuest(this); //!< Sets the currentQuest (this) as parentquest for the added subquest. 123 this->subQuests_.push_back(quest); //!< Adds the Quest to the end of the list of subquests. 120 124 121 125 COUT(3) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 126 130 /** 127 131 @brief 128 Adds a Hint to the list of hints132 Adds a QuestHint to the list of QuestHints 129 133 @param hint 130 The hint that should be added to the list of hints.134 The QuestHint that should be added to the list of QuestHints. 131 135 @return 132 136 Returns true if the hint was successfully added. … … 134 138 bool Quest::addHint(QuestHint* hint) 135 139 { 136 if(hint == NULL) 140 if(hint == NULL) //!< We don't want to set NULL-Pointers. Seriously! 137 141 { 138 142 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; … … 140 144 } 141 145 142 this->hints_.push_back(hint);143 hint->setQuest(this);146 hint->setQuest(this); //!< Sets the current Quest (this) as Quest for the added QuestHint. 147 this->hints_.push_back(hint); //!< Adds the QuestHint to the end of the list of QuestHints. 144 148 145 149 COUT(3) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 149 153 /** 150 154 @brief 151 155 Adds an QuestEffect to the list of fail QuestEffects. 156 @param effect 157 The QuestEffect to be added. 158 @return 159 Returns true if successful. 152 160 */ 153 161 bool Quest::addFailEffect(QuestEffect* effect) 154 162 { 155 if(effect == NULL) 163 if(effect == NULL) //!< We don't want to set NULL-Pointers. 156 164 { 157 165 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 159 167 } 160 168 161 this->failEffects_.push_back(effect); 169 this->failEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of fail QuestEffects. 162 170 163 171 COUT(3) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 167 175 /** 168 176 @brief 169 177 Adds an QuestEffect to the list of complete QuestEffects. 178 @param effect 179 The QuestEffect to be added. 180 @return 181 Returns true if successful. 170 182 */ 171 183 bool Quest::addCompleteEffect(QuestEffect* effect) 172 184 { 173 if(effect == NULL) 185 if(effect == NULL) //!< We don't want to set NULL-Pointers. 174 186 { 175 187 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 177 189 } 178 190 179 this->completeEffects_.push_back(effect); 191 this->completeEffects_.push_back(effect); //!< Adds the QuestEffect to the end of the list of complete QuestEffects. 180 192 181 193 COUT(3) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 185 197 /** 186 198 @brief 187 199 Returns the parentquest of the Quest. 200 @return 201 Returns a pointer to the parentquest of the Quest. 188 202 */ 189 203 const Quest* Quest::getParentQuest(void) … … 194 208 /** 195 209 @brief 196 197 */ 198 const Quest* Quest::getSubQuests(unsigned int index) const 210 Returns the subquest at the given index. 211 @param 212 The index. 213 @return 214 Returns a pointer to the subquest at the given index. NULL if there is no element at the given index. 215 */ 216 const Quest* Quest::getSubQuest(unsigned int index) const 199 217 { 200 218 int i = index; 219 220 //! Iterate through all subquests. 201 221 for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest) 202 222 { 203 if(i == 0) 223 if(i == 0) //!< We're counting down... 204 224 { 205 225 return *subQuest; … … 207 227 i--; 208 228 } 209 return NULL; 210 } 211 212 /** 213 @brief 214 215 */ 216 const QuestHint* Quest::getHints(unsigned int index) const 229 230 return NULL; //!< If the index is greater than the number of elements in the list. 231 } 232 233 /** 234 @brief 235 Returns the QuestHint at the given index. 236 @param 237 The index. 238 @return 239 Returns a pointer to the QuestHint at the given index. NULL if there is no element at the given index. 240 */ 241 const QuestHint* Quest::getHint(unsigned int index) const 217 242 { 218 243 int i = index; 244 245 //! Iterate through all QuestHints. 219 246 for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint) 220 247 { 221 if(i == 0) 248 if(i == 0) //!< We're counting down... 222 249 { 223 250 return *hint; … … 225 252 i--; 226 253 } 227 return NULL; 228 } 229 230 /** 231 @brief 232 233 */ 234 const QuestEffect* Quest::getFailEffects(unsigned int index) const 254 return NULL; //!< If the index is greater than the number of elements in the list. 255 } 256 257 /** 258 @brief 259 Returns the fail QuestEffect at the given index. 260 @param 261 The index. 262 @return 263 Returns a pointer to the fail QuestEffect at the given index. NULL if there is no element at the given index. 264 */ 265 const QuestEffect* Quest::getFailEffect(unsigned int index) const 235 266 { 236 267 int i = index; 268 269 //! Iterate through all fail QuestEffects. 237 270 for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect) 238 271 { 239 if(i == 0) 272 if(i == 0) //!< We're counting down... 240 273 { 241 274 return *effect; … … 243 276 i--; 244 277 } 245 return NULL; 246 } 247 248 /** 249 @brief 250 251 */ 252 const QuestEffect* Quest::getCompleteEffects(unsigned int index) const 278 return NULL; //!< If the index is greater than the number of elements in the list. 279 } 280 281 /** 282 @brief 283 Returns the complete QuestEffect at the given index. 284 @param 285 The index. 286 @return 287 Returns a pointer to the complete QuestEffect at the given index. NULL if there is no element at the given index. 288 */ 289 const QuestEffect* Quest::getCompleteEffect(unsigned int index) const 253 290 { 254 291 int i = index; 292 293 //! Iterate through all complete QuestEffects. 255 294 for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect) 256 295 { 257 if(i == 0) 296 if(i == 0) //!< We're counting down... 258 297 { 259 298 return *effect; … … 261 300 i--; 262 301 } 263 return NULL; 302 return NULL; //!< If the index is greater than the number of elements in the list. 264 303 } 265 304 … … 274 313 Throws an exception if getStatus throws one. 275 314 */ 276 bool Quest::isInactive(const Player * player) const315 bool Quest::isInactive(const PlayerInfo* player) const 277 316 { 278 317 return this->getStatus(player) == questStatus::inactive; … … 289 328 Throws an exception if getStatus throws one. 290 329 */ 291 bool Quest::isActive(const Player * player) const330 bool Quest::isActive(const PlayerInfo* player) const 292 331 { 293 332 … … 305 344 Throws an exception if getStatus throws one. 306 345 */ 307 bool Quest::isFailed(const Player * player) const346 bool Quest::isFailed(const PlayerInfo* player) const 308 347 { 309 348 return this->getStatus(player) == questStatus::failed; … … 320 359 Throws an exception if getStatus throws one. 321 360 */ 322 bool Quest::isCompleted(const Player * player) const361 bool Quest::isCompleted(const PlayerInfo* player) const 323 362 { 324 363 return this->getStatus(player) == questStatus::completed; … … 327 366 /** 328 367 @brief 329 Starts the quest.330 @param player 331 The player. 332 @return 333 Returns true if the quest could be started, false if not.334 */ 335 bool Quest::start(Player * player)336 { 337 if(this->isStartable(player)) 368 Starts the Quest for an input player. 369 @param player 370 The player. 371 @return 372 Returns true if the Quest could be started, false if not. 373 */ 374 bool Quest::start(PlayerInfo* player) 375 { 376 if(this->isStartable(player)) //!< Checks whether the quest can be started. 338 377 { 339 378 this->setStatus(player, questStatus::active); 340 379 return true; 341 380 } 342 COUT(2) << "A non-startable quest was trying to be started." << std::endl; 381 382 COUT(4) << "A non-startable quest was trying to be started." << std::endl; 343 383 return false; 344 384 } 345 385 346 /**347 @brief348 Fails the quest.349 @param player350 The player.351 @return352 Returns true if the quest could be failed, false if not.353 */354 bool Quest::fail(Player* player)355 {356 if(this->isFailable(player))357 {358 this->setStatus(player, questStatus::failed);359 QuestEffect::invokeEffects(player, this->failEffects_);360 return true;361 }362 COUT(2) << "A non-failable quest was trying to be failed." << std::endl;363 return false;364 }365 366 /**367 @brief368 Completes the quest.369 @param player370 The player.371 @return372 Returns true if the quest could be completed, false if not.373 */374 bool Quest::complete(Player* player)375 {376 if(this->isCompletable(player))377 {378 this->setStatus(player, questStatus::completed);379 QuestEffect::invokeEffects(player, this->completeEffects_);380 return true;381 }382 COUT(2) << "A non-completable quest was trying to be completed." << std::endl;383 return false;384 }385 386 386 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/Quest.h (added) merged: 2146,2159,2191,2205,2251,2258 /code/trunk/src/orxonox/objects/quest/Quest.h merged: 1925-2089
r2096 r2530 26 26 * 27 27 */ 28 28 29 /** 30 @file Quest.h 31 @brief 32 Definition of the Quest class. 33 34 The Quest is the parent class of LocalQuest and GlobalQuest. 35 */ 36 29 37 #ifndef _Quest_H__ 30 38 #define _Quest_H__ … … 36 44 37 45 #include "core/XMLPort.h" 46 38 47 #include "QuestItem.h" 39 48 … … 41 50 { 42 51 52 //!Different states of a Quest. 43 53 enum Enum 44 54 { … … 53 63 namespace orxonox { 54 64 55 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.56 57 65 /** 58 66 @brief 59 Represents a quest in the game. 60 A quest has a list of subquests and a parentquest (if it is not a rootquest). 61 Each quest exists only once but it has a different status (inactive, active, failed or completed) for each player. 67 Represents a Quest in the game. 68 A Quest has a list of subquests and a parentquest (if it is not a rootquest). 69 Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player. 70 A Quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the Quest. 71 A Quest has a list of QuestEffects that are invoked when the quest is failed and also a list of QuestEffects that are invoked, when the Quest is completed. 72 73 Quest itself should not be instantiated, if you want to create a quest either go for LocalQuest or GlobalQuest, whichever suits you needs better. 62 74 @author 63 75 Damian 'Mozork' Frick … … 69 81 virtual ~Quest(); 70 82 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 83 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Quest object through XML. 72 84 73 inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. 85 /** 86 @brief Returns the parentquest of the Quest. 87 @return Returns a pointer to the parentquest of the Quest. 88 */ 89 inline Quest* getParentQuest(void) const 74 90 { return this->parentQuest_; } 75 inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests. 76 { return this->subQuests_; } 77 78 bool isInactive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 79 bool isActive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'active'. 80 bool isFailed(const Player* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 81 bool isCompleted(const Player* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 82 83 bool start(Player* player); //!< Sets a quest to active. 84 bool fail(Player* player); //!< Fails the quest. 85 bool complete(Player* player); //!< Completes the quest. 91 92 /** 93 @brief Returns the list of subquests. 94 @return Returns a reference to the list of subquests of the quest. 95 */ 96 inline const std::list<Quest*> & getSubQuestList(void) const 97 { return this->subQuests_; } 98 99 /** 100 @brief Returns the list of all QuestHints of this Quest. 101 @return Returns a reference to the list of QuestHints of the Quest. 102 */ 103 inline const std::list<QuestHint*> & getHintsList(void) const 104 { return this->hints_; } 105 106 bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 107 bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'. 108 bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 109 bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 110 111 bool start(PlayerInfo* player); //!< Sets a Quest to active. 112 virtual bool fail(PlayerInfo* player) = 0; //!< Fails the Quest. 113 virtual bool complete(PlayerInfo* player) = 0; //!< Completes the Quest. 86 114 87 115 protected: 88 void initialize(void); //!< Initialized the object. 116 virtual bool isStartable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be started. 117 virtual bool isFailable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be failed. 118 virtual bool isCompletable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be completed. 89 119 90 virtual bool isStartable(const Player* player) const = 0; //!< Checks whether the quest can be started. 91 virtual bool isFailable(const Player* player) const = 0; //!< Checks whether the quest can be failed. 92 virtual bool isCompletable(const Player* player) const = 0; //!< Checks whether the quest can be completed. 120 const Quest* getParentQuest(void); //!< Returns the parentquest of the Quest. 121 const Quest* getSubQuest(unsigned int index) const; //!<Returns the subquest at the given index. 122 const QuestHint* getHint(unsigned int index) const; //!< Returns the QuestHint at the given index. 123 const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the fail QuestEffect at the given index. 124 const QuestEffect* getCompleteEffect(unsigned int index) const; //!< Returns the complete QuestEffect at the given index. 125 126 /** 127 @brief Returns the list of fail QuestEffects. 128 @return Returns a reference to the list of fail QuestEffects. 129 */ 130 inline std::list<QuestEffect*> & getFailEffectList(void) 131 { return this->failEffects_; } 132 133 /** 134 @brief Returns the list of complete QuestEffects. 135 @return Returns a reference to the list of complete QuestEffects. 136 */ 137 inline std::list<QuestEffect*> & getCompleteEffectList(void) 138 { return this->completeEffects_; } 93 139 94 bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest. 95 bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest. 96 bool addHint(QuestHint* hint); //!< Add a hint to the list of hints. 97 bool addFailEffect(QuestEffect* effect); 98 bool addCompleteEffect(QuestEffect* effect); 140 virtual questStatus::Enum getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player. 141 virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. 142 143 private: 144 Quest* parentQuest_; //!< Pointer to the parentquest. 145 std::list<Quest*> subQuests_; //!< List of all the subquests. 99 146 100 const Quest* getParentQuest(void); 101 const Quest* getSubQuests(unsigned int index) const; 102 const QuestHint* getHints(unsigned int index) const; 103 const QuestEffect* getFailEffects(unsigned int index) const; 104 const QuestEffect* getCompleteEffects(unsigned int index) const; 147 std::list<QuestHint*> hints_; //!< A list of all the QuestHints tied to this Quest. 105 148 106 virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player. 107 virtual bool setStatus(Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. 108 109 Quest* parentQuest_; //!< Pointer to the parent quest. 110 std::list<Quest*> subQuests_; //!< List of all the sub quests. 111 112 std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest. 113 114 std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed. 115 std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed. 149 std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed. 150 std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed. 151 152 bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest. 153 bool addSubQuest(Quest* quest); //!< Adds a subquest to the Quest. 154 bool addHint(QuestHint* hint); //!< Add a QuestHint to the list of QuestHints. 155 bool addFailEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of fail QuestEffects. 156 bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects. 116 157 117 158 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestDescription.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestDescription.cc (added) merged: 2159,2205,2251 /code/trunk/src/orxonox/objects/quest/QuestDescription.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file QuestDescription.cc 31 @brief 32 Implementation of the QuestDescription class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 36 30 37 #include "QuestDescription.h" 31 38 … … 36 43 CreateFactory(QuestDescription); 37 44 45 /** 46 @brief 47 Constructor. Registers and initializes the object. 48 */ 38 49 QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator) 39 50 { 40 51 RegisterObject(QuestDescription); 41 42 this->initialize(); 52 53 this->title_ = ""; 54 this->description_ = ""; 43 55 } 44 56 57 /** 58 @brief 59 Destructor. 60 */ 45 61 QuestDescription::~QuestDescription() 46 62 { … … 48 64 } 49 65 66 /** 67 @brief 68 Method for creating a QuestDescription object through XML. 69 */ 50 70 void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode) 51 71 { … … 58 78 } 59 79 60 /**61 @brief62 Initializes the object. Has to be called first in every constructor of this class.63 */64 void QuestDescription::initialize(void)65 {66 RegisterObject(QuestDescription);67 }68 69 80 70 81 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestDescription.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestDescription.h (added) merged: 2159,2191,2221,2251 /code/trunk/src/orxonox/objects/quest/QuestDescription.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file QuestDescription.h 31 @brief 32 Definition of the QuestDescription class. 33 */ 34 29 35 #ifndef _QuestDescription_H__ 30 36 #define _QuestDescription_H__ … … 43 49 This class is a description of a QuestItem. 44 50 It holds a title and a description. 51 52 Creating a QuestDescription through XML goes as follows: 53 54 <QuestDescription title="Title" description="Description Text" /> 45 55 @author 46 56 Damian 'Mozork' Frick … … 52 62 virtual ~QuestDescription(); 53 63 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML. 55 65 56 inline const std::string & getTitle(void) const //!< Returns the title. 66 /** 67 @brief Returns the title. 68 @return Returns a string containing the title of the QuestDescription. 69 */ 70 inline const std::string & getTitle(void) const 57 71 { return this->title_; } 58 inline const std::string & getDescription(void) const //!< Returns the description text. 72 73 /** 74 @brief Returns the description text. 75 @return Returns a string containing the description text of the QuestDescription. 76 */ 77 inline const std::string & getDescription(void) const 59 78 { return this->description_; } 60 79 61 80 private: 62 void initialize(void);63 64 inline void setTitle(const std::string & title) //!< Sets the title.65 { this->title_ = title; }66 inline void setDescription(const std::string & description) //!< Sets the description text.67 { this->description_ = description; }68 69 81 std::string title_; //!< The title. 70 82 std::string description_; //!< The description. 83 84 /** 85 @brief Sets the title. 86 @param title The title to be set. 87 */ 88 inline void setTitle(const std::string & title) 89 { this->title_ = title; } 90 91 /** 92 @brief Sets the description text. 93 @param description The description text to be set. 94 */ 95 inline void setDescription(const std::string & description) 96 { this->description_ = description; } 71 97 72 98 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestEffect.cc (added) merged: 2146,2159,2191,2205,2251 /code/trunk/src/orxonox/objects/quest/QuestEffect.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file QuestEffect.cc 31 @brief 32 Implementation of the QuestEffect class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "QuestEffect.h" 31 37 32 38 #include "core/CoreIncludes.h" 39 40 #include "orxonox/objects/infos/PlayerInfo.h" 33 41 34 42 namespace orxonox { … … 55 63 /** 56 64 @brief 57 Static method. Invoke all effects of an effect list.65 Static method. Invoke all QuestEffects in an QuestEffect-list on a given player. 58 66 @param player 59 The player the effects are invoked on.67 The player the QuestEffects are invoked on. 60 68 @param effects 61 A list of all the effects to be invoked.69 A list of all the QuestEffects to be invoked. 62 70 @return 63 71 Returns false if there was an error, view console of log for further detail. 64 72 */ 65 bool QuestEffect::invokeEffects(Player * player, std::list<QuestEffect*> & effects)73 bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects) 66 74 { 67 75 bool check = true; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestEffect.h (added) merged: 2146,2159,2191,2205,2251 /code/trunk/src/orxonox/objects/quest/QuestEffect.h merged: 1925-2089
r2096 r2530 26 26 * 27 27 */ 28 29 /** 30 @file QuestEffect.h 31 @brief 32 Definition of the QuestEffect class. 33 */ 28 34 29 35 #ifndef _QuestEffect_H__ … … 38 44 namespace orxonox { 39 45 40 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.41 42 46 /** 43 47 @brief 44 Handles effects for quests. 48 Handles QuestEffects for Quests. 49 QuestEffects are the only way for Quests to have any sideeffects in the game world. They are also the only way for a player to gain, complete or fail Quests. 45 50 @author 46 51 Damian 'Mozork' Frick … … 52 57 virtual ~QuestEffect(); 53 58 54 virtual bool invoke(Player * player) = 0; //!< Invokes the effect.55 static bool invokeEffects(Player * player, std::list<QuestEffect*> & effects); //!< Invokes all effects in the list.59 virtual bool invoke(PlayerInfo* player) = 0; //!< Invokes the QuestEffect. 60 static bool invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects); //!< Invokes all QuestEffects in the list. 56 61 57 62 - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestEffectBeacon.cc
- Property svn:eol-style set to native
-
code/branches/bugger/src/orxonox/objects/quest/QuestEffectBeacon.h
- Property svn:eol-style set to native
r2261 r2530 113 113 114 114 private: 115 static const int INFINITE = -1; //!< Constant to avoid using magic numbers.115 //static const int INFINITE = -1; //!< Constant to avoid using magic numbers. 116 116 117 117 std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player. -
code/branches/bugger/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestHint.cc (added) merged: 2146,2159,2191,2205,2226,2251 /code/trunk/src/orxonox/objects/quest/QuestHint.cc merged: 1925-2089
r2105 r2530 26 26 * 27 27 */ 28 29 /** 30 @file QuestHint.cc 31 @brief 32 Implementation of the QuestHint class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 33 39 #include "util/Exception.h" 34 40 41 #include "orxonox/objects/infos/PlayerInfo.h" 42 #include "QuestManager.h" 35 43 #include "Quest.h" 36 44 … … 41 49 /** 42 50 @brief 43 Constructor. 51 Constructor. Registers the object. 44 52 */ 45 53 QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator) 46 54 { 47 55 RegisterObject(QuestHint); 48 49 this->initialize();50 56 } 51 57 … … 59 65 } 60 66 61 void QuestHint::initialize(void) 62 { 63 RegisterObject(QuestHint); 64 } 65 67 /** 68 @brief 69 Method for creating a QuestHint object through XML. 70 */ 66 71 void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 67 72 { 68 73 SUPER(QuestHint, XMLPort, xmlelement, mode); 69 74 75 QuestManager::registerHint(this); //!< Registers the QuestHint with the QuestManager. 76 70 77 COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl; 71 78 } … … 74 81 /** 75 82 @brief 76 Checks whether the hint is active for a specific player.83 Checks whether the QuestHint is active for a specific player. 77 84 @param player 78 85 The player. … … 80 87 Throws an Argument Exception if the input Player-pointer is NULL. 81 88 @return 82 Returns true if the hint is active for the specified player.89 Returns true if the QuestHint is active for the specified player. 83 90 */ 84 bool QuestHint::isActive( Player* player)91 bool QuestHint::isActive(const PlayerInfo* player) const 85 92 { 86 if(player == NULL) 93 if(player == NULL) //!< NULL-Pointers are ugly! 87 94 { 88 ThrowException(Argument, "The input Player * is NULL.");95 ThrowException(Argument, "The input PlayerInfo* is NULL."); 89 96 return false; 90 97 } 91 98 92 std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player); 93 if (it != this->playerStatus_.end()) 99 //! Find the player. 100 std::map<const PlayerInfo*, questHintStatus::Enum>::const_iterator it = this->playerStatus_.find(player); 101 if (it != this->playerStatus_.end()) //!< If the player is in the map. 94 102 { 95 103 return it->second; 96 104 } 105 97 106 return questStatus::inactive; 98 107 } … … 106 115 Returns true if the activation was successful, false if there were problems. 107 116 */ 108 bool QuestHint:: activate(Player* player)117 bool QuestHint::setActive(PlayerInfo* player) 109 118 { 110 if(this->quest_->isActive(player)) 119 if(this->quest_->isActive(player)) //!< For a hint to get activated the quest must be active. 111 120 { 112 if(!(this->isActive(player))) 121 if(!(this->isActive(player))) //!< If the hint is already active, activation is pointless. 113 122 { 114 123 this->playerStatus_[player] = questHintStatus::active; … … 121 130 } 122 131 } 132 123 133 COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl; 124 134 return false; … … 127 137 /** 128 138 @brief 129 Sets the quest the QuestHitnbelongs to.139 Sets the Quest the QuestHint belongs to. 130 140 @param quest 141 The Quest to be set as Quest the QuestHint is attached to. 131 142 @return 143 Returns true if successful. 132 144 */ 133 145 bool QuestHint::setQuest(Quest* quest) 134 146 { 135 if(quest == NULL) 147 if(quest == NULL) //!< NULL-Pointer. Again..? 136 148 { 137 149 COUT(2) << "The input Quest* is NULL." << std::endl; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestHint.h (added) merged: 2146,2159,2191,2205,2251 /code/trunk/src/orxonox/objects/quest/QuestHint.h merged: 1925-2089
r2096 r2530 26 26 * 27 27 */ 28 29 /** 30 @file QuestHint.h 31 @brief 32 Definition of the QuestHint class. 33 */ 28 34 29 35 #ifndef _QuestHint_H__ … … 41 47 { 42 48 49 //! The status of the hint. 43 50 enum Enum 44 51 { … … 52 59 { 53 60 54 class Player; //Forward declaration, remove when fully integrated into the objecthirarchy.55 56 61 /** 57 62 @brief 58 63 Represents a hint in the game towards completing a Quest. 59 Consists of title and description in textual form and must belong to a quest. 60 A QuestHit has a defined status (inactive or active, where inactive is default) for each player, which means each QuestHint exists only once for all players, it doesn't belong to a player, it just has different stati for each of them. 64 Consists of title and description (which is stored in a QuestDescription object) in textual form and must belong to a quest. 65 A QuestHint has a defined status (inactive or active, where inactive is default) for each player, which means each a QuestHint exists only once for all players, it doesn't belong to a player, it just has different states for each of them. 66 67 Creating a QuestHint through XML goes as follows: 68 69 <QuestHint id="hintId"> //Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information 70 <QuestDesctription title="" description="" /> 71 </QuestHint> 61 72 @author 62 73 Damian 'Mozork' Frick … … 69 80 virtual ~QuestHint(); 70 81 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 82 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestHint object through XML. 72 83 73 bool isActive( Player* player); //!< Returns true if the hint is active for the input player.84 bool isActive(const PlayerInfo* player) const; //!< Returns true if the QuestHint is active for the input player. 74 85 75 bool activate(Player* player); //!< Activates the hint for the input player. 86 bool setActive(PlayerInfo* player); //!< Activates the QuestHint for the input player. 87 bool setQuest(Quest* quest); //!< Sets the Quest the QuestHint belongs to. 76 88 77 bool setQuest(Quest* quest); //!< Sets the quest the hint belongs to. 78 89 /** 90 @brief Returns the Quest the QuestHint is attached to. 91 @return Returns a pointer to the Quest the QuestHint is attached to. 92 */ 79 93 inline Quest* getQuest(void) 80 94 { return this->quest_; } 81 95 82 96 private: 83 84 void initialize(void); 85 86 Quest* quest_; //!< The quest the hint belongs to. 87 std::map<Player*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 97 Quest* quest_; //!< The Quest the QuestHint belongs to. 98 std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key. 88 99 89 100 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestItem.cc (added) merged: 2146,2159,2251 /code/trunk/src/orxonox/objects/quest/QuestItem.cc merged: 1925-2089
r2105 r2530 26 26 * 27 27 */ 28 29 /** 30 @file QuestItem.cc 31 @brief 32 Implementation of the QuestItem class. 33 */ 28 34 29 35 #include "OrxonoxStableHeaders.h" … … 36 42 namespace orxonox { 37 43 44 /** 45 @brief 46 Constructor. Registers and initializes the object. 47 */ 38 48 QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) 39 49 { 40 50 RegisterObject(QuestItem); 41 51 42 this->i nitialize();52 this->id_ = ""; 43 53 } 44 54 … … 52 62 } 53 63 64 /** 65 @brief 66 Method for creating a QuestItem object through XML. 67 */ 54 68 void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 69 { … … 57 71 58 72 XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode); 59 //Doesn't getDescription have to be of type getDescription(unsigned int) ?60 //XMLPortObjectTemplate(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode, unsigned int);61 73 XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode); 62 63 74 } 64 65 75 66 76 /** 67 77 @brief 68 Initializes the object. 69 Should be called first in every constructor of this class. 78 Sets the id of the QuestItem. 79 The id must be of GUID form. See 'http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure' for more information. 80 @param id 81 The id to be set. 70 82 */ 71 void QuestItem::initialize(void)72 {73 RegisterObject(QuestItem);74 75 this->id_ = "";76 }77 78 83 void QuestItem::setId(const std::string & id) 79 84 { 80 if(!isId(id)) 85 if(!isId(id)) //!< Checks whether the id is a valid id. 81 86 { 82 87 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; 83 88 return; 84 89 } 90 85 91 this->id_ = id; 86 92 } 87 88 //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem.89 //{90 // if(index != 0)91 // return NULL;92 // return this->description_;93 //}94 93 95 94 /** - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestItem.h (added) merged: 2146,2159,2191,2251 /code/trunk/src/orxonox/objects/quest/QuestItem.h merged: 1925-2089
r2096 r2530 26 26 * 27 27 */ 28 29 /** 30 @file QuestItem.h 31 @brief 32 Definition of the QuestItem class. 33 34 The QuestItem is the parent class of Quest and QuestHint. 35 */ 36 28 37 29 38 #ifndef _QuestItem_H__ … … 42 51 /** 43 52 @brief 44 Functions as a base class for Quest classes such as Quest or QuestHint.53 Functions as a base class for quest classes such as Quest or QuestHint. 45 54 Has a unique identifier and a description. 46 55 @author … … 54 63 virtual ~QuestItem(); 55 64 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 65 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestItem object through XML. 57 66 58 inline const std::string & getId(void) const //!< Returns the id of this quest. 67 /** 68 @brief Returns the id of this QuestItem. 69 @return Returns the id of the QuestItem. 70 */ 71 inline const std::string & getId(void) const 59 72 { return this->id_; } 60 inline const QuestDescription* getDescription(void) const //!< Returns the description of the QuestItem. 73 /** 74 @brief Returns the QuestDescription of the QuestItem. 75 @return Returns a pointer to the QuestDescription object of the QuestItem. 76 */ 77 inline const QuestDescription* getDescription(void) const 61 78 { return this->description_; } 62 //const QuestDescription* getDescription(unsigned int index) const; //!< Returns the description of the QuestItem.63 79 64 80 static bool isId(const std::string & id); //!< Checks whether a given id is valid. 65 81 66 82 protected: 67 void setId(const std::string & id); 83 void setId(const std::string & id); //!< Sets the id of the QuestItem. 84 85 /** 86 @brief Sets the description of the QuestItem. 87 @param description The QuestDescription to be set. 88 */ 68 89 inline void setDescription(QuestDescription* description) 69 90 { this->description_ = description; } … … 71 92 private: 72 93 std::string id_; //!< Identifier. Should be of GUID form: http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure 73 QuestDescription* description_; //!< The description of the QuestItem. 74 75 void initialize(void); //!< Initializes the object. 94 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 76 95 77 96 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestManager.cc (added) merged: 2159,2191,2251 /code/trunk/src/orxonox/objects/quest/QuestManager.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file QuestManager.cc 31 @brief 32 Implementation of the QuestManager class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "QuestManager.h" … … 38 44 namespace orxonox { 39 45 40 std::map<std::string, Quest*> QuestManager::questMap_; 41 std::map<std::string, QuestHint*> QuestManager::hintMap_; 42 46 //! All Quests registered by their id's. 47 std::map<std::string, Quest*> QuestManager::questMap_s; 48 //! All QuestHints registered by their id's. 49 std::map<std::string, QuestHint*> QuestManager::hintMap_s; 50 51 /** 52 @brief 53 Constructor. Registers the object. 54 */ 43 55 QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator) 44 56 { … … 46 58 } 47 59 48 60 /** 61 @brief 62 Destructor. 63 */ 49 64 QuestManager::~QuestManager() 50 65 { … … 54 69 /** 55 70 @brief 56 Registers a quest with the QuestManager to make it globally accessable. 71 Registers a Quest with the QuestManager to make it globally accessable. 72 Uses it's id to make sure to be able to be identify and retrieve it later. 57 73 @param quest 58 The quest that is to be registered.74 The Quest that is to be registered. 59 75 @return 60 76 Returns true if successful, false if not. … … 62 78 bool QuestManager::registerQuest(Quest* quest) 63 79 { 64 if(quest == NULL) 80 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. 65 81 { 66 82 COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl; … … 68 84 } 69 85 70 std::pair<std::map<std::string, Quest*>::iterator,bool> re t;71 re t = questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) );72 73 if(re t.second)86 std::pair<std::map<std::string, Quest*>::iterator,bool> result; 87 result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest. 88 89 if(result.second) //!< If inserting was a success. 74 90 { 75 91 COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl; … … 86 102 @brief 87 103 Registers a QuestHint with the QuestManager to make it globally accessable. 104 Uses it's id to make sure to be able to be identify and retrieve it later. 88 105 @param hint 89 106 The QuestHint to be registered. … … 93 110 bool QuestManager::registerHint(QuestHint* hint) 94 111 { 95 if(hint == NULL) 112 if(hint == NULL) //!< Still not liking NULL-pointers. 96 113 { 97 114 COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl; … … 99 116 } 100 117 101 std::pair<std::map<std::string, QuestHint*>::iterator,bool> re t;102 re t = hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) );103 104 if(re t.second)118 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; 119 result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint. 120 121 if(result.second) //!< If inserting was a success. 105 122 { 106 123 COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl; … … 116 133 /** 117 134 @brief 118 Finds a quest with the given id.135 Finds a Quest with the given id. 119 136 @param questId 120 The id of the quest sought for.121 @return 122 Returns a reference to the quest with the input id.123 Returns NULL if there is no quest with the given questId.137 The id of the Quest sought for. 138 @return 139 Returns a pointer to the Quest with the input id. 140 Returns NULL if there is no Quest with the given questId. 124 141 @throws 125 142 Throws an exception if the given questId is invalid. … … 127 144 Quest* QuestManager::findQuest(const std::string & questId) 128 145 { 129 if(!QuestItem::isId(questId)) 146 if(!QuestItem::isId(questId)) //!< Check vor validity of the given id. 130 147 { 131 148 ThrowException(Argument, "Invalid questId."); … … 133 150 134 151 Quest* quest; 135 std::map<std::string, Quest*>::iterator it = questMap_ .find(questId);136 if (it != questMap_ .end())152 std::map<std::string, Quest*>::iterator it = questMap_s.find(questId); 153 if (it != questMap_s.end()) //!< If the Quest is registered. 137 154 { 138 155 quest = it->second; … … 150 167 /** 151 168 @brief 152 Finds a hint with the given id.169 Finds a QuestHint with the given id. 153 170 @param hintId 154 The id of the hint sought for.155 @return 156 Returns a reference to the hint with the input id.157 Returns NULL if there is no hint with the given hintId.171 The id of the QuestHint sought for. 172 @return 173 Returns a pointer to the QuestHint with the input id. 174 Returns NULL if there is no QuestHint with the given hintId. 158 175 @throws 159 176 Throws an exception if the given hintId is invalid. … … 161 178 QuestHint* QuestManager::findHint(const std::string & hintId) 162 179 { 163 if(!QuestItem::isId(hintId)) 180 if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id. 164 181 { 165 182 ThrowException(Argument, "Invalid hintId."); … … 167 184 168 185 QuestHint* hint; 169 std::map<std::string, QuestHint*>::iterator it = hintMap_ .find(hintId);170 if (it != hintMap_ .end())186 std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId); 187 if (it != hintMap_s.end()) //!< If the QuestHint is registered. 171 188 { 172 189 hint = it->second; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/QuestManager.h (added) merged: 2159,2191,2251 /code/trunk/src/orxonox/objects/quest/QuestManager.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file QuestManager.h 31 @brief 32 Definition of the QuestManager class. 33 */ 34 29 35 #ifndef _QuestManager_H__ 30 36 #define _QuestManager_H__ … … 41 47 /** 42 48 @brief 43 Manages quests, by making them globally accessable.44 Quests (and Hints) are registered in the QuestManager trough their id, and can be accessed in the same way.49 Is a static class and manages Quests, by registering every Quest/QuestHint (through registerX()) and making them globally accessable (through findX()). 50 Quests (and QuestHints) are registered in the QuestManager with their id, and can be accessed in the same way. 45 51 @author 46 52 Damian 'Mozork' Frick … … 53 59 virtual ~QuestManager(); 54 60 55 static bool registerQuest(Quest* quest); //!< Registers a quest in the QuestManager.61 static bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager. 56 62 static bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 57 63 58 static Quest* findQuest(const std::string & questId); //!< Returns the quest with the input id.64 static Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id. 59 65 static QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id. 60 66 61 67 private: 62 static std::map<std::string, Quest*> questMap_ ; //!< All quests registered by their id's.63 static std::map<std::string, QuestHint*> hintMap_ ; //!< All hints registered by their id's.68 static std::map<std::string, Quest*> questMap_s; //!< All Quests registered by their id's. 69 static std::map<std::string, QuestHint*> hintMap_s; //!< All QuestHints registered by their id's. 64 70 65 71 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/Rewardable.cc (added) merged: 2159,2251 /code/trunk/src/orxonox/objects/quest/Rewardable.cc merged: 1925-2089
r2105 r2530 27 27 */ 28 28 29 /** 30 @file Rewardable.cc 31 @brief 32 Implementation of the Rewardable class. 33 */ 34 29 35 #include "OrxonoxStableHeaders.h" 30 36 #include "Rewardable.h" … … 34 40 namespace orxonox { 35 41 36 42 /** 43 @brief 44 Constructor. Registers the object. 45 */ 37 46 Rewardable::Rewardable(BaseObject* creator) : BaseObject(creator) 38 47 { … … 40 49 } 41 50 42 51 /** 52 @brief 53 Destructor, 54 */ 43 55 Rewardable::~Rewardable() 44 56 { - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/quest/Rewardable.h (added) merged: 2146,2159,2205,2251 /code/trunk/src/orxonox/objects/quest/Rewardable.h merged: 1925-2089
r2096 r2530 27 27 */ 28 28 29 /** 30 @file Rewardable.h 31 @brief 32 Definition of the Rewardable class. 33 */ 34 29 35 #ifndef _Rewardable_H__ 30 36 #define _Rewardable_H__ … … 36 42 namespace orxonox { 37 43 38 class Player; //Forward declaration, remove when fully integrated in objecthirarchy.39 40 44 /** 41 45 @brief 42 Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward to a player through QuestEffects. 46 Rewardable is an Interface, that can be implemented by any object to enable it to be given as reward to a player through QuestEffects. (With the AddReward effect.) 47 48 It just needs to inherit form Rewardable, and implement the reward() method. 43 49 @author 44 50 Damian 'Mozork' Frick … … 51 57 virtual ~Rewardable(); 52 58 53 virtual bool reward(Player* player) = 0; //!<Method to transcribe a rewardable object to the player. 59 /** 60 @brief 61 Method to transcribe a rewardable object to the player. 62 Must be implemented by every class inheriting from Rewardable. 63 @param player 64 A pointer to the ControllableEntity, do whatever you want with it. 65 @return 66 Return true if successful. 67 */ 68 virtual bool reward(PlayerInfo* player) = 0; //!< 54 69 55 70 }; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/ParticleSpawner.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/ParticleSpawner.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2479 r2530 106 106 void Pawn::tick(float dt) 107 107 { 108 this->health_ -= dt * rnd() * 150; 109 108 110 SUPER(Pawn, tick, dt); 109 111 -
code/branches/bugger/src/orxonox/objects/worldentities/triggers/CMakeLists.txt
r2131 r2530 3 3 DistanceTrigger.cc 4 4 EventTrigger.cc 5 PlayerTrigger.cc 5 6 ) 6 7 -
code/branches/bugger/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc (added) merged: 2193,2196,2205-2206,2209,2221
r2171 r2530 35 35 #include "core/XMLPort.h" 36 36 37 #include "orxonox/objects/worldentities/ControllableEntity.h" 38 37 39 namespace orxonox 38 40 { 39 41 CreateFactory(DistanceTrigger); 40 42 41 DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)43 DistanceTrigger::DistanceTrigger(BaseObject* creator) : PlayerTrigger(creator) 42 44 { 43 45 RegisterObject(DistanceTrigger); … … 45 47 this->distance_ = 100; 46 48 this->targetMask_.exclude(Class(BaseObject)); 49 this->setForPlayer(false); //!< Normally hasn't just ControllableEntities as targets. 47 50 } 48 51 … … 83 86 { 84 87 Identifier* targetId = ClassByString(targets); 88 89 //! Checks whether the target is (or is derived from) a ControllableEntity. 90 Identifier* controllableEntityId = Class(ControllableEntity); 91 if(targetId->isA(controllableEntityId)) 92 { 93 this->setForPlayer(true); 94 } 95 85 96 if (!targetId) 86 97 { … … 117 128 Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition(); 118 129 if (distanceVec.length() < this->distance_) 130 { 131 132 //! If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity. 133 if(this->isForPlayer()) 134 { 135 ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity); 136 this->setTriggeringPlayer(player); 137 } 138 119 139 return true; 140 } 120 141 } 121 142 return false; 122 123 143 } 124 144 … … 126 146 { 127 147 if (Trigger::isTriggered(mode)) 148 { 128 149 return checkDistance(); 150 } 129 151 else 130 152 return false; - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h (added) merged: 2193,2196
r2171 r2530 30 30 #define _DistanceTrigger_H__ 31 31 32 #include " Trigger.h"32 #include "PlayerTrigger.h" 33 33 34 34 #include <set> … … 37 37 #include "core/BaseObject.h" 38 38 39 #include "orxonox/objects/worldentities/ControllableEntity.h" 40 39 41 namespace orxonox 40 42 { 41 class _OrxonoxExport DistanceTrigger : public Trigger43 class _OrxonoxExport DistanceTrigger : public PlayerTrigger 42 44 { 43 45 public: … … 66 68 std::set<Ogre::Node*> targetSet_; 67 69 float distance_; 70 68 71 }; 69 72 } - Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/worldentities/triggers/PlayerTrigger.cc
- Property svn:eol-style set to native
-
code/branches/bugger/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
- Property svn:eol-style set to native
-
code/branches/bugger/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/orxonox/objects/worldentities/triggers/Trigger.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/tolua/tolua-5.1.pkg
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/util
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/util/CMakeLists.txt
r2087 r2530 15 15 ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES}) 16 16 17 IF(TESTING_ENABLED)18 ADD_SUBDIRECTORY(testing)19 ENDIF(TESTING_ENABLED)20 21 17 TARGET_LINK_LIBRARIES(util 22 18 ${OGRE_LIBRARIES} -
code/branches/bugger/src/util/Exception.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/util/Exception.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/util/SignalHandler.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/bugger/src/util/SignalHandler.h
- Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset
for help on using the changeset viewer.