Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 19, 2008, 11:50:03 AM (16 years ago)
Author:
dafrick
Message:

Some tweaks and solved some bugs…

Location:
code/branches/questsystem2/src/orxonox/objects/quest
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem2/src/orxonox/objects/quest/AddQuest.h

    r2205 r2221  
    4848    @brief
    4949        Adds a Quest, resp. changes the quests status to active for the player invoking the Quest.
     50       
     51        Creating a AddQuest through XML goes as follows:
     52       
     53        <AddQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
    5054    @author
    5155        Damian 'Mozork' Frick
  • code/branches/questsystem2/src/orxonox/objects/quest/AddQuestHint.h

    r2205 r2221  
    4747    @brief
    4848        Adds a QuestHint, resp. activates the QuestHint of the given id for the player the QuestEffect is invoked on.
     49       
     50        Creating a AddQuestHint through XML goes as follows:
     51       
     52        <AddQuestHint hintId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added.
    4953    @author
    5054        Damian 'Mozork' Frick
  • code/branches/questsystem2/src/orxonox/objects/quest/AddReward.h

    r2205 r2221  
    4848    @brief
    4949        Adds a list of Rewardables to a player.
     50       
     51        Creating a AddReward through XML goes as follows:
     52       
     53        <AddReward>
     54            <Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations.
     55            ...
     56            <Rewardable />
     57        </AddReward>
    5058    @author
    5159        Damian 'Mozork' Frick
  • code/branches/questsystem2/src/orxonox/objects/quest/CompleteQuest.h

    r2205 r2221  
    4848    @brief
    4949        Completes a Quest (with a specified id) for the player invoking the QuestEffect.
     50       
     51        Creating a CompleteQuest through XML goes as follows:
     52       
     53        <CompleteQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be completed.
    5054    @author
    5155        Damian 'Mozork' Frick
  • code/branches/questsystem2/src/orxonox/objects/quest/FailQuest.h

    r2205 r2221  
    4747    /**
    4848    @brief
    49         Fails a quest.
     49        Fails a quest (with a specified id) for the player invoking the QuestEffect.
     50       
     51        Creating a FailQuest through XML goes as follows:
     52       
     53        <FailQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be failed.
    5054    @author
    5155        Damian 'Mozork' Frick
  • code/branches/questsystem2/src/orxonox/objects/quest/QuestDescription.h

    r2191 r2221  
    4949        This class is a description of a QuestItem.
    5050        It holds a title and a description.
     51       
     52        Creating a QuestDescription through XML goes as follows:
     53       
     54        <QuestDescription title="Title" description="Description Text" />
    5155    @author
    5256        Damian 'Mozork' Frick
  • code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2209 r2221  
    2727 */
    2828
     29/**
     30    @file QuestEffectBeacon.cc
     31    @brief
     32        Implementation of the QuestEffectBeacon class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "QuestEffectBeacon.h"
     
    4450    CreateFactory(QuestEffectBeacon);
    4551
     52    /**
     53    @brief
     54        Constructor. Registers the object and initializes defaults.
     55    */
    4656    QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : PositionableEntity(creator)
    4757    {
     
    4959       
    5060        this->status_ = QuestEffectBeaconStatus::active;
    51         this->times_ = -1;
    52         this->trigger_ = NULL;
    53     }
    54 
     61        this->times_ = INFINITE;
     62    }
     63
     64    /**
     65        Destructor.
     66    */
    5567    QuestEffectBeacon::~QuestEffectBeacon()
    5668    {
    5769    }
    5870   
     71    /**
     72    @brief
     73        Method for creating a QuestEffectBeacon object through XML.
     74    */
    5975    void QuestEffectBeacon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6076    {
     
    6278
    6379        XMLPortParam(QuestEffectBeacon, "times", setTimes, getTimes, xmlelement, mode);
    64         XMLPortObject(QuestEffectBeacon, QuestEffect, "", addEffect, getEffect, xmlelement, mode);
    65         XMLPortObject(QuestEffectBeacon, PlayerTrigger, "", addTrigger, getTrigger, xmlelement, mode);
    66     }
    67    
     80        XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode);
     81    }
     82   
     83    /**
     84    @brief
     85        Processes an event for this QuestEffectBeacon.
     86    */
    6887    void QuestEffectBeacon::processEvent(Event& event)
    6988    {
     89        SUPER(QuestEffectBeacon, processEvent, event);
     90   
    7091        SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
    7192    }
    7293   
     94    /**
     95    @brief
     96        Executes the QuestEffectBeacon.
     97        This means extracting the ControllableEntity from the PlayerTrigger, provided by the Event causing the execution, and the extracting the PlayerInfo from the received ControllableEntity and invoking the QuestEffectbeacon's QuestEffects on the received PlayerInfo.
     98    @param b
     99        TDO: What is this???
     100    @param trigger
     101        Apointer to the PlayerTrigger that threw the Event.
     102    @return
     103        Returns true if successfully executed, false if not.
     104    */
    73105    bool QuestEffectBeacon::execute(bool b, PlayerTrigger* trigger)
    74106    {
    75107        if(!b)
    76108        {
     109            //TDO: Better message, please.
    77110            COUT(2) << "b is false." << std::endl;
    78111        }
    79         if(!(this->isActive()))
     112        if(!(this->isActive())) //!< If the QuestEffectBeacon is inactive it cannot be executed.
    80113        {
    81114            COUT(3) << "The QuestEffectBeacon is inactive." << std::endl;
    82115            return false;
    83116        }
    84 
     117       
     118        if(!trigger->isForPlayer()) //!< The PlayerTrigger is not exclusively for ControllableEntities which means we cannot extract one.
     119        {
     120            return false;
     121        }
     122
     123        //! Extracting the ControllableEntity form the PlayerTrigger.
    85124        ControllableEntity* entity = trigger->getTriggeringPlayer();
    86125
     
    91130        }
    92131       
     132        //! Extract the PlayerInfo from the ControllableEntity.
    93133        PlayerInfo* player = entity->getPlayer();
    94134       
     
    99139        }
    100140
    101         COUT(3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;       
    102 
    103         bool check = QuestEffect::invokeEffects(player, this->effects_);
     141        COUT(3) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;
     142
     143        bool check = QuestEffect::invokeEffects(player, this->effects_); //!< Invoke the QuestEffects on the PlayerInfo.
    104144        if(check)
    105145        {
    106             this->decrementTimes();
     146            this->decrementTimes(); //!< Decrement the number of times the beacon can be used.
    107147            return true;
    108148        }
    109        
     149
    110150        return false;
    111151    }
    112152   
    113     bool QuestEffectBeacon::isActive(void)
    114     {
    115         return this->status_ == QuestEffectBeaconStatus::active;
    116     }
    117    
     153    /**
     154    @brief
     155        Set the status of the QuestEffectBeacon.
     156    @param activate
     157        If true the QuestEffectBeacon is activated, if false it is deactivated.
     158    @return
     159        Returns whether the activation/deactivation was successful.
     160    */
     161    bool QuestEffectBeacon::setActive(bool activate)
     162    {
     163        if(this->getTimes() == 0 && activate) //!< A QuestEffectBeacon that can be executed only 0 times is always inactive.
     164        {
     165            return false;
     166        }
     167       
     168        if(activate)
     169        {
     170            this->status_ = QuestEffectBeaconStatus::active;
     171            return true;
     172        }
     173       
     174        this->status_ = QuestEffectBeaconStatus::inactive;
     175        return true;
     176    }
     177   
     178    /**
     179    @brief
     180        Decrement the number of times the QuestEffectBeacon can be executed.
     181    @return
     182        Returns true if successful.
     183    */
    118184    bool QuestEffectBeacon::decrementTimes(void)
    119185    {
    120         if(!(this->isActive()))
    121         {
    122             return false;
    123         }
    124         if(this->getTimes() == -1)
     186        if(!(this->isActive())) //!< The QuestEffectBeacon mus be active to decrement the number of times it can be executed.
     187        {
     188            return false;
     189        }
     190        if(this->getTimes() == INFINITE) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times.
    125191        {
    126192            return true;
    127193        }
    128194       
    129         this->times_ = this->times_ - 1;
    130         if(this->getTimes() == 0)
     195        this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed.
     196        if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
    131197        {
    132198            this->status_ = QuestEffectBeaconStatus::inactive;
     
    136202    }
    137203   
    138    
     204    /**
     205    @brief
     206        Set the number of times the QuestEffectBeacon can be executed.
     207        The number must be eighter <= 0, or INFINITY which is '-1'.
     208    @param n
     209        The number of times the QuestEffectBeacon can be executed.
     210        The number must be eighter <= 0, or INFINITY which is '-1'.
     211    @return
     212        Returns true if successful.
     213    */
    139214    bool QuestEffectBeacon::setTimes(const int & n)
    140215    {
    141         if(n < -1)
     216        if(n < 0 && n != INFINITE)
    142217        {
    143218            return false;
     
    148223    }
    149224   
    150    
    151     /**
    152     @brief
    153 
     225    /**
     226    @brief
     227        Adds a QuestEffect to the QuestEffectBeacon.
     228    @param effect
     229        A pointer to the QuestEffect to be added.
     230    @return
     231        Returns true if successful.
    154232    */
    155233    bool QuestEffectBeacon::addEffect(QuestEffect* effect)
    156234    {
    157         if(effect == NULL)
     235        if(effect == NULL) //!< NULL-pointers are not well liked here...
    158236        {
    159237            COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl;
     
    167245    }
    168246   
    169     bool QuestEffectBeacon::addTrigger(PlayerTrigger* trigger)
    170     {
    171         if(this->trigger_ != NULL)
    172         {
    173            COUT(2) << "A Trigger was trying to be added, where one was already set." << std::endl;
    174            return false;
    175         }
    176         if(trigger == NULL)
    177         {
    178             COUT(2) << "A NULL-Trigger was trying to be added." << std::endl;
    179             return false;
    180         }
    181        
    182         COUT(3) << "A Trigger was added to a QuestEffectBeacon." << std::endl;
    183         this->trigger_ = trigger;
    184         return true;
    185     }
    186    
    187      /**
    188     @brief
    189 
     247    /**
     248    @brief
     249        Returns the QuestEffect at the given index.
     250    @param index
     251        The index.
     252    @return
     253        Returns a pointer to the QuestEffect at the given index.
    190254    */
    191255    const QuestEffect* QuestEffectBeacon::getEffect(unsigned int index) const
     
    203267    }
    204268
    205     const PlayerTrigger* QuestEffectBeacon::getTrigger(unsigned int index) const
    206     {
    207         if(index == 0)
    208         {
    209             return this->trigger_;
    210         }
    211        
    212         return NULL;
    213     }
    214 
    215269}
  • code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2209 r2221  
    2727 */
    2828
     29/**
     30    @file QuestEffectBeacon.h
     31    @brief
     32        Definition of the QuestEffectBeacon class.
     33*/
     34
    2935#ifndef _QuestEffectBeacon_H__
    3036#define _QuestEffectBeacon_H__
     
    3743{
    3844
     45    //! The status of the beacon, can be either active or inactive.
    3946    enum Enum
    4047    {
     
    4249        active
    4350    };
    44    
     51
    4552}
    4653
     
    4956    /**
    5057    @brief
    51         A QuestEffectBeacon is an entity which can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s).
     58        A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s).
    5259        The conditions under which the QuestEffects are invoked on the player are defined by Triggers.
    5360        A QuestEffectBeacon can be executed a defined number of times.
     61        A QuestEffectBeacon can be inactive or active.
     62       
     63        Creating a QuestEffectBeacon through XML goes as follows:
     64       
     65        <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
     66            <effects>
     67                <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
     68                ...
     69                <QuestEffect />
     70            </effects>
     71            <events>
     72                <execute>
     73                    <PlayerTrigger /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
     74                </execute>
     75            </events>
     76        </QuestEffectBeacon>
    5477    @author
    5578        Damian 'Mozork' Frick
     
    6184            virtual ~QuestEffectBeacon();
    6285           
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     86            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
    6487           
    65             virtual void processEvent(Event& event);
     88            virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
    6689           
    6790            bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
    6891           
    69             bool isActive(void); //!< Test whether the QuestEffectBeacon is active.
     92            /**
     93            @brief Tests whether the QuestEffectBeacon is active.
     94            @return Returns true if the QuestEffectBeacon is active, fals if not.
     95            */
     96            inline bool isActive(void)
     97               { return this->status_ == QuestEffectBeaconStatus::active; }
     98           
     99            bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
    70100           
    71101        protected:
    72102            bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
    73103           
    74             inline const int & getTimes(void) const //!< Return the number of times the QUestEffectBeacon can still be executed.
     104            /**
     105            @brief Returns the number of times the QUestEffectBeacon can still be executed.
     106            @return Returns the number of times the QUestEffectBeacon can still be executed.
     107            */
     108            inline const int & getTimes(void) const
    75109                { return this->times_; }
    76110
    77111        private:
     112            static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
     113       
    78114            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
    79115            int times_; //!< Number of times the beacon can be exectued.
    80116            QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
    81             PlayerTrigger* trigger_;
    82117           
    83118            bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
    84             bool addEffect(QuestEffect* effect);
    85             bool addTrigger(PlayerTrigger* trigger);
     119            bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
    86120           
    87             const QuestEffect* getEffect(unsigned int index) const;
    88             const PlayerTrigger* getTrigger(unsigned int index) const;
     121            const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
    89122   
    90123    };
Note: See TracChangeset for help on using the changeset viewer.