Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapon2/src/orxonox/objects/quest/AddReward.cc @ 2272

Last change on this file since 2272 was 2105, checked in by rgrieder, 16 years ago

updated msvc files and precompiled headers.

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