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 | |
---|
31 | #include "QuestManager.h" |
---|
32 | |
---|
33 | namespace orxonox { |
---|
34 | |
---|
35 | std::map<std::string, Quest*> QuestManager::questMap_; |
---|
36 | std::map<std::string, QuestHint*> QuestManager::hintMap_; |
---|
37 | |
---|
38 | QuestManager::QuestManager() : BaseObject() |
---|
39 | { |
---|
40 | RegisterObject(QuestManager); |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | QuestManager::~QuestManager() |
---|
45 | { |
---|
46 | |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | @brief |
---|
51 | Registers a quest with the QuestManager to make it globally accessable. |
---|
52 | @param quest |
---|
53 | The quest that is to be registered. |
---|
54 | @return |
---|
55 | Returns true if successful, false if not. |
---|
56 | */ |
---|
57 | bool QuestManager::registerQuest(Quest* quest) |
---|
58 | { |
---|
59 | questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); |
---|
60 | return true; |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | @brief |
---|
65 | Registers a QuestHint with the QuestManager to make it globally accessable. |
---|
66 | @param hint |
---|
67 | The QuestHint to be registered. |
---|
68 | @return |
---|
69 | Returns true if successful, false if not. |
---|
70 | */ |
---|
71 | bool QuestManager::registerHint(QuestHint* hint) |
---|
72 | { |
---|
73 | hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); |
---|
74 | return true; |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | @brief |
---|
79 | Finds a quest with the given id. |
---|
80 | @param questId |
---|
81 | The id of the quest sought for. |
---|
82 | @return |
---|
83 | Returns a reference to the quest with the input id. |
---|
84 | @todo |
---|
85 | Throw exceptions in case of errors. |
---|
86 | */ |
---|
87 | Quest* QuestManager::findQuest(const std::string & questId) |
---|
88 | { |
---|
89 | Quest* quest; |
---|
90 | std::map<std::string, Quest*>::iterator it = questMap_.find(questId); |
---|
91 | if (it != questMap_.end()) |
---|
92 | { |
---|
93 | quest = it->second; |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | quest = NULL; |
---|
98 | COUT(2) << "The quest with id {" << questId << "} is nowhere to be found." << std::endl; |
---|
99 | } |
---|
100 | |
---|
101 | return quest; |
---|
102 | |
---|
103 | } |
---|
104 | |
---|
105 | /** |
---|
106 | @brief |
---|
107 | Finds a hint with the given id. |
---|
108 | @param hintId |
---|
109 | The id of the hint sought for. |
---|
110 | @return |
---|
111 | Returns a reference to the hint with the input id. |
---|
112 | @todo |
---|
113 | Throw exceptopns in case of errors. |
---|
114 | */ |
---|
115 | QuestHint* QuestManager::findHint(const std::string & hintId) |
---|
116 | { |
---|
117 | QuestHint* hint; |
---|
118 | std::map<std::string, QuestHint*>::iterator it = hintMap_.find(hintId); |
---|
119 | if (it != hintMap_.end()) |
---|
120 | { |
---|
121 | hint = it->second; |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | hint = NULL; |
---|
126 | COUT(2) << "The hint with id {" << hintId << "} is nowhere to be found." << std::endl; |
---|
127 | } |
---|
128 | |
---|
129 | return hint; |
---|
130 | |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | } |
---|