#include <src/orxonox/objects/quest/GlobalQuest.h>
Public Member Functions | |
virtual bool | complete (PlayerInfo *player) |
Completes the Quest. | |
virtual bool | fail (PlayerInfo *player) |
Fails the Quest. | |
GlobalQuest (BaseObject *creator) | |
Constructor. Registers the object. | |
virtual void | XMLPort (Element &xmlelement, XMLPort::Mode mode) |
Method for creating a GlobalQuest object through XML. | |
virtual | ~GlobalQuest () |
Destructor. | |
Protected Member Functions | |
virtual QuestStatus::Value | getStatus (const PlayerInfo *player) const |
Returns the status of the Quest for a specific player. | |
virtual bool | isCompletable (const PlayerInfo *player) const |
Checks whether the Quest can be completed. | |
virtual bool | isFailable (const PlayerInfo *player) const |
Checks whether the Quest can be failed. | |
virtual bool | isStartable (const PlayerInfo *player) const |
Checks whether the Quest can be started. | |
virtual bool | setStatus (PlayerInfo *player, const QuestStatus::Value &status) |
Sets the status for a specific player. | |
Private Member Functions | |
bool | addRewardEffect (QuestEffect *effect) |
Adds a reward QuestEffect to the list of reward QuestEffects. | |
const QuestEffect * | getRewardEffects (unsigned int index) const |
Returns the reward QuestEffect at the given index. | |
Private Attributes | |
std::set< PlayerInfo * > | players_ |
The set of players which possess this Quest. | |
std::list< QuestEffect * > | rewards_ |
Reward QuestEffects only invoked on the player completing the Quest. | |
QuestStatus::Value | status_ |
The status of this Quest. |
Creating a GlobalQuest through XML goes as follows:
<GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information <QuestDescription title="Title" description="Description."> //The description of the quest. <subquests> <Quest id="questId1"> //A list of n subquest, be aware, each of the <Quest> tags must have a description and so on and so forth as well. ... <Quest id="questIdn"> </subquests> <hints> <QuestHint id="hintId1"> //A list of n QuestHints, see QuestHint for the full XML representation of those. ... <QuestHint id="hintIdn"> </hints> <fail-effects> <QuestEffect> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation. ... <QuestEffect> </fail-effects> <complete-effects> <QuestEffect> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is completed, see QuestEffect for the full XML representation. ... <QuestEffect> </complete-effects> <reward-effects> <QuestEffect> //A list of QuestEffects, invoked on the player completing this quest. See QuestEffect for the full XML representation. ... <QuestEffect> </reward-effects> </GlobalQuest>
orxonox::GlobalQuest::GlobalQuest | ( | BaseObject * | creator | ) |
orxonox::GlobalQuest::~GlobalQuest | ( | ) | [virtual] |
Destructor.
bool orxonox::GlobalQuest::addRewardEffect | ( | QuestEffect * | effect | ) | [private] |
Adds a reward QuestEffect to the list of reward QuestEffects.
effect | The QuestEffect to be added. |
< We don't want NULL-Pointers!
< Add the QuestEffect to the list.
References COUT, orxonox::QuestItem::getId(), and rewards_.
Referenced by XMLPort().
bool orxonox::GlobalQuest::complete | ( | PlayerInfo * | player | ) | [virtual] |
Completes the Quest.
Completes the Quest for all players. Invokes the complete QuestEffects on all the players possessing this Quest. Invokes the reward QuestEffects on the player completing the Quest.
player | The player completing it. |
< Check whether the Quest can be completed.
Iterate through all players possessing the Quest.
< Invoke reward QuestEffects on the player completing the Quest.
Reimplemented from orxonox::Quest.
References orxonox::Quest::complete(), COUT, orxonox::Quest::getCompleteEffectList(), orxonox::QuestEffect::invokeEffects(), isCompletable(), players_, and rewards_.
bool orxonox::GlobalQuest::fail | ( | PlayerInfo * | player | ) | [virtual] |
Fails the Quest.
Fails the Quest for all players. Invokes the fail QuestEffects on all the players possessing this Quest.
player | The player failing it. |
< Check whether the Quest can be failed.
Iterate through all players possessing this Quest.
Reimplemented from orxonox::Quest.
References COUT, orxonox::Quest::fail(), orxonox::Quest::getFailEffectList(), orxonox::QuestEffect::invokeEffects(), isFailable(), and players_.
const QuestEffect * orxonox::GlobalQuest::getRewardEffects | ( | unsigned int | index | ) | const [private] |
Returns the reward QuestEffect at the given index.
index | The index. |
References rewards_.
Referenced by XMLPort().
QuestStatus::Value orxonox::GlobalQuest::getStatus | ( | const PlayerInfo * | player | ) | const [protected, virtual] |
Returns the status of the Quest for a specific player.
player | The player. |
Throws | an Exception if player is NULL. |
< We don't want NULL-Pointers!
Find the player.
< If the player was found.
Implements orxonox::Quest.
References orxonox::QuestStatus::Inactive, players_, status_, and ThrowException.
bool orxonox::GlobalQuest::isCompletable | ( | const PlayerInfo * | player | ) | const [protected, virtual] |
Checks whether the Quest can be completed.
player | The player for whom is to be checked. |
Throws | an Exception if isActive() throws one. |
Implements orxonox::Quest.
References orxonox::BaseObject::isActive().
Referenced by complete().
bool orxonox::GlobalQuest::isFailable | ( | const PlayerInfo * | player | ) | const [protected, virtual] |
Checks whether the Quest can be failed.
player | The player for whom is to be checked. |
Throws | an Exception if isActive() throws one. |
Implements orxonox::Quest.
References orxonox::BaseObject::isActive().
Referenced by fail().
bool orxonox::GlobalQuest::isStartable | ( | const PlayerInfo * | player | ) | const [protected, virtual] |
Checks whether the Quest can be started.
player | The player for whom is to be checked. |
Throws | an exception if either isInactive() of isActive() throws one. |
Implements orxonox::Quest.
References orxonox::QuestStatus::Completed, orxonox::QuestStatus::Failed, orxonox::Quest::getParentQuest(), orxonox::BaseObject::isActive(), orxonox::Quest::isInactive(), and status_.
bool orxonox::GlobalQuest::setStatus | ( | PlayerInfo * | player, | |
const QuestStatus::Value & | status | |||
) | [protected, virtual] |
Sets the status for a specific player.
Sets the status for a specific player. But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing.
player | The player. | |
status | The status to be set. |
< We don't want NULL-Pointers!
Find the player.
< Player is not yet in the list.
< Add the player to the set.
< Set the status, which is global, remember...?
Implements orxonox::Quest.
void orxonox::GlobalQuest::XMLPort | ( | Element & | xmlelement, | |
XMLPort::Mode | mode | |||
) | [virtual] |
Method for creating a GlobalQuest object through XML.
Reimplemented from orxonox::Quest.
References addRewardEffect(), COUT, orxonox::QuestItem::getId(), getRewardEffects(), SUPER, and XMLPortObject.
std::set<PlayerInfo*> orxonox::GlobalQuest::players_ [private] |
The set of players which possess this Quest.
Referenced by complete(), fail(), getStatus(), and setStatus().
std::list<QuestEffect*> orxonox::GlobalQuest::rewards_ [private] |
Reward QuestEffects only invoked on the player completing the Quest.
Referenced by addRewardEffect(), complete(), and getRewardEffects().