orxonox::Quest Class Reference

Represents a Quest in the game. A Quest has a list of subquests and a parentquest (if it is not a rootquest). Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player. A Quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the Quest. 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. More...

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

Inheritance diagram for orxonox::Quest:

orxonox::QuestItem orxonox::BaseObject orxonox::OrxonoxClass orxonox::GlobalQuest orxonox::LocalQuest

List of all members.

Public Member Functions

bool addListener (QuestListener *listener)
 Adds a QuestListener to the list of QuestListeners listening to this Quest.
virtual bool complete (PlayerInfo *player)
 Completes the Quest.
virtual bool fail (PlayerInfo *player)
 Fails the Quest.
const std::list< QuestHint * > & getHintsList (void) const
 Returns the list of all QuestHints of this Quest.
QuestgetParentQuest (void) const
 Returns the parentquest of the Quest.
const std::list< Quest * > & getSubQuestList (void) const
 Returns the list of subquests.
bool isActive (const PlayerInfo *player) const
 Returns true if the quest status for the specific player is 'active'.
bool isCompleted (const PlayerInfo *player) const
 Returns true if the quest status for the specific player is 'completed'.
bool isFailed (const PlayerInfo *player) const
 Returns true if the quest status for the specific player is 'failed'.
bool isInactive (const PlayerInfo *player) const
 Returns true if the quest status for the specific player is 'inactive'.
 Quest (BaseObject *creator)
 Constructor. Registers and initializes object.
bool start (PlayerInfo *player)
 Sets a Quest to active.
virtual void XMLPort (Element &xmlelement, XMLPort::Mode mode)
 Method for creating a Quest object through XML.
virtual ~Quest ()
 Destructor.

Protected Member Functions

const QuestEffectgetCompleteEffect (unsigned int index) const
 Returns the complete QuestEffect at the given index.
std::list< QuestEffect * > & getCompleteEffectList (void)
 Returns the list of complete QuestEffects.
const QuestEffectgetFailEffect (unsigned int index) const
 Returns the fail QuestEffect at the given index.
std::list< QuestEffect * > & getFailEffectList (void)
 Returns the list of fail QuestEffects.
const QuestHintgetHint (unsigned int index) const
 Returns the QuestHint at the given index.
virtual QuestStatus::Value getStatus (const PlayerInfo *player) const =0
 Returns the status of the Quest for a specific player.
const QuestgetSubQuest (unsigned int index) const
 Returns the subquest at the given index.
virtual bool isCompletable (const PlayerInfo *player) const =0
 Checks whether the Quest can be completed.
virtual bool isFailable (const PlayerInfo *player) const =0
 Checks whether the Quest can be failed.
virtual bool isStartable (const PlayerInfo *player) const =0
 Checks whether the Quest can be started.
virtual bool setStatus (PlayerInfo *player, const QuestStatus::Value &status)=0
 Changes the status for a specific player.

Private Member Functions

bool addCompleteEffect (QuestEffect *effect)
 Adds an QuestEffect to the list of complete QuestEffects.
bool addFailEffect (QuestEffect *effect)
 Adds an QuestEffect to the list of fail QuestEffects.
bool addHint (QuestHint *hint)
 Add a QuestHint to the list of QuestHints.
bool addSubQuest (Quest *quest)
 Adds a subquest to the Quest.
bool setParentQuest (Quest *quest)
 Sets the parentquest of the Quest.

Private Attributes

std::list< QuestEffect * > completeEffects_
 A list of QuestEffects to be invoked, when the Quest has been completed.
std::list< QuestEffect * > failEffects_
 A list of all QuestEffects to be invoked, when the Quest has been failed.
std::list< QuestHint * > hints_
 A list of all the QuestHints tied to this Quest.
std::list< QuestListener * > listeners_
 A list of QuestListeners, that listen to what exactly happens with this Quest.
QuestparentQuest_
 Pointer to the parentquest.
std::list< Quest * > subQuests_
 List of all the subquests.


Detailed Description

