Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem/src/orxonox/objects/LocalQuest.cc @ 2076

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

Completed XMLPort for all objects.

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