Orxonox  0.0.5 Codename: Arcturus
Quest.h
Go to the documentation of this file.
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 
36 #ifndef _Quest_H__
37 #define _Quest_H__
38 
40 
41 #include <list>
42 #include "QuestItem.h"
43 
44 namespace orxonox // tolua_export
45 { // tolua_export
46 
53  enum class QuestStatus
54  {
55  Inactive,
56  Active,
57  Failed,
58  Completed
59  };
60 
77  class _QuestsystemExport Quest // tolua_export
78  : public QuestItem
79  { // tolua_export
80  public:
81  Quest(Context* context);
82  virtual ~Quest();
83 
84  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
85 
90  inline Quest* getParentQuest(void) const
91  { return this->parentQuest_; }
92 
97  inline const std::list<Quest*> & getSubQuestList(void) const
98  { return this->subQuests_; }
99 
104  inline const std::list<QuestHint*> & getHintsList(void) const
105  { return this->hints_; }
106 
107  bool isInactive(const PlayerInfo* player) const;
108  bool isActive(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'active'.
109  bool isFailed(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'failed'.
110  bool isCompleted(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'completed'.
111 
112  bool start(PlayerInfo* player);
113  virtual bool fail(PlayerInfo* player);
114  virtual bool complete(PlayerInfo* player);
115 
116  bool addListener(QuestListener* listener);
117 
118  protected:
119  virtual bool isStartable(const PlayerInfo* player) const = 0;
120  virtual bool isFailable(const PlayerInfo* player) const = 0;
121  virtual bool isCompletable(const PlayerInfo* player) const = 0;
122 
123  const Quest* getSubQuest(unsigned int index) const;
124  const QuestHint* getHint(unsigned int index) const;
125  const QuestEffect* getFailEffect(unsigned int index) const;
126  const QuestEffect* getCompleteEffect(unsigned int index) const;
127 
132  inline std::list<QuestEffect*> & getFailEffectList(void)
133  { return this->failEffects_; }
134 
139  inline std::list<QuestEffect*> & getCompleteEffectList(void)
140  { return this->completeEffects_; }
141 
142  virtual QuestStatus getStatus(const PlayerInfo* player) const = 0;
143  virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) = 0;
144 
145  private:
147  std::list<Quest*> subQuests_;
148 
149  std::list<QuestHint*> hints_;
150 
151  std::list<QuestEffect*> failEffects_;
152  std::list<QuestEffect*> completeEffects_;
153 
154  std::list<QuestListener*> listeners_;
155 
156  bool setParentQuest(Quest* quest);
157  bool addSubQuest(Quest* quest);
158  bool addHint(QuestHint* hint);
159  bool addFailEffect(QuestEffect* effect);
160  bool addCompleteEffect(QuestEffect* effect);
161 
162  }; // tolua_export
163 
164 } // tolua_export
165 
166 #endif /* _Quest_H__ */
The Quest has been failed.
Quest * getParentQuest(void) const
Returns the parent-quest of the Quest.
Definition: Quest.h:90
std::list< QuestEffect * > & getCompleteEffectList(void)
Returns the list of complete QuestEffects.
Definition: Quest.h:139
The Quest has been completed.
const std::list< QuestHint * > & getHintsList(void) const
Returns the list of all QuestHints of this Quest.
Definition: Quest.h:104
Definition of the QuestItem class.
std::list< QuestEffect * > & getFailEffectList(void)
Returns the list of fail QuestEffects.
Definition: Quest.h:132
Represents a Quest in the game.
Definition: Quest.h:77
std::list< QuestEffect * > completeEffects_
A list of QuestEffects to be invoked, when the Quest has been completed.
Definition: Quest.h:152
std::list< Quest * > subQuests_
List of all the sub-quests.
Definition: Quest.h:147
xmlelement
Definition: Super.h:519
Handles QuestEffects for Quests.
Definition: QuestEffect.h:56
std::list< QuestEffect * > failEffects_
A list of all QuestEffects to be invoked, when the Quest has been failed.
Definition: Quest.h:151
The Quest is inactive.
std::list< QuestListener * > listeners_
A list of QuestListeners, that listen to what exactly happens with this Quest.
Definition: Quest.h:154
QuestStatus
Different states of a Quest.
Definition: Quest.h:53
Provides a way to react to the starting, completing and failing of Quests.
Definition: QuestListener.h:82
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the questsystem module ...
Definition: Context.h:45
The Quest is active.
void status(const std::string &text)
Prints output with status level.
Definition: ConsoleCommandCompilation.cc:153
Quest * parentQuest_
Pointer to the parent-quest.
Definition: Quest.h:146
Definition: PlayerInfo.h:39
std::list< QuestHint * > hints_
A list of all the QuestHints tied to this Quest.
Definition: Quest.h:149
Represents a hint in the game that gives aid towards completing a Quest.
Definition: QuestHint.h:76
const std::list< Quest * > & getSubQuestList(void) const
Returns the list of sub-quests.
Definition: Quest.h:97
Functions as a base class for quest classes such as Quest or QuestHint.
Definition: QuestItem.h:58
#define _QuestsystemExport
Definition: QuestsystemPrereqs.h:60