| 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 "AddReward.h" |
|---|
| 32 | |
|---|
| 33 | namespace orxonox { |
|---|
| 34 | |
|---|
| 35 | CreateFactory(AddReward); |
|---|
| 36 | |
|---|
| 37 | AddReward::AddReward() : QuestEffect() |
|---|
| 38 | { |
|---|
| 39 | this->initialize(); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | /** |
|---|
| 43 | @brief |
|---|
| 44 | Destructor. |
|---|
| 45 | */ |
|---|
| 46 | AddReward::~AddReward() |
|---|
| 47 | { |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | void AddReward::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
|---|
| 51 | { |
|---|
| 52 | SUPER(AddReward, XMLPort, xmlelement, mode); |
|---|
| 53 | |
|---|
| 54 | XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode); |
|---|
| 55 | |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | /** |
|---|
| 59 | @brief |
|---|
| 60 | Initializes the object. Needs to be called first by every constructor of this class. |
|---|
| 61 | */ |
|---|
| 62 | void AddReward::initialize(void) |
|---|
| 63 | { |
|---|
| 64 | RegisterObject(AddReward); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | const Rewardable* AddReward::getRewardables(unsigned int index) const |
|---|
| 68 | { |
|---|
| 69 | int i = index; |
|---|
| 70 | for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward) |
|---|
| 71 | { |
|---|
| 72 | if(i == 0) |
|---|
| 73 | { |
|---|
| 74 | return *reward; |
|---|
| 75 | } |
|---|
| 76 | i--; |
|---|
| 77 | } |
|---|
| 78 | return NULL; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /** |
|---|
| 82 | @brief |
|---|
| 83 | Invokes the effect. |
|---|
| 84 | @param player |
|---|
| 85 | The player. |
|---|
| 86 | @return |
|---|
| 87 | Returns true if the effect was invoked successfully. |
|---|
| 88 | */ |
|---|
| 89 | bool AddReward::invoke(Player* player) |
|---|
| 90 | { |
|---|
| 91 | bool check = true; |
|---|
| 92 | for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward ) |
|---|
| 93 | { |
|---|
| 94 | check = check && (*reward)->reward(player); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | return check; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | } |
|---|