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 "Quest.h" |
---|
31 | |
---|
32 | namespace orxonox { |
---|
33 | |
---|
34 | CreateFactory(Quest); |
---|
35 | |
---|
36 | /** |
---|
37 | @brief |
---|
38 | Constructor. Creates a quest with a given id, title and description. |
---|
39 | @param id |
---|
40 | The unique identifier of the quest. |
---|
41 | @param title |
---|
42 | The title of the quest. |
---|
43 | @param description |
---|
44 | The description of the quest. |
---|
45 | */ |
---|
46 | Quest::Quest(std::string id, std::string title = "", std::string description = "") : QuestItem(id, title, description) |
---|
47 | { |
---|
48 | initialize(); |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | @brief |
---|
53 | Destructor. |
---|
54 | */ |
---|
55 | Quest::~Quest() |
---|
56 | { |
---|
57 | //TDO: Unload lists... |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | @brief |
---|
62 | Initializes the object. Needs to be called first in every constructor of this class. |
---|
63 | */ |
---|
64 | void Quest::initialize(void) |
---|
65 | { |
---|
66 | RegisterObject(Quest); |
---|
67 | |
---|
68 | this->parentQuest_ = 0; |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | @brief |
---|
73 | Adds a Hint to the list of hints |
---|
74 | @param hint |
---|
75 | The hint that should be added to the list of hints. |
---|
76 | */ |
---|
77 | void Quest::addHint(QuestHint & hint) |
---|
78 | { |
---|
79 | if ( hint != NULL ) |
---|
80 | { |
---|
81 | this->hints_.push_back(hint); |
---|
82 | hint.setQuest(this); |
---|
83 | } |
---|
84 | else |
---|
85 | { |
---|
86 | COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | @brief |
---|
92 | Starts the quest. |
---|
93 | @param player |
---|
94 | The player. |
---|
95 | */ |
---|
96 | void Quest::start(const Player & player) |
---|
97 | { |
---|
98 | if(this->isInactive(player)) |
---|
99 | { |
---|
100 | this->setStatus(player, questStatus::active); |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | COUT(2) << "A non-inactive quest was trying to be started." << std::endl; |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | /** |
---|
109 | @brief |
---|
110 | Fails the quest. |
---|
111 | @param player |
---|
112 | The player. |
---|
113 | */ |
---|
114 | void Quest::fail(Player & player) |
---|
115 | { |
---|
116 | if(this->isActive(player)) |
---|
117 | { |
---|
118 | this->setStatus(player, questStatus::failed); |
---|
119 | QuestEffect::invokeEffects(player, this->failEffects_); |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | COUT(2) << "A non-pending quest was trying to be failed." << std::endl; |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | /** |
---|
128 | @brief |
---|
129 | Completes the quest. |
---|
130 | @param player |
---|
131 | The player. |
---|
132 | */ |
---|
133 | void Quest::complete(Player & player) |
---|
134 | { |
---|
135 | if(this->isActive(player)) |
---|
136 | { |
---|
137 | this->setStatus(player, questStatus::completed); |
---|
138 | QuestEffect::invokeEffects(player, this->completeEffects_); |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | COUT(2) << "A non-pending quest was trying to be completed." << std::endl; |
---|
143 | } |
---|
144 | } |
---|
145 | |
---|
146 | } |
---|