Represents a Quest in the game. A Quest has a list of subquests and a parentquest (if it is not a rootquest). Each Quest exists only once but it has a different status (inactive, active, failed or completed) for each player. A Quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the Quest. 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.

Quest itself should not be instantiated, if you want to create a quest either go for LocalQuest or GlobalQuest, whichever suits you needs better.

Author:
Damian 'Mozork' Frick

Constructor & Destructor Documentation

orxonox::Quest::Quest ( BaseObject creator  ) 

Constructor. Registers and initializes object.

References parentQuest_, and RegisterObject.

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

Destructor.


Member Function Documentation

bool orxonox::Quest::addCompleteEffect ( QuestEffect effect  )  [private]

Adds an QuestEffect to the list of complete QuestEffects.

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

< We don't want to set NULL-Pointers.

< Adds the QuestEffect to the end of the list of complete QuestEffects.

References completeEffects_, COUT, and orxonox::QuestItem::getId().

Referenced by XMLPort().

bool orxonox::Quest::addFailEffect ( QuestEffect effect  )  [private]

Adds an QuestEffect to the list of fail QuestEffects.

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

< We don't want to set NULL-Pointers.

< Adds the QuestEffect to the end of the list of fail QuestEffects.

References COUT, failEffects_, and orxonox::QuestItem::getId().

Referenced by XMLPort().

bool orxonox::Quest::addHint ( QuestHint hint  )  [private]

Add a QuestHint to the list of QuestHints.

Adds a QuestHint to the list of QuestHints.

Parameters:
hint The QuestHint that should be added to the list of QuestHints.
Returns:
Returns true if the hint was successfully added.

< We don't want to set NULL-Pointers. Seriously!

< Sets the current Quest (this) as Quest for the added QuestHint.

< Adds the QuestHint to the end of the list of QuestHints.

References COUT, orxonox::QuestItem::getId(), hints_, and orxonox::QuestHint::setQuest().

Referenced by XMLPort().

bool orxonox::Quest::addListener ( QuestListener listener  ) 

Adds a QuestListener to the list of QuestListeners listening to this Quest.

Parameters:
listener The QuestListener to be added.
Returns:
Returns true if successful, false if not.

References COUT, and listeners_.

Referenced by orxonox::QuestListener::XMLPort().

bool orxonox::Quest::addSubQuest ( Quest quest  )  [private]

Adds a subquest to the Quest.

Parameters:
quest A pointer to the Quest to be set as subquest.
Returns:
Returns true if the subquest could be set.

< We don't want to set NULL-Pointers.

< Sets the currentQuest (this) as parentquest for the added subquest.

< Adds the Quest to the end of the list of subquests.

References COUT, orxonox::QuestItem::getId(), setParentQuest(), and subQuests_.

Referenced by XMLPort().

bool orxonox::Quest::complete ( PlayerInfo player  )  [virtual]

Completes the Quest.

Completes the Quest for an input player.

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

< Tells the QuestListeners, that the status has changed to completed.

Reimplemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

References orxonox::QuestListener::advertiseStatusChange(), orxonox::QuestStatus::Completed, COUT, orxonox::QuestItem::getDescription(), orxonox::QuestItem::getId(), listeners_, orxonox::QuestDescription::sendCompleteQuestNotification(), and setStatus().

Referenced by orxonox::LocalQuest::complete(), orxonox::GlobalQuest::complete(), and orxonox::CompleteQuest::invoke().

bool orxonox::Quest::fail ( PlayerInfo player  )  [virtual]

Fails the Quest.

Fails the Quest for an input player.

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

< Tells the QuestListeners, that the status has changed to failed.

Reimplemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

References orxonox::QuestListener::advertiseStatusChange(), COUT, orxonox::QuestStatus::Failed, orxonox::QuestItem::getDescription(), orxonox::QuestItem::getId(), listeners_, orxonox::QuestDescription::sendFailQuestNotification(), and setStatus().

Referenced by orxonox::LocalQuest::fail(), orxonox::GlobalQuest::fail(), and orxonox::FailQuest::invoke().

