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 "Quest.h" |
---|
32 | |
---|
33 | namespace orxonox { |
---|
34 | |
---|
35 | Quest::Quest() : QuestItem() |
---|
36 | { |
---|
37 | |
---|
38 | } |
---|
39 | |
---|
40 | /** |
---|
41 | @brief |
---|
42 | Constructor. Creates a quest with a given id, title and description. |
---|
43 | @param id |
---|
44 | The unique identifier of the quest. |
---|
45 | @param title |
---|
46 | The title of the quest. |
---|
47 | @param description |
---|
48 | The description of the quest. |
---|
49 | */ |
---|
50 | Quest::Quest(std::string id, std::string title, std::string description) : QuestItem(id, title, description) |
---|
51 | { |
---|
52 | initialize(); |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | @brief |
---|
57 | Destructor. |
---|
58 | */ |
---|
59 | Quest::~Quest() |
---|
60 | { |
---|
61 | //TDO: Unload lists... |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | @brief |
---|
66 | Initializes the object. Needs to be called first in every constructor of this class. |
---|
67 | */ |
---|
68 | void Quest::initialize(void) |
---|
69 | { |
---|
70 | RegisterObject(Quest); |
---|
71 | |
---|
72 | this->parentQuest_ = 0; |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | @brief |
---|
77 | Sets the parent quest of the quest. |
---|
78 | @param quest |
---|
79 | A pointer to the quest to be set as parent quest. |
---|
80 | */ |
---|
81 | bool Quest::setParentQuest(Quest* quest) |
---|
82 | { |
---|
83 | this->parentQuest_ = quest; |
---|
84 | return true; |
---|
85 | } |
---|
86 | |
---|
87 | /** |
---|
88 | @brief |
---|
89 | Adds a sub quest to the quest. |
---|
90 | @param quest |
---|
91 | A pointer to the quest to be set as sub quest. |
---|
92 | */ |
---|
93 | bool Quest::addSubQuest(Quest* quest) |
---|
94 | { |
---|
95 | this->subQuests_.push_back(quest); |
---|
96 | return true; |
---|
97 | } |
---|
98 | |
---|
99 | /** |
---|
100 | @brief |
---|
101 | Adds a Hint to the list of hints |
---|
102 | @param hint |
---|
103 | The hint that should be added to the list of hints. |
---|
104 | */ |
---|
105 | void Quest::addHint(QuestHint* hint) |
---|
106 | { |
---|
107 | if ( hint != NULL ) |
---|
108 | { |
---|
109 | this->hints_.push_back(hint); |
---|
110 | hint->setQuest(this); |
---|
111 | } |
---|
112 | else |
---|
113 | { |
---|
114 | COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | @brief |
---|
120 | Starts the quest. |
---|
121 | @param player |
---|
122 | The player. |
---|
123 | @return |
---|
124 | Returns true if the quest could be started, false if not. |
---|
125 | */ |
---|
126 | bool Quest::start(Player* player) |
---|
127 | { |
---|
128 | if(this->isStartable(player)) |
---|
129 | { |
---|
130 | this->setStatus(player, questStatus::active); |
---|
131 | return true; |
---|
132 | } |
---|
133 | COUT(2) << "A non-startable quest was trying to be started." << std::endl; |
---|
134 | return false; |
---|
135 | } |
---|
136 | |
---|
137 | /** |
---|
138 | @brief |
---|
139 | Fails the quest. |
---|
140 | @param player |
---|
141 | The player. |
---|
142 | @return |
---|
143 | Returns true if the quest could be failed, false if not. |
---|
144 | */ |
---|
145 | bool Quest::fail(Player* player) |
---|
146 | { |
---|
147 | if(this->isFailable(player)) |
---|
148 | { |
---|
149 | this->setStatus(player, questStatus::failed); |
---|
150 | QuestEffect::invokeEffects(player, this->failEffects_); |
---|
151 | return true; |
---|
152 | } |
---|
153 | COUT(2) << "A non-failable quest was trying to be failed." << std::endl; |
---|
154 | return false; |
---|
155 | } |
---|
156 | |
---|
157 | /** |
---|
158 | @brief |
---|
159 | Completes the quest. |
---|
160 | @param player |
---|
161 | The player. |
---|
162 | @return |
---|
163 | Returns true if the quest could be completed, false if not. |
---|
164 | */ |
---|
165 | bool Quest::complete(Player* player) |
---|
166 | { |
---|
167 | if(this->isCompletable(player)) |
---|
168 | { |
---|
169 | this->setStatus(player, questStatus::completed); |
---|
170 | QuestEffect::invokeEffects(player, this->completeEffects_); |
---|
171 | return true; |
---|
172 | } |
---|
173 | COUT(2) << "A non-completable quest was trying to be completed." << std::endl; |
---|
174 | return false; |
---|
175 | } |
---|
176 | |
---|
177 | } |
---|