Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Started with XMLPort…

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