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/GlobalQuest.cc

    r2371 r2385  
    2929/**
    3030    @file GlobalQuest.cc
    31     @brief
    32     Implementation of the GlobalQuest class.
     31    @brief Implementation of the GlobalQuest class.
    3332*/
    3433
     
    3837#include "orxonox/objects/infos/PlayerInfo.h"
    3938#include "core/CoreIncludes.h"
     39#include "core/Super.h"
    4040#include "util/Exception.h"
    4141
     
    8888    bool GlobalQuest::fail(PlayerInfo* player)
    8989    {
    90         if(this->isFailable(player)) //!< Check whether the Quest can be failed.
    91         {
    92             this->setStatus(player, questStatus::failed);
    93            
    94             //! Iterate through all players possessing this Quest.
    95             for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    96             {
    97                 QuestEffect::invokeEffects(*it, this->getFailEffectList());
    98             }
    99 
    100             return true;
    101         }
    102        
    103         COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
    104         return false;
     90        if(!this->isFailable(player)) //!< Check whether the Quest can be failed.
     91        {
     92            COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
     93            return false;
     94        }
     95       
     96        Quest::fail(player);
     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;
    105105    }
    106106
     
    117117    bool GlobalQuest::complete(PlayerInfo* player)
    118118    {
    119         if(this->isCompletable(player)) //!< Check whether the Quest can be completed.
    120         {
    121             this->setStatus(player, questStatus::completed);
    122            
    123             //! Iterate through all players possessing the Quest.
    124             for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    125             {
    126                 QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
    127             }
    128            
    129             QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
    130             return true;
    131         }
    132        
    133         COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
    134         return false;
     119        if(!this->isCompletable(player)) //!< Check whether the Quest can be completed.
     120        {
     121            COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
     122            return false;
     123        }
     124       
     125        //! Iterate through all players possessing the Quest.
     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;
    135135    }
    136136
     
    207207        }
    208208
    209     return questStatus::inactive;
     209        return questStatus::inactive;
    210210    }
    211211
Note: See TracChangeset for help on using the changeset viewer.