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