[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 | */ |
---|
[2146] | 28 | |
---|
| 29 | /** |
---|
| 30 | @file Quest.h |
---|
| 31 | @brief |
---|
| 32 | Definition of the Quest class. |
---|
| 33 | |
---|
| 34 | The Quest is the parent class of LocalQuest and GlobalQuest. |
---|
| 35 | */ |
---|
| 36 | |
---|
[1992] | 37 | #ifndef _Quest_H__ |
---|
| 38 | #define _Quest_H__ |
---|
| 39 | |
---|
[2095] | 40 | #include "OrxonoxPrereqs.h" |
---|
| 41 | |
---|
[1992] | 42 | #include <list> |
---|
| 43 | #include <string> |
---|
| 44 | |
---|
[2076] | 45 | #include "core/XMLPort.h" |
---|
[1992] | 46 | #include "QuestItem.h" |
---|
| 47 | |
---|
[2146] | 48 | |
---|
[2021] | 49 | namespace questStatus |
---|
| 50 | { |
---|
| 51 | |
---|
[2146] | 52 | //!Different states of a quest. |
---|
[2021] | 53 | enum Enum |
---|
| 54 | { |
---|
| 55 | inactive, |
---|
| 56 | active, |
---|
| 57 | failed, |
---|
| 58 | completed |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | } |
---|
| 62 | |
---|
[1992] | 63 | namespace orxonox { |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | @brief |
---|
| 67 | Represents a quest in the game. |
---|
[2068] | 68 | A quest has a list of subquests and a parentquest (if it is not a rootquest). |
---|
| 69 | Each quest exists only once but it has a different status (inactive, active, failed or completed) for each player. |
---|
[2146] | 70 | A quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the quest. |
---|
| 71 | A quest has a list of QuestEffects that are invoked when the quest is failed and also a list of effects that are invoked, when the quest is completed. |
---|
| 72 | |
---|
| 73 | 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] | 74 | @author |
---|
| 75 | Damian 'Mozork' Frick |
---|
| 76 | */ |
---|
[2095] | 77 | class _OrxonoxExport Quest : public QuestItem |
---|
[1992] | 78 | { |
---|
[2093] | 79 | public: |
---|
[2092] | 80 | Quest(BaseObject* creator); |
---|
[2093] | 81 | virtual ~Quest(); |
---|
[2092] | 82 | |
---|
[2146] | 83 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Quest object through XML. |
---|
[2092] | 84 | |
---|
[1992] | 85 | inline Quest* getParentQuest(void) const //!< Returns the parent quest of the quest. |
---|
| 86 | { return this->parentQuest_; } |
---|
[2093] | 87 | inline const std::list<Quest*> & getSubQuestList(void) const //!< Returns the list of sub quests. |
---|
[1992] | 88 | { return this->subQuests_; } |
---|
[2159] | 89 | inline const std::list<QuestHint*> & getHintsList(void) const //!< Returns the list of all hints of this quest. |
---|
| 90 | { return this->hints_; } |
---|
[2092] | 91 | |
---|
[2146] | 92 | bool isInactive(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. |
---|
| 93 | bool isActive(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'active'. |
---|
| 94 | bool isFailed(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'failed'. |
---|
| 95 | bool isCompleted(const ControllableEntity* player) const; //!< Returns true if the quest status for the specific player is 'completed'. |
---|
[2092] | 96 | |
---|
[2146] | 97 | bool start(ControllableEntity* player); //!< Sets a quest to active. |
---|
| 98 | virtual bool fail(ControllableEntity* player) = 0; //!< Fails the quest. |
---|
| 99 | virtual bool complete(ControllableEntity* player) = 0; //!< Completes the quest. |
---|
[2092] | 100 | |
---|
[1992] | 101 | protected: |
---|
[2146] | 102 | virtual bool isStartable(const ControllableEntity* player) const = 0; //!< Checks whether the quest can be started. |
---|
| 103 | virtual bool isFailable(const ControllableEntity* player) const = 0; //!< Checks whether the quest can be failed. |
---|
| 104 | virtual bool isCompletable(const ControllableEntity* player) const = 0; //!< Checks whether the quest can be completed. |
---|
[2092] | 105 | |
---|
[2146] | 106 | const Quest* getParentQuest(void); //!< Returns the parent quest of the quest. |
---|
[2159] | 107 | const Quest* getSubQuest(unsigned int index) const; //!<Returns the sub quest of the given index. |
---|
| 108 | const QuestHint* getHint(unsigned int index) const; //!< Returns the hint of the given index. |
---|
| 109 | const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the failEffect of the given index. |
---|
| 110 | const QuestEffect* getCompleteEffect(unsigned int index) const; //!< Returns the completeEffect of the given index. |
---|
| 111 | inline std::list<QuestEffect*> & getFailEffectList(void) //!< Returns the list of failEffects. |
---|
| 112 | { return this->failEffects_; } |
---|
| 113 | inline std::list<QuestEffect*> & getCompleteEffectList(void) //!< Returns the list of completeEffects. |
---|
| 114 | { return this->completeEffects_; } |
---|
[2092] | 115 | |
---|
[2146] | 116 | virtual questStatus::Enum getStatus(const ControllableEntity* player) const = 0; //!< Returns the status of the quest for a specific player. |
---|
| 117 | virtual bool setStatus(ControllableEntity* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. |
---|
[2159] | 118 | |
---|
| 119 | private: |
---|
[1992] | 120 | Quest* parentQuest_; //!< Pointer to the parent quest. |
---|
[2021] | 121 | std::list<Quest*> subQuests_; //!< List of all the sub quests. |
---|
[2092] | 122 | |
---|
[2021] | 123 | std::list<QuestHint*> hints_; //!< A list of all the hints tied to this quest. |
---|
[2092] | 124 | |
---|
[2021] | 125 | std::list<QuestEffect*> failEffects_; //!< A list of all effects to be invoked, when the quest has been failed. |
---|
| 126 | std::list<QuestEffect*> completeEffects_; //!< A list of effects to be invoked, when the quest has been completed. |
---|
[2159] | 127 | |
---|
| 128 | bool setParentQuest(Quest* quest); //!< Sets the parent quest of the quest. |
---|
| 129 | bool addSubQuest(Quest* quest); //!< Adds a sub quest to the quest. |
---|
| 130 | bool addHint(QuestHint* hint); //!< Add a hint to the list of hints. |
---|
| 131 | bool addFailEffect(QuestEffect* effect); //!< Adds an effect to the list of failEffects. |
---|
| 132 | bool addCompleteEffect(QuestEffect* effect); //!< Adds an effect to the list of completeEffects. |
---|
[1992] | 133 | |
---|
| 134 | }; |
---|
| 135 | |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | #endif /* _Quest_H__ */ |
---|