Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/Quest.h @ 3251

Last change on this file since 3251 was 3196, checked in by rgrieder, 15 years ago

Merged pch branch back to trunk.

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