Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 4:19:44 PM (15 years ago)
Author:
dafrick
Message:

Merged questsystem3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/objects/quest/Quest.cc

    r2371 r2385  
    2929/**
    3030    @file Quest.cc
    31     @brief
    32     Implementation of the Quest class.
     31    @brief Implementation of the Quest class.
    3332*/
    3433
     
    4342#include "QuestHint.h"
    4443#include "QuestEffect.h"
     44#include "QuestListener.h"
    4545
    4646namespace orxonox {
     
    363363        return this->getStatus(player) == questStatus::completed;
    364364    }
     365   
     366    /**
     367    @brief
     368        Fails the Quest for an input player.
     369    @param player
     370        The player.
     371    @return
     372        Returns true if the Quest could be failed, false if not.
     373    */
     374    bool Quest::fail(PlayerInfo* player)
     375    {
     376        QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed.
     377        this->setStatus(player, questStatus::failed);
     378       
     379        COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl;
     380       
     381        this->getDescription()->sendFailQuestNotification();
     382        return true;
     383    }
     384   
     385    /**
     386    @brief
     387        Completes the Quest for an input player.
     388    @param player
     389        The player.
     390    @return
     391        Returns true if the Quest could be completed, false if not.
     392    */
     393    bool Quest::complete(PlayerInfo* player)
     394    {
     395        QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed.
     396        this->setStatus(player, questStatus::completed);
     397       
     398        COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl;
     399       
     400        this->getDescription()->sendCompleteQuestNotification();
     401        return true;
     402    }
    365403
    366404    /**
     
    374412    bool Quest::start(PlayerInfo* player)
    375413    {
    376         if(this->isStartable(player)) //!< Checks whether the quest can be started.
    377         {
    378             this->setStatus(player, questStatus::active);
    379             return true;
    380         }
    381        
    382         COUT(4) << "A non-startable quest was trying to be started." << std::endl;
    383         return false;
     414        if(!this->isStartable(player)) //!< Checks whether the quest can be started.
     415        {
     416            COUT(4) << "A non-startable quest was trying to be started." << std::endl;
     417            return false;
     418        }
     419       
     420        COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl;
     421       
     422        QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active.
     423       
     424        this->setStatus(player, questStatus::active);
     425       
     426        this->getDescription()->sendAddQuestNotification();
     427        return true;
     428    }
     429   
     430    /**
     431    @brief
     432        Adds a QuestListener to the list of QuestListeners listening to this Quest.
     433    @param listener
     434        The QuestListener to be added.
     435    @return
     436        Returns true if successful, false if not.
     437    */
     438    bool Quest::addListener(QuestListener* listener)
     439    {
     440        if(listener == NULL)
     441        {
     442            COUT(2) << "A NULL-QuestListener was trying to be added to a Quests listeners." << std::endl;
     443            return false;
     444        }
     445       
     446        this->listeners_.push_back(listener);
     447        return true;
    384448    }
    385449
Note: See TracChangeset for help on using the changeset viewer.