Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/LocalQuest.cc @ 2093

Last change on this file since 2093 was 2093, checked in by landauf, 16 years ago

converted tabs to spaces

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