Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem3/src/orxonox/objects/quest/AddQuest.cc @ 2329

Last change on this file since 2329 was 2328, checked in by dafrick, 15 years ago
  • Created QuestListeners, they can be used to affect Objects due to status changes of quests.
File size: 3.0 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/**
30    @file AddQuest.cc
31    @brief
32    Implementation of the AddQuest class.
33*/
34
35#include "OrxonoxStableHeaders.h"
36#include "AddQuest.h"
37
38#include <string>
39
40#include "core/CoreIncludes.h"
41#include "util/Exception.h"
42
43#include "orxonox/objects/infos/PlayerInfo.h"
44#include "orxonox/overlays/notifications/Notification.h"
45#include "QuestManager.h"
46#include "Quest.h"
47
48namespace orxonox {
49
50    CreateFactory(AddQuest);
51
52    /**
53    @brief
54        Constructor. Registers the object.
55    */
56    AddQuest::AddQuest(BaseObject* creator) : ChangeQuestStatus(creator)
57    {
58        RegisterObject(AddQuest);
59    }
60
61    /**
62    @brief
63        Destructor.
64    */
65    AddQuest::~AddQuest()
66    {
67    }
68
69    /**
70    @brief
71        Method for creating a AddQuest object through XML.
72    */
73    void AddQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode)
74    {
75        SUPER(AddQuest, XMLPort, xmlelement, mode);
76       
77        COUT(3) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
78    }
79
80    /**
81    @brief
82        Invokes the QuestEffect.
83    @param player
84        The player the QuestEffect is invoked on.
85    @return
86        Returns true if the QuestEffect was successfully invoked.
87    */
88    bool AddQuest::invoke(PlayerInfo* player)
89    {
90        if(player == NULL) //!< Null-pointers are badass.
91        {
92            COUT(2) << "Input player is NULL." << std::endl;
93            return false;
94        }
95
96        COUT(3) << "AddQuest on player: " << player << " ." << std::endl;
97
98        try
99        {
100            Quest* quest = QuestManager::findQuest(this->getQuestId());
101            if(quest == NULL || !quest->start(player))
102            {
103               return false;
104            }
105        }
106        catch(const orxonox::Exception& ex)
107        {
108            COUT(2) << ex.getFullDescription() << std::endl;
109            return false;
110        }
111
112        COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl;
113        Notification* notification = new Notification("Crazy Message...", "Title", 30);
114        notification->send();
115        return true;
116    }
117
118
119}
Note: See TracBrowser for help on using the repository browser.