Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem/src/orxonox/objects/QuestHint.cc @ 2138

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

Ready for merge! (It won't compile after the merge, though ;) )

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