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 | #ifndef _Quest_H__ |
---|
30 | #define _Quest_H__ |
---|
31 | |
---|
32 | #include <list> |
---|
33 | #include <string> |
---|
34 | |
---|
35 | #include "core/XMLPort.h" |
---|
36 | #include "QuestDescription.h" |
---|
37 | #include "QuestItem.h" |
---|
38 | #include "QuestHint.h" |
---|
39 | #include "QuestEffect.h" |
---|
40 | |
---|
41 | namespace questStatus |
---|
42 | { |
---|
43 | |
---|
44 | enum Enum |
---|
45 | { |
---|
46 | inactive, |
---|
47 | active, |
---|
48 | failed, |
---|
49 | completed |
---|
50 | }; |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | namespace orxonox { |
---|
55 | |
---|
56 | class Player; //Forward declaration, remove when fully integrated into the objecthirarchy. |
---|
57 | |
---|
58 | /** |
---|
59 | @brief |
---|
60 | Represents a quest in the game. |
---|
61 | A quest has a list of subquests and a parentquest (if it is not a rootquest). |
---|
62 | Each quest exists only once but it has a different status (inactive, active, failed or completed) for each player. |
---|
63 | @author |
---|
64 | Damian 'Mozork' Frick |
---|
65 | */ |
---|
66 | class Quest : public QuestItem |
---|
67 | { |
---|
68 | public: |
---|
69 | Quest(); |
---|
70 | virtual ~Quest(); |
---|
71 | |
---|
72 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
73 | |
---|
74 | inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. |
---|
75 | { return this->parentQuest_; } |
---|
76 | inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests. |
---|
77 | { return this->subQuests_; } |
---|
78 | |
---|
79 | bool isInactive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. |
---|
80 | bool isActive(const Player* player) const; //!< Returns true if the quest status for the specific player is 'active'. |
---|
81 | bool isFailed(const Player* player) const; //!< Returns true if the quest status for the specific player is 'failed'. |
---|
82 | bool isCompleted(const Player* player) const; //!< Returns true if the quest status for the specific player is 'completed'. |
---|
83 | |
---|
84 | bool start(Player* player); //!< Sets a quest to active. |
---|
85 | bool fail(Player* player); //!< Fails the quest. |
---|
86 | bool complete(Player* player); //!< Completes the quest. |
---|
87 | |
---|
88 | protected: |
---|
89 | void initialize(void); //!< Initialized the object. |
---|
90 | |
---|
91 | virtual bool isStartable(const Player* player) const = 0; //!< Checks whether the quest can be started. |
---|
92 | virtual bool isFailable(const Player* player) const = 0; //!< Checks whether the quest can be failed. |
---|
93 | virtual bool isCompletable(const Player* player) const = 0; //!< Checks whether the quest can be completed. |
---|
94 | |
---|
95 | bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest. |
---|
96 | bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest. |
---|
97 | bool addHint(QuestHint* hint); //!< Add a hint to the list of hints. |
---|
98 | bool addFailEffect(QuestEffect* effect); |
---|
99 | bool addCompleteEffect(QuestEffect* effect); |
---|
100 | |
---|
101 | const Quest* getParentQuest(void); |
---|
102 | const Quest* getSubQuests(unsigned int index) const; |
---|
103 | const QuestHint* getHints(unsigned int index) const; |
---|
104 | const QuestEffect* getFailEffects(unsigned int index) const; |
---|
105 | const QuestEffect* getCompleteEffects(unsigned int index) const; |
---|
106 | |
---|
107 | virtual questStatus::Enum getStatus(const Player* player) const = 0; //!< Returns the status of the quest for a specific player. |
---|
108 | virtual bool setStatus(Player* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. |
---|
109 | |
---|
110 | Quest* parentQuest_; //!< Pointer to the parent quest. |
---|
111 | std::list<Quest*> subQuests_; //!< List of all the sub quests. |
---|
112 | |
---|
113 | std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest. |
---|
114 | |
---|
115 | std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed. |
---|
116 | std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed. |
---|
117 | |
---|
118 | }; |
---|
119 | |
---|
120 | } |
---|
121 | |
---|
122 | #endif /* _Quest_H__ */ |
---|