Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/questsystem/Quest.h @ 8601

Last change on this file since 8601 was 7552, checked in by dafrick, 14 years ago

Resolving some TODOs and doing some additional cleanup. Almost done now…

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