Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2352 for code


Ignore:
Timestamp:
Dec 7, 2008, 11:39:44 PM (16 years ago)
Author:
dafrick
Message:
  • Changed questStatus to mode in QuestListener.
  • Added new mode 'all' in QuestListener
  • Documented QuestListener
  • Cleaned up some code, replaced tabs with spaces, a.s.o.
Location:
code/branches/questsystem3/src/orxonox/objects/quest
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.cc

    r2346 r2352  
    2929/**
    3030    @file AddQuest.cc
    31     @brief
    32     Implementation of the AddQuest class.
     31    @brief Implementation of the AddQuest class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.h

    r2261 r2352  
    2929/**
    3030    @file AddQuest.h
    31     @brief
    32     Definition of the AddQuest class.
     31    @brief Definition of the AddQuest class.
    3332*/
    3433
     
    5857    {
    5958        public:
    60             AddQuest(BaseObject* creator);
    61             virtual ~AddQuest();
    62 
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
    64 
    65             virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
     59        AddQuest(BaseObject* creator);
     60        virtual ~AddQuest();
     61   
     62        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
     63   
     64        virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    6665
    6766    };
  • code/branches/questsystem3/src/orxonox/objects/quest/AddQuestHint.cc

    r2261 r2352  
    2929/**
    3030    @file AddQuestHint.cc
    31     @brief
    32     Implementation of the AddQuestHint class.
     31    @brief Implementation of the AddQuestHint class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/AddQuestHint.h

    r2261 r2352  
    2929/**
    3030    @file AddQuestHint.h
    31     @brief
    32     Definition of the AddQuestHint class.
     31    @brief Definition of the AddQuestHint class.
    3332*/
    3433
     
    7372            inline const std::string & getHintId(void) const
    7473                { return this->hintId_; }
     74           
    7575            bool setHintId(const std::string & id); //!< Sets the id of the QuestHint.
    7676
  • code/branches/questsystem3/src/orxonox/objects/quest/AddReward.cc

    r2261 r2352  
    2929/**
    3030    @file AddReward.cc
    31     @brief
    32     Implementation of the AddReward class.
     31    @brief Implementation of the AddReward class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/AddReward.h

    r2261 r2352  
    2929/**
    3030    @file AddReward.h
    31     @brief
    32     Definition of the AddReward class.
     31    @brief Definition of the AddReward class.
    3332*/
    3433
     
    7877            inline void addRewardable(Rewardable* reward)
    7978                { this->rewards_.push_back(reward); }
     79       
    8080            const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index.
    8181
  • code/branches/questsystem3/src/orxonox/objects/quest/ChangeQuestStatus.cc

    r2261 r2352  
    2929/**
    3030    @file ChangeQuestStatus.cc
    31     @brief
    32     Implementation of the ChangeQuestStatus class.
     31    @brief Implementation of the ChangeQuestStatus class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/ChangeQuestStatus.h

    r2261 r2352  
    2929/**
    3030    @file ChangeQuestStatus.h
    31     @brief
    32     Definition of the ChangeQuestStatus class.
     31    @brief Definition of the ChangeQuestStatus class.
    3332*/
    3433
     
    6362        protected:
    6463            /**
    65                 @brief Returns the id of the Quest.
    66                 @return Returns the id of the Quest.
     64            @brief Returns the id of the Quest.
     65            @return Returns the id of the Quest.
    6766            */
    6867            inline const std::string & getQuestId(void) const
  • code/branches/questsystem3/src/orxonox/objects/quest/CompleteQuest.cc

    r2346 r2352  
    2929/**
    3030    @file CompleteQuest.cc
    31     @brief
    32     Implementation of the CompleteQuest class.
     31    @brief Implementation of the CompleteQuest class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/CompleteQuest.h

    r2261 r2352  
    2929/**
    3030    @file CompleteQuest.h
    31     @brief
    32     Definition of the CompleteQuest class.
     31    @brief Definition of the CompleteQuest class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.cc

    r2346 r2352  
    2929/**
    3030    @file FailQuest.cc
    31     @brief
    32     Implementation of the FailQuest class.
     31    @brief Implementation of the FailQuest class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/FailQuest.h

    r2261 r2352  
    2929/**
    3030    @file FailQuest.h
    31     @brief
    32     Definition of the FailQuest class.
     31    @brief Definition of the FailQuest class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/GlobalQuest.cc

    r2328 r2352  
    2929/**
    3030    @file GlobalQuest.cc
    31     @brief
    32     Implementation of the GlobalQuest class.
     31    @brief Implementation of the GlobalQuest class.
    3332*/
    3433
     
    9695       
    9796        Quest::fail(player);
    98        
    99         //! Iterate through all players possessing this Quest.
    100         for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    101         {
    102             QuestEffect::invokeEffects(*it, this->getFailEffectList());
    103         }
    104 
    105         return true;
     97   
     98    //! Iterate through all players possessing this Quest.
     99    for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     100    {
     101        QuestEffect::invokeEffects(*it, this->getFailEffectList());
     102    }
     103
     104    return true;
    106105    }
    107106
     
    125124       
    126125        //! Iterate through all players possessing the Quest.
    127         for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    128         {
    129             QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
    130         }
    131        
    132         Quest::complete(player);
    133        
    134         QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
    135         return true;
     126        for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     127        {
     128            QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
     129        }
     130   
     131        Quest::complete(player);
     132   
     133        QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
     134        return true;
    136135    }
    137136
     
    208207        }
    209208
    210     return questStatus::inactive;
     209        return questStatus::inactive;
    211210    }
    212211
  • code/branches/questsystem3/src/orxonox/objects/quest/GlobalQuest.h

    r2261 r2352  
    2929/**
    3030    @file GlobalQuest.h
    31     @brief
    32     Definition of the GlobalQuest class.
     31    @brief Definition of the GlobalQuest class.
    3332*/
    3433
     
    5655            <QuestDescription title="Title" description="Description." /> //The description of the quest.
    5756            <subquests>
    58         <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.
    59         ...
    60         <Quest id="questIdn" />
    61         </subquests>
    62         <hints>
    63         <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
    64         ...
    65         <QuestHint id="hintIdn" />
    66         </hints>
     57                <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.
     58                ...
     59                <Quest id="questIdn" />
     60            </subquests>
     61            <hints>
     62                <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
     63                ...
     64                <QuestHint id="hintIdn" />
     65            </hints>
    6766            <fail-effects>
    6867                <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation.
  • code/branches/questsystem3/src/orxonox/objects/quest/LocalQuest.cc

    r2328 r2352  
    2929/**
    3030    @file LocalQuest.cc
    31     @brief
    32     Implementation of the LocalQuest class.
     31    @brief Implementation of the LocalQuest class.
    3332*/
    3433
     
    9594        Quest::fail(player);
    9695       
    97         QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects.
    98         return true;
     96        QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects.
     97        return true;
    9998    }
    10099
     
    118117        Quest::complete(player);
    119118       
    120         QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects.
    121         return true;
     119        QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects.
     120        return true;
    122121    }
    123122
  • code/branches/questsystem3/src/orxonox/objects/quest/LocalQuest.h

    r2261 r2352  
    2929/**
    3030    @file LocalQuest.h
    31     @brief
    32     Definition of the LocalQuest class.
     31    @brief Definition of the LocalQuest class.
    3332*/
    3433
     
    6564        <QuestHint id="hintIdn" />
    6665        </hints>
    67             <fail-effects>
    68                 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation.
    69                 ...
    70                 <QuestEffect />
    71             </fail-effects>
    72             <complete-effects>
    73                 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation.
    74                 ...
    75                 <QuestEffect />
    76             </complete-effects>
     66    <fail-effects>
     67        <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation.
     68        ...
     69        <QuestEffect />
     70    </fail-effects>
     71    <complete-effects>
     72        <QuestEffect /> //A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation.
     73        ...
     74        <QuestEffect />
     75    </complete-effects>
    7776        </LocalQuest>
    7877    @author
  • code/branches/questsystem3/src/orxonox/objects/quest/Quest.cc

    r2346 r2352  
    2929/**
    3030    @file Quest.cc
    31     @brief
    32     Implementation of the Quest class.
     31    @brief Implementation of the Quest class.
    3332*/
    3433
     
    420419       
    421420        this->getDescription()->sendAddQuestNotification();
    422         return true;
     421        return true;
    423422    }
    424423   
  • code/branches/questsystem3/src/orxonox/objects/quest/Quest.h

    r2328 r2352  
    2929/**
    3030    @file Quest.h
    31     @brief
    32     Definition of the Quest class.
    33    
    34     The Quest is the parent class of LocalQuest and GlobalQuest.
     31    @brief Definition of the Quest class.
     32        The Quest is the parent class of LocalQuest and GlobalQuest.
    3533*/
    3634 
     
    9088                { return this->parentQuest_; }
    9189               
    92             /**
    93             @brief Returns the list of subquests.
    94             @return Returns a reference to the list of subquests of the quest.
    95             */
    96             inline const std::list<Quest*> & getSubQuestList(void) const
    97                 { return this->subQuests_; }
    98                    
    99             /**
    100             @brief Returns the list of all QuestHints of this Quest.
    101             @return Returns a reference to the list of QuestHints of the Quest.
    102             */
    103             inline const std::list<QuestHint*> & getHintsList(void) const
    104                 { return this->hints_; }
    105            
    106             bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
    107             bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
    108             bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
    109             bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
    110            
    111             bool start(PlayerInfo* player); //!< Sets a Quest to active.
    112             virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
    113             virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
    114            
    115             bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest.
     90            /**
     91            @brief Returns the list of subquests.
     92            @return Returns a reference to the list of subquests of the quest.
     93            */
     94            inline const std::list<Quest*> & getSubQuestList(void) const
     95                { return this->subQuests_; }
     96
     97            /**
     98            @brief Returns the list of all QuestHints of this Quest.
     99            @return Returns a reference to the list of QuestHints of the Quest.
     100            */
     101            inline const std::list<QuestHint*> & getHintsList(void) const
     102                { return this->hints_; }
     103       
     104            bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
     105            bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
     106            bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
     107            bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
     108       
     109            bool start(PlayerInfo* player); //!< Sets a Quest to active.
     110            virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
     111            virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
     112       
     113            bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest.
    116114
    117115        protected:
     
    133131                { return this->failEffects_; }
    134132               
    135             /**
    136             @brief Returns the list of complete QuestEffects.
    137             @return Returns a reference to the list of complete QuestEffects.
    138             */
    139             inline std::list<QuestEffect*> & getCompleteEffectList(void)
     133            /**
     134            @brief Returns the list of complete QuestEffects.
     135            @return Returns a reference to the list of complete QuestEffects.
     136            */
     137            inline std::list<QuestEffect*> & getCompleteEffectList(void)
    140138                { return this->completeEffects_; }
    141139
     
    143141            virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
    144142           
    145     private:
     143        private:
    146144            Quest* parentQuest_; //!< Pointer to the parentquest.
    147145            std::list<Quest*> subQuests_; //!< List of all the subquests.
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.cc

    r2349 r2352  
    2929/**
    3030    @file QuestDescription.cc
    31     @brief
    32     Implementation of the QuestDescription class.
     31    @brief Implementation of the QuestDescription class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestDescription.h

    r2346 r2352  
    2929/**
    3030    @file QuestDescription.h
    31     @brief
    32     Definition of the QuestDescription class.
     31    @brief Definition of the QuestDescription class.
    3332*/
    3433
     
    6463            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML.
    6564
    66             /**
    67             @brief Returns the title.
    68             @return Returns a string containing the title of the QuestDescription.
    69             */
    70             inline const std::string & getTitle(void) const
    71                 { return this->title_; }
    72            
    73             /**
    74             @brief Returns the description text.
    75             @return Returns a string containing the description text of the QuestDescription.
    76             */
    77             inline const std::string & getDescription(void) const
    78                 { return this->description_; }
    79                
    80             /**
    81             @brief Returns the fail message.
    82             @return Returns a string containing the fail message of the QuestDescription.
    83             */
    84             inline const std::string & getFailMessage(void) const
    85                 { return this->failMessage_; }
    86                
    87             /**
    88             @brief Returns the complete message.
    89             @return Returns a string containing the complete message of the QuestDescription.
    90             */
    91             inline const std::string & getCompleteMessage(void) const
    92                 { return this->completeMessage_; }
    93            
    94             /**
    95             @brief Sends a Notification displaying that a QuestHint was added.
    96             @return Returns true if successful.
    97             */
    98             inline bool sendAddHintNotification(void) const
     65            /**
     66            @brief Returns the title.
     67            @return Returns a string containing the title of the QuestDescription.
     68            */
     69            inline const std::string & getTitle(void) const
     70                { return this->title_; }
     71       
     72            /**
     73            @brief Returns the description text.
     74            @return Returns a string containing the description text of the QuestDescription.
     75            */
     76            inline const std::string & getDescription(void) const
     77                { return this->description_; }
     78       
     79            /**
     80            @brief Returns the fail message.
     81            @return Returns a string containing the fail message of the QuestDescription.
     82            */
     83            inline const std::string & getFailMessage(void) const
     84                { return this->failMessage_; }
     85       
     86            /**
     87            @brief Returns the complete message.
     88            @return Returns a string containing the complete message of the QuestDescription.
     89            */
     90            inline const std::string & getCompleteMessage(void) const
     91                { return this->completeMessage_; }
     92       
     93            /**
     94            @brief Sends a Notification displaying that a QuestHint was added.
     95            @return Returns true if successful.
     96            */
     97            inline bool sendAddHintNotification(void) const
    9998                { return notificationHelper("hint", ""); }
    100            
    101             /**
    102             @brief Sends a Notification displaying that a Quest was added.
    103             @return Returns true if successful.
    104             */
    105             inline bool sendAddQuestNotification(void) const
     99       
     100            /**
     101            @brief Sends a Notification displaying that a Quest was added.
     102            @return Returns true if successful.
     103            */
     104            inline bool sendAddQuestNotification(void) const
    106105                { return notificationHelper("quest", "start"); }
    107            
    108             /**
    109             @brief Sends a Notification displaying that a Quest was failed.
    110             @return Returns true if successful.
    111             */
    112             inline bool sendFailQuestNotification(void) const
     106       
     107            /**
     108            @brief Sends a Notification displaying that a Quest was failed.
     109            @return Returns true if successful.
     110            */
     111            inline bool sendFailQuestNotification(void) const
    113112                { return notificationHelper("quest", "fail"); }
    114            
    115             /**
    116             @brief Sends a Notification displaying that a Quest was completed.
    117             @return Returns true if successful.
    118             */
    119             inline bool sendCompleteQuestNotification(void) const
     113       
     114            /**
     115            @brief Sends a Notification displaying that a Quest was completed.
     116            @return Returns true if successful.
     117            */
     118            inline bool sendCompleteQuestNotification(void) const
    120119                { return notificationHelper("quest", "complete"); }
    121120
     
    149148                { this->failMessage_ = message; }
    150149               
    151             /**
     150            /**
    152151            @brief Sets the complete message.
    153152            @param message The complete message to be set.
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestEffect.cc

    r2261 r2352  
    2929/**
    3030    @file QuestEffect.cc
    31     @brief
    32     Implementation of the QuestEffect class.
     31    @brief Implementation of the QuestEffect class.
    3332*/
    3433
     
    7170        Returns false if there was an error, view console of log for further detail.
    7271    */
    73     bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)
     72    /*static*/ bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)
    7473    {
    7574        bool check = true;
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestEffect.h

    r2261 r2352  
    2929/**
    3030    @file QuestEffect.h
    31     @brief
    32     Definition of the QuestEffect class.
     31    @brief Definition of the QuestEffect class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2349 r2352  
    2929/**
    3030    @file QuestEffectBeacon.cc
    31     @brief
    32     Implementation of the QuestEffectBeacon class.
     31    @brief Implementation of the QuestEffectBeacon class.
    3332*/
    3433
     
    145144            this->decrementTimes(); //!< Decrement the number of times the beacon can be used.
    146145            return true;
    147     }
    148 
    149     return false;
     146        }
     147
     148        return false;
    150149    }
    151150   
     
    167166        if(activate)
    168167        {
    169             this->status_ = QuestEffectBeaconStatus::active;
    170             return true;
     168        this->status_ = QuestEffectBeaconStatus::active;
     169        return true;
    171170        }
    172171       
     
    193192       
    194193        this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed.
    195         if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
    196         {
    197                 this->status_ = QuestEffectBeaconStatus::inactive;
    198         }
    199            
     194        if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
     195        {
     196            this->status_ = QuestEffectBeaconStatus::inactive;
     197        }
     198       
    200199        return true;
    201200    }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2349 r2352  
    2929/**
    3030    @file QuestEffectBeacon.h
    31     @brief
    32     Definition of the QuestEffectBeacon class.
     31    @brief Definition of the QuestEffectBeacon class.
    3332*/
    3433
     
    6160        A QuestEffectBeacon can be inactive or active.
    6261       
    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             <EventListener event=eventIdString />
    74         </execute>
    75         </events>
    76         <attached>
    77            <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
    78         </attached>
    79     </QuestEffectBeacon>
     62        Creating a QuestEffectBeacon through XML goes as follows:
     63       
     64        <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.
     65            <effects>
     66                <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
     67                ...
     68                <QuestEffect />
     69            </effects>
     70            <events>
     71                <execute>
     72                    <EventListener event=eventIdString />
     73                </execute>
     74            </events>
     75            <attached>
     76                <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
     77            </attached>
     78        </QuestEffectBeacon>
    8079    @author
    8180        Damian 'Mozork' Frick
     
    8382    class _OrxonoxExport QuestEffectBeacon : public PositionableEntity
    8483    {
    85     public:
    86         QuestEffectBeacon(BaseObject* creator);
    87         virtual ~QuestEffectBeacon();
    88        
    89         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
    90        
    91         virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
    92        
    93         bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
    94        
    95         /**
    96         @brief Tests whether the QuestEffectBeacon is active.
    97         @return Returns true if the QuestEffectBeacon is active, fals if not.
    98         */
    99         inline bool isActive(void)
    100            { return this->status_ == QuestEffectBeaconStatus::active; }
    101        
    102         bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
    103        
    104     protected:
    105         bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
    106        
    107         /**
    108         @brief Returns the number of times the QUestEffectBeacon can still be executed.
    109         @return Returns the number of times the QUestEffectBeacon can still be executed.
    110         */
    111         inline const int & getTimes(void) const
    112             { return this->times_; }
    113 
    114     private:
    115         static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
     84        public:
     85            QuestEffectBeacon(BaseObject* creator);
     86            virtual ~QuestEffectBeacon();
     87           
     88            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
     89           
     90            virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
     91           
     92            bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
     93           
     94            /**
     95            @brief Tests whether the QuestEffectBeacon is active.
     96            @return Returns true if the QuestEffectBeacon is active, fals if not.
     97            */
     98            inline bool isActive(void)
     99            { return this->status_ == QuestEffectBeaconStatus::active; }
     100           
     101            bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
     102           
     103        protected:
     104            bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
     105           
     106            /**
     107            @brief Returns the number of times the QUestEffectBeacon can still be executed.
     108            @return Returns the number of times the QUestEffectBeacon can still be executed.
     109            */
     110            inline const int & getTimes(void) const
     111                { return this->times_; }
    116112   
    117         std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
    118         int times_; //!< Number of times the beacon can be exectued.
    119         QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
    120        
    121         bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
    122         bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
    123        
    124         const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
     113        private:
     114            static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
     115           
     116            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
     117            int times_; //!< Number of times the beacon can be exectued.
     118            QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
     119           
     120            bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
     121            bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
     122           
     123            const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
    125124   
    126125    };
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestHint.cc

    r2346 r2352  
    2929/**
    3030    @file QuestHint.cc
    31     @brief
    32     Implementation of the QuestHint class.
     31    @brief Implementation of the QuestHint class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestHint.h

    r2261 r2352  
    2929/**
    3030    @file QuestHint.h
    31     @brief
    32     Definition of the QuestHint class.
     31    @brief Definition of the QuestHint class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestItem.cc

    r2261 r2352  
    2929/**
    3030    @file QuestItem.cc
    31     @brief
    32     Implementation of the QuestItem class.
     31    @brief Implementation of the QuestItem class.
    3332*/
    3433
     
    102101        Clarify form, more vigorous checks.
    103102    */
    104     bool QuestItem::isId(const std::string & id)
     103    /*static*/ bool QuestItem::isId(const std::string & id)
    105104    {
    106105        return id.size() >= 32;
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestItem.h

    r2346 r2352  
    2929/**
    3030    @file QuestItem.h
    31     @brief
    32     Definition of the QuestItem class.
    33    
    34     The QuestItem is the parent class of Quest and QuestHint.
     31    @brief Definition of the QuestItem class.
     32        The QuestItem is the parent class of Quest and QuestHint.
    3533*/
    3634
     
    7169            inline const std::string & getId(void) const
    7270                { return this->id_; }
    73             /**
    74             @brief Returns the QuestDescription of the QuestItem.
    75             @return Returns a pointer to the QuestDescription object of the QuestItem.
    76             */
     71           
     72            /**
     73            @brief Returns the QuestDescription of the QuestItem.
     74            @return Returns a pointer to the QuestDescription object of the QuestItem.
     75            */
    7776            inline const QuestDescription* getDescription(void) const
    7877                { return this->description_; }
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.cc

    r2346 r2352  
    2727 */
    2828
     29/**
     30    @file QuestListener.cc
     31    @brief Implementation of the QuestListener class.
     32*/
     33
    2934#include "OrxonoxStableHeaders.h"
    3035#include "QuestListener.h"
     
    4045    CreateFactory(QuestListener);
    4146
     47    /**
     48    @brief
     49        Constructor. Registers the object and initializes variables.
     50    */
    4251    QuestListener::QuestListener(BaseObject* creator) : BaseObject(creator)
    4352    {
    4453        RegisterObject(QuestListener);
    4554       
    46         this->status_ = questListenerStatus::start;
     55        this->status_ = questListenerMode::all;
    4756        this->quest_ = NULL;
    4857    }
    4958   
     59    /**
     60    @brief
     61        Destructor.
     62    */
    5063    QuestListener::~QuestListener()
    5164    {
     
    6174
    6275        XMLPortParam(QuestListener, "questId", setQuestId, getQuestId, xmlelement, mode);
    63         XMLPortParam(QuestListener, "questStatus", setQuestStatus, getQuestStatus, xmlelement, mode);
    64 
    65         this->quest_->addListener(this);
    66        
    67         COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} and status '" << this->getQuestStatus() << "'." << std::endl;
    68     }
    69    
    70     void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status)
    71     {
    72         for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it)
     76        XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode);
     77
     78        this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners.
     79       
     80        COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getQuestStatus() << "'." << std::endl;
     81    }
     82   
     83    /**
     84    @brief
     85        Makes all QuestListener in the list aware that a certain status change has occured and executes them if the status change affects them.
     86    @param listeners
     87        The list of QuestListeners that have to be made aware of the status change.
     88    @param status
     89        The status that has changed. Can be 'start' (if the Quest was started), 'complete' (if the Quest was completed) or 'fail' (if the Quest was failed).
     90    */
     91    /* static */ void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status)
     92    {
     93        for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) //!< Iterate through all QuestListeners
    7394        {
    7495            QuestListener* listener = *it;
    75             if(listener->getQuestStatus() == status)
     96            if(listener->getMode() == status || listener->getMode() == questListenerMode::all) //!< Check whether the status change affects the give QuestListener.
    7697            {
    7798                listener->execute();
     
    80101    }
    81102   
     103    /**
     104    @brief
     105        Sets the questId of the Quest the QuestListener reacts to.
     106    @param id
     107        The questId of the Quest the QUestListener reacts to.
     108    @return
     109        Returns true if successful.
     110    */
     111    bool QuestListener::setQuestId(const std::string & id)
     112    {
     113        this->quest_ = QuestManager::findQuest(id); //!< Find the Quest corresponding to the given questId.
     114       
     115        if(this->quest_ == NULL) //!< If there is no such Quest.
     116        {
     117            COUT(1) << "This is bad! The QuestListener has not found a Quest qith a corresponding id." << std::endl; //TDO Throw a damn Exception!
     118            return false;
     119        }
     120       
     121        return true;
     122    }
     123   
     124    /**
     125    @brief
     126        Sets the mode of the QuestListener.
     127    @param mode
     128        The mode to be set. Can be eighter 'all', 'start', 'fail' or 'complete'.
     129    @return
     130        Returns true if successful.
     131    */
     132    bool QuestListener::setMode(const std::string & mode)
     133    {
     134        if(status == "all")
     135        {
     136            this->status_ = questListenerMode::all;
     137        }
     138        else if(status == "start")
     139        {
     140            this->status_ = questListenerMode::start;
     141        }
     142        else if(status == "fail")
     143        {
     144            this->status_ = questListenerMode::fail;
     145        }
     146        else if(status == "complete")
     147        {
     148            this->status_ = questListenerMode::complete;
     149        }
     150        else
     151        {
     152            COUT(2) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << std::endl;
     153            this->status_ = questListenerMode::all;
     154            return false;
     155        }
     156       
     157        return true;
     158    }
     159   
     160    /**
     161    @brief
     162        Get the mode of the QuestListener.
     163    @return
     164        Return the mode of the QuestListener. Can be eighter 'all', 'start', 'fail' or 'complete'.
     165    */
     166    const std::string QuestListener::getMode(void)
     167    {
     168        if(this->status_ == questListenerMode::all)
     169        {
     170            return "all";
     171        }
     172        else if(this->status_ == questListenerMode::start)
     173        {
     174            return "start";
     175        }
     176        else if(this->status_ == questListenerMode::fail)
     177        {
     178            return "fail";
     179        }
     180        else if(this->status_ == questListenerMode::complete)
     181        {
     182            return "complete";
     183        }
     184        else
     185        {
     186            COUT(1) << "An unforseen, never to happen, Error has occured. This is impossible!" << std::endl;
     187            return "";
     188        }
     189    }
     190
     191    /**
     192    @brief
     193        Executes the QuestListener, resp. fires an Event.
     194    @return
     195        Returns true if successful.
     196    */
    82197    bool QuestListener::execute()
    83198    {
     
    85200        return true;
    86201    }
    87    
    88     bool QuestListener::setQuestId(const std::string & id)
    89     {
    90         this->quest_ = QuestManager::findQuest(id);
    91         if(this->quest_ == NULL)
    92         {
    93             COUT(1) << "This is bad!" << std::endl; //TDO Find a better way.
    94             return false;
    95         }
    96        
    97         return true;
    98     }
    99    
    100     bool QuestListener::setQuestStatus(const std::string & status)
    101     {
    102         if(status == "start")
    103         {
    104             this->status_ = questListenerStatus::start;
    105             return true;
    106         }
    107         else if(status == "fail")
    108         {
    109             this->status_ = questListenerStatus::fail;
    110             return true;
    111         }
    112         else if(status == "complete")
    113         {
    114             this->status_ = questListenerStatus::complete;
    115             return true;
    116         }
    117         else
    118         {
    119             COUT(2) << "QuestListener with invalid status '" << status << "' created. Status set to 'start'." << std::endl;
    120             this->status_ = questListenerStatus::start;
    121             return false;
    122         }
    123     }
    124    
    125     const std::string QuestListener::getQuestStatus(void)
    126     {
    127         if(this->status_ == questListenerStatus::start)
    128         {
    129             return "start";
    130         }
    131         else if(this->status_ == questListenerStatus::fail)
    132         {
    133             return "fail";
    134         }
    135         else if(this->status_ == questListenerStatus::complete)
    136         {
    137             return "complete";
    138         }
    139         else
    140         {
    141             COUT(1) << "An unforseen, never to happen, Error has occured. This is impossible!" << std::endl;
    142             return "";
    143         }
    144     }
    145 
    146202
    147203}
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestListener.h

    r2346 r2352  
    2727 */
    2828
     29/**
     30    @file QuestListener.h
     31    @brief Definition of the QuestListener class.
     32*/
     33
    2934#ifndef _QuestListener_H__
    3035#define _QuestListener_H__
     
    3641
    3742#include "core/BaseObject.h"
     43
    3844#include "Quest.h"
    3945
    40 namespace questListenerStatus
     46namespace questListenerMode
    4147{
    4248
     49    //! The mode of the QuestListener.
    4350    enum Enum
    4451    {
     52        all,
    4553        start,
    4654        fail,
     
    5462    /**
    5563    @brief
     64        Provides a way to react to the starting, completing and failing of Quests.
    5665       
     66        The XML representation goes as follows:
     67        You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes.
     68       
     69        <BaseObject> // The object that should react to the status change of a Quest.
     70            <events>
     71                <function> // Where function is the method of the object that schould be executed. Normally this would be visibility or activity.
     72                    <QuestListener questId="someQuestId" mode="someMode" /> // Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail).
     73                </function>
     74            </events>
     75        </BaseObject>
    5776    @author
    5877        Damian 'Mozork' Frick
     
    6685            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML.
    6786           
    68             bool setQuestId(const std::string & id);
    69             bool setQuestStatus(const std::string & status);
     87            static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status); //!< Makes all QuestListener in the list aware that a certain status change has occured.
    7088           
    71             const std::string getQuestStatus(void);
     89            bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to.
     90            bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener.
     91           
     92            const std::string getMode(void); //!< Get the mode of the QuestListener.
     93           
     94            /**
     95            @brief Get the questId of the Quest the QuestListener reacts to.
     96            @return Returns the questId of the Quest the QuestListener reacts to.
     97            */
    7298            inline const std::string & getQuestId(void)
    7399                { return this->quest_->getId(); }
    74                
    75             static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status);
    76100           
    77             bool execute(void);
     101            bool execute(void); //!< Executes the QuestListener, resp. fires an Event.
    78102           
    79103        private:
    80             questListenerStatus::Enum status_;
    81             Quest* quest_;
     104            questListenerMode::Enum mode_; //!< The mode of the QuestListener.
     105            Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
    82106   
    83107    };
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestManager.cc

    r2261 r2352  
    2929/**
    3030    @file QuestManager.cc
    31     @brief
    32     Implementation of the QuestManager class.
     31    @brief Implementation of the QuestManager class.
    3332*/
    3433
     
    7675        Returns true if successful, false if not.
    7776    */
    78     bool QuestManager::registerQuest(Quest* quest)
     77    /*static*/ bool QuestManager::registerQuest(Quest* quest)
    7978    {
    8079        if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers.
     
    108107        Returns true if successful, false if not.
    109108    */
    110     bool QuestManager::registerHint(QuestHint* hint)
     109    /*static*/ bool QuestManager::registerHint(QuestHint* hint)
    111110    {
    112111        if(hint == NULL) //!< Still not liking NULL-pointers.
     
    142141        Throws an exception if the given questId is invalid.
    143142    */
    144     Quest* QuestManager::findQuest(const std::string & questId)
     143    /*static*/ Quest* QuestManager::findQuest(const std::string & questId)
    145144    {
    146145        if(!QuestItem::isId(questId)) //!< Check vor validity of the given id.
     
    176175        Throws an exception if the given hintId is invalid.
    177176    */
    178     QuestHint* QuestManager::findHint(const std::string & hintId)
     177    /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId)
    179178    {
    180179        if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id.
  • code/branches/questsystem3/src/orxonox/objects/quest/QuestManager.h

    r2261 r2352  
    2929/**
    3030    @file QuestManager.h
    31     @brief
    32     Definition of the QuestManager class.
     31    @brief Definition of the QuestManager class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/Rewardable.cc

    r2261 r2352  
    2929/**
    3030    @file Rewardable.cc
    31     @brief
    32     Implementation of the Rewardable class.
     31    @brief Implementation of the Rewardable class.
    3332*/
    3433
  • code/branches/questsystem3/src/orxonox/objects/quest/Rewardable.h

    r2261 r2352  
    2929/**
    3030    @file Rewardable.h
    31     @brief
    32     Definition of the Rewardable class.
     31    @brief Definition of the Rewardable class.
    3332*/
    3433
     
    6160                Method to transcribe a rewardable object to the player.
    6261                Must be implemented by every class inheriting from Rewardable.
    63         @param player
     62            @param player
    6463                A pointer to the ControllableEntity, do whatever you want with it.
    65         @return
     64            @return
    6665                Return true if successful.
    6766            */
    68             virtual bool reward(PlayerInfo* player) = 0; //!<
     67            virtual bool reward(PlayerInfo* player) = 0;
    6968
    7069    };
Note: See TracChangeset for help on using the changeset viewer.