orxonox::GlobalQuest Class Reference

GlobalQuests are Quests, that have the same status for all players. This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it. More...

#include <src/orxonox/objects/quest/GlobalQuest.h>

Inheritance diagram for orxonox::GlobalQuest:

orxonox::Quest orxonox::QuestItem orxonox::BaseObject orxonox::OrxonoxClass

List of all members.

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 QuestEffectgetRewardEffects (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.


Detailed Description

GlobalQuests are Quests, that have the same status for all players. This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it.

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>

Author:
Damian 'Mozork' Frick

Constructor & Destructor Documentation

orxonox::GlobalQuest::GlobalQuest ( BaseObject creator  ) 

Constructor. Registers the object.

References RegisterObject.

orxonox::GlobalQuest::~GlobalQuest (  )  [virtual]

Destructor.


Member Function Documentation

bool orxonox::GlobalQuest::addRewardEffect ( QuestEffect effect  )  [private]

Adds a reward QuestEffect to the list of reward QuestEffects.

Parameters:
effect The QuestEffect to be added.
Returns:
Returns true if successful.

< 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.

Parameters:
player The player completing it.
Returns:
Returns true if the Quest could be completed, false if not.

< 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.

Parameters:
player The player failing it.
Returns:
Returns true if the Quest could be failed, false if not.

< 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.

Parameters:
index The index.
Returns:
Returns the QuestEffect at the given 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.

Parameters:
player The player.
Exceptions:
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.

Parameters:
player The player for whom is to be checked.
Returns:
Returns true if the Quest can be completed, false if not.
Exceptions:
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.

Parameters:
player The player for whom is to be checked.
Returns:
Returns true if the Quest can be failed, false if not.
Exceptions:
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.

Parameters:
player The player for whom is to be checked.
Returns:
Returns true if the quest can be started, false if not.
Exceptions:
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.

Parameters:
player The player.
status The status to be set.
Returns:
Returns false if player is NULL.

< 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.

References players_, and status_.

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.


Member Data Documentation

The set of players which possess this Quest.

Referenced by complete(), fail(), getStatus(), and setStatus().

Reward QuestEffects only invoked on the player completing the Quest.

Referenced by addRewardEffect(), complete(), and getRewardEffects().

The status of this Quest.

Referenced by getStatus(), isStartable(), and setStatus().


The documentation for this class was generated from the following files:

Generated on Tue Jul 28 16:22:32 2009 for Orxonox by  doxygen 1.5.6