Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups/src/orxonox/objects/quest/Quest.h @ 3011

Last change on this file since 3011 was 2826, checked in by landauf, 16 years ago

merged miniprojects branch back to trunk

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