Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/questsystem/QuestDescription.cc @ 7456

Last change on this file since 7456 was 7456, checked in by dafrick, 14 years ago

Reviewing documentation fo Questsystem, moving documentation fully into doxygen.
Added some files to modules they belong to.

  • Property svn:eol-style set to native
File size: 3.7 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 QuestDescription.cc
31    @brief Implementation of the QuestDescription class.
32*/
33
34
35#include "QuestDescription.h"
36
37#include "core/CoreIncludes.h"
38#include "core/XMLPort.h"
39
40#include "QuestNotification.h"
41
42namespace orxonox
43{
44    CreateFactory(QuestDescription);
45
46    /**
47    @brief
48        Constructor. Registers and initializes the object.
49    */
50    QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator)
51    {
52        RegisterObject(QuestDescription);
53    }
54
55    /**
56    @brief
57        Destructor.
58    */
59    QuestDescription::~QuestDescription()
60    {
61
62    }
63
64    /**
65    @brief
66        Method for creating a QuestDescription object through XML.
67    */
68    void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode)
69    {
70        SUPER(QuestDescription, XMLPort, xmlelement, mode);
71
72        XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode);
73        XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode);
74        XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
75        XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
76
77        COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
78    }
79
80    /**
81    @brief
82        This method is a helper for sending QuestDescriptions as Notifications.
83    @param item
84        The item the QuestDescription is for.
85    @param status
86        The status the QuestDescription us for.
87    @param player
88        The player the Notification is sent to.
89    @return
90        Returns true if successful.
91    */
92    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status, PlayerInfo* player)
93    {
94        std::string message;
95        if(item == "hint")
96            message = "You received a hint: '" + this->title_ + '\'';
97        else if(item == "quest")
98        {
99            if(status == "start")
100                message = "You received a new quest: '" + this->title_ + '\'';
101            else if(status == "fail")
102                message = "You failed the quest: '" + this->title_ + '\'';
103            else if(status == "complete")
104                message = "You successfully completed the quest: '" + this->title_ + '\'';
105            else
106            {
107                COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
108                return false;
109            }
110        }
111        else
112        {
113            COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
114            return false;
115        }
116
117        QuestNotification* notification = new QuestNotification(this, message);
118        notification->send(player);
119        return true;
120    }
121
122
123}
Note: See TracBrowser for help on using the repository browser.