[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" |
---|
| 30 | |
---|
| 31 | #include "GlobalQuest.h" |
---|
| 32 | |
---|
| 33 | namespace orxonox { |
---|
| 34 | |
---|
| 35 | CreateFactory(GlobalQuest); |
---|
| 36 | |
---|
[2021] | 37 | GlobalQuest::GlobalQuest() : Quest() |
---|
| 38 | { |
---|
| 39 | |
---|
| 40 | } |
---|
| 41 | |
---|
[1992] | 42 | /** |
---|
| 43 | @brief |
---|
| 44 | Constructor. |
---|
| 45 | @param id |
---|
| 46 | The unique identifier. |
---|
| 47 | @param title |
---|
| 48 | The title of the quest. |
---|
| 49 | @param description |
---|
| 50 | The description of the quest. |
---|
| 51 | */ |
---|
[2021] | 52 | GlobalQuest::GlobalQuest(std::string id, std::string title, std::string description) : Quest(id, title, description) |
---|
[1992] | 53 | { |
---|
| 54 | RegisterObject(GlobalQuest); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | /** |
---|
| 58 | @brief |
---|
| 59 | Destructor. |
---|
| 60 | */ |
---|
| 61 | GlobalQuest::~GlobalQuest() |
---|
| 62 | { |
---|
| 63 | |
---|
| 64 | } |
---|
[1996] | 65 | |
---|
| 66 | /** |
---|
| 67 | @brief |
---|
| 68 | Checks whether the quest can be started. |
---|
| 69 | @param player |
---|
| 70 | The player for whom is to be checked. |
---|
| 71 | @return |
---|
| 72 | Returns true if the quest can be started, false if not. |
---|
| 73 | */ |
---|
[2043] | 74 | bool GlobalQuest::isStartable(const Player* player) const |
---|
[1996] | 75 | { |
---|
| 76 | return this->isInactive(player) || this->isActive(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. |
---|
| 86 | */ |
---|
[2043] | 87 | bool GlobalQuest::isFailable(const Player* player) const |
---|
[1996] | 88 | { |
---|
| 89 | return this->isActive(player); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /** |
---|
| 93 | @brief |
---|
| 94 | Checks whether the quest can be completed. |
---|
| 95 | @param player |
---|
| 96 | The player for whom is to be checked. |
---|
| 97 | @return |
---|
| 98 | Returns true if the quest can be completed, false if not. |
---|
| 99 | */ |
---|
[2043] | 100 | bool GlobalQuest::isCompletable(const Player* player) const |
---|
[1996] | 101 | { |
---|
| 102 | return this->isActive(player); |
---|
| 103 | } |
---|
[1992] | 104 | |
---|
| 105 | /** |
---|
| 106 | @brief |
---|
| 107 | Returns the status of the quest for a specific player. |
---|
| 108 | @param player |
---|
| 109 | The player. |
---|
| 110 | */ |
---|
[2043] | 111 | questStatus::Enum GlobalQuest::getStatus(const Player* player) const |
---|
[1992] | 112 | { |
---|
| 113 | //TDO: Does this really work??? |
---|
[2021] | 114 | std::set<Player*>::const_iterator it = this->players_.find((Player*)(void*)player); |
---|
| 115 | if (it != this->players_.end()) |
---|
[1992] | 116 | { |
---|
| 117 | return this->status_; |
---|
| 118 | } |
---|
| 119 | else |
---|
| 120 | { |
---|
| 121 | return questStatus::inactive; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | @brief |
---|
| 128 | Sets the status for a specific player. |
---|
| 129 | @param player |
---|
| 130 | The player. |
---|
| 131 | @param status |
---|
| 132 | The status to be set. |
---|
| 133 | */ |
---|
[2021] | 134 | bool GlobalQuest::setStatus(Player* player, const questStatus::Enum & status) |
---|
[1992] | 135 | { |
---|
[2021] | 136 | std::set<Player*>::const_iterator it = this->players_.find(player); |
---|
| 137 | if (it == this->players_.end()) //!< Player is not yet in the list. |
---|
[1996] | 138 | { |
---|
[2021] | 139 | this->players_.insert(player); |
---|
[1996] | 140 | } |
---|
| 141 | this->status_ = status; |
---|
[2021] | 142 | return true; |
---|
[1992] | 143 | } |
---|
| 144 | |
---|
[1996] | 145 | |
---|
[1992] | 146 | } |
---|