| [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 |  | 
|---|
| [2105] | 29 | #include "OrxonoxStableHeaders.h" | 
|---|
 | 30 | #include "LocalQuest.h" | 
|---|
 | 31 |  | 
|---|
| [1992] | 32 | #include "core/CoreIncludes.h" | 
|---|
| [2068] | 33 | #include "util/Exception.h" | 
|---|
| [1992] | 34 |  | 
|---|
 | 35 | namespace orxonox { | 
|---|
 | 36 |  | 
|---|
 | 37 |     CreateFactory(LocalQuest); | 
|---|
 | 38 |  | 
|---|
| [2092] | 39 |     LocalQuest::LocalQuest(BaseObject* creator) : Quest(creator) | 
|---|
| [2021] | 40 |     { | 
|---|
| [2092] | 41 |         RegisterObject(LocalQuest); | 
|---|
 | 42 |  | 
|---|
| [2068] | 43 |         this->initialize(); | 
|---|
| [2021] | 44 |     } | 
|---|
| [2092] | 45 |  | 
|---|
| [1992] | 46 |     /** | 
|---|
 | 47 |     @brief | 
|---|
 | 48 |         Destructor. | 
|---|
 | 49 |     */ | 
|---|
 | 50 |     LocalQuest::~LocalQuest() | 
|---|
 | 51 |     { | 
|---|
| [2092] | 52 |  | 
|---|
| [1992] | 53 |     } | 
|---|
| [2092] | 54 |  | 
|---|
| [2076] | 55 |     void LocalQuest::XMLPort(Element& xmlelement, XMLPort::Mode mode) | 
|---|
 | 56 |     { | 
|---|
 | 57 |         SUPER(LocalQuest, XMLPort, xmlelement, mode); | 
|---|
 | 58 |  | 
|---|
| [2081] | 59 |         COUT(3) << "New LocalQuest {" << this->getId() << "} created." << std::endl; | 
|---|
| [2076] | 60 |     } | 
|---|
| [2092] | 61 |  | 
|---|
| [2068] | 62 |     void LocalQuest::initialize(void) | 
|---|
 | 63 |     { | 
|---|
 | 64 |         RegisterObject(LocalQuest); | 
|---|
 | 65 |     } | 
|---|
| [2092] | 66 |  | 
|---|
| [1992] | 67 |     /** | 
|---|
 | 68 |     @brief | 
|---|
| [1996] | 69 |         Checks whether the quest can be started. | 
|---|
 | 70 |     @param player | 
|---|
 | 71 |         The player for whom is to be checked. | 
|---|
 | 72 |     @return | 
|---|
 | 73 |         Returns true if the quest can be started, false if not. | 
|---|
| [2068] | 74 |     @throws | 
|---|
 | 75 |         Throws an exception if isInactive(Player*) throws one. | 
|---|
| [1996] | 76 |     */ | 
|---|
| [2043] | 77 |     bool LocalQuest::isStartable(const Player* player) const | 
|---|
| [1996] | 78 |     { | 
|---|
 | 79 |         return this->isInactive(player); | 
|---|
 | 80 |     } | 
|---|
| [2092] | 81 |  | 
|---|
| [1996] | 82 |     /** | 
|---|
 | 83 |     @brief | 
|---|
 | 84 |         Checks whether the quest can be failed. | 
|---|
 | 85 |     @param player | 
|---|
 | 86 |         The player for whom is to be checked. | 
|---|
 | 87 |     @return | 
|---|
 | 88 |         Returns true if the quest can be failed, false if not. | 
|---|
| [2068] | 89 |     @throws | 
|---|
 | 90 |         Throws an exception if isActive(Player*) throws one. | 
|---|
| [1996] | 91 |     */ | 
|---|
| [2043] | 92 |     bool LocalQuest::isFailable(const Player* player) const | 
|---|
| [1996] | 93 |     { | 
|---|
 | 94 |         return this->isActive(player); | 
|---|
 | 95 |     } | 
|---|
| [2092] | 96 |  | 
|---|
| [1996] | 97 |     /** | 
|---|
 | 98 |     @brief | 
|---|
 | 99 |         Checks whether the quest can be completed. | 
|---|
 | 100 |     @param player | 
|---|
 | 101 |         The player for whom is to be checked. | 
|---|
 | 102 |     @return | 
|---|
 | 103 |         Returns true if the quest can be completed, false if not. | 
|---|
| [2068] | 104 |     @throws | 
|---|
 | 105 |         Throws an exception if isInactive(Player*) throws one. | 
|---|
| [1996] | 106 |     */ | 
|---|
| [2043] | 107 |     bool LocalQuest::isCompletable(const Player* player) const | 
|---|
| [1996] | 108 |     { | 
|---|
 | 109 |         return this->isActive(player); | 
|---|
 | 110 |     } | 
|---|
| [2092] | 111 |  | 
|---|
| [1996] | 112 |     /** | 
|---|
 | 113 |     @brief | 
|---|
| [1992] | 114 |         Returns the status of the quest for a specific player. | 
|---|
 | 115 |     @param player | 
|---|
| [1996] | 116 |         The player. | 
|---|
 | 117 |     @return | 
|---|
 | 118 |         Returns the status of the quest for the input player. | 
|---|
| [2068] | 119 |     @throws | 
|---|
 | 120 |         Throws an Exception if player is NULL. | 
|---|
| [1992] | 121 |     */ | 
|---|
| [2043] | 122 |     questStatus::Enum LocalQuest::getStatus(const Player* player) const | 
|---|
| [1992] | 123 |     { | 
|---|
| [2068] | 124 |         if(player == NULL) | 
|---|
 | 125 |         { | 
|---|
 | 126 |             ThrowException(Argument, "The input Player* is NULL."); | 
|---|
 | 127 |         } | 
|---|
| [2092] | 128 |  | 
|---|
| [2021] | 129 |         std::map<Player*, questStatus::Enum>::const_iterator it = this->playerStatus_.find((Player*)(void*)player); //Thx. to x3n for the (Player*)(void*) 'hack'. | 
|---|
| [2093] | 130 |         if (it != this->playerStatus_.end()) | 
|---|
 | 131 |         { | 
|---|
 | 132 |             return it->second; | 
|---|
 | 133 |         } | 
|---|
 | 134 |         return questStatus::inactive; | 
|---|
| [1992] | 135 |     } | 
|---|
| [2092] | 136 |  | 
|---|
| [1992] | 137 |     /** | 
|---|
 | 138 |     @brief | 
|---|
 | 139 |         Sets the status for a specific player. | 
|---|
| [2068] | 140 |         But be careful wit this one, the status will just be set without checking for its validity. You have to know what you're doing. | 
|---|
| [1992] | 141 |     @param player | 
|---|
 | 142 |         The player. | 
|---|
 | 143 |     @param status | 
|---|
 | 144 |         The status. | 
|---|
| [2068] | 145 |     @return | 
|---|
 | 146 |         Returns false if player is NULL. | 
|---|
| [1992] | 147 |     */ | 
|---|
| [2021] | 148 |     bool LocalQuest::setStatus(Player* player, const questStatus::Enum & status) | 
|---|
| [1992] | 149 |     { | 
|---|
| [2068] | 150 |         if(player == NULL) | 
|---|
 | 151 |         { | 
|---|
 | 152 |             return false; | 
|---|
| [2093] | 153 |         } | 
|---|
| [2021] | 154 |         this->playerStatus_[player] = status; | 
|---|
 | 155 |         return true; | 
|---|
| [1992] | 156 |     } | 
|---|
 | 157 |  | 
|---|
 | 158 | } | 
|---|