[1996] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "core/CoreIncludes.h" |
---|
| 30 | #include "QuestManager.h" |
---|
| 31 | |
---|
| 32 | namespace orxonox { |
---|
| 33 | |
---|
| 34 | std::map<std::string, Quest> QuestManager::questMap_; |
---|
| 35 | std::map<std::string, QuestHint> QuestManager::hintMap_; |
---|
| 36 | |
---|
| 37 | QuestManager::QuestManager() : BaseObject() |
---|
| 38 | { |
---|
| 39 | RegisterObject(QuestManager); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | QuestManager::~QuestManager() |
---|
| 44 | { |
---|
| 45 | |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | @brief |
---|
| 50 | Registers a quest with the QuestManager to make it globally accessable. |
---|
| 51 | @param quest |
---|
| 52 | The quest that is to be registered. |
---|
| 53 | @return |
---|
| 54 | Returns true if successful, false if not. |
---|
| 55 | */ |
---|
| 56 | bool QuestManager::registerQuest(Quest & quest) |
---|
| 57 | { |
---|
| 58 | this->questMap_.insert ( pair<std::string,Quest>(quest.getId(),quest) ); |
---|
| 59 | return true; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | @brief |
---|
| 64 | Registers a QuestHint with the QuestManager to make it globally accessable. |
---|
| 65 | @param hint |
---|
| 66 | The QuestHint to be registered. |
---|
| 67 | @return |
---|
| 68 | Returns true if successful, false if not. |
---|
| 69 | */ |
---|
| 70 | bool QuestManager::registerHint(QuestHint & hint) |
---|
| 71 | { |
---|
| 72 | this->hintMap_.insert ( pair<std::string,Hint>(hint.getId(),hint) ); |
---|
| 73 | return true; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | @brief |
---|
| 78 | Finds a quest with the given id. |
---|
| 79 | @param questId |
---|
| 80 | The id of the quest sought for. |
---|
| 81 | @return |
---|
| 82 | Returns a reference to the quest with the input id. |
---|
| 83 | @todo |
---|
| 84 | Throw exceptions in case of errors. |
---|
| 85 | */ |
---|
| 86 | Quest & QuestManager::findQuest(const std::string & questId) const |
---|
| 87 | { |
---|
| 88 | Quest* quest; |
---|
| 89 | std::map<std::string, Quest>::iterator it = this->questMap_.find(questId); |
---|
| 90 | if (it != this->questMap_.end()) |
---|
| 91 | { |
---|
| 92 | quest = &(it->second); |
---|
| 93 | } |
---|
| 94 | else |
---|
| 95 | { |
---|
| 96 | quest = NULL; |
---|
| 97 | COUT(2) << "The quest with id {" << questId << "} is nowhere to be found." << std::endl; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | return *quest; |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | @brief |
---|
| 106 | Finds a hint with the given id. |
---|
| 107 | @param hintId |
---|
| 108 | The id of the hint sought for. |
---|
| 109 | @return |
---|
| 110 | Returns a reference to the hint with the input id. |
---|
| 111 | @todo |
---|
| 112 | Throw exceptopns in case of errors. |
---|
| 113 | */ |
---|
| 114 | QuestHint & QuestManager::findHint(const std::string & hintId) const |
---|
| 115 | { |
---|
| 116 | QuestHint* hint; |
---|
| 117 | std::map<std::string, QuestHint>::iterator it = this->hintMap_.find(hintId); |
---|
| 118 | if (it != this->hintMap_.end()) |
---|
| 119 | { |
---|
| 120 | hint = &(it->second); |
---|
| 121 | } |
---|
| 122 | else |
---|
| 123 | { |
---|
| 124 | hint = NULL; |
---|
| 125 | COUT(2) << "The hint with id {" << hintId << "} is nowhere to be found." << std::endl; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | return hint; |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | } |
---|