Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/GlobalQuest.cc @ 2110

Last change on this file since 2110 was 2105, checked in by rgrieder, 16 years ago

updated msvc files and precompiled headers.

File size: 4.3 KB
RevLine 
[1992]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[2105]29#include "OrxonoxStableHeaders.h"
30#include "GlobalQuest.h"
31
[1992]32#include "core/CoreIncludes.h"
[2068]33#include "util/Exception.h"
[1992]34
35namespace orxonox {
36
37    CreateFactory(GlobalQuest);
38
[2068]39    /**
40    @brief
41        Constructor.
42    */
[2092]43    GlobalQuest::GlobalQuest(BaseObject* creator) : Quest(creator)
[2021]44    {
[2092]45        RegisterObject(GlobalQuest);
46
[2068]47        this->initialize();
[2021]48    }
[2092]49
[1992]50    /**
51    @brief
52        Destructor.
53    */
54    GlobalQuest::~GlobalQuest()
55    {
[2092]56
[1992]57    }
[2092]58
[2076]59    void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
60    {
61        SUPER(GlobalQuest, XMLPort, xmlelement, mode);
62
[2081]63        COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
[2076]64    }
[2092]65
[2068]66    void GlobalQuest::initialize(void)
67    {
68        RegisterObject(GlobalQuest);
69    }
[2092]70
[1996]71    /**
72    @brief
73        Checks whether the quest can be started.
74    @param player
75        The player for whom is to be checked.
76    @return
77        Returns true if the quest can be started, false if not.
[2068]78    @throws
79        Throws an exception if either isInactive() of isActive() throws one.
[1996]80    */
[2043]81    bool GlobalQuest::isStartable(const Player* player) const
[1996]82    {
[2068]83        return this->isInactive(player) ||  this->isActive(player);
[1996]84    }
[2092]85
[1996]86    /**
87    @brief
88        Checks whether the quest can be failed.
89    @param player
90        The player for whom is to be checked.
91    @return
92        Returns true if the quest can be failed, false if not.
[2068]93    @throws
94        Throws an Exception if isActive() throws one.
[1996]95    */
[2043]96    bool GlobalQuest::isFailable(const Player* player) const
[1996]97    {
98        return this->isActive(player);
[2068]99
[1996]100    }
[2092]101
[1996]102    /**
103    @brief
104        Checks whether the quest can be completed.
105    @param player
106        The player for whom is to be checked.
107    @return
108        Returns true if the quest can be completed, false if not.
[2068]109    @throws
110        Throws an Exception if isActive() throws one.
[1996]111    */
[2043]112    bool GlobalQuest::isCompletable(const Player* player) const
[1996]113    {
114        return this->isActive(player);
115    }
[1992]116
117    /**
118    @brief
119        Returns the status of the quest for a specific player.
120    @param player
121        The player.
[2068]122    @throws
123        Throws an Exception if player is NULL.
[1992]124    */
[2043]125    questStatus::Enum GlobalQuest::getStatus(const Player* player) const
[1992]126    {
[2068]127        if(player == NULL)
128        {
129            ThrowException(Argument, "The input Player* is NULL.");
130        }
[2092]131
[1992]132        //TDO: Does this really work???
[2021]133        std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player);
134        if (it != this->players_.end())
[2093]135        {
136            return this->status_;
137        }
138        else
139        {
140           return questStatus::inactive;
141        }
[1992]142
143    }
[2092]144
[1992]145    /**
146    @brief
147        Sets the status for a specific player.
[2093]148        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.
[1992]149    @param player
150        The player.
151    @param status
152        The status to be set.
[2068]153    @return
154        Returns false if player is NULL.
[1992]155    */
[2021]156    bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status)
[1992]157    {
[2068]158        if(player == NULL)
159        {
160            return false;
[2093]161        }
[2092]162
[2021]163        std::set<Player*>::const_iterator it = this->players_.find(player);
164        if (it == this->players_.end()) //!< Player is not yet in the list.
[2093]165        {
166            this->players_.insert(player);
167        }
168        this->status_ = status;
169        return true;
[1992]170    }
171
[1996]172
[1992]173}
Note: See TracBrowser for help on using the repository browser.