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
Line 
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"
30#include "util/Exception.h"
31
32#include "LocalQuest.h"
33
34namespace orxonox {
35
36    CreateFactory(LocalQuest);
37
38    LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator)
39    {
40        RegisterObject(LocalQuest);
41
42        this->initialize();
43    }
44
45    /**
46    @brief
47        Destructor.
48    */
49    LocalQuest::~LocalQuest()
50    {
51
52    }
53
54    void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
55    {
56        SUPER(LocalQuest, XMLPort, xmlelement, mode);
57
58        COUT(3) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
59    }
60
61    void LocalQuest::initialize(void)
62    {
63        RegisterObject(LocalQuest);
64    }
65
66    /**
67    @brief
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.
73    @throws
74        Throws an exception if isInactive(Player*) throws one.
75    */
76    bool LocalQuest::isStartable(const Player* player) const
77    {
78        return this->isInactive(player);
79    }
80
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.
88    @throws
89        Throws an exception if isActive(Player*) throws one.
90    */
91    bool LocalQuest::isFailable(const Player* player) const
92    {
93        return this->isActive(player);
94    }
95
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.
103    @throws
104        Throws an exception if isInactive(Player*) throws one.
105    */
106    bool LocalQuest::isCompletable(const Player* player) const
107    {
108        return this->isActive(player);
109    }
110
111    /**
112    @brief
113        Returns the status of the quest for a specific player.
114    @param player
115        The player.
116    @return
117        Returns the status of the quest for the input player.
118    @throws
119        Throws an Exception if player is NULL.
120    */
121    questStatus::Enum LocalQuest::getStatus(const Player* player) const
122    {
123        if(player == NULL)
124        {
125            ThrowException(Argument, "The input Player* is NULL.");
126        }
127
128        std::map<Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'.
129        if (it != this->playerStatus_.end())
130        {
131            return it->second;
132        }
133        return questStatus::inactive;
134    }
135
136    /**
137    @brief
138        Sets the status for a specific player.
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.
140    @param player
141        The player.
142    @param status
143        The status.
144    @return
145        Returns false if player is NULL.
146    */
147    bool LocalQuest::setStatus(Player* player, const questStatus::Enum & status)
148    {
149        if(player == NULL)
150        {
151            return false;
152        }
153        this->playerStatus_[player] = status;
154        return true;
155    }
156
157}
Note: See TracBrowser for help on using the repository browser.