Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

updated msvc files and precompiled headers.

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