const QuestEffect * orxonox::Quest::getCompleteEffect ( unsigned int  index  )  const [protected]

Returns the complete QuestEffect at the given index.

Parameters:
The index.
Returns:
Returns a pointer to the complete QuestEffect at the given index. NULL if there is no element at the given index.

Iterate through all complete QuestEffects.

< We're counting down...

< If the index is greater than the number of elements in the list.

References completeEffects_.

Referenced by XMLPort().

std::list<QuestEffect*>& orxonox::Quest::getCompleteEffectList ( void   )  [inline, protected]

Returns the list of complete QuestEffects.

Returns:
Returns a reference to the list of complete QuestEffects.

Referenced by orxonox::LocalQuest::complete(), and orxonox::GlobalQuest::complete().

const QuestEffect * orxonox::Quest::getFailEffect ( unsigned int  index  )  const [protected]

Returns the fail QuestEffect at the given index.

Parameters:
The index.
Returns:
Returns a pointer to the fail QuestEffect at the given index. NULL if there is no element at the given index.

Iterate through all fail QuestEffects.

< We're counting down...

< If the index is greater than the number of elements in the list.

References failEffects_.

Referenced by XMLPort().

std::list<QuestEffect*>& orxonox::Quest::getFailEffectList ( void   )  [inline, protected]

Returns the list of fail QuestEffects.

Returns:
Returns a reference to the list of fail QuestEffects.

Referenced by orxonox::LocalQuest::fail(), and orxonox::GlobalQuest::fail().

const QuestHint * orxonox::Quest::getHint ( unsigned int  index  )  const [protected]

Returns the QuestHint at the given index.

Parameters:
The index.
Returns:
Returns a pointer to the QuestHint at the given index. NULL if there is no element at the given index.

Iterate through all QuestHints.

< We're counting down...

< If the index is greater than the number of elements in the list.

References hints_.

Referenced by XMLPort().

const std::list<QuestHint*>& orxonox::Quest::getHintsList ( void   )  const [inline]

Returns the list of all QuestHints of this Quest.

Returns:
Returns a reference to the list of QuestHints of the Quest.

Referenced by orxonox::QuestManager::addHints().

Quest* orxonox::Quest::getParentQuest ( void   )  const [inline]

Returns the parentquest of the Quest.

Returns:
Returns a pointer to the parentquest of the Quest.

Referenced by orxonox::QuestManager::getRootQuests(), orxonox::LocalQuest::isStartable(), and orxonox::GlobalQuest::isStartable().

virtual QuestStatus::Value orxonox::Quest::getStatus ( const PlayerInfo player  )  const [protected, pure virtual]

Returns the status of the Quest for a specific player.

Implemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

Referenced by isActive(), isCompleted(), isFailed(), and isInactive().

const Quest * orxonox::Quest::getSubQuest ( unsigned int  index  )  const [protected]

Returns the subquest at the given index.

Parameters:
The index.
Returns:
Returns a pointer to the subquest at the given index. NULL if there is no element at the given index.

Iterate through all subquests.

< We're counting down...

< If the index is greater than the number of elements in the list.

References subQuests_.

Referenced by XMLPort().

const std::list<Quest*>& orxonox::Quest::getSubQuestList ( void   )  const [inline]

Returns the list of subquests.

Returns:
Returns a reference to the list of subquests of the quest.

Referenced by orxonox::QuestManager::addSubQuest().

bool orxonox::Quest::isActive ( const PlayerInfo player  )  const

Returns true if the quest status for the specific player is 'active'.

Parameters:
player The player.
Returns:
Returns true if the quest status for the specific player is 'active'.
Exceptions:
Throws an exception if getStatus throws one.

References orxonox::QuestStatus::Active, and getStatus().

Referenced by orxonox::QuestManager::addSubQuest(), and orxonox::QuestHint::setActive().

virtual bool orxonox::Quest::isCompletable ( const PlayerInfo player  )  const [protected, pure virtual]

