orxonox::LocalQuest Class Reference

Handles Quests which have different states for different players. LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest. More...

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

Inheritance diagram for orxonox::LocalQuest:

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.
 LocalQuest (BaseObject *creator)
 Constructor. Registers and initializes the object.
virtual void XMLPort (Element &xmlelement, XMLPort::Mode mode)
 Method for creating a LocalQuest object through XML.
virtual ~LocalQuest ()
 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 Attributes

std::map< const PlayerInfo
*, QuestStatus::Value
playerStatus_
 List of the status for each player, with the Player-pointer as key.


Detailed Description

Handles Quests which have different states for different players. LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest.

Creating a LocalQuest through XML goes as follows:

<LocalQuest 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 when the Quest is failed, see QuestEffect for the full XML representation. ... <QuestEffect> </fail-effects> <complete-effects> <QuestEffect> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation. ... <QuestEffect> </complete-effects> </LocalQuest>

Author:
Damian 'Mozork' Frick

Constructor & Destructor Documentation

orxonox::LocalQuest::LocalQuest ( BaseObject creator  ) 

Constructor. Registers and initializes the object.

References RegisterObject.

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

Destructor.


Member Function Documentation

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

Completes the Quest.

Completes the Quest for a given player. Invokes all the complete QuestEffects on the player.

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

< Checks whether the Quest can be completed.

< Invoke the complete QuestEffects.

Reimplemented from orxonox::Quest.

References orxonox::Quest::complete(), COUT, orxonox::Quest::getCompleteEffectList(), orxonox::QuestEffect::invokeEffects(), and isCompletable().

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

Fails the Quest.

Fails the Quest for a given player. Invokes all the failEffects on the player.

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

< Checks whether the quest can be failed.

< Invoke the failEffects.

Reimplemented from orxonox::Quest.

References COUT, orxonox::Quest::fail(), orxonox::Quest::getFailEffectList(), orxonox::QuestEffect::invokeEffects(), and isFailable().

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

Returns the status of the Quest for a specific player.

Parameters:
player The player.
Returns:
Returns the status of the Quest for the input player.
Exceptions:
Throws an Exception if player is NULL.

< No player has no defined status.

< If there is a player in the map.

< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.

Implements orxonox::Quest.

References orxonox::QuestStatus::Inactive, playerStatus_, and ThrowException.

bool orxonox::LocalQuest::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 isInactive(PlayerInfo*) throws one.

Implements orxonox::Quest.

References orxonox::BaseObject::isActive().

Referenced by complete().

bool orxonox::LocalQuest::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(PlayerInfo*) throws one.

Implements orxonox::Quest.

References orxonox::BaseObject::isActive().

Referenced by fail().

bool orxonox::LocalQuest::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 isInactive(PlayerInfo*) throws one.

Implements orxonox::Quest.

References orxonox::Quest::getParentQuest(), orxonox::BaseObject::isActive(), and orxonox::Quest::isInactive().

bool orxonox::LocalQuest::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. Really!

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

< We can't set a status for no player.

Implements orxonox::Quest.

References playerStatus_.

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

Method for creating a LocalQuest object through XML.

Reimplemented from orxonox::Quest.

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


Member Data Documentation

List of the status for each player, with the Player-pointer as key.

Referenced by getStatus(), and setStatus().


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

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