[1996] | 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 | |
---|
[2261] | 29 | /** |
---|
[7456] | 30 | @file QuestDescription.cc |
---|
[2662] | 31 | @brief Implementation of the QuestDescription class. |
---|
[2261] | 32 | */ |
---|
| 33 | |
---|
| 34 | |
---|
[2105] | 35 | #include "QuestDescription.h" |
---|
| 36 | |
---|
[1996] | 37 | #include "core/CoreIncludes.h" |
---|
[3196] | 38 | #include "core/XMLPort.h" |
---|
[7456] | 39 | |
---|
[2911] | 40 | #include "QuestNotification.h" |
---|
[2021] | 41 | |
---|
[2662] | 42 | namespace orxonox |
---|
| 43 | { |
---|
[1996] | 44 | CreateFactory(QuestDescription); |
---|
[2092] | 45 | |
---|
[2261] | 46 | /** |
---|
| 47 | @brief |
---|
| 48 | Constructor. Registers and initializes the object. |
---|
| 49 | */ |
---|
[2092] | 50 | QuestDescription::QuestDescription(BaseObject* creator) : BaseObject(creator) |
---|
[1996] | 51 | { |
---|
[2092] | 52 | RegisterObject(QuestDescription); |
---|
[2021] | 53 | } |
---|
[2092] | 54 | |
---|
[2261] | 55 | /** |
---|
| 56 | @brief |
---|
| 57 | Destructor. |
---|
| 58 | */ |
---|
[1996] | 59 | QuestDescription::~QuestDescription() |
---|
| 60 | { |
---|
[2092] | 61 | |
---|
[1996] | 62 | } |
---|
[2092] | 63 | |
---|
[2261] | 64 | /** |
---|
| 65 | @brief |
---|
| 66 | Method for creating a QuestDescription object through XML. |
---|
| 67 | */ |
---|
[2068] | 68 | void QuestDescription::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 69 | { |
---|
| 70 | SUPER(QuestDescription, XMLPort, xmlelement, mode); |
---|
[2092] | 71 | |
---|
[2068] | 72 | XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode); |
---|
| 73 | XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); |
---|
[2662] | 74 | XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode); |
---|
| 75 | XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); |
---|
[2092] | 76 | |
---|
[7163] | 77 | COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; |
---|
[2068] | 78 | } |
---|
[6417] | 79 | |
---|
[2662] | 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. |
---|
[7403] | 87 | @param player |
---|
| 88 | The player the Notification is sent to. |
---|
[2662] | 89 | @return |
---|
| 90 | Returns true if successful. |
---|
| 91 | */ |
---|
[7403] | 92 | bool QuestDescription::notificationHelper(const std::string & item, const std::string & status, PlayerInfo* player) |
---|
[2662] | 93 | { |
---|
[6417] | 94 | std::string message; |
---|
[2662] | 95 | if(item == "hint") |
---|
[6417] | 96 | message = "You received a hint: '" + this->title_ + '\''; |
---|
[2662] | 97 | else if(item == "quest") |
---|
| 98 | { |
---|
| 99 | if(status == "start") |
---|
[6417] | 100 | message = "You received a new quest: '" + this->title_ + '\''; |
---|
[2662] | 101 | else if(status == "fail") |
---|
[6417] | 102 | message = "You failed the quest: '" + this->title_ + '\''; |
---|
[2662] | 103 | else if(status == "complete") |
---|
[6417] | 104 | message = "You successfully completed the quest: '" + this->title_ + '\''; |
---|
[2662] | 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 | } |
---|
[6417] | 116 | |
---|
[7163] | 117 | QuestNotification* notification = new QuestNotification(this, message); |
---|
[7403] | 118 | notification->send(player); |
---|
[2662] | 119 | return true; |
---|
| 120 | } |
---|
[2092] | 121 | |
---|
[1996] | 122 | |
---|
| 123 | } |
---|