Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Some minor adjustements, just comitting to be on the safe side.

File size: 3.5 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
31#include "GlobalQuest.h"
32
33namespace orxonox {
34
35    CreateFactory(GlobalQuest);
36
37    GlobalQuest::GlobalQuest() : Quest()
38    {
39       
40    }
41
42    /**
43    @brief
44        Constructor.
45    @param id
46        The unique identifier.
47    @param title
48        The title of the quest.
49    @param description
50        The description of the quest.
51    */
52    GlobalQuest::GlobalQuest(std::string id, std::string title, std::string description) : Quest(id, title, description)
53    {
54        RegisterObject(GlobalQuest);
55    }
56   
57    /**
58    @brief
59        Destructor.
60    */
61    GlobalQuest::~GlobalQuest()
62    {
63       
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    */
74    bool GlobalQuest::isStartable(const Player* player) const
75    {
76        return this->isInactive(player) || this->isActive(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    */
87    bool GlobalQuest::isFailable(const Player* player) const
88    {
89        return this->isActive(player);
90    }
91   
92    /**
93    @brief
94        Checks whether the quest can be completed.
95    @param player
96        The player for whom is to be checked.
97    @return
98        Returns true if the quest can be completed, false if not.
99    */
100    bool GlobalQuest::isCompletable(const Player* player) const
101    {
102        return this->isActive(player);
103    }
104
105    /**
106    @brief
107        Returns the status of the quest for a specific player.
108    @param player
109        The player.
110    */
111    questStatus::Enum GlobalQuest::getStatus(const Player* player) const
112    {
113        //TDO: Does this really work???
114        std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player);
115        if (it != this->players_.end())
116        {
117            return this->status_;
118        }
119        else
120        {
121           return questStatus::inactive;
122        }
123
124    }
125   
126    /**
127    @brief
128        Sets the status for a specific player.
129    @param player
130        The player.
131    @param status
132        The status to be set.
133    */
134    bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status)
135    {
136        std::set<Player*>::const_iterator it = this->players_.find(player);
137        if (it == this->players_.end()) //!< Player is not yet in the list.
138        {
139            this->players_.insert(player);
140        }
141        this->status_ = status;
142        return true;
143    }
144
145
146}
Note: See TracBrowser for help on using the repository browser.