Checks whether the Quest can be completed.

Implemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

bool orxonox::Quest::isCompleted ( const PlayerInfo player  )  const

Returns true if the quest status for the specific player is 'completed'.

Parameters:
player The player.
Returns:
Returns true if the quest status for the specific player is 'completed'.
Exceptions:
Throws an exception if getStatus throws one.

References orxonox::QuestStatus::Completed, and getStatus().

Referenced by orxonox::QuestManager::addSubQuest().

virtual bool orxonox::Quest::isFailable ( const PlayerInfo player  )  const [protected, pure virtual]

Checks whether the Quest can be failed.

Implemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

bool orxonox::Quest::isFailed ( const PlayerInfo player  )  const

Returns true if the quest status for the specific player is 'failed'.

Parameters:
player The player.
Returns:
Returns true if the quest status for the specific player is 'failed'.
Exceptions:
Throws an exception if getStatus throws one.

References orxonox::QuestStatus::Failed, and getStatus().

Referenced by orxonox::QuestManager::addSubQuest().

bool orxonox::Quest::isInactive ( const PlayerInfo player  )  const

Returns true if the quest status for the specific player is 'inactive'.

Parameters:
player The player.
Returns:
Returns true if the quest status for the specific player is 'inactive'.
Exceptions:
Throws an exception if getStatus throws one.

References getStatus(), and orxonox::QuestStatus::Inactive.

Referenced by orxonox::QuestManager::addSubQuest(), orxonox::QuestManager::getRootQuests(), orxonox::LocalQuest::isStartable(), and orxonox::GlobalQuest::isStartable().

virtual bool orxonox::Quest::isStartable ( const PlayerInfo player  )  const [protected, pure virtual]

Checks whether the Quest can be started.

Implemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

Referenced by start().

bool orxonox::Quest::setParentQuest ( Quest quest  )  [private]

Sets the parentquest of the Quest.

Parameters:
quest A pointer to the Quest to be set as parentquest.
Returns:
Returns true if the parentquest could be set.

< We don't want to set NULL-Pointers.

References COUT, orxonox::QuestItem::getId(), and parentQuest_.

Referenced by addSubQuest().

virtual bool orxonox::Quest::setStatus ( PlayerInfo player,
const QuestStatus::Value status 
) [protected, pure virtual]

Changes the status for a specific player.

Implemented in orxonox::GlobalQuest, and orxonox::LocalQuest.

Referenced by complete(), fail(), and start().

bool orxonox::Quest::start ( PlayerInfo player  ) 

Sets a Quest to active.

Starts the Quest for an input player.

Parameters:
player The player.
Returns:
Returns true if the Quest could be started, false if not.

< Checks whether the quest can be started.

< Tells the QuestListeners, that the status has changed to active.

References orxonox::QuestStatus::Active, orxonox::QuestListener::advertiseStatusChange(), COUT, orxonox::QuestItem::getDescription(), orxonox::QuestItem::getId(), isStartable(), listeners_, orxonox::QuestDescription::sendAddQuestNotification(), and setStatus().

Referenced by orxonox::AddQuest::invoke().

void orxonox::Quest::XMLPort ( Element &  xmlelement,
XMLPort::Mode  mode 
) [virtual]


Member Data Documentation

A list of QuestEffects to be invoked, when the Quest has been completed.

Referenced by addCompleteEffect(), and getCompleteEffect().

A list of all QuestEffects to be invoked, when the Quest has been failed.

Referenced by addFailEffect(), and getFailEffect().

std::list<QuestHint*> orxonox::Quest::hints_ [private]

A list of all the QuestHints tied to this Quest.

Referenced by addHint(), and getHint().

A list of QuestListeners, that listen to what exactly happens with this Quest.

Referenced by addListener(), complete(), fail(), and start().

Pointer to the parentquest.

Referenced by Quest(), and setParentQuest().

std::list<Quest*> orxonox::Quest::subQuests_ [private]

List of all the subquests.

Referenced by addSubQuest(), and getSubQuest().


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

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