Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem/src/orxonox/objects/GlobalQuest.cc @ 2255

Last change on this file since 2255 was 2081, checked in by dafrick, 16 years ago

Ready for merge! (It won't compile after the merge, though ;) )

File size: 4.2 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
29#include "core/CoreIncludes.h"
[2068]30#include "util/Exception.h"
[1992]31
32#include "GlobalQuest.h"
33
34namespace orxonox {
35
36    CreateFactory(GlobalQuest);
37
[2068]38    /**
39    @brief
40        Constructor.
41    */
[2021]42    GlobalQuest::GlobalQuest() : Quest()
43    {
[2068]44        this->initialize();
[2021]45    }
[1992]46   
47    /**
48    @brief
49        Destructor.
50    */
51    GlobalQuest::~GlobalQuest()
52    {
53       
54    }
[1996]55   
[2076]56    void GlobalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
57    {
58        SUPER(GlobalQuest, XMLPort, xmlelement, mode);
59
[2081]60        COUT(3) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
[2076]61    }
62   
[2068]63    void GlobalQuest::initialize(void)
64    {
65        RegisterObject(GlobalQuest);
66    }
67   
[1996]68    /**
69    @brief
70        Checks whether the quest can be started.
71    @param player
72        The player for whom is to be checked.
73    @return
74        Returns true if the quest can be started, false if not.
[2068]75    @throws
76        Throws an exception if either isInactive() of isActive() throws one.
[1996]77    */
[2043]78    bool GlobalQuest::isStartable(const Player* player) const
[1996]79    {
[2068]80        return this->isInactive(player) ||  this->isActive(player);
[1996]81    }
82   
83    /**
84    @brief
85        Checks whether the quest can be failed.
86    @param player
87        The player for whom is to be checked.
88    @return
89        Returns true if the quest can be failed, false if not.
[2068]90    @throws
91        Throws an Exception if isActive() throws one.
[1996]92    */
[2043]93    bool GlobalQuest::isFailable(const Player* player) const
[1996]94    {
95        return this->isActive(player);
[2068]96
[1996]97    }
98   
99    /**
100    @brief
101        Checks whether the quest can be completed.
102    @param player
103        The player for whom is to be checked.
104    @return
105        Returns true if the quest can be completed, false if not.
[2068]106    @throws
107        Throws an Exception if isActive() throws one.
[1996]108    */
[2043]109    bool GlobalQuest::isCompletable(const Player* player) const
[1996]110    {
111        return this->isActive(player);
112    }
[1992]113
114    /**
115    @brief
116        Returns the status of the quest for a specific player.
117    @param player
118        The player.
[2068]119    @throws
120        Throws an Exception if player is NULL.
[1992]121    */
[2043]122    questStatus::Enum GlobalQuest::getStatus(const Player* player) const
[1992]123    {
[2068]124        if(player == NULL)
125        {
126            ThrowException(Argument, "The input Player* is NULL.");
127        }
128       
[1992]129        //TDO: Does this really work???
[2021]130        std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player);
131        if (it != this->players_.end())
[1992]132        {
133            return this->status_;
134        }
135        else
136        {
137           return questStatus::inactive;
138        }
139
140    }
141   
142    /**
143    @brief
144        Sets the status for a specific player.
[2068]145        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]146    @param player
147        The player.
148    @param status
149        The status to be set.
[2068]150    @return
151        Returns false if player is NULL.
[1992]152    */
[2021]153    bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status)
[1992]154    {
[2068]155        if(player == NULL)
156        {
157            return false;
158        }
159       
[2021]160        std::set<Player*>::const_iterator it = this->players_.find(player);
161        if (it == this->players_.end()) //!< Player is not yet in the list.
[1996]162        {
[2021]163            this->players_.insert(player);
[1996]164        }
165        this->status_ = status;
[2021]166        return true;
[1992]167    }
168
[1996]169
[1992]170}
Note: See TracBrowser for help on using the repository browser.