Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ois_update/src/modules/questsystem/Quest.h @ 7571

Last change on this file since 7571 was 7456, checked in by dafrick, 14 years ago

Reviewing documentation fo Questsystem, moving documentation fully into doxygen.
Added some files to modules they belong to.

  • Property svn:eol-style set to native
File size: 7.5 KB
Line 
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/**
30    @file Quest.h
31    @brief Definition of the Quest class.
32        The Quest class is the parent class of @ref orxonox::LocalQuest "LocalQuest" and @ref orxonox::GlobalQuest "GlobalQuest".
33    @ingroup Questsystem
34*/
35
36#ifndef _Quest_H__
37#define _Quest_H__
38
39#include "questsystem/QuestsystemPrereqs.h"
40
41#include <list>
42#include "QuestItem.h"
43
44namespace orxonox // tolua_export
45{ // tolua_export
46    namespace QuestStatus
47    {
48        //! Different states of a @ref orxonox::Quest "Quest".
49        enum Value
50        {
51            Inactive,
52            Active,
53            Failed,
54            Completed
55        };
56    }
57
58    /**
59    @brief
60        Represents a Quest in the game. A Quest is a task that the player can (or has to) fulfill upon which he will (possibly) receive some kind of reward.
61
62        A Quest can have a list of sub-quests and has a parent-quest (if it is not a root-quest).
63        Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player.
64        A Quest can have several hints (QuestHint) that can be unlocked through @ref orxonox::QuestEffect "QuestEffects" and then display aid in solving the Quest.
65        A Quest can have a list of @ref orxonox::QuestEffect "QuestEffects" that are invoked when the quest is failed and also a list of @ref orxonox::QuestEffect "QuestEffects" that are invoked, when the Quest is completed.
66
67        Quest itself should not be instantiated, if you want to create a quest either use LocalQuest or GlobalQuest, whichever suits you needs better.
68    @author
69        Damian 'Mozork' Frick
70    */
71    class _QuestsystemExport Quest // tolua_export
72        : public QuestItem
73    { // tolua_export
74        public:
75            Quest(BaseObject* creator);
76            virtual ~Quest();
77
78            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Quest object through XML.
79
80            /**
81            @brief Returns the parent-quest of the Quest.
82            @return Returns a pointer to the parent-quest of the Quest.
83            */
84            inline Quest* getParentQuest(void) const
85                { return this->parentQuest_; }
86
87            /**
88            @brief Returns the list of sub-quests.
89            @return Returns a reference to the list of sub-quests of the quest.
90            */
91            inline const std::list<Quest*> & getSubQuestList(void) const
92                { return this->subQuests_; }
93
94            /**
95            @brief Returns the list of all QuestHints of this Quest.
96            @return Returns a reference to the list of QuestHints of the Quest.
97            */
98            inline const std::list<QuestHint*> & getHintsList(void) const
99                { return this->hints_; }
100
101            bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
102            bool isActive(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'active'.
103            bool isFailed(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'failed'.
104            bool isCompleted(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'completed'.
105
106            bool start(PlayerInfo* player); //!< Sets a Quest to active.
107            virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
108            virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
109
110            bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest.
111
112        protected:
113            virtual bool isStartable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be started.
114            virtual bool isFailable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be failed.
115            virtual bool isCompletable(const PlayerInfo* player) const = 0; //!< Checks whether the Quest can be completed.
116
117            const Quest* getSubQuest(unsigned int index) const; //!<Returns the sub-quest at the given index.
118            const QuestHint* getHint(unsigned int index) const; //!< Returns the QuestHint at the given index.
119            const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the fail QuestEffect at the given index.
120            const QuestEffect* getCompleteEffect(unsigned int index) const; //!< Returns the complete QuestEffect at the given index.
121
122            /**
123            @brief Returns the list of fail QuestEffects.
124            @return Returns a reference to the list of fail QuestEffects.
125            */
126            inline std::list<QuestEffect*> & getFailEffectList(void)
127                { return this->failEffects_; }
128
129            /**
130            @brief Returns the list of complete QuestEffects.
131            @return Returns a reference to the list of complete QuestEffects.
132            */
133            inline std::list<QuestEffect*> & getCompleteEffectList(void)
134                { return this->completeEffects_; }
135
136            virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
137            virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
138
139        private:
140            Quest* parentQuest_; //!< Pointer to the parent-quest.
141            std::list<Quest*> subQuests_; //!< List of all the sub-quests.
142
143            std::list<QuestHint*> hints_; //!< A list of all the QuestHints tied to this Quest.
144
145            std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed.
146            std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed.
147
148            std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest.
149
150            bool setParentQuest(Quest* quest); //!< Sets the parent-quest of the Quest.
151            bool addSubQuest(Quest* quest); //!< Adds a sub-quest to the Quest.
152            bool addHint(QuestHint* hint); //!< Add a QuestHint to the list of QuestHints.
153            bool addFailEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of fail QuestEffects.
154            bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects.
155
156    }; // tolua_export
157
158} // tolua_export
159
160#endif /* _Quest_H__ */
Note: See TracBrowser for help on using the repository browser.