Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/orxonox/objects/quest/QuestHint.cc @ 2274

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

updated msvc files and precompiled headers.

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 "OrxonoxStableHeaders.h"
30#include "QuestHint.h"
31
32#include "core/CoreIncludes.h"
33#include "util/Exception.h"
34
35#include "Quest.h"
36
37namespace orxonox {
38
39    CreateFactory(QuestHint);
40
41    /**
42    @brief
43        Constructor.
44    */
45    QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator)
46    {
47        RegisterObject(QuestHint);
48
49        this->initialize();
50    }
51
52    /**
53    @brief
54        Destructor.
55    */
56    QuestHint::~QuestHint()
57    {
58
59    }
60
61    void QuestHint::initialize(void)
62    {
63        RegisterObject(QuestHint);
64    }
65
66    void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
67    {
68        SUPER(QuestHint, XMLPort, xmlelement, mode);
69
70        COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
71    }
72
73
74    /**
75    @brief
76        Checks whether the hint is active for a specific player.
77    @param player
78        The player.
79    @throws
80        Throws an Argument Exception if the input Player-pointer is NULL.
81    @return
82        Returns true if the hint is active for the specified player.
83    */
84    bool QuestHint::isActive(Player* player)
85    {
86        if(player == NULL)
87        {
88            ThrowException(Argument, "The input Player* is NULL.");
89            return false;
90        }
91
92        std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
93        if (it != this->playerStatus_.end())
94        {
95            return it->second;
96        }
97        return questStatus::inactive;
98    }
99
100    /**
101    @brief
102        Activates a QuestHint for a given player.
103    @param player
104        The player.
105    @return
106        Returns true if the activation was successful, false if there were problems.
107    */
108    bool QuestHint::activate(Player* player)
109    {
110        if(this->quest_->isActive(player))
111        {
112            if(!(this->isActive(player)))
113            {
114                this->playerStatus_[player] = questHintStatus::active;
115                return true;
116            }
117            else
118            {
119                COUT(2) << "An already active questHint was trying to get activated." << std::endl;
120                return false;
121            }
122        }
123        COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
124        return false;
125    }
126
127    /**
128    @brief
129        Sets the quest the QuestHitn belongs to.
130    @param quest
131    @return
132    */
133    bool QuestHint::setQuest(Quest* quest)
134    {
135        if(quest == NULL)
136        {
137            COUT(2) << "The input Quest* is NULL." << std::endl;
138            return false;
139        }
140
141        this->quest_ = quest;
142        return true;
143    }
144
145}
Note: See TracBrowser for help on using the repository browser.