Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/QuestHint.cc @ 2092

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