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